I use the framework to debug native Newton C++ modules using gdb within Xcode; it provides all the RefVar stuff and lets me breakpoint/examine my own code without the pain of downloading to a Newton device and testing using Hammer.

See the Imager project for examples.

Installation

Copy Newton.framework to ~/Library/Frameworks.

Add Newton.framework to your Xcode project. The only change you need to make to your NCT sources is to include a modified Objects.h when building for Xcode:

#if defined(__NCT__)
#include "Objects.h"
#else
#include "Newton/Objects.h"
#endif

 

Use

Newton.framework provides the API declared in the NCT headers. In other words, if you can link with NewtonInterfaceLib.o, you can use the Newton.framework. It includes an interpreter and many (but not all) magic pointers, global functions and variables. If you want to call a global function, for example:

RefVar bitmap = NSCallGlobalFn(SYM(MakeBitmap), MAKEINT(width), MAKEINT(height), options);

Or if you want to execute your own NewtonScript:

extern "C" Ref	DoBlock(RefArg codeBlock, RefArg args);
extern "C" Ref	DoMessage(RefArg rcvr, RefArg msg, RefArg args);

RefVar cmdRcvr(GetArraySlot(cmdFrame, 2));
RefVar cmdFunc(GetArraySlot(cmdFrame, 0));
RefVar cmdArg(GetArraySlot(cmdFrame, 1));
if (EQRef(ClassOf(cmdFrame), SYMundo))
{
	if (IsFunction(cmdFunc))
		DoBlock(cmdFunc, cmdArg);
	else
		DoMessage(cmdRcvr, cmdFunc, cmdArg);
}

There is a NewtonScript compiler within the framework, but you should use NTK to create NewtonScript codeblocks.

The framework initializes itself the first time you access any function within it. You don't need explicitly to call anything or otherwise modify your Newton code to run on Mac instead of Newton device.

The frames heap size is fixed at 256K. This has been plenty in my experience, but if you need more let me know.

 


Imager

The Imager native C++ module decodes the following image types into Newton pixelmaps for display by the Image Stationery:
GIF based on versit vCard sample code
JPEG based on the Independent JPEG Group’s JPEG software release 6b
PNG based on libpng 1.2.4
TIFF based on Sam Leffler’s tifflib version 3.4beta037
Also required:
ZLIB based on zlib 1.1.4

It uses the open source libraries as indicated, each of which has its own license.

Imager is copyright ©2002-2004 by Simon Bell,
licensed under the Open Software License version 2.1.

Installation

Copy the contents of the NCT_Projects folder in the Image Stationery archive to your own NCT_Projects folder (or whatever you have called it on your system). The zlib folder is at the same level as Imager_NCT so it can be shared by other projects.

You can build using MPW in the normal way; or if you have the Newton.framework installed you can build a desktop version for debugging within Xcode.