\batchmode
\documentclass{article}
\RequirePackage{ifthen}


\usepackage{pstricks,pst-node,html,epsf,makeidx}

%
\providecommand{\hyperref}[4]{#1#2\ref{#4}#3}


\title{Classdesc Documentation}
\author{Russell K. Standish}

%
\providecommand{\EcoLab}{{\sffamily\slshape
    \mbox{\raisebox{.5ex}{Eco}\hspace{-.4em}{\makebox[.5em]{L}ab}}}} 

%
\providecommand{\psection}[1]{\section{#1}}%
\providecommand{\psubsection}[1]{\subsection{#1}} 


\usepackage{makeidx}
\makeindex



\usepackage[dvips]{pstcol}


\pagecolor[gray]{.7}

\usepackage[latin1]{inputenc}



\makeatletter

\makeatletter
\count@=\the\catcode`\_ \catcode`\_=8 
\newenvironment{tex2html_wrap}{}{}%
\catcode`\<=12\catcode`\_=\count@
\newcommand{\providedcommand}[1]{\expandafter\providecommand\csname #1\endcsname}%
\newcommand{\renewedcommand}[1]{\expandafter\providecommand\csname #1\endcsname{}%
  \expandafter\renewcommand\csname #1\endcsname}%
\newcommand{\newedenvironment}[1]{\newenvironment{#1}{}{}\renewenvironment{#1}}%
\let\newedcommand\renewedcommand
\let\renewedenvironment\newedenvironment
\makeatother
\let\mathon=$
\let\mathoff=$
\ifx\AtBeginDocument\undefined \newcommand{\AtBeginDocument}[1]{}\fi
\newbox\sizebox
\setlength{\hoffset}{0pt}\setlength{\voffset}{0pt}
\addtolength{\textheight}{\footskip}\setlength{\footskip}{0pt}
\addtolength{\textheight}{\topmargin}\setlength{\topmargin}{0pt}
\addtolength{\textheight}{\headheight}\setlength{\headheight}{0pt}
\addtolength{\textheight}{\headsep}\setlength{\headsep}{0pt}
\setlength{\textwidth}{349pt}
\newwrite\lthtmlwrite
\makeatletter
\let\realnormalsize=\normalsize
\global\topskip=2sp
\def\preveqno{}\let\real@float=\@float \let\realend@float=\end@float
\def\@float{\let\@savefreelist\@freelist\real@float}
\def\liih@math{\ifmmode$\else\bad@math\fi}
\def\end@float{\realend@float\global\let\@freelist\@savefreelist}
\let\real@dbflt=\@dbflt \let\end@dblfloat=\end@float
\let\@largefloatcheck=\relax
\let\if@boxedmulticols=\iftrue
\def\@dbflt{\let\@savefreelist\@freelist\real@dbflt}
\def\adjustnormalsize{\def\normalsize{\mathsurround=0pt \realnormalsize
 \parindent=0pt\abovedisplayskip=0pt\belowdisplayskip=0pt}%
 \def\phantompar{\csname par\endcsname}\normalsize}%
\def\lthtmltypeout#1{{\let\protect\string \immediate\write\lthtmlwrite{#1}}}%
\newcommand\lthtmlhboxmathA{\adjustnormalsize\setbox\sizebox=\hbox\bgroup\kern.05em }%
\newcommand\lthtmlhboxmathB{\adjustnormalsize\setbox\sizebox=\hbox to\hsize\bgroup\hfill }%
\newcommand\lthtmlvboxmathA{\adjustnormalsize\setbox\sizebox=\vbox\bgroup %
 \let\ifinner=\iffalse \let\)\liih@math }%
\newcommand\lthtmlboxmathZ{\@next\next\@currlist{}{\def\next{\voidb@x}}%
 \expandafter\box\next\egroup}%
\newcommand\lthtmlmathtype[1]{\gdef\lthtmlmathenv{#1}}%
\newcommand\lthtmllogmath{\dimen0\ht\sizebox \advance\dimen0\dp\sizebox
  \ifdim\dimen0>.95\vsize
   \lthtmltypeout{%
*** image for \lthtmlmathenv\space is too tall at \the\dimen0, reducing to .95 vsize ***}%
   \ht\sizebox.95\vsize \dp\sizebox\z@ \fi
  \lthtmltypeout{l2hSize %
:\lthtmlmathenv:\the\ht\sizebox::\the\dp\sizebox::\the\wd\sizebox.\preveqno}}%
\newcommand\lthtmlfigureA[1]{\let\@savefreelist\@freelist
       \lthtmlmathtype{#1}\lthtmlvboxmathA}%
\newcommand\lthtmlpictureA{\bgroup\catcode`\_=8 \lthtmlpictureB}%
\newcommand\lthtmlpictureB[1]{\lthtmlmathtype{#1}\egroup
       \let\@savefreelist\@freelist \lthtmlhboxmathB}%
\newcommand\lthtmlpictureZ[1]{\hfill\lthtmlfigureZ}%
\newcommand\lthtmlfigureZ{\lthtmlboxmathZ\lthtmllogmath\copy\sizebox
       \global\let\@freelist\@savefreelist}%
\newcommand\lthtmldisplayA{\bgroup\catcode`\_=8 \lthtmldisplayAi}%
\newcommand\lthtmldisplayAi[1]{\lthtmlmathtype{#1}\egroup\lthtmlvboxmathA}%
\newcommand\lthtmldisplayB[1]{\edef\preveqno{(\theequation)}%
  \lthtmldisplayA{#1}\let\@eqnnum\relax}%
\newcommand\lthtmldisplayZ{\lthtmlboxmathZ\lthtmllogmath\lthtmlsetmath}%
\newcommand\lthtmlinlinemathA{\bgroup\catcode`\_=8 \lthtmlinlinemathB}
\newcommand\lthtmlinlinemathB[1]{\lthtmlmathtype{#1}\egroup\lthtmlhboxmathA
  \vrule height1.5ex width0pt }%
\newcommand\lthtmlinlineA{\bgroup\catcode`\_=8 \lthtmlinlineB}%
\newcommand\lthtmlinlineB[1]{\lthtmlmathtype{#1}\egroup\lthtmlhboxmathA}%
\newcommand\lthtmlinlineZ{\egroup\expandafter\ifdim\dp\sizebox>0pt %
  \expandafter\centerinlinemath\fi\lthtmllogmath\lthtmlsetinline}
\newcommand\lthtmlinlinemathZ{\egroup\expandafter\ifdim\dp\sizebox>0pt %
  \expandafter\centerinlinemath\fi\lthtmllogmath\lthtmlsetmath}
\newcommand\lthtmlindisplaymathZ{\egroup %
  \centerinlinemath\lthtmllogmath\lthtmlsetmath}
\def\lthtmlsetinline{\hbox{\vrule width.1em \vtop{\vbox{%
  \kern.1em\copy\sizebox}\ifdim\dp\sizebox>0pt\kern.1em\else\kern.3pt\fi
  \ifdim\hsize>\wd\sizebox \hrule depth1pt\fi}}}
\def\lthtmlsetmath{\hbox{\vrule width.1em\kern-.05em\vtop{\vbox{%
  \kern.1em\kern0.8 pt\hbox{\hglue.17em\copy\sizebox\hglue0.8 pt}}\kern.3pt%
  \ifdim\dp\sizebox>0pt\kern.1em\fi \kern0.8 pt%
  \ifdim\hsize>\wd\sizebox \hrule depth1pt\fi}}}
\def\centerinlinemath{%
  \dimen1=\ifdim\ht\sizebox<\dp\sizebox \dp\sizebox\else\ht\sizebox\fi
  \advance\dimen1by.5pt \vrule width0pt height\dimen1 depth\dimen1 
 \dp\sizebox=\dimen1\ht\sizebox=\dimen1\relax}

\def\lthtmlcheckvsize{\ifdim\ht\sizebox<\vsize 
  \ifdim\wd\sizebox<\hsize\expandafter\hfill\fi \expandafter\vfill
  \else\expandafter\vss\fi}%
\providecommand{\selectlanguage}[1]{}%
\makeatletter \tracingstats = 1 


\begin{document}
\pagestyle{empty}\thispagestyle{empty}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength hsize=\the\hsize}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength vsize=\the\vsize}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength hoffset=\the\hoffset}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength voffset=\the\voffset}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength topmargin=\the\topmargin}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength topskip=\the\topskip}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength headheight=\the\headheight}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength headsep=\the\headsep}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength parskip=\the\parskip}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength oddsidemargin=\the\oddsidemargin}\lthtmltypeout{}%
\makeatletter
\if@twoside\lthtmltypeout{latex2htmlLength evensidemargin=\the\evensidemargin}%
\else\lthtmltypeout{latex2htmlLength evensidemargin=\the\oddsidemargin}\fi%
\lthtmltypeout{}%
\makeatother
\setcounter{page}{1}
\onecolumn

% !!! IMAGES START HERE !!!

{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline2736}%
$\leftrightarrow $%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
{\newpage\clearpage
\lthtmlfigureA{figure289}%
\begin{figure}
\epsfclipon 
\epsfxsize =\textwidth
\epsfbox{polymorph-example.eps}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{section}
\stepcounter{section}
\stepcounter{section}
\stepcounter{section}
\stepcounter{section}
{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline726}%
$i$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}

\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsubsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsubsection}
\stepcounter{subsection}
\stepcounter{section}
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure471}%
\begin{figure}\epsfbox{fig1.eps}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{figure480}%
\begin{figure}\begin{center}
{\em compiler converts to\\
function call}\\
$\underbrace[\mathit{a message}]{\mathtt{[receiver select arg1
      \ldots]}} \rightarrow \mathtt{objc msgSend(receiver,selector,arg1,\ldots)}$\end{center}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure494}%
\begin{figure}\begin{tabular}{|l|l|l|}
\hline
File name \& extension & Purpose & Remarks\\\hline
myobj.h & C++ header file & User model\\
myobj.cc & C++ object implementation file & User model\\
myobj.mh & ObjC object header & Interface file 1\\
myobj.m & ObjC object implementation & Interface file 2\\
myobjExportCpp.cc & ObjC program calls C++ objects& Interface file 3\\
myObjExportObjc.m & C++ program calls ObjC/Swarm objects & Interface file 4\\
myobj.mo & Compiled ObjC object & ObjC object file\\
myobj.o & Compiled C++ object & C++ object file\\
myobj.cd & Classdesc description file & Classdesc output \\\hline
\end{tabular}
\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure504}%
\begin{figure}\begin{verbatim}

#include <stdarg.h>
#include "ObjCsupport.h"            // ObjC supports
#include "vector"

class myCounter: public objc_obj {  // need to be derived from ObjC class
   public:
      char   sName[20];
      int    iaX[2][4];
      . . .

   public:
      int    sum3_x1(int x1, double x2, double x3); // std parameter passing
      double sumN_x1(double x1, objc_t& buf);       // using va_list
      int prtVec(vector<int> v);  // c++ only method - no ObjC translation
      int cpp_prtVec();           // C++ only method due to "cpp_" sub-string
};\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{figure510}%
\begin{figure}\begin{verbatim}

#import <objc/Object.h>

@interface myCounter : Object
{  @public
      char sName[20];
      int iaX[2][4];
      . . .
}
- init;
- (double) sum3_x1: (double) x1 x2: (double) x2 x3: (double) x3;
- (double) sumN_x1: (double) x1, ...;
@end\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure522}%
\begin{figure}\begin{description}
\item[Standard parameter passing method:]\mbox{}\\
\begin{description}
\item[C++ method :]     \verb+double sum2_x1(double x1, double x2);+
\item[Objective-C:]     \verb+- (double) sum3_x1: (double) x1 x2: (double) x2;+
\end{description}
\par
\item[Parameter passing using {\tt va\_list}:]\mbox{}\\
\begin{description}
\item[C++ method :]     \verb+double sumN_x1(double x1, objc_t& buf);+
\item[Objective-C:]     \verb+- (double) sumN_x1: (double) x1, ...;+
\end{description}
\par
\item[Example of Objective-C calls in user main program (main.m):]\mbox{}\\
\begin{verbatim}

   double dx = [myObj sumN_x1: 1.1, 2.2, 3.3];\end{verbatim}

\par
\item[Example of user method implementation in C++ (myCounter.cc):]\mbox{}\\
\begin{verbatim}

   double sumN_x1(double x1, objc_t& buf)
   { double x2, x3 ; buf >> x2 >> x3, return x1 + x2 + x3; }\end{verbatim}

\end{description}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{figure541}%
\begin{figure}\begin{description}
\item[Objective-C interface functions generated (stored in .m file) :]\mbox{}\\
\begin{verbatim}

double cpp_myCounter_sum2_x1(myCounter * obj, double x1 , double x2);
- (double) sum2_x1: (double) x1 x2: (double) x2 
{ return cpp_myCounter_sum2_x1(self, x1, x2); }

double cpp_myCounter_sumN_x1(myCounter * obj, double x1, va_list * ap);
- (double) sumN_x1: (double) x1, ...
{ double rtnvalue;  va_list ap;  va_start(ap, x1);
  rtnvalue = cpp_myCounter_sumN_x1(self, x1, &ap);
  va_end(ap);
  return rtnvalue; }\end{verbatim}

\par
\item[C++ interface functions generated (stored in ExportCpp.cc
  file):]\mbox{}\\
\begin{verbatim}

extern "C"
double cpp_myCounter_sum2_x1(myCounter * obj, double x1 , double x2)
{ return obj->sum2_x1(x1, x2); }

extern "C"
double cpp_myCounter_sumN_x1(myCounter * obj, double x1, va_list * ap)
{ objc_t buffer;  buffer.ap = ap;  return obj->sumN_x1(x1, buffer); }\end{verbatim}

\end{description}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{figure554}%
\begin{figure}\begin{verbatim}

Given C++ function prototype :
       Cpp-return-type   function-name   Cpp-argument-list
Output Objective-C equivalent:
       ObjC-return-type  function-name   ObjC-argument-list

construct ObjC-return-type + function name
IF C++-only function
   no-function-translation
ELSE IF (#arg==2 & arg2-type==objc_t&)
   construct va_list-type-ObjC-argument-list
ELSE
   FOR arg1 to argn
      construct standard ObjC-type-argument-list\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure562}%
\begin{figure}\small
\begin{verbatim}

#include "writeobjc_base.h"
inline void writeobjc(writeobjc_t* targ, string desc,class myCounter& arg)
{
writeobjc(targ,desc+"",(objc_obj&)arg);
writeobjc(targ,desc+".sName",is_array(),arg.sName[0],"[20]");
. . .
writeobjc(targ,desc+".sum2_x1",arg,&myCounter::sum2_x1, "double", "double x1, double x2");
writeobjc(targ,desc+".sumN_x1",arg,&myCounter::sumN_x1, "double", "double x1 , objc_t & buf");
}\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure572}%
\begin{figure}\begin{verbatim}

#define WRITE_OBJC(classname) \
writeobjc_headers(&targ, (string) STRING(classname)); \
writeobjc(&targ, (string) STRING(classname), arg);\
writeobjc_tail(&targ)

#include "writeobjc_base.h"
#include FILE_NAME(CNAME,.h)
#include FILE_NAME(CNAME,.cd)
int main()
{  writeobjc_t targ;
   CNAME arg;
   WRITE_OBJC(CNAME);
   return 0;
}\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure581}%
\begin{figure}\begin{enumerate}
\item Parse C++ model using Classdesc
\item Create a translator
\item Auto-generate interface files
\item Generate final application
\end{enumerate}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{figure587}%
\begin{figure}\epsfbox{fig12.eps}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure594}%
\begin{figure}\begin{description}
\item[Specify a C++ compiler to use in {\tt
    \~{}/\$(SWARMHOME)/etc/swarm/Makefile.common} file]\mbox{}\\[-5ex] 
