World: r3wp
[!REBOL3 Extensions] REBOL 3 Extensions discussions
older newer | first last |
Rebolek 6-Nov-2009 [319x2] | IIRC, there was some support for blocks as long as they can be converted to arrray. Now that the COMPILE part works ok, I can focus more on the RebC dialect to enhance it. |
The main reason I wrote the dialect was to convert mathematic functions in Sintezar to C to make it faster and not write it in C as C syntax makes my eyes hurt :) | |
Geomol 6-Nov-2009 [321] | Good idea. And you have strong typing rules, right? So if a var is defined as an integer, you can't change it to something else along the way? |
Rebolek 6-Nov-2009 [322] | Hm, I'm not sure right now, I think it was possible to change it, but I may be wrong. But I think there were no error checks, it was just a basic version that can produce something working and I haven't much time to improve it since. That has changed recently. |
Geomol 6-Nov-2009 [323] | Rebolek, about documentation, feel free to use NicomDoc: http://www.fys.ku.dk/~niclasen/nicomdoc/ It can easily produce HTML output as (MakeDoc), but also PDF output by first producing LaTeX. |
Rebolek 6-Nov-2009 [324] | Geomol thanks. Currently the documentation is written in special version of MakeDoc that supports literate programming so it's mixed with the source code. |
Maxim 6-Nov-2009 [325] | rebolek, I will definitely check this out. if you have any docs converted to html, I will read them, so know it will not have been done in vain ;-) |
BrianH 6-Nov-2009 [326x2] | I was looking at making a libtcc extension, which would allow something like RebC to be used as a JIT compiler. |
You wouldn't need to package your generated code as an extension, just generate to memory and run it from there. | |
Rebolek 6-Nov-2009 [328] | Hm, that would be interesting. |
BrianH 6-Nov-2009 [329x4] | The command! type makes this possible, since commands can dispatch to dynamically generated code if need be. |
Eventually I was going to make a libjit or LLVM backend, but it looks like I can get libtcc working sooner. | |
Not the first thing on my list though (which is HTTP) so if you want to take a crack at it first, I can help with the extension/module model. | |
It looks like libtcc can be statically linked into an extension, only providiing an extension interface to its functions. | |
Rebolek 6-Nov-2009 [333x2] | Hm, I haven't looked at libtcc yet, but it it looks very interesting. |
But first, I need to go thru the RebC code and improve it. It shows it's age :) | |
BrianH 6-Nov-2009 [335x4] | A command! is an indexed dispatch function, and the index has no inherent meaning. You could dynamically generate functions with libtcc, which would all have the same function signiature because they would just take command! call frames. These generated functions could be referenced from an array of function pointers. After you generate a new function and assign it to a new array slot, return the index of that slot to the calling REBOL code (embedded in the libtcc extension) and it can then make a command! with the libtcc extension's handle and that index. Then that command! can be called like any other REBOL function. A trick though is that the generated C code would need to use the extension macros to manipulate the function arguments, rather than direct variable access. In other words, your generated functions would be extension-style code, not regular C code. |
Pekr, the reason callbacks are so tricky in R3 is that you need a way to dispatch to the correct task within REBOL. R3 is not going to be single-tasking anymore, so direct callbacks will be impossible: You have to coordinate between the task/thread of the external code and the tasks/threads of R3. Devices manage that coordination and synchronization. | |
Bolek, if you have the commands that are exported from the libtcc extension themselves implemented as functions with the same signiature as the generated functions, you can call them through the dispatch array as well. This would reduce your RX_Call function to just a few lines. | |
Be sure to BSD the extension wraapper code though, so it can be reused by an LLVM wrapper :) | |
Rebolek 6-Nov-2009 [339x2] | If you mean BSD-license, that's understood. I prefer PD/MIT/BSD licenses, GPL is stupid. |
(I prefer no licenses at all, but I'm an anarchist) | |
BrianH 6-Nov-2009 [341x3] | Well, libtcc is LGPL (2, I think), as is libjit, but LLVM is BSD. The extension interface is LGPL compatible, so if you BSD the wrapper code (or more permissive, as long as it's LGPL compatible) then you should be fine. |
I prefer more permissive licenses too :) | |
especially PD | |
Rebolek 6-Nov-2009 [344] | I'm fine with PD - code is just organized characters. Milion monkeys with typewriters can do same thing ;) so why licensing anything. But that's offtopic - the license will not be deffinitely more restrictive than BSD and it may be PD as well. Depends on my mood when I add it to header ;) |
BrianH 6-Nov-2009 [345] | libtcc is LGPL 2.1 |
Robert 28-Nov-2009 [346x5] | Playing with the extension example: IMO it's done to complicated. - Why do I need make-ext.r? Do I always need it or just for this specific example? - Why is the init block a const char array and not just a plain ASCII text? |
How do I return a new string back to Rebol? | |
I seems I need to construct a RX string and set every single char? | |
This uniton gives a warning/error with mingw: typedef union rxi_arg_val { i64 int64; double dec64; REBYTE bytes[8]; struct { i32 int32a; i32 int32b; }; struct { u32 index; void *series; }; void *handle; } RXIARG; | |
The structs give: warning: declaration does not declare anything | |
Ladislav 28-Nov-2009 [351x3] | yes, Robert, the other elements clearly declare something, but the structs don't declare anything, the compiler is right |
generally, struct {...} my-struct; declares my-struct, while struct {...}; does not declare anything | |
(should have been my_struct) | |
Robert 28-Nov-2009 [354] | I commented the struct part and than it works. So either we need to give it a name, which will result in a ->struct_name.series sequence. Not sure if this makes any difference instead of just putting the members into the union. |
Ladislav 28-Nov-2009 [355x3] | yes, it makes a difference |
(since it is a union) | |
-only one of the variants is correct | |
Robert 28-Nov-2009 [358x4] | Ok, right. Using int32 and ser as struct names. |
Works. | |
BTW: I'm currently making a R3 SQLite extension. | |
Looks like one need to be carful when designing the command interface (arguments) because if you insert an argument, the refinements shift to a new position. As the access to arguments on the c side is via positions you need to adjust your code. Need to think abou a good way to abstract this. | |
jocko 29-Nov-2009 [362] | is there a document showing how to define refinements in extensions ? |
Robert 29-Nov-2009 [363x2] | What do you mean with "define"? On the Rebol side or on the C side? |
Anyhow, yes refinements are no problem. | |
jocko 29-Nov-2009 [365] | well in fact I have not found any mechanism to call a function with a changing number of arguments, like, for instance: my-func a b my-func a b c or, my-func a b my-func/my-refinement a b c |
Graham 29-Nov-2009 [366] | use a block of arguments ? |
jocko 29-Nov-2009 [367x2] | Yes, of course it is a solution, but not a clean on in my case in fact, you cannot know, from inside the C part of the code, the real number of arguments send to the function. |
RXA_COUNT returns the number of arguments defined by the prototype of the function, not the actual one | |
older newer | first last |