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

World: r3wp

[!REBOL3 Extensions] REBOL 3 Extensions discussions

BrianH
11-Feb-2010
[749]
Robert, three problems with that approach (even just on Windows):

- Not all DLLs export that info, some just export numbered entry 
points ane expect you to use a .def file or some such.

- Even for the DLLs that do export names, the C-compatible APIs don't 
have info about function arguments, data structures, ...

- The languages that have real reflection models and encoded info 
(Delphi, C++, .NET, Java) aren't compatible with an R2-style model.

Which is what Maxim is working on. You can't use reflection with 
C-style APIs, and API models that you can use reflection on can get 
their own extensions to access them :)
Robert
11-Feb-2010
[750x2]
DLL by enum: Yes, than you need to know what it's about. But within 
R3 you could use a name.
Arguments must always be known up front to DLL functions. I never 
meant that it can be derived automatically.
BrianH
11-Feb-2010
[752]
At least not for C APIs :(
Gregg
11-Feb-2010
[753]
If there are only ordinals for func in the DLL, REBOL should be able 
to specify those. Just use an integer! rather than a string! (in 
R2 library parlance).
Robert
11-Feb-2010
[754]
That's not the problem. But you need to know what functionn Nr-1 
is about?
Gregg
11-Feb-2010
[755]
Yes, and that can only come from docs of some kind.
BrianH
11-Feb-2010
[756]
Or from header files.
Gregg
11-Feb-2010
[757]
I would consider those docs "of some kind". :-)
Maxim
12-Feb-2010
[758]
Robert,  even if you know the function arguments, how do you call 
the function itself?


the extension will be compiled, so we can't create generic function 
calls.   The calling convention is part of a function's compilation 
process, on Windows any DLL may have three different argument passing 
methods simultaneously!!


get the problem is that you have to push arguments on the stack and 
retrieve them.  there are NO C functions which manipulate the stack 
directly.  these are always done via assembly, either inline or libraries.
Robert
13-Feb-2010
[759]
Ok, I might have missed something. If you want to make it totaly 
dynamic than you are right. My ideas was more like a hybrid soltuion. 
Keeping the R2 structure how to deal with DLLs within R3(so you avoid 
porting code) but get use the R3 extensions model. Well, but you 
need to do the R3 extension. Not what most people would expect...
BrianH
3-Mar-2010
[760x3]
Here's the place to ask that question, Robert. The answer is that 
there may not be a way to do that until the next (redesigned) host 
kit comes out.
And the associated new extension model.
Don't worry, it's mostly an enhance ment of the existing model, but 
the command! type will be enhanced.
Robert
3-Mar-2010
[763]
Ah, I was searching for !REBOL3 Extension. Maybe we can rename this 
group.
BrianH
3-Mar-2010
[764]
We can't, but a world master could. !REBOL3 Extensions sounds good.
Pekr
3-Mar-2010
[765]
agreed on the rename ...
Robert
3-Mar-2010
[766]
How would this than work? What does the COMMAND! stuff do?
BrianH
3-Mar-2010
[767]
The command! type is the function type that you export from extensions 
into REBOL. There are supposed to be many enhancements to the command! 
type in the next host kit, and extensions are supposed to be embeddable 
in the host as well. And DELECT is going to be redone too. With all 
of these changes, more enhancements to the extension model are likely 
as well.
Pekr
3-Mar-2010
[768]
the question is ... when? :-)
BrianH
3-Mar-2010
[769]
The problem with creating blocks from within extensions is synchronizing 
with the R3 internals, which are multitasking (in theory). It's the 
same problem as with callbacks, but worse. In theory you could create 
extension-internal data that would be marshalled into R3 when passed 
back as a return value, but I'm not sure that is what you want.
Robert
3-Mar-2010
[770x2]
What I want to do is return a string that is LOADed before being 
returned.
Or DOne.
BrianH
3-Mar-2010
[772x3]
Sorry, do you mean that you want to return new, non-string REBOL 
data in a block that you make? Right now you can do that (sort-of) 
with a limited set of datatypes supported, and it gets marshalled. 
There may be hacks to create more, but others would have to answer 
that with the current system.
If you really want to return a string that is loaded before being 
returned, the script that is embedded in the extension becomes a 
module that can contain arbitrary REBOL code, including functions 
that massage data that is returned from (possibly internal) command! 
functions.
So return the string to a REBOL function that LOADs or DOes it.
Robert
3-Mar-2010
[775]
Example: Rebol code sends [a b [c d] [e [f g]] h i] to extension. 
The extension makes a string out of this and stores it. Later the 
extension should take the string and make block out of it, so that 
the script gets a block! and can do result/1, result/b etc.
BrianH
3-Mar-2010
[776x3]
outer: func [] [load inner]
inner: command []
And you don't have to export the command if you don't want to.
Just export the wrapper function from the extension's inner module 
and the calling code won't have to know the difference.
Robert
3-Mar-2010
[779]
Up to now I don't have used a Rebol module to wrap the extension. 
The code just loads the extension. Just to be sure I understand your 
proposal: You would create a Rebol module that the user code uses, 
and this modul would deal with the extension?
BrianH
3-Mar-2010
[780]
There is a module inside the extension, and it gets wrapped around 
the extension automatically at LOAD time. That REBOL code in the 
string constant that you return from RX_Init is the module that I 
am talking about.
Robert
4-Mar-2010
[781]
Ok, I see. I will play around with this.
Robert
6-Mar-2010
[782x2]
So, decision made: Serializing BLOCK within in Extensions is a PITA. 
As long as you want to walk a BLOCK and don't have to deal that much 
with nested BLOCKs it's OK.


