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

World: r3wp

[!REBOL3 Extensions] REBOL 3 Extensions discussions

Oldes
17-Jan-2011
[2006x2]
It's quite clear, what it should return, when you see it in REBOL 
like form, but it's quite difficult to do such a decision when parsing 
the spec.. that's also the main reason, why I decided to work on 
human readable dialect. (I was trying to generate the extension directly, 
it's possible, but it seems to be hard to maintain.)
Just to make clear what's the issue.. for above example, the extension 
command should looks like:

MagickGetImageChannelRange: command [
	"Gets the range for one or more image channels"
	wand       [handle!] "the magick wand."
	channel  [integer!] "the image channel(s)."
]


The minima, maxima are just pointers to values which are used to 
return the result, which I must convert to REBOL block.
Oldes
25-Jan-2011
[2008x5]
I'm using this piece of code to get pointer to binary argument:
            char *srcData;
            REBSER *ser = RXA_SERIES(frm, 1);
            srcLen = - RL_GET_STRING(ser, 0, (void **) &srcData);
But also must do this:
	srcData+=RXA_INDEX(frm,1);

To fix the pointer to correct position if the source binary index 
is > 0.
Is this a bug or is it normal? Should it be reported in CC?
OH... forget it... the correct way is using:

	REBSER *ser = RXA_SERIES(frm, 1);
            char *srcData  = RL_SERIES(ser, RXI_SER_DATA);
            u32 srcLen = RL_SERIES(ser, RXI_SER_SIZE);
Correction... the right result is:

	srcData = RL_SERIES(ser, RXI_SER_DATA) + RXA_INDEX(frm,1);

 srcLen =  RL_SERIES(ser, RXI_SER_SIZE) - RL_SERIES(ser, RXI_SER_LEFT) 
 - RXA_INDEX(frm,1) -1;

so I don't know what is better.
the recapitulation: http://issue.cc/r3/1836
Also added comment to related bug http://curecode.org/rebol3/ticket.rsp?id=1816&cursor=21#comments
Maxim
25-Jan-2011
[2013x2]
Oldes, AFAIK its normal... in C we always have access to the full 
string.  

we use RL_SERIES to figure out the portion of the string which is 
used by a specific Series reference.

so basically if you call:

a: [1 2 3]
b: next a


and use A or B in the command, you get the same string (logically, 
not physically), but with only the RL_SERIES and RXA_INDEX() which 
are set to different values.
I'd say your option 2) is the more "correct" method.  though both 
are OK.

basically, one counts from the end, the other from the start.
Oldes
25-Jan-2011
[2015]
I expect the pointer in the correct position. Reload the issue http://issue.cc/r3/1816
and read my last comment.
Maxim
25-Jan-2011
[2016x2]
nice note about the RL_GET_STRING bug though...
yes for binaries, the use of wide chars makes no sense.
Oldes
25-Jan-2011
[2018]
and yes.. it's fine that RL_SERIES(ser, RXI_SER_DATA) returns string 
at it head. Than I would like to have the RXI_SER_LENGTH as a shorthand 
for: RL_SERIES(ser, RXI_SER_SIZE) - RL_SERIES(ser, RXI_SER_LEFT) 
- RXA_INDEX(frm,1) -1 


and the bug is, that the binary is not using wide, but reports it 
and counts the pointer position as wide - as Kay reported.
Maxim
25-Jan-2011
[2019x5]
I never liked that Carl wrapped all pointer data as SERIES... they 
share very little in fact.


I added quite a few MACROS in my hostkit to make working with a few 
of the types more xplicit in code...  I also wished Carl stored the 
type right in the RXA_ARG ... which is why I did a superset of it 
which has the type value at the end...  then I can just look it up 
instead of passing it as an argument within my own code all the time.
(but its been 2 months since I last played with this... so its a 
little far in my head)
just propose it in the 1836 CC, Carl is quite open to improvements 
of these kind.
I've had a few things added with obvious requests like this.
especially when they are One liners and quite usefull.
Oldes
25-Jan-2011
[2024x2]
 I also wished Carl stored the type right in the RXA_ARG
 ... what about => RXA_TYPE(f,n)
I wish Carl had more time for extensions and devices as well.
Maxim
25-Jan-2011
[2026]
that only works when you use the types within the argument list... 
when you are creating things and passing them over to functions, 
you must always pass the type as well as the data.
Oldes
25-Jan-2011
[2027]
I wonder if we can somehow solve that you must provide handle in 
most cases for each command..

In Kaj'scurl it's the SESSION handle, in iMagick it's the WAND handle... 
etc. what we can expect from the devices?
Maxim
25-Jan-2011
[2028]
yes.. I hope he gets devices done and current devices end up in the 
open source part of the hostkit.
Pekr
25-Jan-2011
[2029]
Oldes, CC it as a wish (RXA_TYPE(f,n))
Maxim
25-Jan-2011
[2030x2]
that's how it is... and that is the problem.
we should be able to do   arg.type directly.
Oldes
25-Jan-2011
[2032x2]
I don't see it as a problem when I write:
    RXA_SERIES(frm, 1) = destSer;
    RXA_TYPE(frm, 1)   = RXT_BINARY;
    RXA_INDEX(frm, 1)  = 0;

At least it's clear in the source, what you can expect. Or what you 
want to propose. It's Maxim's wish:)
Or you want to use:
   RXA_BINARY(frm, 1) = destSer;
? That would be just a cosmetic thing.
Maxim
25-Jan-2011
[2034x2]
you are only working against the argument list.  I use args outside 
of the commands in other functions which manipulate rebol values.
I always have to track the types manually, when they could be a property 
of the data.
Oldes
25-Jan-2011
[2036]
I'm not so far... I'm just a C newbie:)
Maxim
25-Jan-2011
[2037x3]
which is why I built this structure when I know I am going to be 
using the data outside of my command block...

typedef struct ht_value HTVAL;
struct ht_value {
	RXIARG value;
	u32 type;
};
it can be used in place of RXIARG directly, but it can also store 
the type right there.  so other functions can ask for type, just 
like we do in Rebol.
(because some functions act on several different types)
Andreas
25-Jan-2011
[2040]
Oldes, to get the length of the series use:
RL_SERIES(ser, RXI_SER_TAIL) - RXA_INDEX(frm, 1)
Maxim
25-Jan-2011
[2041]
I just realized that it sucks that that index position is also part 
of the argument frame and not the argument itself  :-(
Andreas
25-Jan-2011
[2042x3]
Well, it actually is part of the _argument_, but not of the REBSER 
"series" (which is really the series data).
I.e. if you have an RXIARG of of a series type (RXT_BINARY, RXT_STRING, 
etc), this arg also holds the index.
And a pointer to the series data.
Maxim
25-Jan-2011
[2045]
ok. so it does hold the value.
Oldes
25-Jan-2011
[2046]
TAIL - INDEX looks better, thanks... btw.. https://github.com/Oldes/R3A110/tree/master/extensions/zlib
Kaj
26-Jan-2011
[2047]
Has it ever been discussed that R3 should be able to do IMPORT %file 
and know to look for %file.so on POSIX systems and %file.dll on Windows?
Maxim
26-Jan-2011
[2048]
thing is you can import  %file   for     %file.r   too.
BrianH
26-Jan-2011
[2049]
You can import 'file for %file.r (or whatever system/options/default-suffix 
is), but when specifying a file you are assumed to know what name 
it is. And you can use %.rx if you want a cross-platform file extension 
for your extension.
Kaj
26-Jan-2011
[2050]
Operating systems may react badly to that, because they may expect 
their standard file extension. R3 extensions are OS dynamic libraries 
and are expected to be registered that way in the system
BrianH
26-Jan-2011
[2051x2]
On Windows at least this is not a problem - libraries can have any 
extension, even .exe.
But the real trick is to load your platform-specific filenames ahead 
of time and then refer to them by module name.
Kaj
26-Jan-2011
[2053]
How would you know ahead of time which program a user wants to start?
BrianH
26-Jan-2011
[2054]
You can load your extensions delayed. Beyond the pre-delayed extensions 
the "user" should probably not be loading them. Unless the user is 
you, at which point you know. Modules are imported into the system, 
they aren't sandboxed.
Kaj
26-Jan-2011
[2055]
How come? Computer is started. User may start a program on Monday 
that needs to load cURL extension. May decide to start a program 
on Tuesday that needs to load 0MQ extension