World: r3wp
[!REBOL3 Extensions] REBOL 3 Extensions discussions
older newer | first last |
Andreas 9-Nov-2010 [1669] | Will need more investigation. Either RL_SET_VALUE never worked, but I guess someone would have noticed. Or the minimal sample is missing something (more or less obvious). |
Maxim 9-Nov-2010 [1670] | the odbc extension uses RL_SET_VALUE IIRC. |
Andreas 9-Nov-2010 [1671x4] | Yes, it does. |
Ah, yes. We were missing something obvious :) | |
Ok, confirmed that it works on both Linux and Windows A110. | |
A simple `a.index = 0` is missing. | |
Maxim 9-Nov-2010 [1675] | ah yes... they are allocated on the stack, so memory its not cleared by default. |
Andreas 9-Nov-2010 [1676] | Updated the snippet accordingly: https://gist.github.com/0c6305d7c25e40742b31 |
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 [1716x3] | RL_PRINT should work in any uses of the host_kit |
ok... that is easy to fix. | |
open reb-lib.h | |
older newer | first last |