• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Pekr
25-Aug-2012
[1390]
what is now latest temp.reds source? I got:

Compiling tests/temp.reds ...
Script: "Red/System IA-32 code emitter" (none)
*** Compilation Error: missing argument
*** in file: %runtime/win32.reds
*** in function: ***-dll-entry-point
*** at line: 204
*** near: [hinstDLL]
DocKimbel
25-Aug-2012
[1391x2]
hmm...let me see...
Red/System []

on-load: func [a [integer!]][
	print-line "on-load executed"
]

on-unload: func [a [integer!]][
	print-line "on-unload executed"
]

i: 56
foo: func [a [integer!] return: [integer!]][a + 1]

#export [foo i]
Pekr
25-Aug-2012
[1393x2]
>> exists? %temp.dll
== true
>> lib: load/library %temp.dll
>>
No need to become dirty with WinDbg :-)
DocKimbel
25-Aug-2012
[1395]
Try now:

foo: make routine! [a [integer!] return: [integer!]] lib "foo"
foo 123
Pekr
25-Aug-2012
[1396]
>> foo: make routine! [a [integer!] return: [integer!]] lib "foo"
>> foo 123
== 124
DocKimbel
25-Aug-2012
[1397]
Good! :-)
Pekr
25-Aug-2012
[1398x2]
Yes :-)
So what was the difference? Rellocation support?
DocKimbel
25-Aug-2012
[1400]
It seems some systems are forcing relocation on loading DLLs (even 
when no conflict) while others not.
Pekr
25-Aug-2012
[1401x2]
So we have finally improved DLL support for R2, right? :-)
I mean - now we can make wrapper libs, coding almost in REBOL (syntax), 
no need to become dirty with C, and hence get more libraries to work 
with R2, via a wrapper libraries written in Red/System?
DocKimbel
25-Aug-2012
[1403x2]
It might also be caused by real conflicts from DLLs loaded by REBOL...only 
WinDbg could tell us by looking at the base address of all loaded 
DLLs.
Pekr: yep. :-)
sqlab
25-Aug-2012
[1405]
I can confirm, that it works now
DocKimbel
25-Aug-2012
[1406]
Great!
Pekr
25-Aug-2012
[1407]
Well, if someone would create a plug-in wrapper, we could use the 
aproach for R3 too ...
Robert
25-Aug-2012
[1408]
Doc, can you statically link other C libs and use the functions from 
Red?
DocKimbel
25-Aug-2012
[1409]
Not yet Robert, but that's on the roadmap.
Robert
25-Aug-2012
[1410x2]
Ok, that would be very cool.
Easly creating self-contained DLLs with a R2 / R3 interface would 
be a major time-saver.
DocKimbel
25-Aug-2012
[1412]
can you statically link other C libs...

 you mean link static libraries with Red/System executable, right?
Robert
25-Aug-2012
[1413]
yes, to get one binary.
DocKimbel
25-Aug-2012
[1414x4]
Because for statically linking to dynamic libraries, that's already 
possible.
For static libs linking, if someone could contribute by providing 
a .lib and .a file reader/parser, that would help get that feature 
implemented sooner.
(.lib and .a reader coded in R2)
So, next steps (next week), add PIC support to backends and implement 
shared lib support in Mach-o and ELF emitters.
Pekr
25-Aug-2012
[1418x2]
that's not a microcontroller, right? :-)
OK, position independent code, got it via Wikipedia ...
DocKimbel
25-Aug-2012
[1420x2]
No, it's Position Independent Code: http://en.wikipedia.org/wiki/Position-independent_code
PIC is mandatory in UNIX shared libs.
Pekr
25-Aug-2012
[1422]
so so far only Windows DLLs are supported, right?
DocKimbel
25-Aug-2012
[1423x2]
Right.
But that enables already to build a lot of things, like bridges with 
other languages or VMs.
Pekr
25-Aug-2012
[1425]
yes, generally we are now able to write low level binding using rebol 
like syntax, generate libraries for environments like Delphi, etc., 
which e.g. my friend still uses :-)
DocKimbel
25-Aug-2012
[1426x3]
My personal favorite is Blender, I'd very much like to add Red/System 
support to it (and kick out Python later when Red will be there). 
;-)
But bridging with Android and iOS is high priority, so Blender will 
wait.
BTW, best option for bridging with Java can be discussed here (on 
the ML). I'm not sure anymore that the JNI way is the best one...
Pekr
25-Aug-2012
[1429]
What I still think is, that we need strong parse. It is very cool 
technology. Yes, I dare to call it a technology. We need r3 level 
parse. Then we can create dialects, and show other guys, that dialecting 
is a cool concept. Pity we were not able to capitalise on it more, 
mainly due to closed nature of R2 possibilities to bind to other 
environments .... you imo :-)
DocKimbel
25-Aug-2012
[1430]
*(or on the ML)
Pekr
25-Aug-2012
[1431x2]
you = just
some kind of brige is required, if we want to get into an Android 
API. Ditto for .NET?
DocKimbel
25-Aug-2012
[1433x3]
Yes
Same issue.
I have added a sample program for those who want to play with DLL 
generation:


https://github.com/dockimbel/Red/blob/dyn-lib-emitter/red-system/tests/shared-lib.reds
Kaj
25-Aug-2012
[1436x2]
I've looked at the Blender interface, but it's rather big and complex
Petr, I think we need Topaz level PARSE :-)
Pekr
25-Aug-2012
[1438x2]
you used -dlib option, does it replace -t one? Not skilled here, 
but - can I generate e.g. ARM executable/library from Windows Red/System? 
Or is target environment needed?
Topaz has even better parse than R3?