Re: [NTLK] Newton C/C++ and NTK development

From: Paul Guyot (pguyot_at_kallisys.net)
Date: Sun Jun 20 2004 - 01:04:14 PDT


Aux environs du 20/06/04 ā 9:36 +0200, sous le titre "[NTLK] Newton
C/C++ and NTK development", Simon Stapleton prit sa plus belle plume
pour écrire les mots suivants:
>Something I've not been able to find an answer to:
>
>Is it possible to build a _single_ package containing both NCT and NTK
>code? I ask as I have a piece of software that I'd quite like to port,
>the back end is a bunch of 'C', and can be ported relatively easily to
>NCT, but the front end is going to have to be NTK.
>
>Extra bonus points if you can point me to example source that I can
>'borrow' from ;-)

I want extra bonus points.

>Otherwise, I suppose I port the C part as a separate package and have a
>small front end package that uses it? Something like the NE2000
>example code from Apple.

AFAIK, the NE2K sample code include both C++ and NewtonScript code in
two different parts but in a single package.

There are two ways to put native code built with NCT (C/C++/Asm) into
Newton packages:
- you can build a native module that is included in the NTK project
and that provides native functions. This native code is included into
NewtonScript parts of the package.
- you can build a native protocol part that is packed by Packer tool
and then can be included as a protocol part of the project. The
native code can also be shipped in a separate package.

What you want to do here is *very* probably the first solution.

Open source examples of the first solution include:
- Demos sample by David Fedor when he worked for Newton DTS.
Available in NewtonDev.
- Gestalt sample code which I wrote to mix DDK and NCT APIs.
Available in NewtonDev.
- Waba. http://cs.gmu.edu/~sean/projects/newton/waba/
- ICVC. http://www.40hz.org/ICVC/
- Neo. http://www.40hz.org/Neo/
- NTox. http://www.40hz.org/NTox/
- ZLib. http://www.kallisys.com/newton/zlib/

Open source examples of the second solution include:
- LPR driver. http://www.kallisys.com/newton/lpr/
- NE2K.

Open source examples of mixing both solutions include:
- GetCardInfo from Newton Bowels. http://www.kallisys.com/newton/bowels/

Eckhart doesn't include protocol parts into NTK packages (e.g. Blunt,
MADMax, first LPR release).
In most case, it means extra work to ensure that the protocol part is
installed and active, but it can be justified because the protocol
part can be used separately. It is definitely the case for the MP3
codec and MADMax. I'm not sure that it's the case for Blunt, though,
and it wasn't the case for LPR so I merged both parts into the
resulting package.

This list of examples implement various methods to communicate
between native and NewtonScript code. You probably want to
investigate this for your port.

There are plenty of things to say about native code.
First probably is: read the documentation. Not once, not twice but at
least three times.
Second is: forget that global variables even existed. They will be
your worst nightmare if you try to port anything.

Paul

-- 
Philosophie de baignoire - consultations sur rendez-vous.
NPDS/NewtonOS: http://newton.kallisys.net:8080/
Apache/FreeBSD: http://www.kallisys.com/
-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
Official Newton FAQ: http://www.chuma.org/newton/faq/
WikiWikiNewt for all kinds of articles: http://tools.unna.org/wikiwikinewt/


This archive was generated by hypermail 2.1.5 : Mon Jun 21 2004 - 05:30:01 PDT