Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


* * * * * 1 votes

Try Angelscript live!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 clb   Members   -  Reputation: 1785

Like
3Likes
Like

Posted 08 December 2012 - 12:48 PM

Hi,

here's something cool I wrote up this weekend. With your modern browser with WebGL enabled, visit this page: MathGeoLib live test site. It is a project consisting of a few parts:
  • Uses my native C++ graphics rendering engine gfxapi. Utilizes the emscripten compiler to deploy the application to HTML5.
  • Integrates Angelscript as the live scripting engine.
  • Uses my MathGeoLib library for scripting primitives and geometry manipulation.
  • Interop between C++ MathGeoLib classes and Angelscript is achieved using an automatic bindings generator based on juj/CodeStructure.
The application allows writing Angelscript live on a web page, and render stuff on the screen by using constructs from MathGeoLib and gfxapi. I really must congratulate Andreas Jönsson for the Angelscript project - it is a very fine piece of technology! I have previously written C++ - script bindings interop for MathGeoLib for QtScript and Javascript, and using Angelscript is the most mature, easist and convenient one of them to work with! I evaluated Python, Lua and Mono to replace my previous JavaScript-based scripting engines, but Angelscript is the king of the hill. The support for strong typing and ability to do value types with function and operator overloading is exactly what is needed for good interop and convenient games scripting, and something where the whole competition falls short :)
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3418

Like
1Likes
Like

Posted 08 December 2012 - 01:49 PM

It's really cool to see different techs come together like this. Thanks for sharing.

I'll have to look into these other projects you link to. They all look interesting.

Thanks for the compliments on AngelScript. I'm very pleased to see you value exactly the features that made me start writing AngelScript almost 10 years ago, i.e. strong/static typing, and proper C++ integration.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#3 clb   Members   -  Reputation: 1785

Like
0Likes
Like

Posted 11 December 2012 - 12:19 AM

Hey, something I was thinking while doing this: Are there any C++->Angelscript bindings generators out there? Something that would take in a set of .h/.cpp files and automatically generate the interop code for the symbols contained in those files?

That's something I ended up doing with this project, and I was wondering whether it is sensible to continue with that effort, or whether tools for that already exist?
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#4 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 11 December 2012 - 04:37 AM

Perform a forum search with "Generate" there are some binder generator scripts posted before.

i have started such project. Serious hurdles are:

- Can not determine object type. Is it a Value, NOCOUNT, Refcounted or Garbage collected
- Parameter type, &in &out &inout . Easy way out is enable unsafe refs.
- Inheritance, not enough to scan a single .h file. Allow casting or not?
- How about primitive typedefs
- Heap corruption errors, Yeah, they happen a lot. you can't spot these until functions are used in script. So, lots of test cases ?

my solution is to put preprocessor directives before some risky declarations.
I am getting tired, just too many cases to handle.
Manually registering them is way easier.

#5 Alpha_ProgDes   Crossbones+   -  Reputation: 4692

Like
0Likes
Like

Posted 11 December 2012 - 05:22 AM

Your web page reminds me of Light Table (somewhat). Very cool!
Beginner in Game Development? Read here.
 
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
 
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts Posted Image
 
Spoiler

#6 clb   Members   -  Reputation: 1785

Like
0Likes
Like

Posted 11 December 2012 - 07:14 AM

Alpha_ProgDes: thanks!

Perform a forum search with "Generate" there are some binder generator scripts posted before.

i have started such project. Serious hurdles are:

- Can not determine object type. Is it a Value, NOCOUNT, Refcounted or Garbage collected
- Parameter type, &in &out &inout . Easy way out is enable unsafe refs.
- Inheritance, not enough to scan a single .h file. Allow casting or not?
- How about primitive typedefs
- Heap corruption errors, Yeah, they happen a lot. you can't spot these until functions are used in script. So, lots of test cases ?

my solution is to put preprocessor directives before some risky declarations.
I am getting tired, just too many cases to handle.
Manually registering them is way easier.


I use doxygen as the backend for my script generator. A lot of the required information is specified in the comments. For example, if a function has a comment /* @param outTriangleCount [out] Receives the number of triangles generated. */, then the presence of the string '[out]' tells the generator to use '&out' for the binding. The bindings are generated at a global project scope, not by scanning a single .h file, so the generator has knowledge of which types the script engine understands, and it automatically leaves out those signatures that contain symbols that aren't understood. Inheritance, #defines and typedefs are detectable, since doxygen knows about those, and the generator can be guided with special comments inside doxygen tags like [noscript] or [valuetype], etc. Whether the types have custom ctor/dtor/assignment/copyctor is known, and function default parameters can also be detected.

This is the third script bindings generator I have written with the same doxygen-based backend code. I have used the same approach with C++ -> QtScript bindings and C++ -> JavaScript (embind) bindings.

So far the generator is very primitive, and only used to expose MathGeoLib value types. What I'm looking for currently is whether I am duplicating my effort here and if it's sensible to write this at all, or whether someone else has solved this already.

I am still a beginner to Angelscript, so your insights on what exactly are the "not-automatically-detectable-by-introspection" kind of cases are very valuable to me. If you can give some pointers on what kind of "external" decisions a developer makes when building interop, that will be very helpful.
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#7 saejox   Members   -  Reputation: 714

Like
0Likes
Like

Posted 11 December 2012 - 09:17 AM

using doxygen is a great idea since it parses both comments and code.
i have used clang, unfortunately clang doesn't parse comments. boost::wave for preprocessor directives.
I dont like how mine turned out. It is a mess. Hard to use and integrate.
What is the point if i have to manually write directives for every parameter.

Maybe a GUI utility to help me fill those missing parts.
a workflow like this

1- generate xml from headers
2- open xml in gui
3- edit unwanted types, parameters, cast, constructors
4- press generate to create bindings
5- see them in gui, if dont like em go back to 3
6- save it so we dont repeat ourself later

generating binding is not worthy if process is just as hard as writing them by hand.

#8 Andreas Jonsson   Moderators   -  Reputation: 3418

Like
0Likes
Like

Posted 12 December 2012 - 10:17 AM

As you already pointed out, some things cannot be automatically generated. For example when to use autohandles, or when to use &in or &out. In these cases a manual decision has to be made. In many cases you also do not want to expose all types and functions either. Access profiles is another thing that has to be chosen manually.

My idea for an auto generator would work like this:

1. For a first time generation, the generator would parse the C++ files looking for potential types and functions that can be registered with the script engine. It should preferrably be possible to filter which C++ files to parse, so the generator doesn't try to understand the inner guts of the program.
2. The generator would store what it finds in an intermediate file where the user can select the types and functions that should and shouldn't register, as well as make the manual decisions mentioned before.
3. From this intermediate file, the generator would then generate the actual binding code that will be built with the application.
4. The generator should also have the capability of doing a new sweep over the C++ files to look for changes that have been made since the last time the binding code was generated. When this happens it should update the intermediate file, clearly marking what has been modified, yet keep the user added information where the C++ file has not been modified.

This 4th bullet is where the real benefit of an auto generator comes in. That is, the ability to automatically identify changes to keep the binding code synchronized with the C++ code.

The generator could have a couple of additional features, such as a GUI to browse and update the intermediate file, as well as to keep track of comments to be used to generate the documentation for the script writers. These features are however much less important.

All this should be done without requiring special comments in the actual C++ files. All user edited information should be kept in the intermediate file.

Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

#9 clb   Members   -  Reputation: 1785

Like
0Likes
Like

Posted 13 December 2012 - 06:58 AM

Thanks saejox and Andreas for the good insight! I think I've now got a good grasp of how to proceed. The tool will be available on github if you are interested in trying it out later.
Me+PC=clb.demon.fi | C++ Math and Geometry library: MathGeoLib, test it live! | C++ Game Networking: kNet | 2D Bin Packing: RectangleBinPack | Use gcc/clang/emcc from VS: vs-tool | Resume+Portfolio | gfxapi, test it live!

#10 Andreas Jonsson   Moderators   -  Reputation: 3418

Like
0Likes
Like

Posted 13 December 2012 - 08:18 AM

It would be great to add a tool like this to the list of useful AS resources.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS