GameMonkey Script

GameMonkey Script Forums
It is currently Wed Aug 15, 2018 1:38 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Game Monkey and .NET
PostPosted: Sun Aug 10, 2014 9:31 pm 
Offline

Joined: Mon Mar 17, 2014 2:30 pm
Posts: 5
Hello!

I've been using GM in C++ for some time now, but I recently had to make a project in C# but I still want to be able to use GM.

My understanding is that there has been projects before to make .NET wrappers for GM, but I haven't found any source for this. If there are source anywhere or someone that's willing to share so I don't have to start from scratch and figure out how to approach this, that'll be great!

I will share whatever I come up with so others may enjoy GM in the .NET environment as well! :)

Thanks in advance!


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Wed Aug 13, 2014 8:37 pm 
Offline

Joined: Mon Mar 17, 2014 2:30 pm
Posts: 5
Okay, so after a bit of research I decided to go with using Swig (http://swig.org/) for this.

So far I've gotten it to run inside the .NET environment, but I need to tweak the interface files for swig for it to be useful.

Whenever I have something useful, I'll post a link to my github repo so anyone that would like to use it can.


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Thu Aug 14, 2014 7:56 am 
Offline

Joined: Thu Jan 01, 2004 4:31 pm
Posts: 307
A few years ago (4+?), I wrote a .NET version of the GM VM, called GreenBean. It was bytecode compatible and had performance around 2x slower than native code when compared against the benchmarks.

What I didn't do, however, was to port the parser/compiler, which in reality made it useless.

Today, I would look instead to create a parser/compiler up front and then implement GM as an interpreter in the same way as Jint does things. I'd likely look to using .NET's expression trees to do the heavy lifting for me, instead of writing an actual VM.

It depends on your goals, I've found that Jint fills the gap nicely for me and allows me to easily script .NET apps in JavaScript, so there's little need for GM in the .NET world.


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Thu Aug 14, 2014 9:23 am 
Offline

Joined: Mon Mar 17, 2014 2:30 pm
Posts: 5
downgraded wrote:
A few years ago (4+?), I wrote a .NET version of the GM VM, called GreenBean. It was bytecode compatible and had performance around 2x slower than native code when compared against the benchmarks.

What I didn't do, however, was to port the parser/compiler, which in reality made it useless.

Well, the thing is that I just need to run bytecode and register C# methods and objects. The project I'm working on interacts with a server that compiles all the GM code.

In terms of run times, how much slower is 2x during runtime? Is it noticeable?

downgraded wrote:
It depends on your goals, I've found that Jint fills the gap nicely for me and allows me to easily script .NET apps in JavaScript, so there's little need for GM in the .NET world.

I would've use V8.NET or jint if that was a possible solution.

I am really interested in any code you might have. Even the C api /C# wrapper you made ages ago, just to see how you approached the problem.


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Thu Aug 14, 2014 10:13 am 
Offline

Joined: Thu Jan 01, 2004 4:31 pm
Posts: 307
I took two approaches; one which was to create a C-style dll for GM, which allowed me to PInvoke. This was killed off a long time ago as it because really hard to maintain.

I can put GreenBean up on Github if you like; you're welcome to fork and do what you want with it.


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Thu Aug 14, 2014 10:22 am 
Offline

Joined: Mon Mar 17, 2014 2:30 pm
Posts: 5
downgraded wrote:
I took two approaches; one which was to create a C-style dll for GM, which allowed me to PInvoke. This was killed off a long time ago as it because really hard to maintain.

Well, okay, I can understand that. But have you tried swig? It generates a wrapper for you based on includes and also generates C# files for you to make a wrapper DLL with. It works directly with c++.

I've begun setting it up and so far I've got it to run and I can create an instance of the gmMachine, but I need to be able to register methods/types and that'll require some tweaking of the wrapper to do, which is why I ask you how you did it. This can then be applied to the swig interface files so that it can be maintained and generated for each new version of GM.

downgraded wrote:
I can put GreenBean up on Github if you like; you're welcome to fork and do what you want with it.

I'd really appreciate that, thanks! :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Fri Aug 15, 2014 3:03 pm 
Offline

Joined: Thu Jan 01, 2004 4:31 pm
Posts: 307
Here be dragons: https://github.com/evolutional/greenbeanscript


Top
 Profile  
Reply with quote  
 Post subject: Re: Game Monkey and .NET
PostPosted: Tue Aug 19, 2014 9:42 am 
Offline

Joined: Mon Mar 17, 2014 2:30 pm
Posts: 5
downgraded wrote:

Thank you very much! I've forked it and will provide patches if I do any fixes. :)


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