But it's not possible to make a to-string block! within an extension 
with a simpe to-string call.


Overall I think we need a way to serialize Rebol datatype into a 
char* or void* in a way that it can be stored and brought back into 
Rebol.
Workaround: Catch blocks on the Rebol side, make strings out of it 
and than go to the extension. Same for the other way: Extension devlivers 
string and Rebol code creates Rebol conform datatypes.
Robert
15-May-2010
[784]
Callbacks: Has anyone made any further investigation how to handle 
async callbacks from an extension to Rebol? Or how to send a notification 
to Rebol? Maybe we can send an event! from outside.
BrianH
15-May-2010
[785x3]
In theory that kind of thing is supposed to be handled by R3's device/port 
model, which also will handle synchronization with R3's tasks. In 
practice noone has made a user-defined device yet, though I'm not 
quite sure why. Device extensions have been promised for a while 
now, but not yet delivered.
Maxim did a bit of research into a non-task-safe workaround to create 
callbacks.
There has been some speculation that the new extension and command! 
model that is coming with the next host kit will help solve this 
kind of thing. We shall see.
Andreas
15-May-2010
[788]
As mentioned a few times in the past, I don't think that user-defined 
devices are at all possible, with the current hostkit. And yes, I'd 
love to be proven wrong :)
Robert
16-May-2010
[789]
Ok, since we are not sure, I will take a deeper look into the code 
and try to ask Carl.
Cyphre
17-May-2010
[790]
I agree with Andreas, when I looked into the hostkit code it looks 
that table of 'names' of the devices is hardcoded in the r3.dll at 
the moment. My only idea (workaround) was to try use for example 
'clipboard device name and try to replace the internal code with 
custom one for testing purposes. I haven't tried that though from 
that time yet. Not sure if it is worth the time. Better wait for 
new hostkit ;)
Maxim
17-Jun-2010
[791]
Carl,   what is left to do for the extension model to support view 
as an extension..

I mean, with absolutely no graphics, or view events related code 
within the core ?
Carl
17-Jun-2010
[792x2]
The main thing: linear command evaluation blocks. The replacement 
for the delect method.


Once that's done, I'll release View, but only with the windowing/event 
system, not rendering... then, Cyphre can bring the rendering method 
back online as his time allows. (Or, you can do your own in OpenGL 
if you feel so inclined.)
dinner time.
Maxim
17-Jun-2010
[794]
a little question... how will the gui be able to call rebol functions?
Pekr
19-Jun-2010
[795]
http://www.rebol.com/r3/notes/command-blocks.html
Maxim
9-Jul-2010
[796x2]
has anyone tried to build R3 host as a dll, and use it within R2 
 as a routine?
I have a client which might need R3 parsing but needs to use the 
R2 run-time...
Ladislav
9-Jul-2010
[798]
R3 parsing is not totally necessary, R2 parsing can emulate everything