From: Jan J. <je...@po...> - 2008-08-12 21:59:17
|
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 |
From: Jan J. <je...@po...> - 2008-08-19 17:15:38
|
Hi, Here is the COM module status report for the last week. As always feel free to respond with any comments/suggestions that you have. I have been somewhat busy with university work lately and therefore have not been able to do as much as I would like to. I have concentrated mostly on improving the test coverage and finishing the documentation. Below is a list of things I have been working on: - Support for running the test suite under Cygwin has been added, using GCC (MinGW/Cygwin), MSVC or Digital Mars C++ (to ensure good compatibility of the generated code), - The build system now supports run-tests written in VBScript in addition to C, which makes writing tests much easier. This requires that Windows Script Host is installed - it works out of the box on Windows/Cygwin and also on Linux/Wine with a lot of tweaking, - I set up a Wiki page with instructions for testing, available here: http://www.dabeaz.com/cgi-bin/wiki.pl?DeveloperInfo/COMTesting - I added two examples ('simple' and 'class') and 6 new VBScript run tests; this uncovered a regression in the class factory code and imperfect detection of non-instantiable classes - both issues have been fixed, - I finished the module documentation with the exception of smart pointers; I haven't looked at them yet and don't know how they should work, - Bug fixes and minor additions: added checking for NULL arguments where necessary, added typemaps for char *& and wchar_t *&, removed unused fragments of the code. The overall state of my module is pretty good in my opinion - there is a reasonably small number of failing tests (29 out of 349 on Cygwin/MSVC), all major features except for smart pointers and directors are implemented, there are no known bugs where the generated code compiles but fails to work correctly. There are still some things that I would like to work on before I would like the module to be considered for inclusion in mainline SWIG - e.g. better handling of opaque types, more consistent naming of generated functions, preventing potential name clashes in the generated code, more complete INPUT, OUTPUT, INOUT typemaps, better error reporting using SetErrorInfo, support for DCOM (I am still not sure how much is needed for it to work), better compatibility with VB (e.g. using VT_BOOL for booleans). Thanks, Jan Jezabek -- My GSoC 2008 development blog: http://jezabekgsoc.wordpress.com/ |