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

World: r3wp

[!REBOL3 Extensions] REBOL 3 Extensions discussions

jocko
8-Nov-2010
[1576]
With this version, all the inputs and outputs are files. I'm waiting 
for more specs before loading directly into memory. It's possible 
to convert many file formats (including tiff) into may others.
Oldes
8-Nov-2010
[1577x2]
hm.. but I don't see ImageMagickObject.dll in my Imagick folder.
btw.. what is difference between simple CALL with args and using 
the ImageMagickObject?
jocko
8-Nov-2010
[1579x2]
could you check again the installation of ImageMagickObject by doing 
regsvr32 ImageMagickObject.dll (without /c and /s, you will have 
the messages indicating that everything is ok)
That's also a question for me ...

Part of the answer is that using it in a cpp exe will allow to execute 
these functions without te burden of executing a c process while 
masking the dos window (which is a huge challenge here, and I do'nt 
know why). In the case of Rebol, yes, the interest is not so evident.
Oldes
8-Nov-2010
[1581x2]
not found. So I don't have it.
Andreas, so I must copy all series to REBOL's one as you did in the 
zlib example? I guess I will need to put images into REBOL in pure 
binaries at this moment, right?
jocko
8-Nov-2010
[1583]
Maxim, yes, I have seen bindings to other languages, but I am still 
not convinced that its much simpler than coding directly in C or 
C++

Oldes, I did not know im-min.r. It's a nice work. I have not enough 
experience in Extensions to do such work, as the input-output methods 
of R3 extensions are a little tricky.
Maxim
8-Nov-2010
[1584x3]
the images are pointers, so the data doesn't need to be copied if 
you are just manipulating it.   though it seems there was some image 
bugs in the A107 (not sure where) which AFAIK are fixed but not yet 
released in current host-kit (cyphre knows for sure).
the images are pointers
 ....   more precisely:  


R3 image! datatypes are pointers in the extension, so you can access 
them as arrays directly.
though it does require usually thread safety and might require GC 
protection depending on what you are doing.
Oldes
8-Nov-2010
[1587]
How to free the extension?
Maxim
8-Nov-2010
[1588]
AFAIK we can't currently unload extensions.  


The extension interface actually is designed to support it, but right 
now, I think its never called and there is no way to trigger it from 
the REBOL code AFAIK.
Oldes
8-Nov-2010
[1589x4]
What I'm doing wrong here:
//I want: char **MagickQueryConfigureOptions(const char *pattern, 
unsigned long *number_options)
//I have:
            unsigned long *number_options;
            char *item;

            char **list = MagickQueryConfigureOptions("*",number_options);
      
            REBSER *b = RL_MAKE_BLOCK(*number_options);
            RXA_SERIES(frm, 1) = b;
            RXA_INDEX(frm, 1) = 0;
            RXA_TYPE(frm, 1) = RXT_BLOCK;

            int i,j;
            for(i=0; i<*number_options; ++i)    {
                item = list[i];
                REBSER *s = RL_MAKE_STRING(strlen(item), 0);
                for (j = 0; j < strlen(item); ++j)
                    RL_SET_CHAR(s, j, item[i]);
                RL_SET_VALUE(b, i, s, RXT_STRING);
            }
but with error:

wand.c:81: error: incompatible type for argument 3 of indirect function 
call
where line 81 is:  RL_SET_VALUE(b, i, s, RXT_STRING);
Maxim
8-Nov-2010
[1593x2]
you should be using RL_SET_CHAR for starters...
oh sorry... you are  ;-)
Oldes
8-Nov-2010
[1595]
it requires RXIARG but how to get it from the REBSER?
Maxim
8-Nov-2010
[1596x9]
hehe I was going to say it required RXIARG.
REBSER is a type of RXIARG, you build the RXIARG like so:
RXIARG arg;
arg.addr = s;


in the next host-kit version, Carl will be adding macros for this 
exact situation... an oversight of his.
note that when you provide the arg, you must then give it directly 
using: 

RL_SET_VALUE(b, i, arg, RXT_STRING);
this is what carl will be adding to the next host-kit.... 


//------------------
//-    #RXV_xxx
//
// REBOL EXTENSION GET Macros
//
// provide direct RXIARG access macros
// with these macros, the single argument should be an RXIARG *
//

// this is usefull when the RXIARG is NOT being used from an argument 
frame