\begin{verbatim}

CPP=/usr/local/gcc2/bin/g++\end{verbatim}

\item[Add .m.mo and .cc.o rules in
  {\tt\~{}/\$(SWARMHOME)/etc/swarm/Makefile.rule} file:]\mbox{}\\[-5ex]
\begin{verbatim}

.SUFFIXES: .o .m .mo .mh .cd .cc .xm
.m.mo:   $(OBJC) -c -o $@ $(OBJCFLAGS) $(CPPFLAGS) $(DLLCPPFLAGS) \
     $(EXTRACPPFLAGS)  $(SWARMINCLUDES) $<
.cc.o:     $(CPP) -g -c $(OPTFLAGS)  $<\end{verbatim}

\par
\item[Specify the use of C++ for linking in Makefile.appl]\mbox{}\\[-5ex]
\begin{verbatim}

$(APPEXE): $(OBJECTS)
       $(SHELL) $(bindir)/libtool-swarm --mode link $(CPP) $(CFLAGS) $(LDFLAGS) -\end{verbatim}

\end{description}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{subsubsection}
{\newpage\clearpage
\lthtmlfigureA{figure616}%
\begin{figure}\begin{verbatim}

.h.cd: classdesc -objc writeobjc < $< > $@
.h.mh: $(CPP) -g -c myCounter.cc
       $(CPP) -g -DCNAME=myCounter -o write_objc $(CPPOBJ) $(OBJC_TRANSLATOR)
       write_objc
.m.mo: $(CC) -c -o $@ -Wno-import $(CFLAGS) $<
.m.o:  $(CC) -c -Wno-import $(CFLAGS) $<
.cc.o: $(CPP) -g -c $(OPTFLAGS)  $<
LIBS = -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/ \
       -L/usr/local/lib/libstdc++.so -lgcc -lobjc

OBJC_cd=myCounter.cd
OBJC_mh=myCounter.mh
CPPOBJ=myCounter.o
INTERFACE_OBJ= myCounterExportCpp.o
OBJC_TRANSLATOR=write_objc.cc
OBJCOBJ=main.o myCounter.mo
OBJ=$(OBJCOBJ) $(CPPOBJ) $(INTERFACE_OBJ)
appl: $(OBJC_cd) $(OBJC_mh) $(OBJ)
      $(CPP) $(CFLAGS) -o main $(OBJ) $(LIBS)

main.o: main.m
myCounter.cd: myCounter.h
myCounter.mo: myCounter.mh myCounter.m
myCounter.o: myCounter.h myCounter.cc
myCounterExportCpp.o: myCounter.h myCounterExportCpp.cc
myCounter.mh: myCounter.h myCounter.cc

clean:
        rm -f *.o *.mo *.*~ *~ main *.cd *,D
        rm myCounterExportCpp.cc write_objc myCounter.mh myCounter.m
...\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

{\newpage\clearpage
\lthtmlfigureA{figure622}%
\begin{figure}\begin{verbatim}

$ make clean
$ make                                                                  ? Step 1
classdesc -objc writeobjc < myCounter.h > myCounter.cd
/usr/local/gcc2/bin/g++ -g -c myCounter.cc                      ? Step 2
/usr/local/gcc2/bin/g++ -g -DCNAME=myCounter -o write_objc myCounter.o write_objc.cc
write_objc

C++ to ObjC parsing ...                                         ? Step 3
Starts parsing C++ class to ObjC ...
Translating array: "sName[20]" - Translating simple data type: "sName" of-type "char"
. . .
Translating function: double  sumN_x1(double x1 , objc_t & buf )
. . .
End translation.

gcc -c -Wno-import -g main.m                                            ? Step 4
gcc -c -o myCounter.mo -Wno-import -g myCounter.m
g++ -g -c myCounterExportCpp.cc
g++ -g -o main main.o myCounter.mo myCounter.o myCounterExportCpp.o 
    -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95/
    -L/usr/local/lib/libstdc++.so -lgcc -lobjc

$ main                                                                  ? myCounter example
C++ -> ObjC interface testing:
MyCounter C++ Object: byte=<68> ObjName=<c1> dVal=<5.5> iInc=<3>
                      iaX[2][4]=<10 11 12 13 20 21 22 23 >
MyCounter C++ Object: byte=<68> ObjName=<c1> dVal=<8.5> iInc=<3>
                      iaX[2][4]=<10 11 12 13 20 21 22 23 >
Parameter passing using va_list:   Sum = 16.500000
Normal ObjC parameter passing:     Sum = 16.500000
End testing.
$\end{verbatim}

\end{figure}%
\lthtmlfigureZ
\lthtmlcheckvsize\clearpage}

\stepcounter{section}
\stepcounter{subsection}

\end{document}
