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

World: r3wp

[Red] Red language group

BrianH
19-Sep-2011
[3448x2]
Ah, cool, I was worried that you were only going to make explicitly 
marked functions usable as callbacks, rather than all functions.
You can omit the 'stdcall attribute for stdcall callbacks?
Dockimbel
19-Sep-2011
[3450x2]
If we drop 'callback attribute, 'stdcall wouldn't be needed, as it 
is the default convention used by Red/System.
This might be the best option currently, as it would just require 
users to change 'callback to 'cdecl in most cases and just drop the 
'callback attribute in other cases.
BrianH
19-Sep-2011
[3452]
Then we could just specify 'callback if we want the system to guess, 
'cdecl if we know it's that, and nothing if stdcall.
Dockimbel
19-Sep-2011
[3453]
No, it can't work that way. If 'callback is used, then we need the 
error system to catch the unresolved cases, so we need to set initially 
every callback function calling convention as "unknown" instead of 
stdcall. For the unresolved cases, the user must be able to set manually 
the convention, so he needs both 'cdecl and 'stdcall to be accepted.
BrianH
19-Sep-2011
[3454x2]
I guess I just don't understand well enough what is done to support 
callbacks. If you specify a 'callback attribute, is there a shim 
created that marshalls arguments from the callback calling convention 
(cdecl or stdcall) to the internal calling convention of the function 
(stdcall or cdecl)? And if you specify 'cdecl or 'stdcall, does that 
affect the internal calling convention so that no shim is required?
(Probably should just read the source)
Dockimbel
19-Sep-2011
[3456x3]
When you use 'callback attribute on a function, the compiler just 
tries to determine what is the appropriate calling convention to 
apply internally to the callback function. In order to acheive that, 
it checks the first caller function that will take the callback as 
argument and set the callback to the same calling convention. This 
part is done by the compiler's front-end, which just tries to set 
the calling convention correctly (just a word! in an internal block!), 
nothing else.


The compiler's back-end just emits the right code for whatever calling 
convention the function has (cdecl, stdcall, syscall, ...).
If you were asking if a runtime conversion was done between calling 
conventions, the answer is no.
Kaj: I think after this discussion that dropping the whole callback 
thing should be the simplest solution. I would only add a 'cdecl 
attribute for functions that needs to be called from C code. Any 
function (with or without 'cdecl attribute) could then be used as 
callback. Would you agree?
Kaj
19-Sep-2011
[3459x2]
Agreed
You may want to add the stdcall attribute already, as well, for when 
you go to fastcall for native functions
Dockimbel
19-Sep-2011
[3461]
Right.
BrianH
19-Sep-2011
[3462]
Sounds good to me too.
Dockimbel
20-Sep-2011
[3463x4]
BrianH: I need to correct a bit my answer to your question. Actually, 
there is a small code emitter dependency on the 'callback attribute. 
It is used to save special registers (edi, esi, ebx) to conform to 
IA-32 ABI. It is only needed when providing callbacks that are invoked 
by the OS or external libraries.


I should be able to keep this feature in the new revision while making 
it transparent to the users.
BTW, I am glad you're following Red progress closer again. :-)
I have pushed a new revision of Red/System where the 'callback attribute 
is removed. Also, 'cdecl and 'stdcall are now accepted as functon 
attributes. I will update the specifications accordingly later today.
Kaj: as soon as your bindings will be updated for that, I will make 
the v0.2.2 release.
Kaj
20-Sep-2011
[3467x5]
Good, 0.2.1 doesn't work with any binding
Hm, GitHub tarballs are down
cURL updated
0MQ updated
GTK updated
Dockimbel
20-Sep-2011
[3472]
You should be able to use the audio for SDL now.
Kaj
20-Sep-2011
[3473x2]
Have you tested?
Jay, it works!
Dockimbel
20-Sep-2011
[3475]
I just tested that it compiles correctly now. Cool!
Kaj
20-Sep-2011
[3476]
SDL updated. Everything is ready now
Dockimbel
20-Sep-2011
[3477x2]
Good, I'll make the new tag right now then.
Ok, v0.2.2 tagged.
Kaj
20-Sep-2011
[3479]
I can create and close an SQLite database now
Endo
20-Sep-2011
[3480]
that is cool!
Kaj
20-Sep-2011
[3481x4]
Now I can execute SQL statements on a database, and process the results 
row by row with a callback
Since SQL is a dialect, a lot can already be done that way
The binding is now here:
http://red.esperconsultancy.nl/Red-SQLite
Dockimbel
21-Sep-2011
[3485]
I have put the current contributions on a new page: http://www.red-lang.org/p/contributions_21.html
Janko
21-Sep-2011
[3486x4]
I haven't found a way to see any source code on these fossil pages
do I have to login for that?
that captcha password doesn't work for me because characters are 
not fixed width I assume
I copy/pasted it do text editor and was able to login. The code for 
GTK looks very nice
Dockimbel
21-Sep-2011
[3490]
Right, you need to login anonymously. Just click on "anonymous login", 
then "Fill out captcha", then "Login".
Janko
21-Sep-2011
[3491]
(the captcha isn't readable in Chrome because fonts aren't fixed 
width)
Dockimbel
21-Sep-2011
[3492]
I am using Chrome 14 on Win7 and have no issue reading the captcha.
Kaj
21-Sep-2011
[3493x5]
Janko, there's a button that will fill out the CAPTCHA for you
I've added a quick-start SQLite example
Added a WAV player example to the SDL binding
I believe I have now bound the audio part of SDL 1.2 completely
There are sample WAV files, and BMP files for PeterPaint, in the 
SDL documentation