🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Binding and Inheritance

Started by
2 comments, last by WitchLord 16 years, 5 months ago
Another question... if i have class A and class B, and i want to bind both to Angelscript, what do i do with the shared methods? must i regsiter them twice? also what if i try to assign a B class to A class, will inheritance/polymorphism still work?
Advertisement
AngelScript understands C++ inheritance so that it can call virtual methods on classes, but it doesn't know the relationship between classes yet.

You'll have to register both classes with all the methods that AngelScript should be able to call on each, this means that virtual methods that should be available to both types must be registered twice.

You can let AngelScript assign a class B to class A by registering the proper assignment behaviour.

---

I'm currently working on a feature that will make a bit easier to tell AngelScript how types are related to each other. There will be a new behaviour asBEHAVE_REF_CAST that will allow AngelScript to cast a pointer from one type to another. With this you will be able to tell AngelScript that class A can be cast to a class B, and vice versa.

It's still not full inheritance, but at least you can provide an interface to the script writer that will work the same way.

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

Quote: Original post by WitchLord
AngelScript understands C++ inheritance so that it can call virtual methods on classes, but it doesn't know the relationship between classes yet.


Ah I see.. Well, rules it our for now for us.
However, I have to say that I'm very impressed with angelscript, as I believe it's really very well done (design and code wise), and so far the easiest to bind and implement scripting language I have found. The philosophy of the "do it yourself" (strings, tables, etc), and the resemablance to c++ while still supporting variants and other features of scripting languages has suprised me in the good sense.

I'd personally like to see more flexibility for binding to C++ features, like for example creating a flexible way for custom setters/getters/callers is vital in our case. I'm sure it could be added as just one extra behavior. Also i'd love to see better support for inheritance/polymorphism, as our game code uses it deeply (for example, UI components, physics stuff -volumes/body types/etc-, scene tree nodes, etc).

Unfortunately I don't have enough time right now, but otherwise i'd love to help develop the project, or try to get our company to sponsor it, Maybe in the future.

Cheers and great job!

Quote:
Ah I see.. Well, rules it our for now for us.


I can understand. AngelScript is not yet mature enough for everyone. Hopefully you'll stay in touch with AS though, I'm sure that it will have the features you require at one time or another as I continue the development.

Quote:
However, I have to say that I'm very impressed with angelscript, as I believe it's really very well done (design and code wise), and so far the easiest to bind and implement scripting language I have found. The philosophy of the "do it yourself" (strings, tables, etc), and the resemablance to c++ while still supporting variants and other features of scripting languages has suprised me in the good sense.


Thanks for the compliments. I'm glad you like this, as it is the principal driving point for AngelScript. Without it, AngelScript would just be another scripting library and wouldn't really have anything new to bring to the market.

Quote:
I'd personally like to see more flexibility for binding to C++ features, like for example creating a flexible way for custom setters/getters/callers is vital in our case. I'm sure it could be added as just one extra behavior. Also i'd love to see better support for inheritance/polymorphism, as our game code uses it deeply (for example, UI components, physics stuff -volumes/body types/etc-, scene tree nodes, etc).


All of what you're asking is planned for the future. I can't promise when it will be supported, but I can promise that it will be.

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

This topic is closed to new replies.

Advertisement