Object-Oriented Programming Using SOM and DSOM:Hello World in SOM:Summary

From EDM2
Jump to: navigation, search

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: .cpp .obj .idl .xih .xh .c .h

all: cHello.exe cppHello.exe

     icc -1. /c+ $<

     icc -1. /c+ $<

     sc -sxh $*.idl

     sc -sxih $•.idl

     sc -sxc $*.idl

     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?

OOP-SOM-Fig-2 10.png

Figure 2.10 The SOM development process using C++

OOP-SOM-Fig-2 11.png

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.