Port of sp-1.3 to Macintosh


From     owner-sp-prog@cygnus.uwa.edu.au Thu Jul 16 05:15:02 1998
From:    peter.robinson@english.oxford.ac.uk
Date:    Thu, 16 Jul 1998 11:02:12 +0100 (BST)
To:      sp-prog@cygnus.uwa.edu.au
Subject: Re: Port of sp-1.3 to Macintosh


Yep, been there, done that.  With Metrowerks codewarrior 2; works very
nicely (mostly..some problems with Jade I have not got about to fixing.

Here is my list of instructions to myself on how I did it.  You'll see
there are a few odd bits and pieces, as I integrated it withy my collate
application.  But this should help you past the stickiest bits.

Notes on building SP for the Mac...
1.  Make a project, called SP or similar, in the root of the SP source
folder.  Make this as
a ANSI C++ console multitarget project.  Then remove the 'helloworld.cpp'
source provided
2.  Reset the ANSI C++ console settings so that the file
CollateProjPPC-mac.h is prefixed.
3.  Under file mappings, set the compiler to recognize .cxx files.
4.  Add all the files in 'lib' to the project (for tidiness, in folders).
        For Jade: add also files in style, jade, grove and spgraove
        Add access path to include and generic folders
4a Check the access paths carefully.  Several of the .h files JJC uses have
the same names
as Macintosh or MWC .h files: eg types.h, Node.h.  Even more confusing: JJC
supplies TWO
resource.h files, one in groveoa, one in include.  If you get strange
errors (redefinitions
of types already defined, keywords not understood, etc, this is likely to
be because it has
found the wrong .h file.
5.  Remove the file 'memmove.c' from the lib project: this is not
necessary, as the Mac ANSI
C libraries have this
6.  In the files 'OutputByteStream.cxx' and 'CmdLineApp.cxx' and others:
change the line
#include <sys/types.h>
to
#include "types.h"
and replace the line
#include <sys/stat.h>
by
#include <stat.h>
7.  in the file style.h: in the class class StyleStack there is a
ELObj *inherited
this collides with a keyword in Metrowerks.  Change to ELObj *Inherited
Accordingly, in
InheritedC.cxx line 1135   ELObj *obj =
ec.styleStack->inherited(inheritedC_, ec.specLevel, interp,
will give an error.
change to ec.styleStack->Inherited
A similar change has to be made in style.cxx
7a In file ProcessContext.h
  friend struct Connection;
  friend struct Connectable;
  is defined twice in the class class ProcessContext : public
Collector::DynamicRoot {
so I have commented out the second occurrence.
7b in file collector.h:
MWC chokes on:
inline
Collector::DynamicRoot::DynamicRoot(const DynamicRoot &root)
{
  link(&root);
}

inline
void Collector::DynamicRoot::operator=(const DynamicRoot &root)
{
  unlink();
  link(&root);
}
and says that the function is here declared inline after being called.
(It appears we have circular logic here: link and unlink are also inline, so if
we try and declare these functions in the class definition we get the same
problem:
link and unlink are also then declared inline after being called.
So I just commented out the these inline defs in collector.h and moved the
definitions into
collector.cxx and all seems fine.


7c A few files in the Jade directory are system dependent (on windows
specifically).  These are the texfotbuilder and the
rtfole files.  remove these from the project.
Also system dependent are the Winapp.cxx and related files in the lib
folder.  Remove these too.



8.  In OutputByteStream.cxx, the line
  return attach(::open(filename, openFlags, protMode));
does not conform to the prototype for open (set in the file fcntl.mac.h as
int open(const char *path, int oflag);
so: change to
//  return attach(::open(filename, openFlags, protMode));
  return attach(::open(filename, openFlags));


10.  In file posixstorage.cxx:
add line
#define EINTR 4

10a.  In file strerror.c:
The MWC compiler does not like the function declaration:
char *strerror(in)
     int n;
{
Alter this to:
char *strerror(int in)
{
and that is oK
11. Do this next step ONLY if it is not integrated in collate;
Collate integration looks after this
In 'CmdLineApp.cxx' insert line
#include <console.h>
and place
argc=ccommand(&argv)
as first statement in  CmdLineApp::run
int CmdLineApp::run(int argc, AppChar **argv)
{
 argc=ccommand(&argv);

 12.  In the file TeXFOTBuilder.cxx:
 void TeXFOTBuilder::setPageNumberFormat(const String<unsigned short> &name)
 does not match JJC's prototype.  So alter too:
 void TeXFOTBuilder::setPageNumberFormat(const String<unsigned char> &name)
However, there appears to be something wrong with the call in jade.cxx
 makeTeXFOTBuilder(&outputFile_, this, exts);
so this line commented out.

Now everything should go fine!

Integration with Collate

1. The header files as follows make everything work fine, so that you can
mix and match
Collate and SP and native Macintosh routines:
#if defined(MWCMAC)
        #include <MSLHeaders++.h>
        #include <collhdr.h>
        #include <prepare_hdr.h>
        #include <collation_hdr.h>
        #include <coll_dbase.hdr>
        #include <coll_output.hdr>
        #include <coll_blkshdr.h>
        #include <coll_protos.inc>
#if (defined(CONVERTOR))
        #undef COLLATE
        #undef PROJECT
#endif
        #define MACBOOLEANS
#endif
2.  To make this all go, you have to include the file CollateProjPPC-mac.h,
from the prefix
to the whole project.  THis file has only the lines:
#define MWCMAC 1
#define __POWERPC TRUE
Note that this is for the powerpc target.  The 68K target will have a
different prefix:
just omit the line #define __POWERPC TRUE and add #define PPC68 to exclude
old style function
defs etc
3.  Note that you MUST change JJC's Boolean.h file.  This is because this
redefines Boolean.
So the line     #define MACBOOLEANS in the header above allows us to #ifdef
out the whole of
JJC's definition of Boolean.  (We have had to do the same for YASP, where
the same problem arises).
No ill effects have been observed from this, but it is clear that we should
keep generic SP
and Collate etc files apart as far as possible.
4.  To activate the command line parser, using nsgmls: alter the file
nsgmls.cxx as follows
a.  comment out the line
SP_DEFINE_APP(NsgmlsApp)
NOW, do one of two things.  When NOT integrating with Collate, follow steps
b and c:
b.  insert these lines in the file:
//next lines added for integration
typedef char **Handle;

extern pascal Handle NewHandle(size_t);
extern pascal void DisposeHandle(Handle);
void parse_sp_cmdline(void);

void parse_sp_cmdline() {
        NsgmlsApp::sp_nsgmls_cmdline();
}

void NsgmlsApp::sp_nsgmls_cmdline()  {
        int argc=1;
        Handle argv=NewHandle(sizeof(char));
        NsgmlsApp app;
        app.run(argc, argv);
        DisposeHandle(argv);
}

//end additions
c.  in the definition of class NsgmlsApp : public ParserApp add the line
        static void sp_nsgmls_cmdline();
and that's it.
When integrating with collate, life is much easier.  Just add:
//next lines added for integration
void parse_sp_nsgmls(int, char **);

void parse_sp_nsgmls(int argc, char **argv) {
        NsgmlsApp app;
        app.run(argc, argv);
}

//end additions
Collate sets up the argv handle in the menus loop, calls this, and away we go.
The same applies for spam, spent, jade etc..

5.  To activate SPAM: alter the file spam.cxx thus
//next line commented out
// SP_DEFINE_APP(SpamApp)

//next lines added for integration
typedef char **Handle;

extern pascal Handle NewHandle(size_t);
#if defined (__POWERPC)
        extern pascal void DisposeHandle(Handle);
#else
        extern pascal void DisposHandle(Handle);
#endif
void parse_sp_spam(void);

void parse_sp_spam() {
        SpamApp::sp_spam_cmdline();
}

void SpamApp::sp_spam_cmdline()  {
        int argc=1;
        Handle argv=NewHandle(sizeof(char));
        SpamApp app;
        app.run(argc, argv);
#if defined (__POWERPC)
        DisposeHandle(argv);
#else
        DisposHandle(argv);
#endif
}

//end additions
and add
static void sp_spam_cmdline();
to the class definistion for SpamApp

6.  Similarly: in jade.cxx comment out
 #ifdef DSSSL_NAMESPACE
SP_DEFINE_APP(DSSSL_NAMESPACE::JadeApp)
#else
//SP_DEFINE_APP(JadeApp)
#endif
and set up

Compiling for the PPC and 68K with Metrowerks
C/C++ language settings
For both:
activate c++ compiler
enable c++ exceptions, RTTI, bool support, require prototypes, expand trigraphs
turn off: ANSI strict and ANSI keywords only (second will choke on pascal
keywords
have off: map newlines to cr, enums always int, use unsigned chars, relaxed
pointers
C/C++ warnings:
PPC: have extended error checking on.  Have it off for 68K
Code Generation
for both: CRUCIAL: have struct alignment as 68K-4 byte.  Else YASP chokes
for 68K: have 4 byte ints ON ***AND*** have 8 byte doubles OFF.  Far data,
far method tables and
far string constants all should be on, as should global register assignation



***NOTE NEW EMAILS: peter.robinson@english.oxford.ac.uk *********
*****************OR: peter.robinson@dmu.ac.uk********************

The Canterbury Tales Project
Centre for Socio-legal Studies, Wolfson College
Linton Road, Oxford OX2 6UD
Phone +44 (0)1865 284245, fax 284221

Address for correspondence:
Project Manager
The IBM/De Montfort Digital Library Project
International Institute for Electronic Library Research
De Montfort University, The Gateway, Leicester LE1 5XY, UK
Phone +44 (0)116 250 6349, fax 257 7250

Canterbury Tales Project Website: http://www.shef.ac.uk/uni/projects/ctp/
Digital library webite: http://www.dlib.dmu.ac.uk


--
To unsubscribe from this list, send mail to majordomo@cygnus.uwa.edu.au
with the phrase 'unsubscribe sp-prog' in the message body.  If
you have any difficulty with this, please send mail to
owner-sp-prog@cygnus.uwa.edu.au and ask for help.