Jan Jezabek | 12 Aug 23:52
Favicon

COM status report

Hi Ian (and list),

It's been a long time since the last status report - sorry for that. I 
haven't been sitting idle though. Here is what I have been working on in 
the last two weeks:

- support for constants which are wrapped as read-only properties in the 
module class,
- support for enums (type unsafe for now). COM has a very obscure enum 
feature, which is rather useless. Therefore enum values are currently 
just constants in the appropriate scope (e.g. if a class defines an enum 
then the constants are not in the module class which corresponds to 
global scope),
- added of typemaps for char *, std::string, std::wstring (all mapped to 
the OLE BSTR type, using character set conversion if necessary),
- added INPUT, OUTPUT, INOUT typemaps for all primitive types,
- changed wrapped function declarations to return HRESULT, converting 
the real return value to a [ retval, out ] parameter. This is required 
for OLE Automation and for DCOM,
- added stub exception handlers, simply returning E_ABORT,
- various bugfixes which brought the number of non-compiling tests from 
117 down to 25,
- made some changes to allocate.cxx to enable detecting overloading of 
functions which are inherited from base classes and the corresponding 
changes to the COM module,
- added a feature that I call 'class objects' (suggestions for a better 
name are welcome) used to work around the lack of static functions in 
COM. In short this is meant to be used if you need to call a static 
method of a class but you do not have an instance of that class. This is 
probably best shown by an example:

-----
/* example.i */
%module example

class MyClass {
public:
  virtual void something() = 0; // abstract
  static char *sayHello() { return "Hello world!"; }
};
-----

In VBScript you can now use it as follows:

-----
Rem test.vbs

Dim example
Rem Create the module class object
Set example = CreateObject("example.example")

WScript.Echo example.MyClass.sayHello()
-----

This works also for static variables. Below the surface MyClass is a 
read-only property of the module class which returns an object 
implementing an interface containing all static functions and variables 
from MyClass. Static functions and variables can still be accessed from 
a normal instance of MyClass for convenience.

- I created documentation for the COM module, which is not yet complete,
- I have also added some typemaps for std classes, taken mostly from 
Java with some minor changes to work around the lack of function 
overloading in COM.

I have a question about the typemaps for std::* - I have seen lots of 
different typemaps for std_map, std_deque, std_vector, etc. in std/, 
java/, csharp/, python/. Are there any guidelines of what should be in 
these typemaps? I have seen that these files are radically different 
from each other which is a little confusing.

For this week I plan to finish the documentation, add more run-tests and 
some examples and perform some code cleanup afterwards. I have a (rather 
large) backlog of small things that I would still like to improve, but I 
probably will not be able to do much work on them this week.

As always suggestions and comments are very welcome.

Thanks,
Jan Jezabek

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane