Monday, July 25, 2005

Tonight I fleshed out the basics for implementing a simple component manager. What is a component manager? Well, In order for callbacks (like onclick) in JavaScript to be effective, they need to be able to do something more meaningful than dump strings to stderr. To gain more power, they need to interface to external code written in a more powerful language, like C or C++. Components are one way to package code that can be called from JavaScript.

For this project, components and their interfaces are described in a XML file with a sil extension (which stands for Simple Interface Language).

Example:



<component name="simple" id="94981D9E-FC99-11D9-8BDE-F66BAD1E3F3A">
<class name="HelloClass">
<function name="Hello">
<arg name="MyName" type="string"/>
<return type="number"/>
</function>
<property name="age" type="number"/>
</class>
<class name="HelloClass2">
<function name="Hello">
<arg name="MyName" type="string"/>
<return type="number"/>
</function>
<property name="age" type="number"/>
</class>
</component>


Allowed argument and return types are string, number, and bool, corresponding to the basic types supported by JavaScript. Properties are defined with a property tag. The also have a name and type.

Each component is implemented as a single DLL/shared lib that implements the above classes, and methods to create and destroy objects belonging to the classes implemented by the component.

0 Comments:

Post a Comment

<< Home