World: r3wp
[!REBOL3 Extensions] REBOL 3 Extensions discussions
older newer | first last |
Maxim 9-Nov-2010 [1677x3] | actually, in Olde's code its: s.index = 0; |
actually... its: arg.index = 0; | |
we could propose a usefull macro to not get bitten by this again: something like: #define NEW_RXIARG(v) RXIARG v; v.index=0 | |
Andreas 9-Nov-2010 [1680x2] | CLEARS(&a); |
RXIARG a; CLEARS(&a); is the most sensible way. but then you'll better #include <string.h> (at least until some include woes in the hostkit headers are straightened out). | |
Maxim 9-Nov-2010 [1682] | however we do it, the problem is not in how, but that we forget to do it in the first place. |
Andreas 9-Nov-2010 [1683] | that's C for you :) |
Maxim 9-Nov-2010 [1684] | which is why a standard macro which takes care of that would be nice... in the same idea than the RL_MAKE_BLOCK (which I know isn't exactly the same since its just a wrapper around the RL vector) |
Andreas 9-Nov-2010 [1685] | you have to make sure to initialise all stack- and heap-allocated memory |
Maxim 9-Nov-2010 [1686] | yep. |
Oldes 10-Nov-2010 [1687x2] | Ah.. thanks.. so I made another small step in learning extensions:) Thanks. I'm sure I will have more questions later. But I must work now for a while. |
When I have command like: test: command [str [string!]] And on C side I need a pointer to this string, how to get it? | |
Maxim 10-Nov-2010 [1689] | str_arg = RXA_SERIES(frm, 1); |
Oldes 10-Nov-2010 [1690] | with: char *str_arg; ? |
Maxim 10-Nov-2010 [1691] | sorry.. REBSER * str_arg = RXA_SERIES(frm, 1); |
Oldes 10-Nov-2010 [1692x2] | That's not working, the function I'm trying to call is: char **MagickQueryConfigureOptions(const char *pattern, unsigned long *number_options) And I would like to use REBOL input for the *pattern. |
Does it mean that I must use FOR loop with RL_GET_CHAR or I can get the pointer directly? | |
Maxim 10-Nov-2010 [1694x3] | loop with RL_GET_CHAR |
to get the length of the REBOL string you need to use this: | |
RL_Series(str_arg, RXI_SER_TAIL) | |
Oldes 10-Nov-2010 [1697x2] | with RL_Series I have this error: undefined reference to `_imp__RL_Series' |
This works: REBSER *ser; i32 len; ser = RXA_SERIES(frm, 1); len = RL_SERIES (ser, RXI_SER_TAIL) - RXA_INDEX(frm, 1); char pattern[len]; for(n = 0; n < len; ++n) pattern[n] = RL_GET_CHAR(ser, n); | |
Maxim 10-Nov-2010 [1699] | yeah... sorry... I have my own defines, which include the required files. |
Oldes 10-Nov-2010 [1700] | What I must include to be able use RL_Print? |
Maxim 10-Nov-2010 [1701] | AFAIK, you should just need #include "reb-host.h" |
Oldes 10-Nov-2010 [1702x2] | That I have, but I get the similar error: undefined reference to `_imp__RL_Print' |
It would be much more easier to play with extensions with the ability to trace it. | |
Maxim 10-Nov-2010 [1704] | is your file a .c or .cpp ? |
Oldes 10-Nov-2010 [1705] | .c |
Maxim 10-Nov-2010 [1706] | you can try adding extern void RL_Print(char *fmt, ...); at the begining of your file. |
Oldes 10-Nov-2010 [1707] | That does not works. |
Maxim 10-Nov-2010 [1708x2] | are you using gcc of VS ? |
of = or | |
Oldes 10-Nov-2010 [1710x3] | GCC |
it's not working with Andreas' minimal example as well - http://www.curecode.org/rebol3/ticket.rsp?id=1727 | |
(wrong link, this one https://gist.github.com/0c6305d7c25e40742b31 ) | |
Maxim 10-Nov-2010 [1713x2] | ah, I did a little bit of searching and I think I understand... try using RL_PRINT() instead. |
its strange that I've never had a problem with this though cause I use RL_Print in all my files, but I realize that it might just be luck, that in my setup I don't have the linking problem you are having. | |
Oldes 10-Nov-2010 [1715] | That works, but only with 2 args. |
Maxim 10-Nov-2010 [1716x5] | RL_PRINT should work in any uses of the host_kit |
ok... that is easy to fix. | |
open reb-lib.h | |
and replace: #define RL_PRINT(a,b) RL->print(a,b) with: #define RL_PRINT(a,b) RL->print(a,__VA_ARGS__) can't test it right now, but that should work. | |
the function itself is defined with variable arguments, its just the #define which isn't ... the above redefines it so it matches the function declaration. | |
Oldes 10-Nov-2010 [1721] | __VA_ARGS__ can only appear in the expansion of a C99 variadic macro Never mind... I really have to do real work now :) |
Maxim 10-Nov-2010 [1722] | what? I'm using it my own gcc compiled version of the host-kit... I don't understand... Andreas will have to step in... I don't know why you're having that error. |
Oldes 10-Nov-2010 [1723] | Actually it's: ../src/include/reb-lib.h:270:49: warning: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro wand.c:74:43: macro "RL_PRINT" passed 3 arguments, but takes just 2 wand.c: In function `RX_Call': wand.c:74: error: `RL_PRINT' undeclared (first use in this function) |
Maxim 10-Nov-2010 [1724] | ok, well, I guess you'll have to use just two args for now ;-) |
Oldes 10-Nov-2010 [1725] | But I have a solution, this works: RL->print("%d %s\n", n,item); |
Maxim 10-Nov-2010 [1726] | true. btw, keep reb-lib.h open when you code extension stuff, its the best source to get the proper argument information for all the available RLxxxxx functions. |
older newer | first last |