Object-Oriented Programming Using SOM and DSOM:Hello World in SOM:Summary
Language bindings allow SOM objects to be used by different programming languages. They hide the SOM APIs from the programmers and allow the programmers to use SOM objects in the most natural notation. When other language bindings, such as Smalltalk, become available, a C++ program can use or subclass the SOM objects developed in Smalltalk as if they are C++ objects. Similarly, SOM objects developed in other languages can appear as Smalltalk objects, and the Smalltalk browser can be used to browse these objects.
Figures 2.10 and 2.11 summarize the SOM development process when using C++ or C.
SUFFIXES: .SUFFIXES: .cpp .obj .idl .xih .xh .c .h all: cHello.exe cppHello.exe .cpp.obj: icc -1. /c+ $< .c.obj: icc -1. /c+ $< .idl.xh: sc -sxh $*.idl .idl.xih: sc -sxih $•.idl .idl.cpp: sc -sxc $*.idl .idl.h: sc -sh $*.idl # Link cHello cHello.exe: hello.obj cMain.obj icc -Fe"cHello.exe" hello.obj cMain.obj somtk.lib # Link cppHello cppHelto.exe: hello.obj cppMain.obj icc -Fe"cppHello.exe" hello.obj cppMain.obj somtk.lib # Compile Hello SOM class helto.obj : hello.cpp helto.xih hello.xh hello.idl # Compile C client cMain.obj : cMain.c hello.h # Compile C++ client cppMain.obj : cppMain.cpp hello.xh
Figure 2.9 The Hello class Makefile
So what happens if you have added code to the implementation template and then decide to change the interface definition file (the .idl file)? You will need to re-run the SOM compiler to regenerate the binding files and the implementation template. What happens to the existing code? Will it be overwritten?
Figure 2.10 The SOM development process using C++
Figure 2.11 The SOM development process using C
The SOM compiler is smart enough to recognize that an implementation file already exists, and it will not regenerate a new one. Instead, the SOM compiler will make updates to the existing file. New methods will be added, and changes to any existing prototypes will be reflected. These updates will not delete any existing code.