GameMonkey Script

GameMonkey Script Forums
It is currently Tue Mar 19, 2019 6:53 pm

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: gmMachineEx [FINAL]
PostPosted: Sat Oct 06, 2007 10:05 pm 
Offline

Joined: Mon Jun 26, 2006 3:48 pm
Posts: 114
Location: Paris, France
Hey,

I've finished my binding tool. I've included a complete (but useless) example and a documentation in "pdf" format. You need to change GM files a bit first in order to use gmMachineEx, so be sure to read the "READ ME!" file first.
Enjoy!

http://www.mediafire.com/?am4z1secwpz

Seth
[EDIT: I've updated the documentation and I've also changed its format to "pdf". A big thanks to "Will" for correcting me.]


Last edited by Nightmare on Wed Oct 17, 2007 11:24 am, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [RC]
PostPosted: Thu Oct 11, 2007 7:47 pm 
Offline

Joined: Tue Sep 04, 2007 4:40 pm
Posts: 7
edit: [most recent release fixed problems, thanks Nightmare]


Last edited by satellites on Mon Oct 22, 2007 8:03 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [RC]
PostPosted: Fri Oct 12, 2007 2:09 am 
Offline

Joined: Mon Jun 26, 2006 3:48 pm
Posts: 114
Location: Paris, France
You shouldn't have this error. I've compiled it successfully on 3 computers but still, I've updated the code. Tell me if it works for you.
If so, please edit your message and replace it entirely by : [FIXED].
Thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Wed Oct 17, 2007 9:42 am 
Offline

Joined: Mon Jun 26, 2006 3:48 pm
Posts: 114
Location: Paris, France
Ok, this is the last and final version. Changes:

-Derived classes now inherit the base classes operators automatically
-Basic pointers are all automatically bound (int*,bool*,short*,...)
-I've fixed the VC++ bug which prevented binding const member functions returning "void"
-Decreased slightly the compilation time
-Updated the documentation to its final state
-Changes in the read-me file to allow the class to work as expected. NECESSARY. check it again even if you already did!

I'll keep coming back every week-end to check if there's any question.
And for heaven sake, show me there is someone alive here!

Seth


Last edited by Nightmare on Wed Oct 17, 2007 11:41 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Wed Oct 17, 2007 11:07 am 
Offline

Joined: Mon Jun 26, 2006 3:48 pm
Posts: 114
Location: Paris, France
[FIXED]


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Mon Oct 22, 2007 8:04 pm 
Offline

Joined: Tue Sep 04, 2007 4:40 pm
Posts: 7
I'm alive, and I've got it working now. Many thanks, again!


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Sun Oct 28, 2007 10:33 am 
Offline

Joined: Fri Nov 24, 2006 9:50 am
Posts: 165
Hey there,

How did you implement the create-thread-on-death-of-another type functionality?

It says it creates the thread when a thread using the specified function dies, so I presume there is some check of the very base of the stack when the thread is destroyed and then some kind of linked list there of threads to wake up?


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Tue Oct 30, 2007 1:53 am 
Offline

Joined: Mon Jun 26, 2006 3:48 pm
Posts: 114
Location: Paris, France
Hey,

You're right. Here's how it works basically:

1) A basic "MachineCallback" is registered
2) threadEx creates a new thread, pauses it and adds an entry in a multimap (so several threads can be "linked" to one function)
3) whenever a thread is destroyed, a message is sent by GM to the MachineCallback (MC_THREAD_DESTROY)
4) the machine callback then calls another function passing the dead thread. the thread function reference is extracted
and used to find waiting threads in the multimap

That's all. Check out gmMachineEx.cpp, it's self-explanatory.


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Sun Mar 02, 2008 9:22 am 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13
I read the README! file and applied the changes. But I can't get it to work :

C++ code

void noParam()
{
std::cout<<"No param"<<std::endl;
}

void hasParam(int num)
{
std::cout<<num<<std::endl;
}

Then I bind them with
scriptVM->Bind(GLOBAL_NAMESPACE,FUNCTION(noParam),FUNCTION(hasParam,void(int)),END);

gm code:
noParam();
hasParam(1);

it prints:
No Param
Coud not find any matching overloaded function: hasParam

I'm using gm 1.5 from
http://www.gmscript.com/gamemonkey/downloads/


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Sun Mar 02, 2008 11:51 am 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13
I commented out the part of code that tries to find a proper overload and replaced them with pProxy=TempProxy. IT WORKS! I think there's something wrong with that code or maybe it's not compatible with the new GM or C++ compiler. There's no comment there so it's hard to understand what you're trying to do. I don't really need overloading so it's quite ok.

Anyway, nice work :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Sun Mar 02, 2008 2:19 pm 
Offline

Joined: Mon Jun 26, 2006 3:48 pm
Posts: 114
Location: Paris, France
Hi, I've just replied to your PM but I think I should post it here too:

Quote:
Hi,

I stopped using GM a long time ago (I'm a medical student, not a professional programmer :) ) but this should work without any problem.

scriptVM->Bind(
GLOBAL_NAMESPACE,
FUNCTION(noParam),
FUNCTION(hasParam,void(int)), //should be void(*)(int)
END);

Kind regards

And last time I checked, it was working so you shouldn't have to comment out any function.
And...you're welcome :wink:


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Mon Mar 03, 2008 3:07 pm 
Offline

Joined: Thu Dec 20, 2007 8:55 am
Posts: 13
Thanks, I figured it out. The void(*)(int) did not seem to change anything :) .
In your gmMachineEx::Bind, you have
if(isClass)
{
... //perform UpdateTypeIds() on all proxies
}

But when I bind a function, isClass=false -> There's no updating, all the proxies have GM_UNKNOWN type, that's why gmMachineEx::FunctionDispatcher can't find a matching overload.

I changed the code to have UpdateTypeIds, called on the constructor of gmFuncProxy and it works.

Btw, updating everything everytime a class is bound is time-consuming so I changed the code in Bind() to update the newest proxies only. I also added a method called ResolveTypeIds to perform a full update like your old code. In case there is cross-reference between classes, it should be called manually.


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 04, 2008 8:17 pm 
Offline

Joined: Sat Dec 09, 2006 2:41 am
Posts: 6
I recently started using gmMachineEx and found I was having the same problem as you, bull.
Would you mind sharing more information about your solution?

EDIT: after looking around a little I found where the TypeIds needed to be updated; thanks for the fix!


Top
 Profile  
Reply with quote  
 Post subject: Re: gmMachineEx [FINAL]
PostPosted: Tue Feb 21, 2012 3:14 am 
Offline

Joined: Tue Jan 31, 2012 7:53 am
Posts: 12
I cant find latest version of gmMachineEx (with the documentation), the link seems to be broken, I noticed that this topic was posted about 4 years ago,
but just asking, is there anyone who is still keeping the files? thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 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