Contents Up Previous Next

The wxCLIPS type system

To communicate between C++ and CLIPS, wxCLIPS uses long integers to represent objects. For convenience, they are simply the addresses of the C++ objects. However, when these handles are passed back to C++, wxCLIPS cannot simply coerce these integers back to objects, since the object may not exist or the type may be wrong. The program would simply crash without an error message, which is clearly unacceptable.

Instead, there is an explicit type system which, in conjunction with a hash table for the objects, allows C++ implementations of CLIPS functions to check that an objects exists and to check that the type is suitable for the intended operation. The type does not have to be an exact match, as with C++, so long as the passed type is at least a subtype of the intended type. For example, say someone passed a wxFrame to the window-centre function. If a wxWindow has a virtual member function Centre, and wxFrame is a subtype of wxWindow, then it's permissable to coerce the wxFrame to a wxWindow and call the Centre function.

The helper library wxExtend provides the mapping between C++ wxWindows functionality and C functions/callbacks which can be used by interpreted languages such as wxCLIPS. Please refer to the wxExtend documentation for further details.