|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Working on better C++ bindings for IoI'm working on a C++ binding library for Io that allows you to make your C++ objects callable from Io without typing a lot of code. It's called LikeMagic. ("Any sufficiently advanced technology is indistinguishable from magic." --Arthur C. Clarke)
Contrived example: // Here's an existing C++ class we want to bind to Io. class SomeClass { int GetNum(); void SetNum(int n); int AddTwo(int a, int b); // various other functions }; // Here's the LikeMagic binding: class Binds_SomeClass : public LikeMagic::TypeConverter<SomeClass, Backend_Io> { public: BoundTestObj() { BIND(GetNum); BIND(OtherF); BIND(SetNum); BIND(AddTwo); BIND(CompareWith); BIND(GetHalf); BIND(SetHalf); } } instance; /* LikeMagic only requires that you: 1. Inherit from the TypeConverter class 2. Pass the names of all the methods to BIND(). What you get from this is: - All the Io callback functions registered for you. - Creates an IoMethodTable and Io-callable wrapper functions for all the methods you passed to the BIND() macro. - Automatically converts the arguments in the Io message to the equivalent C++ types to pass to the C++ function in BIND(). - Automatically converts the value returned by the C++ function to an equivalent Io primitive or LikeMagic bound Io object. - The TypeConverter you just made will automatically be picked up and used if some other function returns this type of object to Io. */ |
|
|
Re: Working on better C++ bindings for IoAlthough you are working with C++, have you had a look at Lua's Alien project (http://alien.luaforge.net/)? It allows you bind to dynamic libraries from Lua itself (without writing glue). Thought you might be interested. Simon.
--- In iolanguage@..., "dennisf486" <dennisf486@...> wrote: > > I'm working on a C++ binding library for Io that allows you to make your C++ objects callable from Io without typing a lot of code. It's called LikeMagic. ("Any sufficiently advanced technology is indistinguishable from magic." --Arthur C. Clarke) |
|
|
Re: Working on better C++ bindings for IoThanks I'll take a look at that. Unfortunately alien.luaforge.net is down, but I found the google cache of it. I have a good handle on the C++ side of things, but for using the C API from Io to interact with the IoVM I have only the well-commented but somewhat incomplete (or outdated) C++ example from wikibooks.org.
--- In iolanguage@..., "simonhaines" <simonhaines@...> wrote: > > Although you are working with C++, have you had a look at Lua's Alien project (http://alien.luaforge.net/)? It allows you bind to dynamic libraries from Lua itself (without writing glue). Thought you might be interested. Simon. > > > --- In iolanguage@..., "dennisf486" <dennisf486@> wrote: > > > > I'm working on a C++ binding library for Io that allows you to make your C++ objects callable from Io without typing a lot of code. It's called LikeMagic. ("Any sufficiently advanced technology is indistinguishable from magic." --Arthur C. Clarke) > |
| Free embeddable forum powered by Nabble | Forum Help |