Access to COM Objects in Windows

Started by
3 comments, last by GameDev.net 17 years, 8 months ago
First, let me say this is a wonderful script engine and I'd like to thank the developer(s) for taking the time to both write, maintain, and enhance AngelScript. Big thumbs up for that. I have a question about the ability to access an interface defined by a COM object at script run time on Windows machines. Other script languages determine whether or not a function/method exists at run time. This allows someone writing a "COM Object Module" to intercept the undefined method/function calls and inspect the appropriate COM obect to see if that method/function exists within it using the COM Object's Type Library. I realize that the functionality is probably not built into AngelScript. From what I understand, AngelScript checks method and class names at compile time. I have no problem with any of this and I'm not requesting this to change. Given that, I believe the best solution would be to use an existing third party preprocessor, or write my own, to implement functionality similar to Visual Studio's #import statement. Basically, from what I can tell, this loads the COM Object's type library auto-register the COM Object's interfaces, methods, and constants with AngelScript at compile time. Does this seem like a reasonable approach? I realize that using COM objects themselves may not be reasonable to some of you, but some of us don't have much of a choice. I'd like to use AngelScript in my project, but the ease in which this capability can be added is a big factory in whether or not I can use AngelScript. Thanks for any input.
Advertisement
It shouldn't be hard. You can get function points into com objects, after all. The biggest issue I think you'll run into is converting type names to the names used in Angelscript. Here's basically what you will have to do.

-Get the com object
-For each function to be bound;
--Build a string containing the complete function signature, as Angelscript will see it
--Get the function pointer
--Bind it.

Doesn't look that hard at all. If you write a generic com-object-binder, please post it up here. :)
Your approach seems quite reasonable to me.

As COM objects are reference counted they should be quite easy to bind with AngelScript.

Once you know how to determine the function signature from the type library it shouldn't be difficult to register it. I know there exists standard components for reading the type library already, I just don't know the name of them anymore.

You may need to think a bit about how to handle the string type, as it is a special type in the COM world. But this shouldn't be too difficult to register either.

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:Once you know how to determine the function signature from the type library it shouldn't be difficult to register it. I know there exists standard components for reading the type library already, I just don't know the name of them anymore.


This so far has been my problem. I'm sure the capability exists as I see programs like studio's Object Inspector. However, I have yet to find anything in my spare time stating how this is done. I assume it requires the use of the type library but I see no methods in the appropriate C++ interfaces that seem to help.
Look for ITypeInfo interface.


- Gilad Novik

This topic is closed to new replies.

Advertisement