[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
GameMonkey Script • View topic - gmFunctionWrapper : Easy function binding

GameMonkey Script

GameMonkey Script Forums
It is currently Thu Oct 28, 2021 5:27 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Dec 29, 2007 2:10 pm 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13


Last edited by bull on Fri Feb 08, 2008 10:13 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun Dec 30, 2007 1:00 am 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 708
Good stuff bull! Thanks for sharing that, and welcome to the forum. As you suggest, even if not used asis, your imlementation could be the basis for other, (not necessarily GM) binding systems.

Here's a few misc thoughs after looking at your implementation:
o You could add optional parameter validation by getting the user to enter a parameter type string eg.
def(GM_INT,myFunction,"ii"),
Where "ii" is scanned rapidly at call time (or in debug build) to check for integer type.
o Consider alternate macros to simplify syntax eg.
beginlib() // Maybe skip name and just reg per whole file? Use singleton to auto-reg?
reg() // Skip trailing comma?
reg()
endlib() // Close quotes etc?
o Add simple example usage to your source code in comment or readme like you have in the forum.
o The stack implementation (all params are Int32) is not portable. Eg. The PowerPC CPU used in Xbox 360 and PS3 will need float params passed differently. There are various work arounds for this.

Anyway, just a few thoughts. Good work :)


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 06, 2008 6:39 pm 
Offline

Joined: Fri Nov 24, 2006 9:50 am
Posts: 165
Interesting - is that really safe? (the whole passing an array by value to a typecast-overriden function call?)
It seems like it could be and is kind of a crazy way to get around that particular C/C++ limitation.

The only concern I have is that it will be copying 10 values every time - is there a way to construct the array inline so as to remove that copy?

something like func( array( val1, val2, val3 ) )

or at least template it to reduce the copy size (you could create a template class to define a calling function for each no. of parameters).

As Greg says, a validator string would be great too - then you could even take const char* params and cast the pointers to int32s for the stack array. Scanning through the validation string to prepare the args is little to no cost at all at runtime.

SomeFunc( const char* name, float x, float y, int flags )

...
def( SomeFunc, STRING FLOAT FLOAT INT );

where STRING is a macro containing "s", FLOAT is "f" etc., to concatenate into "sffi".

Seems like a great system.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 21, 2008 8:41 am 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 21, 2008 12:57 pm 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 708


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 08, 2008 10:16 am 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group