2nd status update (June 2nd)

Below is the second status update for my project.
This is the second report for my GSoC project. This week I have mostly been busy with the IDL file generation. I decided to start with the globals (variables and methods) to get a good understanding of the SWIG internals. As a result the COM module can produce some potentially useful output already; for example the following header:

int globalVar;
extern int externGlobalVar;
double globalFunc(int,long);
int globalFunc(void);
static int staticGlobalFunc(int);

class aClass {
public:
  aClass();
  virtual int memberFunc(int);
};

class aSubclass {
public:
  virtual int memberFunc(int);
};

int registerAClass(aClass *acl);

generates the following output (command line is: swig -c++ -com test.i):

/*  ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.36
*
* Do not make changes to this file unless you know what you are  doing--modify
* the SWIG interface file instead.
*  -----------------------------------------------------------------------------  */

import "unknwn.idl";

[
  object,
  local
]
  interface testMod : IUnknown {
  void globalVar_set(int arg0);
  int globalVar_get();
  void externGlobalVar_set(int arg0);
  int externGlobalVar_get();
  double globalFunc(int arg0, long arg1);
  int globalFunc();
  int staticGlobalFunc(int arg0);
  int registerAClass(aClass * arg0);
};

Obviously there are many problems here – the classes are completely ignored for now (except as parameters, as in registerAClass), the arguments are not named properly (this is easy to fix, I am working on it right now), the in/out/inout parameters are not properly marked yet. I am also thinking about capitalizing the first letters of functions, as it is done in the C# target (as opposed to the default SWIG convention, which is shown above).

In parallel I have also been working on some aspects of the wrapper module (the C/C++ code responsible for converting parameters, creating getters/setters for variables, changing the calling convention if necessary, etc.). Originally I planned to do this at a later stage in development, but in fact the code needed for this is quite similar to the IDL generating code.

I have been thinking about how to organize the output that SWIG generates. In Java/C# and probably other languages the output can be divided in 4 parts:
1. wrapper code (C/C++ code that wraps the original code so that it has a common calling convention and parameter types as required by the target language),
2. intermediary class (class in target language, consisting only of function definitions – e.g. in Java this is a collection of ‘public static native’ methods),
3. module class (class whose methods correspond to the global functions and variables of the wrapped module),
4. proxy classes (class hierarchy in the target language mirroring the hierarchy of the input module).

I plan to mostly keep this structure, but with some modifications. Part 1 will be responsible for wrapping the (global and member) functions as global functions, taking an IUnknown* as a first parameter – this can be viewed as a change of the calling convention. Part 2 will consist of the definitions of the COM classes – most importantly this is where the vtables will be defined. Parts 3 and 4 will become the definitions in the IDL file.

For this week I am planning to add support for describing classes and their methods in the IDL file. Then I will continue the work on the wrapper code generation. My goal is for the basic IDL and wrapper generation to be functional by the end of week 3.

Something not directly related to development – I have created a blog: https://jezabekgsoc.wordpress.com/ . Although I am not a passionate blogger I will try my best to keep it up to date :).

As always any comments and suggestions are very welcome.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: