r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Extensions] REBOL 3 Extensions discussions

Maxim
9-Nov-2010
[1654x2]
hum... so RL_SET_VALUE has  bug in the A110 host-kit...
but RL_GET_VALUE is working fine... this is strange.
Andreas
9-Nov-2010
[1656]
Interesting. Seems to make a difference whether I run a script which 
imports the extension or import the extension from the command line.
Maxim
9-Nov-2010
[1657x2]
I had that reaction when I had an unstable CGR host-kit.
same thing, command-line would last longer before a crash, but ultimately, 
it would still fail... only further down the execution.
Andreas
9-Nov-2010
[1659]
Same behaviour in A109. Which is actually good, as it basically rules 
out an error introduced by the struct packing changes in A110.
Maxim
9-Nov-2010
[1660]
since my issues where related to heap memory corruption, I'd guess 
either we are using the commands improperly, the includes are not 
reflective of the actual internals, or the internals are causing 
the heap corruptions themselves.
Andreas
9-Nov-2010
[1661]
Does not work in A107 at all, neither script nor manually.
Maxim
9-Nov-2010
[1662]
struct packing changes?
Andreas
9-Nov-2010
[1663]
The A110 host kit more intelligently handles struct packing.
Maxim
9-Nov-2010
[1664]
what are the differences?
Andreas
9-Nov-2010
[1665]
http://www.curecode.org/rebol3/ticket.rsp?id=1727
Maxim
9-Nov-2010
[1666x3]
ahh those.  ok.
I'm wondering if the RL_SET_VALUE or RL_SET_CHAR  might have switched 
to using RXIARG *    instead of RXIARG  internally.
does allocating a struct/union on the stack create an implicit pointer 
(which points to the stack rather than heap) when used?
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.