// but as a single value, like when we use RL_Get_Field() or RL_Get_Value()
//
// if the argument is dynamically allocated, ex:
//    RXIARG arg = OS_MAKE(sizeof(RXIARG)); 
// then use the macros like so:
//     RXV_WORD(*(arg));
//------------------
#define RXV_INT64(a)		(a.int64)
#define RXV_INT32(a)		(i32)(a.int64)
#define RXV_INTEGER(a)	(a.int64) // maps to RXT_INTEGER
#define RXV_DEC64(a)		(a.dec64)
#define RXV_DECIMAL(a)	(a.dec64) // maps to RXT_DECIMAL
#define RXV_LOGIC(a)		(a.int32a)
#define RXV_CHAR(a)		(a.int32a)
#define RXV_TIME(a)		(a.int64)
#define RXV_DATE(a)		(a.int32a)
#define RXV_WORD(a)		(a.int32a)
#define RXV_PAIR(a)		(a.pair)
#define RXV_TUPLE(a)		(a.bytes)
#define RXV_SERIES(a)		(a.series)
#define RXV_BLOCK(a)		(a.series)
#define RXV_INDEX(a)		(a.index)
#define RXV_OBJECT(a)	(a.addr)
#define RXV_MODULE(a)	(a.addr)
#define RXV_HANDLE(a)	(a.addr)
#define RXV_IMAGE(a)		(a.image)
#define RXV_GOB(a)		(a.addr)
oh... sorry... posting this I just saw that the series don't use 
  .addr    but    .series

so you exxample would be:
//I want: char **MagickQueryConfigureOptions(const char *pattern, 
unsigned long *number_options)
//I have:
            unsigned long *number_options;
            char *item;

            char **list = MagickQueryConfigureOptions("*",number_options);
      
            REBSER *b = RL_MAKE_BLOCK(*number_options);
            RXA_SERIES(frm, 1) = b;
            RXA_INDEX(frm, 1) = 0;
            RXA_TYPE(frm, 1) = RXT_BLOCK;

            int i,j;
            for(i=0; i<*number_options; ++i)    {
                RXIARG arg;
                item = list[i];
                REBSER *s = RL_MAKE_STRING(strlen(item), 0);
                for (j = 0; j < strlen(item); ++j)
                    RL_SET_CHAR(s, j, item[i]);
                RL_SET_VALUE(b, i, arg, RXT_STRING);
            }
arrrhhh... sorry... darn CTRL-S got switched...
ignore above... not finished editing.
Andreas
8-Nov-2010
[1605]
Oldes, your number_options usage is wrong.
Oldes
8-Nov-2010
[1606x2]
it works:)
how?
Andreas
8-Nov-2010
[1608]
Should be:
unsigned long number_options;
MagickQueryConfigureOptions("*", &number_options);
REBSER *b = RL_MAKE_BLOCK(number_options);
Maxim
8-Nov-2010
[1609x3]
//I want: char **MagickQueryConfigureOptions(const char *pattern, 
unsigned long *number_options)
//I have:
            unsigned long *number_options;
            char *item;

            char **list = MagickQueryConfigureOptions("*",number_options);
      
            REBSER *b = RL_MAKE_BLOCK(*number_options);
            RXA_SERIES(frm, 1) = b;
            RXA_INDEX(frm, 1) = 0;
            RXA_TYPE(frm, 1) = RXT_BLOCK;

            int i,j;
            for(i=0; i<*number_options; ++i)    {
                RXIARG arg;
                item = list[i];
                REBSER *s = RL_MAKE_STRING(strlen(item), 0);
                arg.series = s;
                for (j = 0; j < strlen(item); ++j)
                    RL_SET_CHAR(s, j, item[i]);
                RL_SET_VALUE(b, i, arg, RXT_STRING);
            }
hehe, yeah andreas... good catch.  :-)
Oldes, without changes given by andreas, you will corrupt the executable's 
memory and will *eventually* have a memory acces failure.
Andreas
8-Nov-2010
[1612]
and of course `for (i=0; i<number_options; ++i)` as well
Oldes
8-Nov-2010
[1613]
Just in the resuted string I'm missing first char
Maxim
8-Nov-2010
[1614]
does   j++   change anything?
Andreas
8-Nov-2010
[1615]
you are missing the first character in all returned strings?
Oldes
8-Nov-2010
[1616x3]
yes
(now I'm missing all, don't know why:)
I must go to sleep, that's the sign:)
Maxim
8-Nov-2010
[1619]
post your current version so we might find a little typo...
Oldes
8-Nov-2010
[1620]
unsigned long number_options;
            char *item;

            char **list = MagickQueryConfigureOptions("*",&number_options);
      
            REBSER *b = RL_MAKE_BLOCK(number_options);
            RXA_SERIES(frm, 1) = b;
            RXA_INDEX(frm, 1) = 0;
            RXA_TYPE(frm, 1) = RXT_BLOCK;

            int i,j;
            for(i=0; i<number_options; ++i)    {
                RXIARG arg;
                item = list[i];
                REBSER *s = RL_MAKE_STRING(strlen(item), 0);
                arg.series = s;
                for (j = 0; j < strlen(item); ++j)
                    RL_SET_CHAR(s, j, item[i]);
                RL_SET_VALUE(b, i, arg, RXT_STRING);
            }
Andreas
8-Nov-2010
[1621x2]
RL_SET_CHAR(s, j, item[i]);
make that
RL_SET_CHAR(s, j, item[j]);
J instead of I
Oldes
8-Nov-2010
[1623x2]
Isn't it possible to debug it somehow?
Still empty.
Andreas
8-Nov-2010
[1625]
That was a definitive bug.