pyhon & C++

Gerry Stringer (gerry@camscan.co.uk)
Fri, 4 Jun 93 19:24:30 BST

There's been a sudden little flareup of mail on this list so I thought I might share some progress and raise a few small questions.

Overview:

We've reached the stage in our project where we need an interpreter front end (ddoesn't everyone) for user scripting/ customisation. I'm also getting a little disenchanted with the speed of C++ compilation so I'm looking for the possibility of the interpreter being used as a replacement for some C++.

Python seemed the obvious choice to fit the bill because:

1. there's a good chance a punter,I mean customer, could understand the syntax ie. not too hieroglyphic with lots of braces etc.

2. there's a reasonable match between Python and C++

Pythongen:

We've got the classic problem of interfacing to lots of existing code (about 400,000 lines of code and headers) hence the obvious move of writing a 'stub generator' which, given a much cut down class description can generate all the necessary code to be able to call the class methods from python. We've done this by writing a utility called pythongen.

eg. given a file "PSessionApplication.pgen" containing:

#include "../PSessionApplication/PSessionApplication.h"
#include "../session.h"
#include "String.h"

class PSessionApplication ;

Constructor = {|<CONSPTR>| = sessionapp ;};

void savetoDB(String asname) ;
void startprog(char* ptypename,int nargs,char* [nargs]) ;
String get_save_name() ;

After running pythongen on the file and the usual compilation tedium I can do

import PSessionApplication
session.startprog('someprogram',3,['-Wp','527','157'])

this is I actuallly