├── .gitignore ├── Demos ├── Playground │ ├── Playground.newtonproj │ ├── SoupFun.newtonscript │ └── e-valuate.newtonscript └── ViewScripts │ ├── ReadMe.txt │ ├── ViewScripts.newtonlayout │ └── ViewScripts.newtonproj ├── NTK.framework ├── Headers ├── NTK ├── Resources └── Versions │ ├── A │ ├── Headers │ │ ├── FakeFrames.h │ │ ├── Funcs.h │ │ ├── Globals.h │ │ ├── Iterators.h │ │ ├── Newton.h │ │ ├── NewtonDebug.h │ │ ├── NewtonErrors.h │ │ ├── NewtonExceptions.h │ │ ├── NewtonMemory.h │ │ ├── NewtonPackage.h │ │ ├── NewtonQD.h │ │ ├── NewtonScript.h │ │ ├── NewtonTime.h │ │ ├── NewtonTypes.h │ │ ├── NewtonWidgets.h │ │ ├── OSErrors.h │ │ ├── ObjHeader.h │ │ ├── ObjectHeap.h │ │ ├── Objects.h │ │ ├── PackageParts.h │ │ ├── Pipes.h │ │ ├── RSSymbols.h │ │ ├── Ref32.h │ │ ├── UStringUtils.h │ │ └── Unicode.h │ ├── NTK │ └── Resources │ │ ├── DictData │ │ ├── Info.plist │ │ └── NTK.rex │ └── Current ├── NTX.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── NTX.xccheckout │ └── xcuserdata │ │ └── simon.xcuserdatad │ │ └── UserInterfaceState.xcuserstate ├── simon.mode1 ├── simon.mode1v3 ├── simon.pbxuser └── xcuserdata │ └── simon.xcuserdatad │ ├── xcdebugger │ ├── Breakpoints.xcbkptlist │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── NTX.xcscheme │ └── xcschememanagement.plist ├── NTX ├── AppDelegate.h ├── AppDelegate.mm ├── Base.lproj │ ├── Credits.rtf │ ├── Error.strings │ ├── InfoPlist.strings │ ├── Layout copy.storyboard │ ├── Layout.storyboard │ ├── MagicPointer.strings │ ├── Main.storyboard │ ├── NTXPackageViewController.xib │ ├── NTXScriptViewController.xib │ ├── NativeCode.storyboard │ ├── Package.storyboard │ ├── Project.storyboard │ ├── Script.storyboard │ ├── Stream.storyboard │ └── X-Layout.storyboard ├── Comms │ ├── CRC.h │ ├── CRC.m │ ├── ChunkBuffer.cc │ ├── ChunkBuffer.h │ ├── ChunkBuffer.m │ ├── Chunks.h │ ├── CircleBuf.cc │ ├── CircleBuf.h │ ├── CommErrors.h │ ├── Comms.h │ ├── Endpoints │ │ ├── EinsteinEndpoint.h │ │ ├── EinsteinEndpoint.m │ │ ├── Endpoint.h │ │ ├── Endpoint.m │ │ ├── MNPSerialEndpoint-experimental.m │ │ ├── MNPSerialEndpoint.h │ │ └── MNPSerialEndpoint.m │ ├── NCBuffer.h │ ├── NCBuffer.m │ └── Protocol │ │ ├── DockErrors.h │ │ ├── NTKProtocol.h │ │ ├── Session.h │ │ └── Session.mm ├── ContentViewController.h ├── ContentViewController.mm ├── Context │ ├── CanonicalProject.newtonproj │ ├── CanonicalProject.newtonscript │ ├── CanonicalProject.newtonstream │ ├── Decompiler │ ├── Decompiler.stream │ ├── EditorCommands │ ├── Engineering │ │ ├── MessagePad Defs │ │ ├── NTK Globals │ │ ├── NTK Globals Simplified │ │ ├── Newton 2.0 Defs │ │ ├── UnitManager.ns │ │ ├── functions.ns │ │ ├── platform.Dump.ns │ │ └── platform.installer.Install.ns │ ├── GlobalData.newtonscript │ ├── GlobalFunctions.newtonscript │ ├── GlobalInit.newtonscript │ ├── Inspector Scripts.rtf │ ├── Platforms │ │ ├── MessagePad │ │ ├── MessagePad Defs │ │ ├── Newton 2.0 │ │ ├── Newton 2.0 Defs │ │ ├── Newton 2.1 │ │ ├── Newton 2.1 1.2d6 │ │ │ ├── Newton 2.1 │ │ │ ├── Newton 2.1 Defs │ │ │ └── Release_Notes_2.0_and_2.1.txt │ │ ├── Newton 2.1 Defs │ │ ├── Newton 2.1.nsof │ │ ├── Platform File Notes │ │ ├── Platform File Notes.idx │ │ ├── Platform_Files_Release_Notes.tx │ │ ├── Platforms Release Notes │ │ └── Release Notes 1.2b2 │ ├── ROM Maps │ │ ├── 1.3 (345025)p3 │ │ ├── 1.3 (414313)p4 │ │ ├── 1.3 (444217) │ │ ├── 2.0 (515299) │ │ ├── 2.0 (526205) │ │ ├── 2.0 (526205) - décodée │ │ ├── 2.1 (717145) │ │ └── 2.1 (717260) │ └── Toolkit.newtonpkg ├── FeedbackProtocol.h ├── FrameDefs.h ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon_16x16.png │ │ ├── icon_256x256.png │ │ ├── icon_32x32.png │ │ └── icon_512x512.png │ ├── layout.iconset │ │ ├── icon_16x16.png │ │ ├── icon_512x512.png │ │ ├── layout_16x16.pxm │ │ └── layout_512x512.pxm │ ├── nativecode.iconset │ │ ├── icon_512x512.png │ │ └── icon_512x512.pxm │ ├── package.iconset │ │ ├── icon_128x128.png │ │ ├── icon_16x16.png │ │ ├── icon_256x256.png │ │ ├── icon_32x32.png │ │ ├── icon_512x512.png │ │ ├── pkg_128x128.pxm │ │ ├── pkg_16x16.pxm │ │ ├── pkg_256x256.pxm │ │ ├── pkg_32x32.pxm │ │ └── pkg_512x512.pxm │ ├── platform.iconset │ │ ├── icon_16x16.png │ │ └── icon_512x512.png │ ├── project.iconset │ │ ├── icon_16x16.png │ │ ├── icon_32x32.png │ │ └── icon_512x512.png │ ├── proto.iconset │ │ ├── icon_16x16.png │ │ └── proto_512x512.pxm │ ├── resource.iconset │ │ ├── icon_512x512.png │ │ └── icon_512x512.pxm │ ├── script.iconset │ │ ├── icon_128x128.png │ │ ├── icon_16x16.png │ │ ├── icon_256x256.png │ │ ├── icon_32x32.png │ │ └── icon_512x512.png │ ├── stream.iconset │ │ ├── icon_512x512.png │ │ └── icon_512x512.pxm │ └── toolkit.iconset │ │ ├── icon_16x16.png │ │ ├── icon_256x256.png │ │ ├── icon_32x32.png │ │ ├── icon_512x512.png │ │ ├── toolkit_16x16.pxm │ │ ├── toolkit_256x256.pxm │ │ ├── toolkit_32x32.pxm │ │ └── toolkit_512x512.pxm ├── Images │ ├── Arrows.graffle │ │ ├── data.plist │ │ └── image2.pdf │ ├── Connected.pdf │ ├── DVTEditorBasic_10_10.pdf │ ├── DVTVersionsEditorCompare_10_10.pdf │ ├── DVTViewDebugArea_10_10.pdf │ ├── DVTViewNavigators_10_10.pdf │ ├── DVTViewUtilities_10_10.pdf │ ├── Disconnected.pdf │ ├── GeneralPrefsViewController.png │ ├── PrintDepth.pdf │ ├── PrintLength.pdf │ ├── UpdatePrefsViewController.png │ ├── book.png │ └── pkg.icns ├── InspectorViewController.h ├── InspectorViewController.mm ├── InspectorWindowController.h ├── LayoutViewController.h ├── LayoutViewController.mm ├── MacRsrcProject.h ├── MacRsrcProject.mm ├── MacRsrcTypes.h ├── NRBox.h ├── NRBox.m ├── NRProgressBox.h ├── NRProgressBox.m ├── NSMutableArray-Extensions.h ├── NSMutableArray-Extensions.m ├── NTX-Info.plist ├── NTX.entitlements ├── NTXDocument.h ├── NTXDocument.mm ├── NTXEditorView.h ├── NTXEditorView.mm ├── NewtonKit.h ├── PackagePart.h ├── PackageViewController.h ├── PackageViewController.mm ├── PkgPart.h ├── PkgPart.mm ├── PreferenceKeys.h ├── Preferences │ ├── GeneralPrefsViewController.h │ ├── GeneralPrefsViewController.m │ ├── Preferences.h │ └── Preferences.m ├── ProjectDocument.h ├── ProjectDocument.mm ├── ProjectItem.h ├── ProjectItem.mm ├── ProjectTypes.h ├── ProjectWindowController.h ├── ProjectWindowController.mm ├── ROMResources.h ├── ROMSymbols.h ├── Resources │ ├── projectfiletype.plist │ └── projectsettings.plist ├── ScriptDocument.mm ├── ScriptViewController.h ├── ScriptViewController.mm ├── SettingsViewController.h ├── SettingsViewController.mm ├── SourceListViewController.h ├── SourceListViewController.mm ├── ToolkitProtocolController.h ├── ToolkitProtocolController.mm ├── Utilities.h ├── Utilities.mm ├── ViewFlags.h ├── main.m ├── stdioDirector.h └── stdioDirector.m └── ReadMe.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | *~.nib 4 | build/ 5 | *.pbxuser 6 | *.perspective 7 | *.perspectivev3 8 | *.mode1v3 9 | *.mode2v3 10 | xcuserdata 11 | *.xcworkspacedata 12 | Test/ 13 | doc/ 14 | Context/VF+Function/ 15 | Context/ROM Maps/2.0 (526205) - décodée 16 | Context/Engineering/ 17 | -------------------------------------------------------------------------------- /Demos/Playground/Playground.newtonproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/Demos/Playground/Playground.newtonproj -------------------------------------------------------------------------------- /Demos/Playground/SoupFun.newtonscript: -------------------------------------------------------------------------------- 1 | 2 | /* ----------------------------------------------------------------------------- 3 | 1. Create a soup to hold colour information. 4 | ----------------------------------------------------------------------------- */ 5 | begin 6 | Print(ParamStr("Building ^0", [kPackageName])); local stor := GetStores()[0]; 7 | local soup := stor:GetSoup("Colors"); 8 | if not soup then 9 | begin 10 | local indexes := [ { structure:'slot, path:'color, type:'string }, 11 | { structure:'slot, path:'label, type:'tags } ]; 12 | soup := stor:CreateSoupXmit("Colors", indexes, nil); 13 | // add some sample entries 14 | soup:AddXmit({color:"Red", label:'primary}, nil); 15 | soup:AddXmit({color:"Green", label:'primary}, nil); 16 | soup:AddXmit({color:"Blue", label:'primary}, nil); 17 | soup:AddXmit({color:"Peach", label:'pastel}, nil); 18 | soup:AddXmit({color:"Mint", label:'pastel}, nil); 19 | soup:AddXmit({color:"Light Red", label:'pastel}, nil); 20 | soup:AddXmit({color:"Lavender", label:'pastel}, nil); 21 | soup:AddXmit({color:"Dark Red", label:'other}, nil); 22 | soup:AddXmit({color:"Indigo", label:'other}, nil); 23 | soup:AddXmit({color:"Really Light Pale Red", label:'pastel}, nil); 24 | end; 25 | 26 | /* ----------------------------------------------------------------------------- 27 | 2. Compile a query function. 28 | ----------------------------------------------------------------------------- */ 29 | local PrintEntries := func(curs) 30 | begin 31 | local e := curs:Entry(); 32 | while e <> nil do 33 | begin 34 | Print(e); 35 | e := curs:Next() 36 | end 37 | end; 38 | 39 | /* ----------------------------------------------------------------------------- 40 | 3. Try some soup queries. 41 | ----------------------------------------------------------------------------- */ 42 | Write("Red colors:\n"); 43 | call PrintEntries with (soup:Query({text:"Red"})); 44 | Write("\nLight red colors:\n"); 45 | call PrintEntries with (soup:Query({words:["Light","Red"]})); 46 | Write("\nPastel colors:\n"); 47 | call PrintEntries with (soup:Query({tagSpec:{equal:'pastel}})); 48 | Write("\nNon-pastel colors:\n"); 49 | call PrintEntries with (soup:Query({tagSpec:{none:'[pastel]}})); 50 | end; 51 | -------------------------------------------------------------------------------- /Demos/Playground/e-valuate.newtonscript: -------------------------------------------------------------------------------- 1 | // Calculating e 2 | // Translated from JavaScript: 3 | // http://mysite.verizon.net/res148h4j/javascript/script_e_spigot.html 4 | // by Matej Horvat: 5 | // http://matejhorvat.si/en/software/nsm/nsmextra.zip 6 | 7 | // if re-evaluating this function, we'll need to undefine the constants 8 | //UndefineGlobalConstant('kDigits); 9 | //UndefineGlobalConstant('kSize); 10 | 11 | 12 | begin 13 | constant kDigits := 20; // How many digits of e to calculate 14 | //constant kSize := kDigits + 10; // The original has "+ 9" and then accesses a[size], which is OK in JS, but not in NS. 15 | // like the Newton ROM compiler we don't do constant folding, so instead we have to say: 16 | constant kSize := 30; 17 | 18 | local a := Array(kSize, nil); 19 | a[0] := 0; 20 | a[1] := 2; 21 | for i := 2 to kSize - 1 do 22 | a[i] := 1; 23 | 24 | local x := 0; 25 | for bigN := kSize - 1 to 10 by -1 do 26 | begin 27 | // Find the next digit 28 | for smallN := bigN to 1 by -1 do 29 | begin 30 | a[smallN] := x mod smallN; 31 | x := 10 * a[smallN - 1] + (x div smallN); 32 | end; 33 | Write(x); 34 | end; 35 | Write($\n); 36 | end; 37 | -------------------------------------------------------------------------------- /Demos/ViewScripts/ReadMe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/Demos/ViewScripts/ReadMe.txt -------------------------------------------------------------------------------- /Demos/ViewScripts/ViewScripts.newtonlayout: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/Demos/ViewScripts/ViewScripts.newtonlayout -------------------------------------------------------------------------------- /Demos/ViewScripts/ViewScripts.newtonproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/Demos/ViewScripts/ViewScripts.newtonproj -------------------------------------------------------------------------------- /NTK.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /NTK.framework/NTK: -------------------------------------------------------------------------------- 1 | Versions/Current/NTK -------------------------------------------------------------------------------- /NTK.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Funcs.h 3 | 4 | Contains: NewtonScript function calling functions(!) 5 | 6 | Written by: Newton Research Group. 7 | */ 8 | 9 | #if !defined(__FUNCS__) 10 | #define __FUNCS__ 1 11 | 12 | #if defined(__cplusplus) 13 | extern "C" { 14 | #endif 15 | 16 | Ref InterpretBlock(RefArg codeBlock, RefArg args); 17 | Ref DoBlock(RefArg codeBlock, RefArg args); 18 | Ref DoScript(RefArg rcvr, RefArg script, RefArg args); 19 | Ref DoMessage(RefArg rcvr, RefArg msg, RefArg args); 20 | Ref DoMessageIfDefined(RefArg rcvr, RefArg msg, RefArg args, bool * isDefined); 21 | 22 | ArrayIndex GetFunctionArgCount(Ref fn); 23 | 24 | #if defined(__cplusplus) 25 | } 26 | #endif 27 | 28 | #endif /* __FUNCS__ */ 29 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Globals.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Globals.h 3 | 4 | Contains: NewtonScript global data. 5 | 6 | Written by: Newton Research Group. 7 | */ 8 | 9 | #if !defined(__GLOBALS__) 10 | #define __GLOBALS__ 1 11 | 12 | 13 | /*------------------------------------------------------------------------------ 14 | G l o b a l V a r i a b l e s 15 | ------------------------------------------------------------------------------*/ 16 | 17 | extern Ref gVarFrame; 18 | extern Ref * RSgVarFrame; 19 | 20 | inline Ref DefGlobalVar(RefArg tag, RefArg value) { SetFrameSlot(RA(gVarFrame), tag, value); return value; } 21 | inline Ref GetGlobalVar(RefArg tag) { return GetFrameSlot(RA(gVarFrame), tag); } 22 | 23 | 24 | /* ----------------------------------------------------------------------------- 25 | D e b u g O u t p u t 26 | ----------------------------------------------------------------------------- */ 27 | 28 | #if defined(__cplusplus) 29 | extern "C" { 30 | #endif 31 | 32 | void PrintObject(Ref obj, int indent); 33 | int REPprintf(const char * inFormat, ...); 34 | void REPflush(void); 35 | 36 | #if defined(__cplusplus) 37 | } 38 | #endif 39 | 40 | 41 | #endif /* __GLOBALS__ */ 42 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Iterators.h: -------------------------------------------------------------------------------- 1 | /* File: Iterators.h Contains: Array and frame slot iterators. Written by: Newton Research Group. */ #if !defined(__ITERATORS_H) #define __ITERATORS_H 1 /*---------------------------------------------------------------------- C O b j e c t I t e r a t o r ----------------------------------------------------------------------*/ class CObjectIterator { public: CObjectIterator(RefArg inObj, bool includeSiblings = false); ~CObjectIterator(); void reset(void); void resetWithObject(RefArg inObj); bool next(void); bool done(void); Ref tag(void); Ref value(void); private: RefStruct fTag; RefStruct fValue; RefStruct fObj; bool fIncludeSiblings; int fIndex; // reset to -1 before iteration ArrayIndex fLength; RefStruct fMapRef; // NILREF indicates an Array iterator ExceptionCleanup x; }; inline Ref CObjectIterator::tag(void) { return fTag; } inline Ref CObjectIterator::value(void) { return fValue; } #define FOREACH(obj, value_var) \ { \ CObjectIterator * _iter = new CObjectIterator(obj); \ if (_iter == NULL) OutOfMemory(); \ RefVar value_var; \ unwind_protect { \ while (!_iter->done()) { \ value_var = _iter->value(); #define FOREACH_WITH_TAG(obj, tag_var, value_var) \ { \ CObjectIterator * _iter = new CObjectIterator(obj); \ if (_iter == NULL) OutOfMemory(); \ RefVar tag_var; \ RefVar value_var; \ unwind_protect { \ while (!_iter->done()) { \ tag_var = _iter->tag(); \ value_var = _iter->value(); #define END_FOREACH \ _iter->next(); \ } \ } \ on_unwind { \ delete _iter; \ } \ end_unwind; \ } /* This is used like RefVar obj; ... FOREACH(obj, value) ... DoSomething(value); ... END_FOREACH ... or RefVar obj; ... FOREACH_WITH_TAG(obj, tag, value) ... if (tag == kSomething) DoSomething(value); ... END_FOREACH ... */ #define WITH_LOCKED_BINARY(obj, ptr_var) \ unwind_protect { \ void * ptr_var = LockedBinaryPtr(obj); #define END_WITH_LOCKED_BINARY(obj) \ } \ on_unwind { \ UnlockRefArg(obj); \ } \ end_unwind; /*---------------------------------------------------------------------- P r e c e d e n t s ----------------------------------------------------------------------*/ class CPrecedents { public: CPrecedents(); ~CPrecedents(); ArrayIndex add(RefArg inObj); ArrayIndex find(RefArg inObj); Ref get(ArrayIndex index); void set(ArrayIndex index, RefArg inObj); private: RefStruct fPrecArray; ArrayIndex fNumEntries; }; #endif /* __ITERATORS_H */ -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Newton.h: -------------------------------------------------------------------------------- 1 | /* File: Newton.h Contains: Newton C++ Tools errors, types, memory, and debug, widgets. Written by: Newton Research Group. */ #if !defined(__NEWTON_H) #define __NEWTON_H 1 /*------------------------------------------------------------------------------ Standard C/C++ includes. ------------------------------------------------------------------------------*/ // malloc, free #if !defined(__STDLIB__) #include #endif // strcpy, memmove #if !defined(__STRING__) #include #endif // size_t et al. #if !defined(__STDDEF__) #include #endif /*------------------------------------------------------------------------------ Platform includes. ------------------------------------------------------------------------------*/ #if !defined(__NEWTONTYPES_H) #include "NewtonTypes.h" #endif #if !defined(__NEWTONWIDGETS_H) #include "NewtonWidgets.h" #endif #if !defined(__NEWTONMEMORY_H) #include "NewtonMemory.h" #endif #if !defined(__NEWTONEXCEPTIONS_H) #include "NewtonExceptions.h" #endif #if !defined(__NEWTONDEBUG_H) #include "NewtonDebug.h" #endif #if !defined(__NEWTONERRORS_H) #include "NewtonErrors.h" #endif #endif /* __NEWTON_H */ -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/NewtonErrors.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Headers/NewtonErrors.h -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/NewtonExceptions.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Headers/NewtonExceptions.h -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/NewtonMemory.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Headers/NewtonMemory.h -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/NewtonPackage.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NewtonPackage.h 3 | 4 | Abstract: An object that loads a Newton package file containing 32-bit big-endian Refs 5 | and presents part entries as 64-bit platform-endian Refs. 6 | 7 | Written by: Newton Research Group, 2015. 8 | */ 9 | 10 | #if !defined(__NEWTONPACKAGE_H) 11 | #define __NEWTONPACKAGE_H 1 12 | 13 | #include 14 | #include "PackageParts.h" 15 | 16 | /* ----------------------------------------------------------------------------- 17 | N e w t o n P a c k a g e 18 | ----------------------------------------------------------------------------- */ 19 | struct MemAllocation 20 | { 21 | char * data; 22 | size_t size; 23 | }; 24 | 25 | 26 | class NewtonPackage 27 | { 28 | public: 29 | NewtonPackage(const char * inPkgPath); 30 | NewtonPackage(void * inPkgData); 31 | ~NewtonPackage(); 32 | 33 | PackageDirectory * directory(void); 34 | const PartEntry * partEntry(ArrayIndex inPartNo); 35 | Ref partRef(ArrayIndex inPartNo); 36 | MemAllocation * partPkgData(ArrayIndex inPartNo); 37 | 38 | private: 39 | FILE * pkgFile; 40 | void * pkgMem; 41 | PackageDirectory * pkgDir; 42 | RelocationHeader pkgRelo; 43 | char * relocationData; 44 | MemAllocation * pkgPartData; 45 | MemAllocation part0Data; 46 | }; 47 | 48 | 49 | #endif /* __NEWTONPACKAGE_H */ 50 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/NewtonScript.h: -------------------------------------------------------------------------------- 1 | /* File: NewtonScript.h Contains: NewtonScript interface for Newton C Tools. Written by: Newton Research Group. */ #if !defined(__NEWTONSCRIPT_H) #define __NEWTONSCRIPT_H 1 #if !defined(__OBJECTS_H) #include "Objects.h" #endif /*------------------------------------------------------------------------------ NewtonScript Callbacks to NewtonScript functions from C++ ------------------------------------------------------------------------------*/ Ref NSCall(RefArg fn); Ref NSCall(RefArg fn, RefArg arg0); Ref NSCall(RefArg fn, RefArg arg0, RefArg arg1); Ref NSCall(RefArg fn, RefArg arg0, RefArg arg1, RefArg arg2); Ref NSCall(RefArg fn, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3); Ref NSCall(RefArg fn, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4); Ref NSCall(RefArg fn, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4, RefArg arg5); Ref NSCallWithArgArray(RefArg fn, RefArg args); Ref NSCallGlobalFn(RefArg sym); Ref NSCallGlobalFn(RefArg sym, RefArg arg0); Ref NSCallGlobalFn(RefArg sym, RefArg arg0, RefArg arg1); Ref NSCallGlobalFn(RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2); Ref NSCallGlobalFn(RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3); Ref NSCallGlobalFn(RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4); Ref NSCallGlobalFn(RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4, RefArg arg5); Ref NSCallGlobalFnWithArgArray(RefArg sym, RefArg args); Ref NSSend(RefArg rcvr, RefArg sym); Ref NSSend(RefArg rcvr, RefArg sym, RefArg arg0); Ref NSSend(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1); Ref NSSend(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2); Ref NSSend(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3); Ref NSSend(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4); Ref NSSend(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4, RefArg arg5); Ref NSSendWithArgArray(RefArg rcvr, RefArg sym, RefArg args); Ref NSSendIfDefined(RefArg rcvr, RefArg sym); Ref NSSendIfDefined(RefArg rcvr, RefArg sym, RefArg arg0); Ref NSSendIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1); Ref NSSendIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2); Ref NSSendIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3); Ref NSSendIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4); Ref NSSendIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4, RefArg arg5); Ref NSSendIfDefinedWithArgArray(RefArg rcvr, RefArg sym, RefArg args); Ref NSSendProto(RefArg rcvr, RefArg sym); Ref NSSendProto(RefArg rcvr, RefArg sym, RefArg arg0); Ref NSSendProto(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1); Ref NSSendProto(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2); Ref NSSendProto(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3); Ref NSSendProto(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4); Ref NSSendProto(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4, RefArg arg5); Ref NSSendProtoWithArgArray(RefArg rcvr, RefArg sym, RefArg args); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym, RefArg arg0); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4); Ref NSSendProtoIfDefined(RefArg rcvr, RefArg sym, RefArg arg0, RefArg arg1, RefArg arg2, RefArg arg3, RefArg arg4, RefArg arg5); Ref NSSendProtoIfDefinedWithArgArray(RefArg rcvr, RefArg sym, RefArg args); #endif /* __NEWTONSCRIPT_H */ -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/NewtonWidgets.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NewtonWidgets.h 3 | 4 | Contains: Handy stuff. 5 | 6 | Written by: Newton Research Group. 7 | */ 8 | 9 | #if !defined(__NEWTONWIDGETS_H) 10 | #define __NEWTONWIDGETS_H 1 11 | 12 | #if !defined(__NEWTONTYPES_H) 13 | #include "NewtonTypes.h" 14 | #endif 15 | 16 | #if !defined(EOF) 17 | #define EOF (-1) 18 | #endif 19 | 20 | #if !defined(EOM) 21 | #define EOM (-2) 22 | #endif 23 | 24 | #if defined(__cplusplus) 25 | enum PositionMode 26 | { 27 | kPosBeg = -1, 28 | kPosCur = 0, 29 | kPosEnd = 1 30 | }; 31 | #endif 32 | 33 | 34 | //-------------------------------------------------------------------------------- 35 | // Byte swapping 36 | //-------------------------------------------------------------------------------- 37 | 38 | // Watch out for these macros...they can silently turn your values into different types... 39 | 40 | #define BYTE_SWAP_CHAR(n) (n) 41 | #define BYTE_SWAP_SHORT(n) (((n << 8) & 0xFF00) | ((n >> 8) & 0x00FF)) 42 | #define BYTE_SWAP_LONG(n) (((n << 24) & 0xFF000000) | ((n << 8) & 0x00FF0000) | ((n >> 8) & 0x0000FF00) | ((n >> 24) & 0x000000FF)) 43 | 44 | // the following macros are for code with static data that 45 | // assumes ordering different from native ordering 46 | 47 | #if defined(hasByteSwapping) 48 | #define CANONICAL_LONG BYTE_SWAP_LONG 49 | #define CANONICAL_SHORT BYTE_SWAP_SHORT 50 | #define CANONICAL_CHAR BYTE_SWAP_CHAR 51 | #else 52 | #define CANONICAL_LONG(n) (n) 53 | #define CANONICAL_SHORT(n) (n) 54 | #define CANONICAL_CHAR(n) (n) 55 | #endif 56 | 57 | void ByteSwap(void * p, int count, int swapSize); 58 | // implementation of ByteSwap is in UtilityClasses:Widgets.c 59 | 60 | 61 | //-------------------------------------------------------------------------------- 62 | // Comparison Macros 63 | //-------------------------------------------------------------------------------- 64 | 65 | #if !defined(ODD) 66 | #define ODD(x) ( (x) & 1 ) 67 | #endif 68 | #if !defined(EVEN) 69 | #define EVEN(x) ( !((x) & 1) ) 70 | #endif 71 | #if !defined(ABS) 72 | #define ABS(a) ( ((a) < 0) ? -(a) : (a) ) 73 | #endif 74 | #if !defined(MAX) 75 | #define MAX(a, b) ( ((a) > (b)) ? (a) : (b) ) 76 | #endif 77 | #if !defined(MIN) 78 | #define MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) 79 | #endif 80 | #if !defined(MINMAX) 81 | #define MINMAX(min, expr, max) ( MIN(MAX(min, expr), max) ) 82 | #endif 83 | 84 | 85 | //-------------------------------------------------------------------------------- 86 | // Bitwiddling Macros 87 | //-------------------------------------------------------------------------------- 88 | 89 | // BIT(N) the Nth bit set 90 | // BITS(N,M) bits N through M set, inclusive. N > M (e.g. "BITS(31,0)"). 91 | 92 | #define BIT(N) (1<<(N)) /* bit N */ 93 | #define BITS(N,M) ((BIT((M)-(N)+1)-1)<<(N)) /* bits N..M inclusive */ 94 | 95 | #define MASKTEST(data, mask) ( (data) & (mask) ) 96 | #define MASKSET(data, mask) ( (data) | (mask) ) 97 | #define MASKCLEAR(data, mask) ( (data) & (~(mask)) ) 98 | #define MASKTOGGLE(data, mask) ( ((data) & (mask)) ? ((data) & (~(mask))) : ((data) | (mask)) ) 99 | 100 | #define FLAGTEST(data, bit) ( (data & (bit)) != 0 ) 101 | #define FLAGSET(data, bit) ( data = data | (bit) ) 102 | #define FLAGCLEAR(data, bit) ( data = data & ~(bit) ) 103 | 104 | 105 | //-------------------------------------------------------------------------------- 106 | // Alignment Macros 107 | //-------------------------------------------------------------------------------- 108 | 109 | // some useful sizes 110 | 111 | #define KByte (1024) 112 | #define MByte (1024*1024) 113 | 114 | // ARM MMU Sizes 115 | 116 | #define kSubPageSize KByte 117 | #define kSubPagesPerPage (4) 118 | #define kPageSize (4 * KByte) 119 | #define kBigPageSize (64 * KByte) 120 | #define kBigSubPageSize (16 * KByte) 121 | #define kSectionSize MByte 122 | 123 | // ALIGN(amount, boundary) round 'amount' up to nearest 'boundary' (which 124 | // must be a power of two) 125 | // 126 | // WORDALIGN(amount) round 'amount' up to a multiple of two 127 | // 128 | // LONGALIGN(amount) round 'amount' up to a multiple of four 129 | // 130 | // PAGEALIGN(amount) ditto, for 4K and 1K (ARM) 131 | // SUBPAGEALIGN(amount) 132 | 133 | #define TRUNC(N,B) (((long)(N)) & ~((long)(B)-1L)) 134 | #define ALIGN(N,B) ((((long)(N))+(long)(B)-1)&~((long)(B)-1L)) 135 | #define WORDALIGN(n) ALIGN((n),2L) 136 | #define LONGALIGN(n) ALIGN((n),4L) 137 | #define PAGEALIGN(n) ALIGN((n),kPageSize) 138 | #define SUBPAGEALIGN(n) ALIGN((n),kSubPageSize) 139 | #define ALIGNED(n,B) (((long)(n)) == ALIGN(((long)(n)),(long)(B))) 140 | #define MISALIGNED(n) (((long)(n) & 3L) != 0) 141 | 142 | #define PAGEOFFSET(n) ((long)(n) & (kPageSize-1)) 143 | 144 | 145 | #endif /* __NEWTONWIDGETS_H */ 146 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/OSErrors.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Headers/OSErrors.h -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/ObjectHeap.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ObjectHeap.h 3 | 4 | Contains: Newton object heap interface. 5 | 6 | Written by: Newton Research Group. 7 | */ 8 | 9 | #if !defined(__OBJECTHEAP__) 10 | #define __OBJECTHEAP__ 1 11 | 12 | #include "ObjHeader.h" 13 | 14 | extern "C" { 15 | bool InHeap(Ref ref); 16 | bool OnStack(const void * obj); 17 | void SetObjectHeapSize(size_t inSize, bool allocateInTempMemory); 18 | } 19 | 20 | /*---------------------------------------------------------------------- 21 | O b j e c t H e a p 22 | ----------------------------------------------------------------------*/ 23 | 24 | class CDeclawingRange; 25 | class CObjectHeap 26 | { 27 | public: 28 | CObjectHeap(size_t inSize, bool allocateInTempMemory = true); 29 | ~CObjectHeap(); 30 | 31 | ObjHeader * allocateBlock(size_t inSize, unsigned char flags); 32 | Ref allocateObject(size_t inSize, unsigned char flags); 33 | Ref allocateBinary(RefArg inClass, size_t length); 34 | Ref allocateIndirectBinary(RefArg inClass, size_t length); 35 | Ref allocateArray(RefArg inClass, ArrayIndex length); 36 | Ref allocateFrame(void); 37 | Ref allocateFrameWithMap(RefArg inMap); 38 | Ref allocateMap(RefArg inSuperMap, ArrayIndex length); 39 | 40 | void makeFreeBlock(ObjHeader * obj, size_t newSize); 41 | 42 | size_t coalesceFreeBlocks(ObjHeader * obj, size_t inSize); 43 | ObjHeader * findFreeBlock(size_t inSize); 44 | void splitBlock(ObjHeader * obj, size_t newSize); 45 | ObjHeader * resizeBlock(ObjHeader * obj, size_t newSize); 46 | void resizeObject(RefArg ref, size_t newSize); 47 | 48 | void unsafeSetArrayLength(RefArg ref, ArrayIndex newLength); 49 | void unsafeSetBinaryLength(RefArg ref, ArrayIndex newLength); 50 | 51 | bool inHeap(Ref ref); 52 | Ref clone(RefArg ref); 53 | void replace(Ref, Ref); 54 | Ref update(Ref); 55 | 56 | bool registerRangeForDeclawing(ULong start, ULong end); 57 | void declawRefsInRegisteredRanges(void); 58 | 59 | void GC(void); 60 | void GCTWA(void); 61 | void cleanUpWeakChain(void); 62 | void mark(Ref); 63 | void sweepAndCompact(void); 64 | 65 | RefHandle * allocateRefHandle(Ref inRef); 66 | void disposeRefHandle(RefHandle * inRefHandle); 67 | RefHandle * expandObjectTable(RefHandle * inRefHandle); 68 | void clearRefHandles(void); 69 | 70 | // For debug 71 | void heapBounds(Ptr * outStart, Ptr * outLimit); 72 | void heapStatistics(size_t * outFree, size_t * outLargest); 73 | void uriah(void); 74 | void uriahBinaryObjects(bool doFile = false); 75 | 76 | private: 77 | 78 | #define kNumOfHandlesInBlock 256 79 | #define kIncrHandlesInBlock 32 80 | 81 | struct RefHandleBlock 82 | { 83 | OBJHEADER 84 | RefHandle data[kNumOfHandlesInBlock]; 85 | }__attribute__((packed)); 86 | 87 | char * mem; // +04 allocated memory for heap 88 | ObjHeader * heapBase; // +08 long-aligned base of heap 89 | ObjHeader * heapLimit; // +0C long-aligned end of heap 90 | ObjHeader * freeHeap; // +10 currently free heap object 91 | RefHandleBlock * refHBlock; // x14 ref handles -- at top of heap 92 | ArrayIndex refHIndex; // x18 index of next free ref handle 93 | Ref objRoot; // +1C object being resized -- needs GC 94 | size_t refHBlockSize; // +20 size of ref handle block -- will grow as necessary 95 | SlottedObject * weakLink; // +24 96 | bool inGC; // +28 97 | CDeclawingRange * declaw; // +2C 98 | bool inDeclaw; // +30 99 | }; 100 | 101 | 102 | extern CObjectHeap * gHeap; 103 | 104 | 105 | #endif /* __OBJECTHEAP__ */ 106 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Objects.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Headers/Objects.h -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/PackageParts.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: PackageParts.h 3 | 4 | Contains: Package structures 5 | 6 | Written by: Newton Research Group 7 | */ 8 | 9 | #if !defined(__PACKAGEPARTS_H) 10 | #define __PACKAGEPARTS_H 1 11 | 12 | #include "NewtonTypes.h" 13 | 14 | typedef ULong Date; 15 | 16 | struct InfoRef 17 | { 18 | UShort offset; 19 | UShort length; 20 | }; 21 | 22 | 23 | /* 24 | Part Entries 25 | ------------ 26 | Following the PackageDirectory, each part is represented by a PartEntry structure. 27 | Parts are often referred to by number (part 0, part 1, and so forth); the number is 28 | determined by the order of the PartEntry structures. The first PartEntry corresponds 29 | to part 0. 30 | */ 31 | 32 | struct PartEntry 33 | { 34 | ULong offset; // offset to part, longword aligned 35 | ULong size; // size of part 36 | ULong size2; // = size 37 | ULong type; // 'form', 'book', 'auto' etc. 38 | ULong reserved1; 39 | ULong flags; // defined below 40 | InfoRef info; // data passed to part when activated 41 | InfoRef compressor; // compressor name 42 | }; 43 | 44 | enum 45 | { 46 | kProtocolPart = 0x00000000, 47 | kNOSPart = 0x00000001, 48 | kRawPart = 0x00000002, 49 | kPackagePart = 0x00000003, 50 | kPartTypeMask = 0x00000003, 51 | 52 | kAutoLoadPartFlag = 0x00000010, // kAutoLoadFlag renamed for consistency with... 53 | kAutoRemovePartFlag = 0x00000020, // kAutoRemoveFlag renamed to avoid clash with package flag 54 | kCompressedFlag = 0x00000040, 55 | kNotifyFlag = 0x00000080, 56 | kAutoCopyFlag = 0x00000100 57 | }; 58 | 59 | 60 | /* 61 | The part entries are followed by the variable-length data area referred to by the 62 | InfoRef values. Most data in this area consists of ASCII or Unicode strings. Note that 63 | although the length of the string is provided in the InfoRef, null terminators are 64 | necessary and should be included at the end of the strings. 65 | */ 66 | 67 | 68 | /* 69 | Relocation Information 70 | ---------------------- 71 | If the package signature is "package1", and the package directory kRelocationFlag 72 | is set, the package contains a relocation information area after the package directory. This 73 | information is used to relocate package-relative addresses to compensate for the virtual 74 | address that gets assigned to the package when it is activated. This allows native code in 75 | the package to use absolute addresses. 76 | 77 | The relocation information begins with a fixed set of fields represented by the 78 | RelocationHeader structure. 79 | */ 80 | 81 | struct RelocationHeader 82 | { 83 | ULong reserved; // must be zero 84 | ULong relocationSize; // total size of relocation information area including this header 85 | ULong pageSize; // size in bytes of a relocation page - must be 1024 86 | ULong numEntries; // number of relocation entries following the header 87 | ULong baseAddress; // original base address of the package 88 | }; 89 | 90 | /* 91 | The RelocationHeader is followed by a series of RelocationEntry structures. Each 92 | RelocationEntry must be padded to a multiple of four bytes. 93 | */ 94 | 95 | struct RelocationEntry 96 | { 97 | UShort pageNumber; // zero-based index of the page in the package 98 | UShort offsetCount; // number of offset bytes in offsets 99 | UByte offsets[]; /* offsets of the words to be relocated. 100 | Each byte is the zero-based index of a word in the page 101 | to be relocated. For example, the offset 0x10 means 102 | to relocate a word 0x40 bytes into the page. */ 103 | }; 104 | 105 | 106 | /* 107 | Package Directory 108 | ----------------- 109 | The format of the package directory is defined as a PackageDirectory structure, 110 | followed by zero or more PartEntry structures (one per part), followed by the 111 | variable-length data area. 112 | 113 | The package directory begins with a fixed set of fields represented by the 114 | PackageDirectory structure. 115 | */ 116 | 117 | struct PackageDirectory 118 | { 119 | // package header 120 | char signature[8]; // 'package0' or 'package1' 121 | ULong id; // reserved1 according to “Newton Formats 1.1” -- typically xxxx 122 | ULong flags; // defined below 123 | ULong version; // arbitrary number 124 | InfoRef copyright; // Unicode copyright notice - optional 125 | InfoRef name; // Unicode package name - unique 126 | ULong size; // total size of package including this directory 127 | Date creationDate; 128 | Date modifyDate; // reserved2 according to “Newton Formats 1.1” -- typically 0 129 | // parts directory header 130 | ULong reserved3; 131 | ULong directorySize; // size of this directory including part entries & data 132 | ULong numParts; // number of parts in the package 133 | // part directory entries 134 | PartEntry parts[]; 135 | }; 136 | 137 | enum 138 | { 139 | kAutoRemoveFlag = 0x80000000, 140 | kCopyProtectFlag = 0x40000000, 141 | kInvisibleFlag = 0x20000000, // undocumented -- set by Packer MPW tool 142 | kNoCompressionFlag = 0x10000000, 143 | kRelocationFlag = 0x04000000, // 2.0 only 144 | kUseFasterCompressionFlag = 0x02000000 // 2.0 only 145 | }; 146 | 147 | 148 | #endif /* __PACKAGEPARTS_H */ 149 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Pipes.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Pipes.h 3 | 4 | Contains: Pipe classes. 5 | A note on types: we use (long) to represent an offset, since 6 | this is what stdio functions use. 7 | 8 | Written by: Newton Research Group. 9 | */ 10 | 11 | #if !defined(__PIPES_H) 12 | #define __PIPES_H 1 13 | 14 | #include "Objects.h" 15 | 16 | DeclareException(exPipe, exRootException); 17 | 18 | 19 | /*------------------------------------------------------------------------------ 20 | C P i p e C a l l b a c k 21 | ------------------------------------------------------------------------------*/ 22 | 23 | class CPipeCallback 24 | { 25 | public: 26 | CPipeCallback(); 27 | virtual ~CPipeCallback(); 28 | 29 | virtual bool status(size_t inNumOfBytesGot, size_t inNumOfBytesPut) = 0; 30 | 31 | size_t f04; // max values for progress indication 32 | size_t f08; 33 | }; 34 | 35 | 36 | /*------------------------------------------------------------------------------ 37 | C P i p e 38 | ------------------------------------------------------------------------------*/ 39 | 40 | class CPipe 41 | { 42 | public: 43 | CPipe(); 44 | virtual ~CPipe(); 45 | 46 | virtual long readSeek(long inOffset, int inSelector) = 0; 47 | virtual long readPosition(void) const = 0; 48 | virtual long writeSeek(long inOffset, int inSelector) = 0; 49 | virtual long writePosition(void) const = 0; 50 | virtual void readChunk(void * outBuf, size_t & ioSize, bool & outEOF) = 0; 51 | virtual void writeChunk(const void * inBuf, size_t inSize, bool inFlush) = 0; 52 | virtual void flushRead(void) = 0; 53 | virtual void flushWrite(void) = 0; 54 | virtual void reset(void) = 0; 55 | virtual void resetRead(); 56 | virtual void resetWrite(); 57 | virtual void overflow() = 0; 58 | virtual void underflow(long, bool&) = 0; 59 | 60 | const CPipe & operator>>(char&); 61 | const CPipe & operator>>(unsigned char&); 62 | const CPipe & operator>>(short&); 63 | const CPipe & operator>>(unsigned short&); 64 | const CPipe & operator>>(int&); 65 | const CPipe & operator>>(unsigned int&); 66 | const CPipe & operator>>(size_t&); // NRG 67 | 68 | const CPipe & operator<<(char); 69 | const CPipe & operator<<(unsigned char); 70 | const CPipe & operator<<(short); 71 | const CPipe & operator<<(unsigned short); 72 | const CPipe & operator<<(int); 73 | const CPipe & operator<<(unsigned int); 74 | const CPipe & operator<<(size_t&); // NRG 75 | }; 76 | 77 | 78 | /*------------------------------------------------------------------------------ 79 | C P t r P i p e 80 | ------------------------------------------------------------------------------*/ 81 | 82 | class CPtrPipe : public CPipe 83 | { 84 | public: 85 | CPtrPipe(); 86 | ~CPtrPipe(); 87 | 88 | void init(size_t inSize, CPipeCallback * inCallback); 89 | void init(void * inPtr, size_t inSize, bool inAssumePtrOwnership, CPipeCallback * inCallback); 90 | 91 | long readSeek(long inOffset, int inSelector); 92 | long readPosition(void) const; 93 | long writeSeek(long inOffset, int inSelector); 94 | long writePosition(void) const; 95 | void readChunk(void * outBuf, size_t & ioSize, bool & outEOF); 96 | void writeChunk(const void * inBuf, size_t inSize, bool inFlush); 97 | void flushRead(void); 98 | void flushWrite(void); 99 | void reset(void); 100 | void overflow(); 101 | void underflow(long, bool&); 102 | 103 | private: 104 | long seek(long inOffset, int inSelector); 105 | 106 | Ptr fPtr; 107 | long fOffset; 108 | long fEnd; 109 | CPipeCallback * fCallback; 110 | bool fPtrIsOurs; 111 | }; 112 | 113 | 114 | /*------------------------------------------------------------------------------ 115 | C R e f P i p e 116 | ------------------------------------------------------------------------------*/ 117 | 118 | class CRefPipe : public CPtrPipe 119 | { 120 | public: 121 | CRefPipe(); 122 | ~CRefPipe(); 123 | 124 | void initSink(size_t inSize, RefArg inRef, CPipeCallback * inCallback); 125 | void initSource(RefArg inRef, CPipeCallback * inCallback); 126 | 127 | Ref ref(void) const; 128 | 129 | private: 130 | // int32_t f14; 131 | RefStruct fTheRef; 132 | }; 133 | inline Ref CRefPipe::ref(void) const { return fTheRef; } 134 | 135 | 136 | /*------------------------------------------------------------------------------ 137 | C S t d I O P i p e 138 | ------------------------------------------------------------------------------*/ 139 | 140 | class CStdIOPipe : public CPipe 141 | { 142 | public: 143 | CStdIOPipe(const char * inFilename, const char * inMode); 144 | ~CStdIOPipe(); 145 | 146 | long readSeek(long inOffset, int inSelector); 147 | long readPosition(void) const; 148 | long writeSeek(long inOffset, int inSelector); 149 | long writePosition(void) const; 150 | void readChunk(void * outBuf, size_t & ioSize, bool & outEOF); 151 | void writeChunk(const void * inBuf, size_t inSize, bool inFlush); 152 | void flushRead(void); 153 | void flushWrite(void); 154 | void reset(void); 155 | void overflow(); 156 | void underflow(long, bool&); 157 | 158 | private: 159 | long seek(long inOffset, int inSelector); 160 | void flush(void); 161 | 162 | FILE * fFile; 163 | int fState; 164 | }; 165 | 166 | 167 | #endif /* __PIPES_H */ 168 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Ref32.h: -------------------------------------------------------------------------------- 1 | 2 | /*------------------------------------------------------------------------------ 3 | Legacy Refs for a 64-bit world. 4 | See also Newton/ObjectSystem.cc which does this for Refs createwd by NTK. 5 | ------------------------------------------------------------------------------*/ 6 | #if !defined(__REF32_H) 7 | #define __REF32_H 1 8 | 9 | typedef int32_t Ref32; 10 | 11 | #define OBJHEADER32 \ 12 | uint32_t size : 24; \ 13 | uint32_t flags : 8; \ 14 | union { \ 15 | struct { \ 16 | uint32_t locks : 8; \ 17 | uint32_t slots : 24; \ 18 | } count; \ 19 | int32_t stuff; \ 20 | Ref32 destRef; \ 21 | }gc; 22 | 23 | struct ObjHeader32 24 | { 25 | OBJHEADER32 26 | }__attribute__((packed)); 27 | 28 | struct BinaryObject32 29 | { 30 | OBJHEADER32 31 | Ref32 objClass; 32 | char data[]; 33 | }__attribute__((packed)); 34 | 35 | struct ArrayObject32 36 | { 37 | OBJHEADER32 38 | Ref32 objClass; 39 | Ref32 slot[]; 40 | }__attribute__((packed)); 41 | 42 | struct FrameObject32 43 | { 44 | OBJHEADER32 45 | Ref32 map; 46 | Ref32 slot[]; 47 | }__attribute__((packed)); 48 | 49 | struct FrameMapObject32 50 | { 51 | OBJHEADER32 52 | Ref32 objClass; 53 | Ref32 supermap; 54 | Ref32 slot[]; 55 | }__attribute__((packed)); 56 | 57 | struct SymbolObject32 58 | { 59 | OBJHEADER32 60 | Ref32 objClass; 61 | ULong hash; 62 | char name[]; 63 | }__attribute__((packed)); 64 | 65 | struct StringObject32 66 | { 67 | OBJHEADER32 68 | Ref32 objClass; 69 | UniChar str[]; 70 | }__attribute__((packed)); 71 | 72 | 73 | #define BYTE_SWAP_SIZE(n) (((n << 16) & 0x00FF0000) | (n & 0x0000FF00) | ((n >> 16) & 0x000000FF)) 74 | #if defined(hasByteSwapping) 75 | #define CANONICAL_SIZE BYTE_SWAP_SIZE 76 | #else 77 | #define CANONICAL_SIZE(n) (n) 78 | #endif 79 | 80 | #define SIZEOF_BINARY32OBJECT (sizeof(ObjHeader32) + sizeof(Ref32)) 81 | #define SIZEOF_ARRAY32OBJECT (sizeof(ObjHeader32) + sizeof(Ref32)) 82 | #define SIZEOF_FRAMEMAP32OBJECT (sizeof(ObjHeader32) + sizeof(Ref32) + sizeof(Ref32)) 83 | 84 | #define ARRAY32LENGTH(_o) (ArrayIndex)((CANONICAL_SIZE(_o->size) - SIZEOF_ARRAY32OBJECT) / sizeof(Ref32)) 85 | #define BINARY32LENGTH(_o) (size_t)(CANONICAL_SIZE(_o->size) - SIZEOF_BINARY32OBJECT) 86 | 87 | 88 | #define k4ByteAlignmentFlag 0x00000001 89 | 90 | #endif /* __REF32_H */ 91 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/UStringUtils.h: -------------------------------------------------------------------------------- 1 | /* File: UStringUtils.h Contains: Unicode-friendly version of some common string utility functions. Written by: Newton Research Group. */ #if !defined(__USTRINGUTILS_H) #define __USTRINGUTILS_H 1 #if !defined(__NEWTON_H) #include "Newton.h" #endif #if !defined(__UNICODE_H) #include "Unicode.h" #endif #if defined(__cplusplus) extern "C" { #endif //------------------------------------------------------------------------ // standard string utilities UniChar * Ustrcpy(UniChar * destStr, const UniChar * sourceStr); UniChar * Ustrncpy(UniChar * destStr, const UniChar * sourceStr, size_t n); UniChar * Ustrcat(UniChar * destStr, const UniChar * sourceStr); UniChar * Ustrncat(UniChar * destStr, const UniChar * sourceStr, size_t n); size_t Ustrlen(const UniChar * str); UniChar * Ustrchr(const UniChar *str, UniChar ch); int Ustrcmp(const UniChar * str1, const UniChar * str2); void * Umemset(void* str, UniChar ch, size_t numChars); size_t Umbstrlen(const UniChar * str, int destEncoding); size_t Umbstrnlen(const UniChar * str, int destEncoding, size_t n); bool HasChars(UniChar * c); bool HasDigits(UniChar * c); bool HasSpaces(UniChar * c); bool IsPunctSymbol(UniChar * inStr, int inOffset); void StripPunctSymbols(UniChar * inStr); bool IsWhiteSpace(UniChar c); bool IsSpace(UniChar c); bool IsTab(UniChar c); bool IsReturn(UniChar c); bool IsBreaker(UniChar c); bool IsDelimiter(UniChar c); bool IsAlphabet(UniChar c); bool IsDigit(UniChar c); bool IsHexDigit(UniChar c); bool IsAlphaNumeric(UniChar c); bool IsFirstByteOf2Byte(UChar c, CharEncoding encoding); // unicode wrappers for char-by-char conversions void ConvertUnicodeCharacters(UniChar * array, Ptr buffer, int conversionType, ArrayIndex len); long ConvertUnicodeChar(UniChar * c, Ptr b, int conversionType); void UpperCaseText(UniChar * str, ArrayIndex len); void UpperCaseNoDiacriticsText(UniChar * str, ArrayIndex len); void LowerCaseText(UniChar * str, ArrayIndex len); #if defined(__cplusplus) } #endif extern const UniChar * gEmptyString; #endif /* __USTRINGUTILS_H */ -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Headers/Unicode.h: -------------------------------------------------------------------------------- 1 | /* File: Unicode.h Contains: Public header for Unicode. Written by: Newton Research Group. */ #if !defined(__UNICODE_H) #define __UNICODE_H 1 #if !defined(__NEWTON_H) #include "Newton.h" #endif #if defined(__cplusplus) extern "C" { #endif // --------------------------------------------------------------------------- // constants typedef enum { kUnsupportedEncoding = -1, kUnicode = 0, // not implemented kMacRomanEncoding, // Macintosh Roman kASCIIEncoding, // 7-bit ASCII kPCRomanEncoding, // not implemented kWizardEncoding, // for English Wizards kShiftJISEncoding, // for Japanese PV-F1, PI-3000, etc. kMacKanjiEncoding // ShiftJIS for Macintosh KanjiTalk 7 // 114... 115... } CharEncoding; #if defined(JapaneseVersion) #define kNumOfEncodings 7 #else #define kNumOfEncodings 5 #endif #define kNoTranslationChar 0x1A #define kEndOfString 0 #define kSystemEncoding kUnicode // kDefaultEncoding represents the character set of the current desktop platform #ifdef usePCRomanEncoding #define kDefaultEncoding kPCRomanEncoding #elif defined(JapaneseVersion) #define kDefaultEncoding kShiftJISEncoding #else #define kDefaultEncoding kMacRomanEncoding #endif // --------------------------------------------------------------------------- // conversion calls #if defined(__cplusplus) void ConvertFromUnicode(const UniChar * source, void * dest, ArrayIndex length = 0x7FFFFFFF, CharEncoding destEncoding = kDefaultEncoding); void ConvertToUnicode(const void * source, UniChar * dest, ArrayIndex length = 0x7FFFFFFF, CharEncoding destEncoding = kDefaultEncoding); #else void ConvertFromUnicode(const UniChar * source, void * dest, ArrayIndex length, CharEncoding destEncoding); void ConvertToUnicode(const void * source, UniChar * dest, ArrayIndex length, CharEncoding srcEncoding); #endif char A_CONST_CHAR(UniChar c); UniChar U_CONST_CHAR(char c); // --------------------------------------------------------------------------- // comparison calls typedef int (*CompareProcPtr)(ArrayIndex, ArrayIndex, void *); #if defined(__cplusplus) class CSortingTable; int CompareUnicodeText(const UniChar * s1, ArrayIndex len1, const UniChar * s2, ArrayIndex len2, const CSortingTable * sorting = (const CSortingTable *)1, bool doDiacritical = false, CompareProcPtr compareProc = NULL, void * refCon = NULL); #else int CompareUnicodeText(const UniChar * s1, ArrayIndex len1, const UniChar * s2, ArrayIndex len2, const void *, bool, CompareProcPtr, void *); #endif int CompareStringNoCase(const UniChar * s1, const UniChar * s2); #if defined(__cplusplus) } #endif #endif /* __UNICODE_H */ -------------------------------------------------------------------------------- /NTK.framework/Versions/A/NTK: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/NTK -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Resources/DictData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Resources/DictData -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 16D32 7 | CFBundleDevelopmentRegion 8 | English 9 | CFBundleIdentifier 10 | org.newton.objects 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | Newton 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleSupportedPlatforms 22 | 23 | MacOSX 24 | 25 | CFBundleVersion 26 | 44 27 | DTCompiler 28 | com.apple.compilers.llvm.clang.1_0 29 | DTPlatformBuild 30 | 8C1002 31 | DTPlatformVersion 32 | GM 33 | DTSDKBuild 34 | 16C58 35 | DTSDKName 36 | macosx10.12 37 | DTXcode 38 | 0821 39 | DTXcodeBuild 40 | 8C1002 41 | 42 | 43 | -------------------------------------------------------------------------------- /NTK.framework/Versions/A/Resources/NTK.rex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTK.framework/Versions/A/Resources/NTK.rex -------------------------------------------------------------------------------- /NTK.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /NTX.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NTX.xcodeproj/project.xcworkspace/xcshareddata/NTX.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 19DD8194-E3E8-44B2-B963-35E818B4DC54 9 | IDESourceControlProjectName 10 | NTX 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | A4E936C8679A32FF4FB020B0A362202883ADF968 14 | https://github.com/newtonresearch/newton-toolkit.git 15 | 16 | IDESourceControlProjectPath 17 | NTX.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | A4E936C8679A32FF4FB020B0A362202883ADF968 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/newtonresearch/newton-toolkit.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | A4E936C8679A32FF4FB020B0A362202883ADF968 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | A4E936C8679A32FF4FB020B0A362202883ADF968 36 | IDESourceControlWCCName 37 | newton-toolkit 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /NTX.xcodeproj/project.xcworkspace/xcuserdata/simon.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX.xcodeproj/project.xcworkspace/xcuserdata/simon.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /NTX.xcodeproj/xcuserdata/simon.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 18 | 19 | 31 | 32 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /NTX.xcodeproj/xcuserdata/simon.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /NTX.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/NTX.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 69 | 70 | 74 | 75 | 79 | 80 | 84 | 85 | 86 | 87 | 88 | 89 | 95 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /NTX.xcodeproj/xcuserdata/simon.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | NTX.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | F4A9275E0945EC6400F746B2 16 | 17 | primary 18 | 19 | 20 | F4FA700009A1FECE00B62DDB 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /NTX/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Controller.h 3 | 4 | Contains: Cocoa controller delegate declarations for the Newton Inspector. 5 | 6 | Written by: Newton Research Group, 2007. 7 | */ 8 | 9 | #import 10 | #import "PreferenceKeys.h" 11 | 12 | 13 | @protocol NTXSleepProtocol 14 | - (BOOL) applicationCanSleep; 15 | - (void) applicationWillSleep; 16 | @end 17 | 18 | 19 | /* ----------------------------------------------------------------------------- 20 | N T X C o n t r o l l e r 21 | ----------------------------------------------------------------------------- */ 22 | @class NTXToolkitProtocolController; 23 | 24 | @interface NTXController : NSObject 25 | // Platform 26 | @property(strong) NSString * currentPlatform; 27 | 28 | // Application 29 | - (BOOL)applicationCanSleep; 30 | 31 | // Toolkit 32 | - (void)setPlatform:(NSString *)inPlatform; 33 | 34 | // Build menu actions 35 | - (IBAction)installToolkit:(id)sender; 36 | - (IBAction)takeScreenshot:(id)sender; 37 | - (IBAction)untetherNewt:(id)sender; 38 | 39 | // UI 40 | - (void)showScreenshot:(NSImage *)inShot; 41 | @end 42 | -------------------------------------------------------------------------------- /NTX/Base.lproj/Credits.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 2 | {\fonttbl\f0\fnil\fcharset77 LucidaGrande;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \deftab720 5 | \pard\pardeftab720\qc 6 | 7 | \f0\fs20 \cf0 Newton lives!} -------------------------------------------------------------------------------- /NTX/Base.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | CFBundleName = "Newton Toolkit"; 4 | CFBundleShortVersionString = "1.2"; 5 | CFBundleGetInfoString = "NTX version 1.2, Copyright ©2017 Newton Research."; 6 | NSHumanReadableCopyright = "Copyright ©2017 Newton Research.\nAll rights reserved."; 7 | -------------------------------------------------------------------------------- /NTX/Base.lproj/NTXScriptViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /NTX/Base.lproj/Script.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /NTX/Base.lproj/Stream.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /NTX/Comms/CRC.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CRC.h 3 | 4 | Contains: CRC16 declarations (used by framed async serial communications tools). 5 | 6 | Written by: Newton Research Group, 2009. 7 | */ 8 | 9 | #include 10 | 11 | 12 | /*-------------------------------------------------------------------------------- 13 | CRC16 14 | --------------------------------------------------------------------------------*/ 15 | 16 | @interface CRC16 : NSObject 17 | { 18 | uint32_t workingCRC; 19 | }; 20 | 21 | - (id) init; 22 | 23 | - (void) reset; 24 | - (void) computeCRC: (unsigned char) inChar; 25 | - (void) computeCRC: (unsigned char *) inData length: (unsigned int) inSize; 26 | - (unsigned char) get: (unsigned int) index; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /NTX/Comms/CRC.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: CRC.m 3 | 4 | Contains: CRC16 implementation (used by framed async serial communications tools). 5 | 6 | Written by: Newton Research Group, 2009. 7 | */ 8 | 9 | #include "CRC.h" 10 | 11 | 12 | /*-------------------------------------------------------------------------------- 13 | CRC16 14 | --------------------------------------------------------------------------------*/ 15 | 16 | static const unsigned short kCRC16LoTable[16] = 17 | { 18 | 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 19 | 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440 20 | }; 21 | 22 | static const unsigned short kCRC16HiTable[16] = 23 | { 24 | 0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401, 25 | 0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400 26 | }; 27 | 28 | 29 | @implementation CRC16 30 | 31 | /*-------------------------------------------------------------------------------- 32 | Initialize. 33 | Args: -- 34 | Return: -- 35 | --------------------------------------------------------------------------------*/ 36 | 37 | - (id) init 38 | { 39 | if (self = [super init]) 40 | [self reset]; 41 | return self; 42 | } 43 | 44 | 45 | /*-------------------------------------------------------------------------------- 46 | Reset the CRC. 47 | Args: -- 48 | Return: -- 49 | --------------------------------------------------------------------------------*/ 50 | 51 | - (void) reset 52 | { 53 | workingCRC = 0; 54 | } 55 | 56 | 57 | /*-------------------------------------------------------------------------------- 58 | Add character into CRC computation. 59 | Args: inChar 60 | Return: -- 61 | --------------------------------------------------------------------------------*/ 62 | 63 | - (void) computeCRC: (unsigned char) inChar 64 | { 65 | uint32_t index = ((workingCRC & 0xFF) ^ inChar); 66 | uint32_t loCRC = kCRC16LoTable[index & 0x0F]; 67 | uint32_t hiCRC = kCRC16HiTable[(index & 0xF0) >> 4]; 68 | workingCRC = (workingCRC >> 8) ^ (hiCRC ^ loCRC); 69 | } 70 | 71 | 72 | /*-------------------------------------------------------------------------------- 73 | Add characters in buffer into CRC computation. 74 | Args: inData 75 | inSize 76 | Return: -- 77 | --------------------------------------------------------------------------------*/ 78 | 79 | - (void) computeCRC: (unsigned char *) inData length: (unsigned int) inSize 80 | { 81 | for ( ; inSize > 0; inSize--) 82 | { 83 | uint32_t index = ((workingCRC & 0xFF) ^ *inData++); 84 | uint32_t loCRC = kCRC16LoTable[index & 0x0F]; 85 | uint32_t hiCRC = kCRC16HiTable[(index & 0xF0) >> 4]; 86 | workingCRC = (workingCRC >> 8) ^ (hiCRC ^ loCRC); 87 | } 88 | } 89 | 90 | 91 | /*-------------------------------------------------------------------------------- 92 | Copy 16-bit CRC into two chars in network byte order. 93 | Args: -- 94 | Return: -- 95 | --------------------------------------------------------------------------------*/ 96 | 97 | - (unsigned char) get: (unsigned int) index; 98 | { 99 | unsigned char crc16[2]; 100 | #if defined(hasByteSwapping) 101 | crc16[1] = workingCRC; 102 | crc16[0] = workingCRC >> 8; 103 | #else 104 | crc16[0] = workingCRC; 105 | crc16[1] = workingCRC >> 8; 106 | #endif 107 | return crc16[index]; 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /NTX/Comms/ChunkBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ChunkBuffer.h 3 | 4 | Contains: Interface to buffered chunks of data. 5 | 6 | Written by: Newton Research Group, 2011. 7 | */ 8 | 9 | #import 10 | 11 | #define kChunkSize 1024 12 | 13 | /*------------------------------------------------------------------------------ 14 | N C C h u n k 15 | ------------------------------------------------------------------------------*/ 16 | 17 | @interface NCChunk : NSObject 18 | { 19 | char data[kChunkSize]; 20 | char * inPtr; 21 | char * outPtr; 22 | } 23 | 24 | @property(readonly) unsigned int amtFilled; 25 | @property(readonly) unsigned int amtLeft; 26 | 27 | - (BOOL) read: (void *) outBuf length: (unsigned int) inSize; 28 | - (void) write: (const void *) inBuf length: (unsigned int) inSize; 29 | 30 | @end 31 | 32 | 33 | /*------------------------------------------------------------------------------ 34 | N C C h u n k B u f f e r 35 | ------------------------------------------------------------------------------*/ 36 | 37 | @interface NCChunkBuffer : NSObject 38 | { 39 | dispatch_queue_t accessQueue; 40 | unsigned int numOfChunks; 41 | NCChunk ** chunks; 42 | } 43 | 44 | @property(readonly) unsigned int size; 45 | @property(readonly) BOOL isEmpty; 46 | @property(readonly) int nextChar; 47 | 48 | - (NCChunk *) getNextChunk; 49 | - (unsigned int) read: (void *) outBuf length: (unsigned int) inSize; 50 | - (unsigned int) write: (const void *) inBuf length: (unsigned int) inSize; 51 | - (void) flush; 52 | 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /NTX/Comms/Chunks.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Chunks.h 3 | 4 | Contains: Interface to buffered chunks of data. 5 | 6 | Written by: Newton Research Group, 2005. 7 | */ 8 | 9 | // USE MAC MEMORY FUNCTIONS 10 | #define __NEWTONMEMORY_H 1 11 | 12 | #include "Newton.h" 13 | 14 | 15 | #define kChunkSize 1024 16 | 17 | /*------------------------------------------------------------------------------ 18 | C C h u n k 19 | ------------------------------------------------------------------------------*/ 20 | 21 | class CChunk 22 | { 23 | public: 24 | CChunk(); 25 | ~CChunk(); 26 | 27 | void init(void); 28 | unsigned int amtFilled(void); 29 | unsigned int amtLeft(void); 30 | BOOL read(void * outBuf, unsigned int inSize); 31 | void write(const void * inBuf, unsigned int inSize); 32 | 33 | private: 34 | char data[kChunkSize]; 35 | char * inPtr; 36 | char * outPtr; 37 | }; 38 | 39 | 40 | /*------------------------------------------------------------------------------ 41 | C C h u n k B u f f e r 42 | ------------------------------------------------------------------------------*/ 43 | 44 | class CChunkBuffer 45 | { 46 | public: 47 | CChunkBuffer(); 48 | ~CChunkBuffer(); 49 | 50 | unsigned int size(void); 51 | CChunk * getNextChunk(void); 52 | unsigned int read(void * outBuf, unsigned int inSize); 53 | unsigned int write(const void * inBuf, unsigned int inSize); 54 | void flush(void); 55 | 56 | private: 57 | unsigned int numOfChunks; 58 | CChunk ** chunks; 59 | }; 60 | 61 | -------------------------------------------------------------------------------- /NTX/Comms/CircleBuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: CircleBuf.h 3 | 4 | Contains: Circle buffer interface. 5 | 6 | Written by: Newton Research Group, 2009. 7 | */ 8 | 9 | #if !defined(__CIRCLEBUF_H) 10 | #define __CIRCLEBUF_H 1 11 | 12 | #include "Chunks.h" 13 | 14 | // from "TraceEvents.h" 15 | typedef enum { eNormalBuffer, eLockedBuffer, eWiredBuffer } EBufferResidence; 16 | 17 | struct MarkerInfo 18 | { 19 | ULong x00; 20 | ULong x04; 21 | }; 22 | 23 | /*------------------------------------------------------------------------------ 24 | C C i r c l e B u f 25 | A circular FIFO buffer for communications services. 26 | ------------------------------------------------------------------------------*/ 27 | 28 | class CCircleBuf 29 | { 30 | public: 31 | CCircleBuf(); 32 | ~CCircleBuf(); 33 | 34 | NewtonErr allocate(size_t inSize); 35 | NewtonErr allocate(size_t inSize, int inArg2, EBufferResidence inResidence, UChar inArg4); 36 | void deallocate(void); 37 | 38 | void reset(void); 39 | void resetStart(void); 40 | 41 | size_t bufferCount(void); 42 | size_t bufferSpace(void); 43 | NewtonErr bufferSpace(size_t inSpaceReqd); 44 | 45 | size_t markerCount(void); 46 | size_t markerSpace(void); 47 | 48 | NewtonErr copyIn(CChunkBuffer * inBuf, size_t * ioSize); 49 | NewtonErr copyIn(UByte * inBuf, ULong * ioSize, BOOL inArg3 = NO, ULong inArg4 = 0); 50 | 51 | NewtonErr copyOut(CChunkBuffer * outBuf, ULong * ioSize, ULong * outArg3 = NULL); 52 | NewtonErr copyOut(UByte * outBuf, ULong * ioSize, ULong * outArg3 = NULL); 53 | 54 | void updateStart(ULong inDelta); 55 | void updateEnd(ULong inDelta); 56 | 57 | NewtonErr putEOM(ULong); 58 | NewtonErr putNextEOM(ULong); 59 | NewtonErr putEOMMark(ULong, ULong); 60 | ULong getEOMMark(ULong *); 61 | ULong peekNextEOMIndex(void); 62 | ULong peekNextEOMIndex(ULong *); 63 | NewtonErr bufferCountToNextMarker(ULong * outCount); 64 | NewtonErr flushToNextMarker(ULong *); 65 | 66 | NewtonErr getBytes(CCircleBuf * inBuf); 67 | NewtonErr getNextByte(UByte * outByte); 68 | NewtonErr getNextByte(UByte * outByte, ULong *); 69 | NewtonErr peekNextByte(UByte * outByte); 70 | NewtonErr peekNextByte(UByte * outByte, ULong *); 71 | NewtonErr peekFirstLong(ULong * outLong); 72 | 73 | NewtonErr putFirstPossible(UByte inByte); 74 | NewtonErr putNextPossible(UByte inByte); 75 | NewtonErr putNextStart(void); 76 | NewtonErr putNextCommit(void); 77 | NewtonErr putNextByte(UByte); 78 | NewtonErr putNextByte(UByte, ULong); 79 | void flushBytes(void); 80 | 81 | private: 82 | void getAlignLong(void); 83 | void putAlignLong(void); 84 | 85 | size_t fBufLen; // +00 86 | UByte * fBuf; // +04 87 | ULong fGetIndex; // +08 88 | ULong fPutIndex; // +0C 89 | ULong f10; 90 | EBufferResidence fBufferResidence; // +14 91 | UChar f15; // +15 flags: 0x02 => lock this in the heap 0x04 => wire it 92 | ULong fNumOfMarkers; // +18 93 | MarkerInfo * fMarkers; // +1C 94 | ULong fGetMarkerIndex; // +20 95 | ULong fPutMarkerIndex; // +24 96 | }; 97 | 98 | 99 | #endif /* __CIRCLEBUF_H */ 100 | -------------------------------------------------------------------------------- /NTX/Comms/Comms.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Comms.h 3 | 4 | Contains: Public interface to Newton Connection comms. 5 | 6 | Written by: Newton Research Group, 2011. 7 | */ 8 | 9 | #if !defined(__COMMS_H) 10 | #define __COMMS_H 1 11 | 12 | typedef int NCError; 13 | 14 | 15 | /* --- General errors --- */ 16 | 17 | #define kErrBase_NC (-98000) 18 | 19 | #define kNCOutOfMemory (kErrBase_NC - 1) 20 | #define kNCInvalidParameter (kErrBase_NC - 2) 21 | #define kNCInternalError (kErrBase_NC - 3) 22 | #define kNCErrorReadingFromPipe (kErrBase_NC - 4) 23 | #define kNCErrorWritingToPipe (kErrBase_NC - 5) 24 | #define kNCInvalidFile (kErrBase_NC - 6) 25 | 26 | /* --- Base error numbers --- */ 27 | 28 | #define kErrBase_Comms (kErrBase_NC - 200) 29 | #define kErrBase_Frames (kErrBase_NC - 400) 30 | #define kErrBase_Session (kErrBase_NC - 600) 31 | 32 | /* --- Comms error numbers --- */ 33 | 34 | #define kCommsNoDispatchSource (kErrBase_Comms - 1) 35 | #define kCommsPartialData (kErrBase_Comms - 2) 36 | #define kCommsNotAllWritten (kErrBase_Comms - 3) 37 | 38 | #endif /* __COMMS_H */ 39 | -------------------------------------------------------------------------------- /NTX/Comms/Endpoints/EinsteinEndpoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: EinsteinEndpoint.h 3 | 4 | Contains: Einstein endpoint communications transport interface. 5 | 6 | Written by: Matthias Melcher, 2017. 7 | */ 8 | 9 | #import "MNPSerialEndpoint.h" 10 | 11 | 12 | /* ----------------------------------------------------------------------------- 13 | E i n s t e i n E n d p o i n t 14 | ----------------------------------------------------------------------------- */ 15 | 16 | @interface EinsteinEndpoint : MNPSerialEndpoint 17 | @end 18 | -------------------------------------------------------------------------------- /NTX/Comms/Endpoints/EinsteinEndpoint.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: EinsteinEndpoint.m 3 | 4 | Contains: Implementation of the Einstein endpoint communications transport interface. 5 | 6 | Written by: Matthias Melcher, 2017. 7 | */ 8 | 9 | #import "EinsteinEndpoint.h" 10 | #import "DockErrors.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | /* ----------------------------------------------------------------------------- 19 | E i n s t e i n E n d p o i n t 20 | ----------------------------------------------------------------------------- */ 21 | 22 | @implementation EinsteinEndpoint 23 | 24 | /* ----------------------------------------------------------------------------- 25 | Check availablilty of Einstein endpoint. 26 | It’s always available. 27 | Maybe we could check whether Einstein is installed on this machine. 28 | ----------------------------------------------------------------------------- */ 29 | 30 | + (BOOL)isAvailable { 31 | return YES; 32 | } 33 | 34 | 35 | /* ----------------------------------------------------------------------------- 36 | Listen to a well-known pipe. Well-known by Einstein anyway. 37 | ----------------------------------------------------------------------------- */ 38 | 39 | - (NCError)listen { 40 | XTRY 41 | { 42 | NSURL * baseURL = [NSFileManager.defaultManager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; 43 | NSURL * pipeFolder = [baseURL URLByAppendingPathComponent:@"Einstein Emulator" isDirectory:YES]; 44 | // if folder doesn’t exist, create it 45 | NSError * error = NULL; 46 | [NSFileManager.defaultManager createDirectoryAtURL:pipeFolder withIntermediateDirectories:NO attributes:nil error:&error]; 47 | // create the sending node if it does not exist yet 48 | NSURL * wPipe = [pipeFolder URLByAppendingPathComponent:@"ExtrSerPortSend"]; 49 | const char * wPipePath = wPipe.fileSystemRepresentation; 50 | if (access(wPipePath, S_IRUSR|S_IWUSR) < 0) { 51 | XFAILIF(mkfifo(wPipePath, S_IRUSR|S_IWUSR) < 0, NSLog(@"***** Error creating named pipe %s - %s (%d).", wPipePath, strerror(errno), errno); ) 52 | } 53 | // create the receiving node if it does not exist yet 54 | NSURL * rPipe = [pipeFolder URLByAppendingPathComponent:@"ExtrSerPortRecv"]; 55 | const char * rPipePath = rPipe.fileSystemRepresentation; 56 | if (access(rPipePath, S_IRUSR|S_IWUSR) < 0) { 57 | XFAILIF(mkfifo(rPipePath, S_IRUSR|S_IWUSR) < 0, NSLog(@"***** Error creating named pipe %s - %s (%d).", rPipePath, strerror(errno), errno); ) 58 | } 59 | 60 | // Open the the pipe for transmitting data from NCX to Einstein 61 | // The O_NONBLOCK flag also causes subsequent I/O on the device to be non-blocking. 62 | // Note: the name of the pipe is seen from Einsten. The receiving port must connect to the "Send" pipe. 63 | XFAILIF((_rfd = open(wPipePath, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0, NSLog(@"Error opening named pipe %s for receiving - %s (%d).", wPipePath, strerror(errno), errno); ) 64 | 65 | // Open the the pipe for transmitting data from NCX to Einstein 66 | // The O_NONBLOCK flag also causes subsequent I/O on the device to be non-blocking. 67 | // Note: the name of the pipe is seen from Einsten. The sneding port must connect to the "Recv" pipe. 68 | XFAILIF((_wfd = open(rPipePath, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0, NSLog(@"Error opening named pipe %s for transmitting - %s (%d).", rPipePath, strerror(errno), errno); ) 69 | 70 | return noErr; 71 | } 72 | XENDTRY; 73 | 74 | if (self.rfd != -1) { 75 | close(self.rfd); 76 | _rfd = -1; 77 | } 78 | if (self.wfd != -1) { 79 | close(self.wfd); 80 | _wfd = -1; 81 | } 82 | return errno; 83 | } 84 | 85 | 86 | /* ----------------------------------------------------------------------------- 87 | Disconnect. 88 | ----------------------------------------------------------------------------- */ 89 | 90 | - (NCError)close { 91 | 92 | if (isLive) { 93 | // Send disconnect frame. 94 | [super xmitLD]; 95 | // The LD Block will be buffered in the pipe. No need to wait until the transfer is done. 96 | } 97 | 98 | if (self.wfd >= 0) { 99 | close(self.wfd); 100 | _wfd = -1; 101 | } 102 | 103 | if (self.rfd >= 0) { 104 | close(self.rfd); 105 | _rfd = -1; 106 | } 107 | 108 | return noErr; 109 | } 110 | 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /NTX/Comms/Endpoints/Endpoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Endpoint.h 3 | 4 | Contains: Communications endpoint and controller interfaces. 5 | 6 | Written by: Newton Research Group, 2011. 7 | */ 8 | 9 | #import 10 | #include 11 | 12 | #import 13 | 14 | #import "Comms.h" 15 | #import "NCBuffer.h" 16 | 17 | #define kDebugOn 1 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | int REPprintf(const char * inFormat, ...); 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | // from "Newton/NewtonDebug.h" 27 | 28 | #define XTRY do 29 | #define XENDTRY while(0) 30 | 31 | #define XDOFAIL(expr) if (expr) do 32 | #define XENDFAIL while(0) 33 | 34 | #define XFAIL(expr) { if ((expr) != 0) { break; } } 35 | #define XFAILIF(expr, action) { if ((expr) != 0) { { action } break; } } 36 | #define XFAILNOT(expr, action) { if ((expr) == 0) { { action } break; } } 37 | 38 | 39 | /* ----------------------------------------------------------------------------- 40 | Disconnection notification. 41 | ----------------------------------------------------------------------------- */ 42 | 43 | #define kNewtonDisconnected @"NCDisconnected" 44 | 45 | 46 | /* ----------------------------------------------------------------------------- 47 | Values that can be passed to setTimeout as timeout values. 48 | ----------------------------------------------------------------------------- */ 49 | 50 | #define kDefaultTimeoutInSecs 30 51 | 52 | 53 | @protocol NTXStreamProtocol 54 | - (void)addData:(NSData *)inData; 55 | @end 56 | 57 | 58 | /* ----------------------------------------------------------------------------- 59 | N C E n d p o i n t 60 | Base class. 61 | Subclass 62 | TCPIPEndpoint 63 | MNPSerialEndpoint 64 | BluetoothEndpoint 65 | ----------------------------------------------------------------------------- */ 66 | #define kRxBufLength 1024 67 | 68 | @interface NCEndpoint : NSObject 69 | { 70 | int _rfd, _wfd; // every endpoint must be based on a file descriptor since the GCD dispatch source requires it 71 | int timeoutSecs; // timeout in seconds 72 | // dispatch_source_t readSrc; // GCD dispatch source for reading data from fd 73 | NCBuffer * rPageBuf; // 1K buffer into which to read fd data 74 | NSMutableData * rData; // buffer into which to read unframed data 75 | 76 | dispatch_queue_t ioQueue; // async serial dispatch queue in which to perform i/o 77 | dispatch_semaphore_t syncWrite; 78 | 79 | // dispatch_source_t writeSrc; // GCD dispatch source for writing data to fd 80 | NCBuffer * wPageBuf; // 1K buffer into which to write fd data 81 | NSMutableData * wData; 82 | BOOL isSyncWrite; 83 | } 84 | @property(nonatomic,readonly) int rfd; // read file descriptor 85 | @property(nonatomic,readonly) int wfd; // write file descriptor 86 | @property(nonatomic,assign) int pipefd; 87 | @property(nonatomic,assign) int timeout; 88 | 89 | // public interface 90 | + (BOOL)isAvailable; 91 | 92 | - (NCError)write:(const void *)inData length:(unsigned int)inLength; 93 | - (NCError)writeSync:(const void *)inData length:(unsigned int)inLength; 94 | - (BOOL)willWrite; 95 | - (void)writeDone; 96 | 97 | // subclass repsonsibility 98 | - (NCError)listen; 99 | - (NCError)accept; 100 | - (void) handleTickTimer; 101 | - (NCError)readPage:(NCBuffer *)inFrameBuf into:(NSMutableData *)ioData; 102 | - (void)writePage:(NCBuffer *)inFrameBuf from:(NSMutableData *)inDataBuf; 103 | - (NCError)close; 104 | 105 | // private 106 | - (NCError)readDispatchSource:(id)inputStream; 107 | - (NCError)writeDispatchSource; 108 | 109 | @end 110 | 111 | 112 | /* ----------------------------------------------------------------------------- 113 | N C E n d p o i n t C o n t r o l l e r 114 | There is a single instance of NCEndpointController that coordinates the 115 | creation of endpoints to listen on all available interfaces, then cancels 116 | endpoints once one has established a connection. 117 | ----------------------------------------------------------------------------- */ 118 | 119 | @interface NCEndpointController : NSObject 120 | @property(nonatomic,readonly) NCEndpoint * endpoint; 121 | @property(nonatomic,readonly) BOOL isActive; 122 | @property(nonatomic,assign) int error; 123 | 124 | - (NCError)startListening:(id)inputStream; 125 | - (void)suppressTimeout:(BOOL)inDoSuppress; 126 | - (void)stop; 127 | @end 128 | -------------------------------------------------------------------------------- /NTX/Comms/Endpoints/MNPSerialEndpoint.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: MNPSerialEndpoint.h 3 | 4 | Contains: MNPSerialEndpoint communications transport interface. 5 | 6 | Written by: Newton Research Group, 2005-2011. 7 | */ 8 | 9 | #import "Endpoint.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "CRC.h" 27 | #include "NCBuffer.h" 28 | 29 | #define kCaptureOn 1 30 | 31 | // Standard ASCII Mnemonics 32 | 33 | #define chNUL 0x00 34 | #define chSOH 0x01 /* Control-A */ 35 | #define chSTX 0x02 /* Control-B */ 36 | #define chETX 0x03 /* Control-C */ 37 | #define chEOT 0x04 /* Control-D */ 38 | #define chENQ 0x05 /* Control-E */ 39 | #define chACK 0x06 /* Control-F */ 40 | #define chBEL 0x07 /* Control-G */ 41 | #define chBS 0x08 /* Control-H */ 42 | #define chHT 0x09 /* Control-I */ 43 | #define chLF 0x0A /* Control-J */ 44 | #define chVT 0x0B /* Control-K */ 45 | #define chFF 0x0C /* Control-L */ 46 | #define chCR 0x0D /* Control-M */ 47 | #define chSO 0x0E /* Control-N */ 48 | #define chSI 0x0F /* Control-O */ 49 | #define chDLE 0x10 /* Control-P */ 50 | #define chDC1 0x11 /* Control-Q */ 51 | #define chDC2 0x12 /* Control-R */ 52 | #define chDC3 0x13 /* Control-S */ 53 | #define chDC4 0x14 /* Control-T */ 54 | #define chNAK 0x15 /* Control-U */ 55 | #define chSYN 0x16 /* Control-V */ 56 | #define chETB 0x17 /* Control-W */ 57 | #define chCAN 0x18 /* Control-X */ 58 | #define chEM 0x19 /* Control-Y */ 59 | #define chSUB 0x1A /* Control-Z */ 60 | #define chESC 0x1B /* Control-[ */ 61 | #define chFS 0x1C 62 | #define chGS 0x1D 63 | #define chRS 0x1E 64 | #define chUS 0x1F 65 | 66 | 67 | #define kMNPPacketSize 256 68 | #define kMNPFrameSize (kMNPPacketSize*2 + 10) 69 | 70 | /* ----------------------------------------------------------------------------- 71 | M N P S e r i a l E n d p o i n t 72 | ----------------------------------------------------------------------------- */ 73 | 74 | @interface MNPSerialEndpoint : NCEndpoint 75 | { 76 | NSString * devPath; 77 | NSUInteger baudRate; 78 | struct termios originalAttrs; 79 | 80 | unsigned char rSequence; 81 | unsigned char prevSequence; 82 | 83 | CRC16 * rFCS; 84 | int fGetFrameState; 85 | int fPreHeaderByteCount; 86 | BOOL fIsGetCharEscaped; 87 | BOOL fIsGetCharStacked; 88 | unsigned char fStackedGetChar; 89 | BOOL isLinkRequest; 90 | NCBufferAccess * rPacketBuf; 91 | NCBuffer * rFrameBuf; 92 | 93 | NCBuffer * wPacketBuf; 94 | unsigned char wSequence; 95 | NCBuffer * wFrameBuf; 96 | CRC16 * wFCS; 97 | 98 | BOOL isLive; 99 | BOOL isACKPending; 100 | int timerT401; 101 | int timerT403; 102 | } 103 | + (NCError)getSerialPorts:(NSArray *__strong *)outPorts; 104 | 105 | - (NCError)processFrame:(NSMutableData *)ioDataBuf; 106 | - (void)rcvLR; 107 | - (void)rcvLT:(NSMutableData *)ioDataBuf; 108 | - (void)rcvLA; 109 | - (void)rcvLD; 110 | - (void)rcvLN; 111 | - (void)rcvLNA; 112 | 113 | - (void)xmitLR; 114 | - (void)xmitLT:(const unsigned char *)inPacketBuf length:(NSUInteger)inCount; 115 | - (void)xmitLA:(BOOL)inOK; 116 | - (void)xmitLD; 117 | 118 | - (void)send:(const unsigned char *)inHeader data:(const unsigned char *)inBuf length:(unsigned int)inSize; 119 | - (void)addToFrameBuf:(const unsigned char *)inBuf length:(unsigned int)inLength; 120 | 121 | - (void)startT401; 122 | - (void)stopT401; 123 | - (void)ackTimeOut; 124 | - (void)startT403; 125 | - (void)stopT403; 126 | - (void)inactiveTimeOut; 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /NTX/Comms/NCBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NCBuffer.h 3 | 4 | Contains: A simple buffer implementation. 5 | 6 | Written by: Newton Research Group, 2012. 7 | */ 8 | 9 | #import 10 | 11 | /* ----------------------------------------------------------------------------- 12 | N C B u f f e r 13 | ----------------------------------------------------------------------------- */ 14 | 15 | @interface NCBufferAccess : NSObject 16 | 17 | @property(readonly) unsigned char * ptr; 18 | @property(readonly) unsigned char * basePtr; 19 | @property(readonly) unsigned int freeSpace; 20 | @property(readonly) unsigned int usedSpace; 21 | @property(assign) unsigned int count; 22 | @property(assign) int nextChar; 23 | 24 | - (void)setData:(unsigned char *)inData length:(NSUInteger)inLength; 25 | - (void)clear; 26 | - (void)reset; 27 | - (void)mark; 28 | - (void)refill; 29 | 30 | - (unsigned int)fill:(unsigned int)inAmount; 31 | - (unsigned int)fill:(unsigned int)inAmount from:(const void *)inBuf; 32 | - (void)drain:(unsigned int)inAmount; 33 | - (unsigned int)drain:(unsigned int)inAmount into:(void *)inBuf; 34 | 35 | @end 36 | 37 | 38 | @interface NCBuffer : NCBufferAccess 39 | @end 40 | -------------------------------------------------------------------------------- /NTX/Comms/NCBuffer.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: NCBuffer.m 3 | 4 | Contains: A simple buffer implementation. 5 | 6 | Written by: Newton Research Group, 2012. 7 | */ 8 | 9 | #import "NCBuffer.h" 10 | 11 | /* ----------------------------------------------------------------------------- 12 | N C B u f f e r 13 | count => limit of data written to buffer 14 | index => limit of data read from buffer 15 | ----------------------------------------------------------------------------- */ 16 | 17 | @interface NCBufferAccess () 18 | { 19 | unsigned int index; 20 | unsigned int lastCount; 21 | } 22 | @property(assign) unsigned char * basePtr; 23 | @end 24 | 25 | #define kPageBufSize 1024 26 | 27 | @interface NCBuffer () 28 | { 29 | unsigned char buf[kPageBufSize]; 30 | } 31 | @end 32 | 33 | 34 | @implementation NCBuffer 35 | 36 | - (id)init { 37 | if (self = [super init]) { 38 | self.basePtr = buf; 39 | } 40 | return self; 41 | } 42 | @end 43 | 44 | 45 | /* ----------------------------------------------------------------------------- 46 | N C B u f f e r A c c e s s 47 | Access to the buffer. 48 | ----------------------------------------------------------------------------- */ 49 | 50 | @implementation NCBufferAccess 51 | 52 | - (id)init { 53 | if (self = [super init]) { 54 | [self clear]; 55 | } 56 | return self; 57 | } 58 | 59 | 60 | - (void)setData:(unsigned char *)inData length:(NSUInteger)inLength { 61 | self.basePtr = inData; 62 | self.count = inLength; 63 | [self reset]; 64 | } 65 | 66 | 67 | - (void)clear { 68 | [self reset]; 69 | self.count = 0; 70 | } 71 | 72 | 73 | - (void)reset { 74 | index = 0; 75 | } 76 | 77 | 78 | - (void)mark { 79 | lastCount = self.count; 80 | } 81 | 82 | 83 | - (void)refill { 84 | [self reset]; 85 | self.count = lastCount; 86 | } 87 | 88 | 89 | - (unsigned char *)ptr { 90 | return self.basePtr + index; 91 | } 92 | 93 | 94 | - (unsigned int) freeSpace { 95 | return kPageBufSize - self.count; 96 | } 97 | 98 | 99 | - (unsigned int) usedSpace { 100 | return self.count - index; 101 | } 102 | 103 | 104 | - (int) nextChar { 105 | if (index < self.count) { 106 | return self.basePtr[index++]; 107 | } else { 108 | [self clear]; 109 | return -1; 110 | } 111 | } 112 | 113 | 114 | - (void)setNextChar:(int)inCh { 115 | if (self.count < kPageBufSize) { 116 | self.basePtr[self.count++] = inCh; 117 | } 118 | } 119 | 120 | 121 | // return amount actually filled 122 | - (unsigned int)fill:(unsigned int)inAmount { 123 | unsigned int actualAmount = inAmount; 124 | if (actualAmount > self.freeSpace) { 125 | actualAmount = self.freeSpace; 126 | } 127 | self.count += actualAmount; 128 | return actualAmount; 129 | } 130 | 131 | 132 | - (unsigned int)fill:(unsigned int)inAmount from:(const void *)inBuf { 133 | unsigned int actualAmount = inAmount; 134 | if (actualAmount > self.freeSpace) { 135 | actualAmount = self.freeSpace; 136 | } 137 | memcpy(self.ptr, inBuf, actualAmount); 138 | [self fill:actualAmount]; 139 | return actualAmount; 140 | } 141 | 142 | 143 | - (void)drain:(unsigned int)inAmount { 144 | unsigned int actualAmount = inAmount; 145 | if (actualAmount > self.usedSpace) { 146 | actualAmount = self.usedSpace; 147 | } 148 | index += actualAmount; 149 | if (index == self.count) { 150 | [self clear]; 151 | } 152 | } 153 | 154 | 155 | - (unsigned int)drain:(unsigned int)inAmount into:(void *)inBuf { 156 | unsigned int actualAmount = inAmount; 157 | if (actualAmount > self.usedSpace) { 158 | actualAmount = self.usedSpace; 159 | } 160 | memcpy(inBuf, self.ptr, actualAmount); 161 | [self drain:actualAmount]; 162 | return actualAmount; 163 | } 164 | 165 | 166 | - (NSString *)description { 167 | char dbuf[1024]; 168 | int i, len = sprintf(dbuf, "NCBuffer index:%u, count:%u", index,self.count); 169 | if (self.count > index) { 170 | len += sprintf(dbuf+len, ", data:"); 171 | char * s = dbuf+len; 172 | unsigned char * p = self.ptr; 173 | for (i = index; i < self.count; i++, p++, s+=3) { 174 | sprintf(s, " %02X", *p); 175 | } 176 | *s = 0; 177 | } 178 | return [NSString stringWithUTF8String:dbuf]; 179 | } 180 | 181 | 182 | @end 183 | 184 | -------------------------------------------------------------------------------- /NTX/Comms/Protocol/DockErrors.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: DockErrors.h 3 | 4 | Contains: Docker error code definitions. 5 | 6 | Written by: Newton Research. 2013. 7 | 8 | !!! WARNING-- THESE ARE NEWTON ERROR CODES !!! 9 | */ 10 | 11 | #define ERRBASE_DOCKER (-28000) // Docker errors 12 | 13 | #define kDockErrBadStoreSignature (ERRBASE_DOCKER - 1) 14 | #define kDockErrBadEntry (ERRBASE_DOCKER - 2) 15 | #define kDockErrAborted (ERRBASE_DOCKER - 3) 16 | #define kDockErrBadQuery (ERRBASE_DOCKER - 4) 17 | #define kDockErrReadEntryError (ERRBASE_DOCKER - 5) 18 | #define kDockErrBadCurrentSoup (ERRBASE_DOCKER - 6) 19 | #define kDockErrBadCommandLength (ERRBASE_DOCKER - 7) 20 | #define kDockErrEntryNotFound (ERRBASE_DOCKER - 8) 21 | #define kDockErrBadConnection (ERRBASE_DOCKER - 9) 22 | #define kDockErrFileNotFound (ERRBASE_DOCKER - 10) 23 | #define kDockErrIncompatibleProtocol (ERRBASE_DOCKER - 11) 24 | #define kDockErrProtocolError (ERRBASE_DOCKER - 12) 25 | #define kDockErrDockingCanceled (ERRBASE_DOCKER - 13) 26 | #define kDockErrStoreNotFound (ERRBASE_DOCKER - 14) 27 | #define kDockErrSoupNotFound (ERRBASE_DOCKER - 15) 28 | #define kDockErrBadHeader (ERRBASE_DOCKER - 16) 29 | #define kDockErrOutOfMemory (ERRBASE_DOCKER - 17) 30 | #define kDockErrNewtonVersionTooNew (ERRBASE_DOCKER - 18) 31 | #define kDockErrPackageCantLoad (ERRBASE_DOCKER - 19) 32 | #define kDockErrProtocolExtAlreadyRegistered (ERRBASE_DOCKER - 20) 33 | #define kDockErrRemoteImportError (ERRBASE_DOCKER - 21) 34 | #define kDockErrBadPasswordError (ERRBASE_DOCKER - 22) 35 | #define kDockErrRetryPW (ERRBASE_DOCKER - 23) 36 | #define kDockErrIdleTooLong (ERRBASE_DOCKER - 24) 37 | #define kDockErrOutOfPower (ERRBASE_DOCKER - 25) 38 | #define kDockErrBadCursor (ERRBASE_DOCKER - 26) 39 | #define kDockErrAlreadyBusy (ERRBASE_DOCKER - 27) 40 | #define kDockErrDesktopError (ERRBASE_DOCKER - 28) 41 | #define kDockErrCantConnectToModem (ERRBASE_DOCKER - 29) 42 | #define kDockErrDisconnected (ERRBASE_DOCKER - 30) 43 | #define kDockErrAccessDenied (ERRBASE_DOCKER - 31) 44 | 45 | #define ERRBASE_DOCKER_ (ERRBASE_DOCKER - 100) // Docker platform errors 46 | 47 | #define kDockErrDisconnectDuringRead (ERRBASE_DOCKER_) 48 | #define kDockErrReadFailed (ERRBASE_DOCKER_ - 1) 49 | #define kDockErrCommunicationsToolNotFound (ERRBASE_DOCKER_ - 2) 50 | #define kDockErrInvalidModemToolVersion (ERRBASE_DOCKER_ - 3) 51 | #define kDockErrCardNotInstalled (ERRBASE_DOCKER_ - 4) 52 | #define kDockErrBrowserFileNotFound (ERRBASE_DOCKER_ - 5) 53 | #define kDockErrBrowserVolumeNotFound (ERRBASE_DOCKER_ - 6) 54 | #define kDockErrBrowserPathNotFound (ERRBASE_DOCKER_ - 7) 55 | -------------------------------------------------------------------------------- /NTX/Comms/Protocol/NTKProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NTKProtocol.h 3 | 4 | Contains: Newton Toolkit communications protocol. 5 | 6 | Written by: Newton Research Group, 2007. 7 | */ 8 | 9 | #if !defined(__NTKPROTOCOL_H) 10 | #define __NTKPROTOCOL_H 1 11 | 12 | // from Newton/Events.h 13 | typedef uint32_t EventClass; 14 | typedef uint32_t EventId; 15 | #define kNewtEventClass 'newt' 16 | 17 | /*------------------------------------------------------------------------------ 18 | The NTK protocol packet structure -- same as the dock. 19 | ------------------------------------------------------------------------------*/ 20 | typedef uint32_t EventType; 21 | 22 | struct DockEventHeader 23 | { 24 | EventClass evtClass; 25 | EventId evtId; 26 | EventType tag; 27 | uint32_t length; 28 | }; 29 | 30 | #define kIndeterminateLength 0xFFFFFFFF 31 | 32 | 33 | /*------------------------------------------------------------------------------ 34 | The toolkit event id. 35 | ------------------------------------------------------------------------------*/ 36 | #define kToolkitEventId 'ntp ' 37 | 38 | 39 | /*------------------------------------------------------------------------------ 40 | Default timeout in seconds if no comms acivity. 41 | ------------------------------------------------------------------------------*/ 42 | #define kDefaultTimeout 30 43 | 44 | 45 | /*------------------------------------------------------------------------------ 46 | NTK protocol commands. 47 | ------------------------------------------------------------------------------*/ 48 | 49 | // Newton -> Desktop 50 | #define kTConnect 'cnnt' 51 | #define kTDownload 'dpkg' 52 | 53 | #define kTText 'text' 54 | #define kTResult 'rslt' 55 | #define kTEOM 'teom' 56 | 57 | #define kTEnterBreakLoop 'eext' 58 | #define kTExitBreakLoop 'bext' 59 | 60 | #define kTExceptionError 'eerr' 61 | #define kTExceptionMessage 'estr' 62 | #define kTExceptionRef 'eref' 63 | 64 | // Desktop -> Newton 65 | #define kTOK 'okln' 66 | #define kTExecute 'lscb' 67 | #define kTSetTimeout 'stou' 68 | #define kTDeletePackage 'pkgX' 69 | #define kTLoadPackage 'pkg ' 70 | 71 | // Desktop -> Newton or Newton -> Desktop 72 | #define kTObject 'fobj' 73 | #define kTCode 'code' 74 | #define kTTerminate 'term' 75 | 76 | #endif /* __NTKPROTOCOL_H */ 77 | -------------------------------------------------------------------------------- /NTX/ContentViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ContentViewController.h 3 | 4 | Abstract: The NTXContentViewController (top half of window content split view) 5 | switches document editor view controller according to the current source list selection. 6 | 7 | Written by: Newton Research, 2015. 8 | */ 9 | 10 | #import 11 | 12 | 13 | /* ----------------------------------------------------------------------------- 14 | N T X C o n t e n t V i e w C o n t r o l l e r 15 | ----------------------------------------------------------------------------- */ 16 | 17 | @interface NTXContentViewController : NSViewController 18 | @end 19 | 20 | -------------------------------------------------------------------------------- /NTX/ContentViewController.mm: -------------------------------------------------------------------------------- 1 | /* 2 | File: ContentViewController.mm 3 | 4 | Abstract: Implementation of NTXContentViewController subclasses. 5 | 6 | Written by: Newton Research, 2015. 7 | */ 8 | 9 | #import "ContentViewController.h" 10 | #import "ProjectWindowController.h" 11 | #import "NTXDocument.h" 12 | 13 | 14 | 15 | #pragma mark - Segue 16 | /* ----------------------------------------------------------------------------- 17 | S e g u e 18 | ----------------------------------------------------------------------------- */ 19 | 20 | @interface EmptySegue : NSStoryboardSegue 21 | @end 22 | 23 | @implementation EmptySegue 24 | - (void)perform { 25 | // Nothing. The NTXContentViewController class handles all of the view controller action. 26 | } 27 | @end 28 | 29 | 30 | #pragma mark - Content 31 | /* ----------------------------------------------------------------------------- 32 | N T X C o n t e n t V i e w C o n t r o l l e r 33 | ----------------------------------------------------------------------------- */ 34 | 35 | @implementation NTXContentViewController 36 | 37 | - (void)viewDidLoad { 38 | [super viewDidLoad]; 39 | 40 | dispatch_async(dispatch_get_main_queue(), ^{ 41 | NTXProjectWindowController * wc = self.view.window.windowController; 42 | wc.contentController = self; 43 | }); 44 | } 45 | 46 | 47 | - (void)prepareForSegue:(NSStoryboardSegue *)segue sender:(id)sender 48 | { 49 | NSViewController * toViewController = (NSViewController *)segue.destinationController; 50 | toViewController.representedObject = sender; 51 | NSViewController * fromViewController = (self.childViewControllers.count > 0)? self.childViewControllers[0] : nil; 52 | 53 | [self addChildViewController:toViewController]; 54 | // [self transitionFromViewController:fromViewController toViewController:toViewController options:0 completionHandler:^{[fromViewController removeFromParentViewController];}]; 55 | [self transitionFromViewController:fromViewController toViewController:toViewController]; 56 | } 57 | 58 | 59 | - (void) transitionFromViewController:(NSViewController *)fromViewController toViewController:(NSViewController *)toViewController 60 | { 61 | // remove any previous item view 62 | if (fromViewController) { 63 | [fromViewController.view removeFromSuperview]; 64 | [fromViewController removeFromParentViewController]; 65 | } 66 | 67 | if (toViewController) { 68 | NTXProjectWindowController * wc = self.view.window.windowController; 69 | NSView * subview = toViewController.view; 70 | // make sure our added subview is placed and resizes correctly 71 | if (subview) { 72 | // ((NCInfoController *)toViewController).document = wc.document; 73 | [subview setTranslatesAutoresizingMaskIntoConstraints:NO]; 74 | [self.view addSubview:subview]; 75 | [self.view addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1 constant:0]]; 76 | [self.view addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeRight multiplier:1 constant:0]]; 77 | [self.view addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0]]; 78 | [self.view addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1 constant:0]]; 79 | } 80 | } 81 | } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /NTX/Context/CanonicalProject.newtonproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/CanonicalProject.newtonproj -------------------------------------------------------------------------------- /NTX/Context/CanonicalProject.newtonscript: -------------------------------------------------------------------------------- 1 | settings := { ntkPlatform: 0, // 0 => Mac, 1 => Windows fileVersion: 2, projectSettings: {platform: "Newton 2.1", language: "English", debugBuild: nil, ignoreNative: nil, checkGlobalFunctions: true, oldBuildRules: nil, useStepChildren: true, suppressByteCodes: nil, fasterFunctions: true}, outputSettings: {applicationName: "", applicationSymbol: "", partType: 0, topFrameExpression: "", autoClose: true, customPartType: "UNKN", fasterSoups: nil, iconProNormal: nil, iconProHighlighted: nil, iconFile: nil}, packageSettings: {packageName: "", version: "1", copyright: "2017 Newton Research. All rights reserved.", optimizeSpeed: true, copyProtected: nil, deleteOnDownload: true, dispatchOnly: nil, newton20Only: nil, fourByteAlignment: true, zippyCompression: true}, profilerSettings: {memory: true, percent: true, compileForProfiling: nil, compileForSpeed: nil, detailedSystemCalls: nil, detailedUserFunctions: true}, projectItems: {sortOrder: 0, items: []} // each item is a frame like: { file: {class: 'filereference, deltafromproject: "Definitions"}, type: 5, isMainLayout: nil } } -------------------------------------------------------------------------------- /NTX/Context/CanonicalProject.newtonstream: -------------------------------------------------------------------------------- 1 |  ntkPlatform fileVersionprojectSettingsoutputSettingspackageSettingsprofilerSettings projectItems platformlanguage 2 | debugBuild ignoreNativecheckGlobalFunctions OldBuildRulesUseStepChildrensuppressByteCodesFasterFunctionsNewton 2.1English 3 | 4 |  5 |  6 |  7 | applicationNameapplicationSymbolpartTypetopFrameExpression autoClosecustomPartType FasterSoups iconProNormaliconProHighlightedIconFile 8 | UNKN 9 | 10 | 11 | 12 |  13 |  packageNameversion copyright optimizeSpeed copyprotectedDeleteOnDownload dispatchonly newton20OnlyfourByteAlignmentzippyCompression1X2017 Newton Research. All rights reserved. 14 |  15 | 16 | memorypercentcompileForProfilingcompileForSpeeddetailedSystemCallsdetailedUserFunctions 17 | 18 | 19 |  sortOrderitems -------------------------------------------------------------------------------- /NTX/Context/Decompiler: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Decompiler -------------------------------------------------------------------------------- /NTX/Context/Decompiler.stream: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Decompiler.stream -------------------------------------------------------------------------------- /NTX/Context/EditorCommands: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/EditorCommands -------------------------------------------------------------------------------- /NTX/Context/Engineering/UnitManager.ns: -------------------------------------------------------------------------------- 1 | 2 | // for information only -- the unit manager is platform specific and defined in __platform.platformVariables 3 | 4 | _UnitManager := { 5 | 6 | declaredUnits: [ 7 | { name: Connection, 8 | major: 1, minor: 0, 9 | alias: Connection, 10 | indexes: { desktopConnectionProto: 0 } }, 11 | 12 | { name: ListView, 13 | major: 1, minor: 0, 14 | alias: ListView, 15 | indexes: { protoListView: 0, protoNewAuntButton: 1, protoNewTopicButton: 2, protoNewDaughterButton: 3, listDataDef: 4, listViewDef: 5, checkViewDef: 6, checkDataDef: 7 } } 16 | ], 17 | 18 | Init: func() 19 | begin 20 | if not GlobalVarExists('language) then 21 | Throw('|evt.ex.msg|, "unit functions only allowed at build-time"); 22 | if not _UnitManager._proto then 23 | vars._UnitManager := { _proto: _UnitManager, 24 | declaredUnits: Clone(declaredUnits), 25 | exportTable: [], 26 | importTable: [] } 27 | end, 28 | 29 | Dispatch: func(message, args) 30 | begin 31 | if vars.kSyntaxCheck then 32 | return '|syntax check weirdness with UR, ignore|; 33 | :Init(); 34 | Perform(_UnitManager, message, args) 35 | end, 36 | 37 | GetDeclaredUnit: func(alias) 38 | begin 39 | local decl := BFetch(declaredUnits, alias, '|sym<|, 'alias); 40 | if not decl then 41 | Throw('|evt.ex.msg|, "undeclared unit:" && alias); 42 | decl 43 | end, 44 | 45 | DeclareUnit: func(unitName, major, minor, indexes) 46 | begin 47 | local newDecl := { name: unitName, 48 | major: major, 49 | minor: minor, 50 | alias: unitName, 51 | indexes: indexes }; 52 | if not BInsert(declaredUnits, newDecl, '|sym<|, 'alias, true) then 53 | Throw('|evt.ex.msg|, "redeclaration of unit:" && unitName); 54 | nil 55 | end, 56 | 57 | AliasUnit: func(alias, unitName) 58 | begin 59 | local decl := :GetDeclaredUnit(unitName); 60 | if not decl then 61 | Throw('|evt.ex.msg|, "undeclared unit:" && alias); 62 | local newDecl := { _proto: decl, alias: alias }; 63 | if not BInsert(declaredUnits, newDecl, '|sym<|, 'alias, true) then 64 | Throw('|evt.ex.msg|, "redeclaration of unit alias:" && alias); 65 | newDecl 66 | end, 67 | 68 | AliasUnitSubset: func(alias, unitName, memberNames) 69 | begin 70 | local decl := :AliasUnit(alias, unitName); 71 | local oldIndexes := decl.indexes; 72 | local newIndexes := {}; 73 | foreach memberName in memberNames do 74 | newIndexes.(memberName) := oldIndexes.(memberName); 75 | decl.indexes := newIndexes; 76 | decl 77 | end, 78 | 79 | DefineUnit: func(unitName, members) 80 | begin 81 | local decl := :GetDeclaredUnit(unitName); 82 | if LFetch(exportTable, unitName, 0, '|=|, 'name) then 83 | Throw('|evt.ex.msg|, "redefinition of unit:" && unitName); 84 | local objects := Array(Length(decl.indexes), nil); 85 | foreach s, v in members do 86 | begin 87 | if IsImmediate(v) or IsSymbol(v) or IsMagicPtr(v) then 88 | Throw('|evt.ex.msg|, "illegal unit member value:" && unitName & $. & s); 89 | local index := decl.indexes.(s); 90 | if not index then 91 | Throw('|evt.ex.msg|, "unit definition contains undeclared member:" && unitName & $. & s); 92 | objects[index] := v 93 | end; 94 | if LSearch(objects, nil, 0, '|=|, nil) then 95 | Throw('|evt.ex.msg|, "unit" && unitName && "missing declared members:" && Substr(stringer(foreach s, v in decl.indexes collect not members.(s) and ", " & s), 2, nil)); 96 | AddArraySlot(exportTable, { name: decl.name, 97 | major: decl.major, minor: decl.minor, 98 | objects: objects }); 99 | SetPartFrameSlot('_exportTable, exportTable); 100 | nil 101 | end, 102 | 103 | ImportDeclaredUnit: func(decl) 104 | begin 105 | local pos := LSearch(importTable, decl.name, 0, '|=|, 'name); 106 | if not pos then 107 | begin 108 | pos := Length(importTable); 109 | AddArraySlot(importTable, { name: decl.name, 110 | major: decl.major, minor: decl.minor }); 111 | SetPartFrameSlot('_importTable, importTable); 112 | end; 113 | pos 114 | end, 115 | 116 | UnitReference: func(unitName, memberName) 117 | begin 118 | if unitName = 'ROM and IsGlobalConstant(memberName) then 119 | begin 120 | local value := GetGlobalConstant(memberName); 121 | if IsMagicPtr(value) then 122 | return value; 123 | end; 124 | local decl := :GetDeclaredUnit(unitName); 125 | local memberIndex := decl.indexes.(memberName); 126 | if not memberIndex then 127 | Throw('|evt.ex.msg|, "undeclared unit member:" && unitName & $. & memberName); 128 | local pos := :ImportDeclaredUnit(decl); 129 | local mpValue := (pos + 2) << 12 + memberIndex; 130 | if GlobalFnExists('ref) then 131 | ref(mpValue << 2 + 3); 132 | else 133 | call Compile($@ & mpValue) with () 134 | end 135 | }; 136 | -------------------------------------------------------------------------------- /NTX/Context/Engineering/functions.ns: -------------------------------------------------------------------------------- 1 | 2 | ntxVars.constantFunctions := { 3 | 4 | // localization 5 | LocObj: func(obj, path) 6 | begin 7 | if not vars.kSyntaxCheck then 8 | begin 9 | if not vars.locRoot exists then 10 | Throw('|evt.ex.msg|, "No localization frame specified."); 11 | if not locRoot.english exists then 12 | locRoot.english := {}; 13 | if locRoot.english.(path) exists then 14 | begin 15 | local pp := locRoot.english.(path); 16 | if ClassOf(obj) = 'string and ClassOf(pp) = 'string and Length(obj) <> Length(pp) then 17 | begin 18 | local err := Stringer(foreach x in path collect x & "."); 19 | err[length(err) div 2 - 2] := $ ; 20 | Throw('|evt.ex.msg|, "Localization string for path '" & err & " redefined as: " & obj) 21 | end 22 | end; 23 | locRoot.english.(path) := obj; 24 | if locRoot.(language) exists then 25 | begin 26 | if locRoot.(language).(path) exists then 27 | locRoot.(language).(path) // this is the expression that’s returned 28 | else 29 | Throw('|evt.ex.msg|, "Localization frame for " & language & " has no entry at " & path)); 30 | end 31 | else 32 | Throw('|evt.ex.msg|, "Localization frame has no entry for language " & language) 33 | end 34 | end, 35 | 36 | GetDateStringSpec: func(elemArray) 37 | begin 38 | local spec := 0; 39 | foreach val in elemArray do 40 | spec := spec << 6 + val[1] << 3 + val[0]; 41 | spec 42 | end, 43 | 44 | // build 45 | GetLayout: func(filename) 46 | begin 47 | if not vars.kSyntaxCheck then 48 | try 49 | call Compile("|Layout_" & filename & "|") with () 50 | onexception |evt.ex| do 51 | Throw('|evt.ex.msg|, "The file " & filename & " has not been processed yet.") 52 | end, 53 | 54 | // units 55 | UnitReference: func(unitName, memberName) 56 | begin 57 | _UnitManager:Dispatch('UnitReference, [unitName, memberName]) 58 | end, 59 | 60 | UR: func(unitName, memberName) 61 | begin 62 | _UnitManager:Dispatch('UnitReference, [unitName, memberName]) 63 | end, 64 | 65 | // text style 66 | tsSize: func(num) num << 10, 67 | 68 | // view frames 69 | vfPen: func(x) x * 256, 70 | vfInset: func(x) x * 65536, 71 | vfShadow: func(x) x * 262144, 72 | vfRound: func(x) x * 16777216, 73 | 74 | // view fx 75 | fxColumns: func(num) num - 1, 76 | fxRows: func(num) (num - 1) << 5, 77 | fxSteps: func(num) (num - 1) << 21, 78 | fxStepTime: func(num) num << 25, 79 | 80 | // bounds 81 | pureRelBounds: func(l, t, w, h) {left: l, top: t, right: l + w, bottom: t + h}, 82 | pureSetBounds: func(l, t, r, b) {left: l, top: t, right: r, bottom: b}, 83 | 84 | ButtonBounds: func(width) 85 | begin 86 | if width > 0 then 87 | SetBounds(7, 2, 7 + width, 15) 88 | else 89 | SetBounds(25, 2, 25 - width, 15) 90 | end, 91 | 92 | PictBounds: func(rsrcName, l, t) 93 | begin 94 | local pict := GetNamedResource("PICT", rsrcName, 'rawPICT); 95 | if pict then 96 | SetBounds(l, t, l + ExtractWord(pict, 8) - ExtractWord(pict, 4), t + ExtractWord(pict, 6) - ExtractWord(pict, 2)) 97 | end 98 | 99 | }; 100 | -------------------------------------------------------------------------------- /NTX/Context/GlobalData.newtonscript: -------------------------------------------------------------------------------- 1 | // Set fn-return key to evaluate selected text protoEditor:DefineKey({key: 76}, 'EvaluateSelection); -------------------------------------------------------------------------------- /NTX/Context/GlobalFunctions.newtonscript: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/GlobalFunctions.newtonscript -------------------------------------------------------------------------------- /NTX/Context/GlobalInit.newtonscript: -------------------------------------------------------------------------------- 1 | // Set debug environment begin vars.printDepth := 16; vars.printLength := nil; vars.dbgKeepVarNames := true; // vars.trace := 'functions; vars.printInstructions := true; // vars.showCodeBlocks := true; end; -------------------------------------------------------------------------------- /NTX/Context/Inspector Scripts.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440 2 | {\fonttbl\f0\fnil\fcharset77 LucidaGrande;} 3 | {\colortbl;\red255\green255\blue255;} 4 | \paperw11900\paperh16840\margl1440\margr1440\vieww11900\viewh16840\viewkind1\viewscale100 5 | \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural 6 | 7 | \f0\fs24 \cf0 \ 8 | // print all slots in NTK\'d5s protoProtoEditor\ 9 | UnDefineGlobalConstant('pe);\ 10 | DefineGlobalConstant('pe, protoProtoEditor);\ 11 | y := pe\ 12 | foreach tag, f pe do\ 13 | begin\ 14 | Write(tag & ": ");\ 15 | Write(f.docString);\ 16 | Write("\\n")\ 17 | end;\ 18 | \ 19 | \ 20 | \ 21 | DefineGlobalConstant('_x_, _UnitManager);\ 22 | \ 23 | x := _x_\ 24 | \ 25 | // create global variable w/ contents of stream file\ 26 | UnDefineGlobalConstant('_x_);\ 27 | \ 28 | DefineGlobalConstant('gemma, ReadStreamFile("OS X:Users:simon:Projects:NTX:NewtonScript:decompiler.stream"));\ 29 | \ 30 | begin\ 31 | local cf := \{\};\ 32 | foreach tag, f in functions do\ 33 | if not IsNativeFunction(f) then\ 34 | cf.(tag) := f;\ 35 | DefineGlobalConstant('_x_, cf);\ 36 | end;\ 37 | \ 38 | \ 39 | } -------------------------------------------------------------------------------- /NTX/Context/Platforms/MessagePad: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/MessagePad -------------------------------------------------------------------------------- /NTX/Context/Platforms/MessagePad Defs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/MessagePad Defs -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.0 -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.0 Defs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.0 Defs -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.1 -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.1 1.2d6/Newton 2.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.1 1.2d6/Newton 2.1 -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.1 1.2d6/Newton 2.1 Defs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.1 1.2d6/Newton 2.1 Defs -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.1 1.2d6/Release_Notes_2.0_and_2.1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.1 1.2d6/Release_Notes_2.0_and_2.1.txt -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.1 Defs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.1 Defs -------------------------------------------------------------------------------- /NTX/Context/Platforms/Newton 2.1.nsof: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Newton 2.1.nsof -------------------------------------------------------------------------------- /NTX/Context/Platforms/Platform File Notes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Platform File Notes -------------------------------------------------------------------------------- /NTX/Context/Platforms/Platform File Notes.idx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Platform File Notes.idx -------------------------------------------------------------------------------- /NTX/Context/Platforms/Platform_Files_Release_Notes.tx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Platform_Files_Release_Notes.tx -------------------------------------------------------------------------------- /NTX/Context/Platforms/Platforms Release Notes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Platforms/Platforms Release Notes -------------------------------------------------------------------------------- /NTX/Context/Platforms/Release Notes 1.2b2: -------------------------------------------------------------------------------- 1 | These are the changes between the 1.2b1 and 1.2b2 releases of the platform files "Newton 2.0" and "Newton 2.1". 2.0 only: added global function BatteryCount (was already in 2.1) both 2.0 and 2.1: added newtInfoBox prototype newtLayout and newtEntryView templates now get a default viewJustify newtApplication template title now defaults to kAppName newtApplication template allSoups.mySoup now defaults to "SoupName:SIG" added soup/union soup functions AddFlushedXmit, GetIndexesModTime, GetInfoModTime, GetSize and MakeKey added store function AtomicAction added global functions: AddAlarmInSeconds, AddAutoAdd, AddMemoryItemUnique, BinEqual, BuildRecConfig, CharPos, DateFromSeconds, GetAppDataDefs, GetCorrectInfo, GetCorrectionWordInfo, GetExchangeRate, GetGroupTransport, GetInkWordInfo, GetMatchedEntries, GetMemorySlot, GetRandomState, GetSoupDef, GetSysEntryData, GetUpdatedExchangeRates, GetViewID, IsPackage, IsPackageActive, IsPrimShape, IsValidDate, LatitudeToString, LoadExpandDictionary, LongitudeToString, MakeStrokeBundle, MapAmbiguousCharacters, MarkPackageBusy, MarkPackageNotBusy, PrepRecConfig, Recognize, RecognizePoly, RemoveAppFolders, RemoveAutoAdd, RethrowWithUserMessage, SafeFreezePackage, SafeMovePackage, SaveExpandDictionary, SectRect, SetCountryClass, SetExchangeRate, SetRandomState, SetSysEntryData, SetTimeInSeconds, StringToDateFrame, StripInk, ThawPackage, TimeInSecondsToTime, TimeToTimeInSeconds, TotalSeconds, TotalTextBounds, TrueSize, UnmapAmbiguousCharacters, UseCurrentEmporium, UseCurrentPersona and ViewAutopsy 2.1 only: added constants: kKbdUsesKeyCodes, kKbdTracksCaret, kKbdforInput and kCMOIrDAConnectAttrName -------------------------------------------------------------------------------- /NTX/Context/Toolkit.newtonpkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Context/Toolkit.newtonpkg -------------------------------------------------------------------------------- /NTX/FeedbackProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: FeedbackProtocol.h 3 | 4 | Abstract: Feedback Protocol from toolkit communicatoins layer to UI. 5 | 6 | Written by: Newton Research, 2015. 7 | */ 8 | 9 | #import 10 | 11 | /* ----------------------------------------------------------------------------- 12 | Keys for notifications sent by the communications layer. 13 | ----------------------------------------------------------------------------- */ 14 | extern NSString * const kNubConnectionDidChangeNotification; 15 | extern NSString * const kNubOwnerDidChangeNotification; 16 | 17 | /* ----------------------------------------------------------------------------- 18 | N T X N u b F e e d b a c k 19 | Protocol for reporting received objects. 20 | ----------------------------------------------------------------------------- */ 21 | @protocol NTXNubFeedback 22 | @property(readonly) NSProgress * progress; 23 | - (void)receivedText:(NSString *)inText; 24 | - (void)receivedObject:(RefArg)inObject; 25 | @end 26 | 27 | -------------------------------------------------------------------------------- /NTX/FrameDefs.h: -------------------------------------------------------------------------------- 1 | 2 | DEFFRAME2(canonicalEditor, 3 | _proto, NILREF, 4 | viewCObject, NILREF) 5 | 6 | -------------------------------------------------------------------------------- /NTX/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "icon_16x16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "idiom" : "mac", 11 | "size" : "16x16", 12 | "scale" : "2x" 13 | }, 14 | { 15 | "size" : "32x32", 16 | "idiom" : "mac", 17 | "filename" : "icon_32x32.png", 18 | "scale" : "1x" 19 | }, 20 | { 21 | "idiom" : "mac", 22 | "size" : "32x32", 23 | "scale" : "2x" 24 | }, 25 | { 26 | "idiom" : "mac", 27 | "size" : "128x128", 28 | "scale" : "1x" 29 | }, 30 | { 31 | "idiom" : "mac", 32 | "size" : "128x128", 33 | "scale" : "2x" 34 | }, 35 | { 36 | "size" : "256x256", 37 | "idiom" : "mac", 38 | "filename" : "icon_256x256.png", 39 | "scale" : "1x" 40 | }, 41 | { 42 | "idiom" : "mac", 43 | "size" : "256x256", 44 | "scale" : "2x" 45 | }, 46 | { 47 | "size" : "512x512", 48 | "idiom" : "mac", 49 | "filename" : "icon_512x512.png", 50 | "scale" : "1x" 51 | }, 52 | { 53 | "idiom" : "mac", 54 | "size" : "512x512", 55 | "scale" : "2x" 56 | } 57 | ], 58 | "info" : { 59 | "version" : 1, 60 | "author" : "xcode" 61 | } 62 | } -------------------------------------------------------------------------------- /NTX/Images.xcassets/AppIcon.appiconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/AppIcon.appiconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/AppIcon.appiconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/AppIcon.appiconset/icon_256x256.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/AppIcon.appiconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/AppIcon.appiconset/icon_32x32.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/AppIcon.appiconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/AppIcon.appiconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/layout.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/layout.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/layout.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/layout.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/layout.iconset/layout_16x16.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/layout.iconset/layout_16x16.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/layout.iconset/layout_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/layout.iconset/layout_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/nativecode.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/nativecode.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/nativecode.iconset/icon_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/nativecode.iconset/icon_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/icon_128x128.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/icon_256x256.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/icon_32x32.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/pkg_128x128.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/pkg_128x128.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/pkg_16x16.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/pkg_16x16.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/pkg_256x256.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/pkg_256x256.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/pkg_32x32.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/pkg_32x32.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/package.iconset/pkg_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/package.iconset/pkg_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/platform.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/platform.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/platform.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/platform.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/project.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/project.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/project.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/project.iconset/icon_32x32.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/project.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/project.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/proto.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/proto.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/proto.iconset/proto_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/proto.iconset/proto_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/resource.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/resource.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/resource.iconset/icon_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/resource.iconset/icon_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/script.iconset/icon_128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/script.iconset/icon_128x128.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/script.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/script.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/script.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/script.iconset/icon_256x256.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/script.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/script.iconset/icon_32x32.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/script.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/script.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/stream.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/stream.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/stream.iconset/icon_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/stream.iconset/icon_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/icon_16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/icon_16x16.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/icon_256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/icon_256x256.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/icon_32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/icon_32x32.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/icon_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/icon_512x512.png -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/toolkit_16x16.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/toolkit_16x16.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/toolkit_256x256.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/toolkit_256x256.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/toolkit_32x32.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/toolkit_32x32.pxm -------------------------------------------------------------------------------- /NTX/Images.xcassets/toolkit.iconset/toolkit_512x512.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images.xcassets/toolkit.iconset/toolkit_512x512.pxm -------------------------------------------------------------------------------- /NTX/Images/Arrows.graffle/image2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/Arrows.graffle/image2.pdf -------------------------------------------------------------------------------- /NTX/Images/Connected.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/Connected.pdf -------------------------------------------------------------------------------- /NTX/Images/DVTEditorBasic_10_10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/DVTEditorBasic_10_10.pdf -------------------------------------------------------------------------------- /NTX/Images/DVTVersionsEditorCompare_10_10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/DVTVersionsEditorCompare_10_10.pdf -------------------------------------------------------------------------------- /NTX/Images/DVTViewDebugArea_10_10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/DVTViewDebugArea_10_10.pdf -------------------------------------------------------------------------------- /NTX/Images/DVTViewNavigators_10_10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/DVTViewNavigators_10_10.pdf -------------------------------------------------------------------------------- /NTX/Images/DVTViewUtilities_10_10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/DVTViewUtilities_10_10.pdf -------------------------------------------------------------------------------- /NTX/Images/Disconnected.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/Disconnected.pdf -------------------------------------------------------------------------------- /NTX/Images/GeneralPrefsViewController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/GeneralPrefsViewController.png -------------------------------------------------------------------------------- /NTX/Images/PrintDepth.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/PrintDepth.pdf -------------------------------------------------------------------------------- /NTX/Images/PrintLength.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/PrintLength.pdf -------------------------------------------------------------------------------- /NTX/Images/UpdatePrefsViewController.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/UpdatePrefsViewController.png -------------------------------------------------------------------------------- /NTX/Images/book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/book.png -------------------------------------------------------------------------------- /NTX/Images/pkg.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/newtonresearch/newton-toolkit/e1d9049494ef950f48048b3b3ef584bbd9901d63/NTX/Images/pkg.icns -------------------------------------------------------------------------------- /NTX/InspectorViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: InspectorViewController.h 3 | 4 | Abstract: The InspectorViewController accepts text for NewtonScript evaluation, 5 | prints results and loads/saves inspector view content. 6 | 7 | Written by: Newton Research, 2015. 8 | */ 9 | 10 | #import 11 | 12 | 13 | /* ----------------------------------------------------------------------------- 14 | N T X I n s p e c t o r S p l i t V i e w C o n t r o l l e r 15 | The divider in the content split view shows TellUser() text. 16 | ----------------------------------------------------------------------------- */ 17 | @interface NTXInspectorSplitViewController : NSSplitViewController 18 | { 19 | IBOutlet NSSplitViewItem * inspectorItem; 20 | } 21 | @property NSString * tellUserText; 22 | - (IBAction)toggleInspector:sender; 23 | @end 24 | 25 | @interface NTXSplitView : NSSplitView 26 | @end 27 | 28 | 29 | /* ----------------------------------------------------------------------------- 30 | I n s p e c t o r V i e w C o n t r o l l e r 31 | Controller for the inspector view. 32 | ----------------------------------------------------------------------------- */ 33 | @class NTXEditorView, NTXOutputRedirect; 34 | 35 | @interface NTXInspectorViewController : NSViewController 36 | { 37 | IBOutlet NTXEditorView * inspectorView; 38 | } 39 | @property(readonly) NSURL * inspectorTextURL; 40 | 41 | @end 42 | 43 | -------------------------------------------------------------------------------- /NTX/InspectorWindowController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: InspectorWindowController.h 3 | 4 | Contains: Cocoa controller delegate declarations for the Newton Inspector. 5 | 6 | Written by: Newton Research Group, 2007. 7 | */ 8 | 9 | #import 10 | #import "NTXEditorView.h" 11 | #import "stdioDirector.h" 12 | 13 | 14 | /* ----------------------------------------------------------------------------- 15 | N T X W i n d o w C o n t r o l l e r 16 | ----------------------------------------------------------------------------- */ 17 | 18 | @interface NTXWindowController : NSWindowController 19 | { 20 | NTXOutputRedirect * redirector; 21 | NSDictionary * txAttrs; 22 | 23 | IBOutlet NSTextField * infoView; 24 | IBOutlet NTXEditorView * txView; 25 | } 26 | - (void) loadText: (NSURL *) inURL; 27 | - (void) saveText: (NSURL *) inURL; 28 | @end 29 | 30 | -------------------------------------------------------------------------------- /NTX/MacRsrcProject.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: MacRsrcProject.h 3 | 4 | Abstract: We import Mac NTK project files (but we don’t save that format). 5 | An NTXRsrcProject reads resources and builds a frame Ref of the type we require. 6 | 7 | Written by: Newton Research Group, 2014. 8 | */ 9 | 10 | #import "MacRsrcTypes.h" 11 | #import "NewtonKit.h" 12 | 13 | 14 | /* ----------------------------------------------------------------------------- 15 | N T X R s r c F i l e 16 | ----------------------------------------------------------------------------- */ 17 | 18 | @interface NTXRsrcFile : NSObject 19 | { 20 | FILE * fref; 21 | int rsrcLen; 22 | char * rsrcImage; 23 | char * rsrcData; 24 | RsrcMap * rsrcMap; 25 | RsrcList * rsrcTypeList; 26 | } 27 | @property(copy) NSURL * url; 28 | @property(readonly) int read4Bytes; 29 | @property(readonly) int read2Bytes; 30 | @property(readonly) int readByte; 31 | 32 | - (void)read:(NSUInteger)inCount into:(char *)inBuffer; 33 | - (void *)readResource:(OSType)inType number:(uint16_t)inNumber; 34 | 35 | - (id)initWithURL:(NSURL *)inURL; 36 | @end 37 | 38 | /* ----------------------------------------------------------------------------- 39 | N T X R s r c P r o j e c t 40 | ----------------------------------------------------------------------------- */ 41 | 42 | @interface NTXRsrcProject : NTXRsrcFile 43 | @property(readonly) Ref projectRef; 44 | @end 45 | -------------------------------------------------------------------------------- /NTX/NRBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NRBox.h 3 | 4 | Contains: An NSBox with iTunes-like appearance. 5 | 6 | Written by: Newton Research Group, 2012. 7 | */ 8 | 9 | #import 10 | 11 | 12 | @interface NRBox : NSBox 13 | @end 14 | -------------------------------------------------------------------------------- /NTX/NRBox.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: NRBox.m 3 | 4 | Contains: An NSBox for the project window content view. 5 | 6 | Written by: Newton Research Group, 2015. 7 | */ 8 | 9 | #import "NRBox.h" 10 | 11 | /* ----------------------------------------------------------------------------- 12 | N R B o x 13 | When awoken, set up our font. 14 | Draw the box filled with a title at the top. 15 | ----------------------------------------------------------------------------- */ 16 | 17 | @implementation NRBox 18 | 19 | - (void)awakeFromNib { 20 | self.titleFont = [NSFont systemFontOfSize:16.0]; // could try [NSFont fontWithName:@"HelveticaNeue-Light" size:18.0] ? 21 | [self.titleCell setTextColor:[NSColor blackColor]]; 22 | } 23 | 24 | 25 | - (void)drawRect:(NSRect)inRect { 26 | if (self.boxType == NSBoxCustom && self.borderType == NSLineBorder) { 27 | NSRect boxRect = self.borderRect; 28 | CGFloat wd = self.borderWidth; 29 | CGFloat insetWd = wd / 2.0; 30 | 31 | if (self.titlePosition != NSNoTitle) { 32 | NSDictionary * attrs = [[self.titleCell attributedStringValue] attributesAtIndex:0 effectiveRange:NULL]; 33 | NSSize titleSize = [self.title sizeWithAttributes:attrs]; 34 | NSRect titleRect = NSMakeRect(boxRect.origin.x + wd + 4, 35 | boxRect.origin.y + boxRect.size.height - titleSize.height - (wd * 2.0), 36 | titleSize.width + (wd * 2.0), 37 | titleSize.height); 38 | titleRect.size.width = MIN(titleRect.size.width, boxRect.size.width - (wd * 2.0)); 39 | // reduce box height to allow for title 40 | boxRect.size.height -= (titleRect.size.height + 8); 41 | 42 | [NSColor.whiteColor set]; 43 | NSRectFill(self.borderRect); 44 | 45 | [self.title drawInRect:titleRect withAttributes:attrs]; 46 | } 47 | [self.fillColor set]; 48 | NSRectFill(boxRect); 49 | 50 | if (self.borderType == NSLineBorder && wd > 0.0) { 51 | [self.borderColor set]; 52 | NSFrameRectWithWidth(NSInsetRect(boxRect, insetWd, insetWd), wd); 53 | } 54 | } else { 55 | [super drawRect: inRect]; 56 | } 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /NTX/NRProgressBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NRProgressBox.h 3 | 4 | Contains: A Yosemite-style (Safari, Xcode) progress box: 5 | round rect, filled white, thin blue progress gauge. 6 | 7 | Written by: Newton Research Group, 2014. 8 | */ 9 | 10 | #import 11 | 12 | 13 | @interface NRProgressBox : NSBox 14 | @property(strong) NSString * statusText; 15 | @property(assign) float barValue; // 0.0 .. 1.0 16 | @property(assign) BOOL canCancel; // YES => show cancel button, respond to it 17 | @end 18 | -------------------------------------------------------------------------------- /NTX/NRProgressBox.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: NRProgressBox.m 3 | 4 | Contains: A Yosemite-style (Safari, Xcode) progress box: 5 | round rect, filled white, thin blue progress gauge. 6 | 7 | Written by: Newton Research Group, 2014. 8 | */ 9 | 10 | #import "NRProgressBox.h" 11 | 12 | 13 | /* ----------------------------------------------------------------------------- 14 | N R P r o g r e s s B o x 15 | 16 | No subviews here - we draw everything as needed. 17 | To update the box, set the properties required and set needsDisplay = YES 18 | TODO: Draw dimmed state? 19 | ----------------------------------------------------------------------------- */ 20 | @implementation NRProgressBox 21 | 22 | - (void)drawRect:(NSRect)inRect { 23 | [NSGraphicsContext saveGraphicsState]; 24 | 25 | // fill round rect with white 26 | NSRect bounds = NSInsetRect(self.bounds, 0.0, 1.0); 27 | 28 | NSBezierPath * path = [NSBezierPath bezierPathWithRoundedRect:bounds xRadius:3.5 yRadius:3.5]; 29 | [self.borderColor setStroke]; 30 | [path stroke]; 31 | [self.fillColor setFill]; 32 | [path fill]; 33 | // apply shadow? 34 | 35 | // clip to round rect 36 | [path setClip]; 37 | 38 | BOOL isActive = NO; 39 | 40 | // if progress bar required, fill with blue 41 | if (0.0 <= self.barValue && self.barValue <= 1.0) { 42 | NSRect bar = bounds; 43 | bar.size.height = 2.0; 44 | bar.size.width *= _barValue; 45 | [[NSColor colorWithCalibratedRed:0.086274 green:0.494117 blue:0.984313 alpha:1.0] setFill]; 46 | NSRectFill(bar); 47 | isActive = YES; 48 | // if (_canCancel) { 49 | // // draw cancel button : if pressed, highlight it 50 | // } 51 | } 52 | 53 | // write status text 54 | if (self.statusText && self.statusText.length > 0) { 55 | NSRect box = NSInsetRect(bounds, 10.0, 3.0); 56 | box.origin.y += 4.0; 57 | [self.statusText drawWithRect:box options:0 attributes:@{ NSFontAttributeName:[NSFont systemFontOfSize:11.0], 58 | NSForegroundColorAttributeName:NSColor.blackColor }]; 59 | isActive = YES; 60 | } 61 | 62 | if (!isActive) { 63 | // draw Newton logo 64 | NSRect box = bounds; 65 | box.origin.x += box.size.width/2.0 - 11.0; 66 | box.origin.y = 2.0; 67 | box.size.width = 22.0; 68 | box.size.height = 22.0; 69 | [[NSImage imageNamed:@"logo"] drawInRect:box]; 70 | } 71 | 72 | [NSGraphicsContext restoreGraphicsState]; 73 | } 74 | 75 | @end 76 | 77 | -------------------------------------------------------------------------------- /NTX/NSMutableArray-Extensions.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NSMutableArray-Extensions.h 3 | 4 | Contains: NSMutableArray support category declarations for Newton Connection. 5 | 6 | Written by: Newton Research Group, 2007. 7 | */ 8 | 9 | #import 10 | 11 | 12 | @interface NSMutableArray (NCXExtensions) 13 | - (void) put: (id) inItem; 14 | - (id) get; 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /NTX/NSMutableArray-Extensions.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: NSMutableArray-Extensions.m 3 | 4 | Contains: NSMutableArray support category declarations for Newton Connection. 5 | 6 | 7 | Written by: Newton Research Group, 2007. 8 | */ 9 | 10 | #import "NSMutableArray-Extensions.h" 11 | 12 | 13 | @implementation NSMutableArray (NCXExtensions) 14 | 15 | /*------------------------------------------------------------------------------ 16 | Put an item into a FIFO queue. 17 | Args: inItem must not be nil 18 | Return: -- 19 | ------------------------------------------------------------------------------*/ 20 | 21 | - (void) put: (id) inItem 22 | { 23 | [self addObject: inItem]; 24 | } 25 | 26 | 27 | /*------------------------------------------------------------------------------ 28 | Get an item from a FIFO queue. 29 | Args: -- 30 | Return: item must be an item in the queue 31 | ------------------------------------------------------------------------------*/ 32 | 33 | - (id) get 34 | { 35 | id __autoreleasing item = nil; 36 | if ([self count] > 0) 37 | { 38 | item = [self objectAtIndex:0]; 39 | [self removeObjectAtIndex:0]; 40 | } 41 | return item; 42 | } 43 | 44 | @end 45 | 46 | -------------------------------------------------------------------------------- /NTX/NTX.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NTX/NTXDocument.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NTXDocument.h 3 | 4 | Abstract: An NTXDocument displays itself in the main project window using a view controller. 5 | 6 | Written by: Newton Research, 2014. 7 | */ 8 | 9 | #import 10 | #import "NewtonKit.h" 11 | 12 | /* ----------------------------------------------------------------------------- 13 | N T X D o c u m e n t 14 | Base class for documents held in a project. 15 | Each document is shown in a view in the project window, not its own window. 16 | ----------------------------------------------------------------------------- */ 17 | 18 | @interface NTXDocument : NSDocument 19 | @property(readonly) NSString * storyboardName; 20 | @property(readonly) NSString * symbol; 21 | 22 | - (Ref)build; 23 | - (void)exportToText:(FILE *)fp error:(NSError *__autoreleasing *)outError; 24 | @end 25 | 26 | 27 | /* ----------------------------------------------------------------------------- 28 | N T X L a y o u t D o c u m e n t 29 | ----------------------------------------------------------------------------- */ 30 | 31 | @interface NTXLayoutDocument : NTXDocument 32 | @property(assign) Ref layoutRef; 33 | @property(readonly) int layoutType; 34 | + (void)startBuild; 35 | + (void)finishBuild; 36 | @end 37 | 38 | 39 | /* ----------------------------------------------------------------------------- 40 | N T X B i t m a p D o c u m e n t 41 | ----------------------------------------------------------------------------- */ 42 | 43 | @interface NTXBitmapDocument : NTXDocument 44 | @end 45 | 46 | 47 | /* ----------------------------------------------------------------------------- 48 | N T X M e t a D o c u m e n t 49 | Unused. 50 | ----------------------------------------------------------------------------- */ 51 | 52 | @interface NTXMetaDocument : NTXDocument 53 | @end 54 | 55 | 56 | /* ----------------------------------------------------------------------------- 57 | N T X S o u n d D o c u m e n t 58 | ----------------------------------------------------------------------------- */ 59 | 60 | @interface NTXSoundDocument : NTXDocument 61 | @end 62 | 63 | 64 | /* ----------------------------------------------------------------------------- 65 | N T X B o o k D o c u m e n t 66 | Deprecated in favor of script items. 67 | ----------------------------------------------------------------------------- */ 68 | 69 | @interface NTXBookDocument : NTXDocument 70 | @end 71 | 72 | 73 | /* ----------------------------------------------------------------------------- 74 | N T X S c r i p t D o c u m e n t 75 | A NewtonScript source document is a simple text file. 76 | ----------------------------------------------------------------------------- */ 77 | 78 | @interface NTXScriptDocument : NTXDocument 79 | @property(strong) NSTextStorage * textStorage; 80 | @end 81 | 82 | 83 | /* ----------------------------------------------------------------------------- 84 | N T X P a c k a g e D o c u m e n t 85 | ----------------------------------------------------------------------------- */ 86 | #include "PkgPart.h" 87 | 88 | @interface NTXPackageDocument : NTXDocument 89 | @property(readonly) NSString * name; 90 | @property(readonly) NSString * size; 91 | @property(readonly) NSString * ident; 92 | @property(readonly) NSString * version; 93 | @property(readonly) NSString * copyright; 94 | @property(readonly) NSString * creationDate; 95 | @property(readonly) BOOL isCopyProtected; 96 | @property(readonly) NSMutableArray * parts; 97 | @end 98 | 99 | 100 | /* ----------------------------------------------------------------------------- 101 | N T X S t r e a m D o c u m e n t 102 | ----------------------------------------------------------------------------- */ 103 | 104 | @interface NTXStreamDocument : NTXDocument 105 | @property(readonly) NSAttributedString * text; 106 | @end 107 | 108 | 109 | /* ----------------------------------------------------------------------------- 110 | N T X N a t i v e C o d e D o c u m e n t 111 | ----------------------------------------------------------------------------- */ 112 | 113 | @interface NTXNativeCodeDocument : NTXDocument 114 | @property(readonly) NSString * name; 115 | @property(readonly) NSString * cpu; 116 | @property(readonly) NSString * size; 117 | @property(readonly) NSString * relocations; 118 | @property(readonly) NSString * debugFile; 119 | @property(readonly) NSAttributedString * entryPoints; 120 | @end 121 | 122 | -------------------------------------------------------------------------------- /NTX/NTXEditorView.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NTXEditorView.h 3 | 4 | Contains: NTXEditorView that despatches key input to NewtonScript handler. 5 | 6 | Written by: Newton Research Group, 2007. 7 | */ 8 | 9 | #include "NewtonKit.h" 10 | 11 | /* ----------------------------------------------------------------------------- 12 | N T X E d i t o r V i e w 13 | A plain text view that accepts NewtonScript editing commands. 14 | ----------------------------------------------------------------------------- */ 15 | 16 | @interface NTXEditorView : NSTextView 17 | { 18 | RefStruct ntxView; 19 | } 20 | @end 21 | 22 | /* ----------------------------------------------------------------------------- 23 | N T X P l a i n T e x t V i e w C o n t r o l l e r 24 | Controller for plain text view (ie not using NewtonScript editing commands). 25 | ----------------------------------------------------------------------------- */ 26 | 27 | @interface NTXPlainTextViewController : NSViewController 28 | { 29 | IBOutlet NSTextView * textView; 30 | 31 | NSDictionary * userTxAttrs; 32 | } 33 | @property(readonly) NSString * fontName; 34 | @property(readonly) NSInteger fontSize; 35 | @end 36 | 37 | -------------------------------------------------------------------------------- /NTX/NewtonKit.h: -------------------------------------------------------------------------------- 1 | /* File: NewtonKit.h Contains: Public interface to the Newton framework. Written by: Newton Research Group, 2005. */ #if !defined(__NEWTONKIT_H) #define __NEWTONKIT_H 1 #if __LITTLE_ENDIAN__ #define hasByteSwapping 1 #endif // USE MAC MEMORY FUNCTIONS #define __NEWTONMEMORY_H 1 #include #include #include #include #include #include #include // access to global NewtonScript vars extern Ref gVarFrame; extern Ref * RSgVarFrame; extern Ref gFunctionFrame; extern Ref * RSgFunctionFrame; // Some commonly used, but strangely private functions #ifdef __cplusplus extern "C" { #endif Ref GetProtoVariable(RefArg context, RefArg name, BOOL * exists = NULL); Ref DoMessage(RefArg rcvr, RefArg msg, RefArg args); void PrintObject(Ref obj, int indent); int REPprintf(const char * inFormat, ...); void REPflush(void); #ifdef __cplusplus } #endif extern void FlattenRef(RefArg inRef, CPipe & inPipe); extern long FlattenRefSize(RefArg inRef); extern Ref UnflattenRef(CPipe & inPipe); extern long UnflattenRefSize(CPipe & inPipe); #endif /* __NEWTONKIT_H */ -------------------------------------------------------------------------------- /NTX/PackagePart.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: PackagePart.h 3 | 4 | Abstract: Wrapper for package part that maintains its data and info. 5 | 6 | Written by: Newton Research Group, 2015. 7 | */ 8 | 9 | #import 10 | #import "NewtonKit.h" 11 | #import "NTK/PackageParts.h" 12 | #import "NTK/ObjHeader.h" 13 | #import "NTK/Ref32.h" 14 | 15 | /* ----------------------------------------------------------------------------- 16 | N T X P a c k a g e P a r t 17 | ----------------------------------------------------------------------------- */ 18 | @interface NTXPackagePart : NSObject 19 | { 20 | PartEntry _dirEntry; 21 | RefStruct _partData; 22 | int _alignment; 23 | ArrayObject32 * partRoot; 24 | const char * infoStr; 25 | } 26 | @property(readonly) PartEntry * entry; 27 | @property(readonly) const char * info; 28 | @property(readonly) NSUInteger infoLen; 29 | @property(readonly) const void * data; 30 | @property(readonly) NSUInteger dataLen; 31 | @property(readonly) const void * relocationData; 32 | @property(readonly) NSUInteger relocationDataLen; 33 | 34 | - (id)initWith:(RefArg)content type:(const char *)type alignment:(int)inAlignment; 35 | - (id)initWithRawData:(const void *)content size:(int)contentSize type:(const char *)type; 36 | - (void)buildPartData:(NSUInteger)inBaseOffset; 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /NTX/PackageViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: PackageViewController.h 3 | 4 | Abstract: Interface for NTXPackageViewController class. 5 | 6 | Written by: Newton Research, 2016. 7 | */ 8 | 9 | #import 10 | 11 | /* ----------------------------------------------------------------------------- 12 | N T X P a c k a g e V i e w C o n t r o l l e r 13 | ----------------------------------------------------------------------------- */ 14 | 15 | @interface NTXPackageViewController : NSViewController 16 | @property IBOutlet NSStackView * stackView; 17 | @property IBOutlet NSView * infoView; 18 | -(void)viewWillLayout; 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /NTX/PackageViewController.mm: -------------------------------------------------------------------------------- 1 | /* 2 | File: PackageViewController.mm 3 | 4 | Abstract: Implementation of NTXPackageViewController subclasses. 5 | 6 | Written by: Newton Research, 2016. 7 | */ 8 | 9 | #import "PackageViewController.h" 10 | #import "NTXDocument.h" 11 | #import "PkgPart.h" 12 | 13 | 14 | /* ----------------------------------------------------------------------------- 15 | N T X P a c k a g e V i e w C o n t r o l l e r 16 | ----------------------------------------------------------------------------- */ 17 | 18 | @implementation NTXPackageViewController 19 | 20 | -(void)viewWillLayout { 21 | [super viewWillLayout]; 22 | 23 | NSStoryboard * sb = self.storyboard; 24 | 25 | // add view controllers for package part info 26 | NTXPackageDocument * document = self.representedObject; 27 | NSView * prevview = self.infoView; 28 | for (PkgPart * part in document.parts) { 29 | NSViewController * viewController = [sb instantiateControllerWithIdentifier:[self viewControllerNameFor:part.partType]]; 30 | NSView * subview = viewController.view; 31 | NSStackView * superview = self.stackView; 32 | viewController.representedObject = part; 33 | [subview setTranslatesAutoresizingMaskIntoConstraints:NO]; 34 | [superview addSubview:subview]; 35 | [superview addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeLeft multiplier:1 constant:0]]; 36 | [superview addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeRight multiplier:1 constant:0]]; 37 | [superview addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:prevview attribute:NSLayoutAttributeBottom multiplier:1 constant:0]]; 38 | // [superview addConstraint:[NSLayoutConstraint constraintWithItem:subview attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:superview attribute:NSLayoutAttributeBottom multiplier:1 constant:0]]; 39 | prevview = subview; 40 | } 41 | } 42 | 43 | 44 | /* ----------------------------------------------------------------------------- 45 | Return storyboard viewcontroller id for part type. 46 | ----------------------------------------------------------------------------- */ 47 | 48 | - (NSString *)viewControllerNameFor:(unsigned int)inType { 49 | NSString * name; 50 | switch (inType) { 51 | case 'form': 52 | case 'auto': 53 | name = @"formPartViewController"; 54 | break; 55 | case 'book': 56 | name = @"bookPartViewController"; 57 | break; 58 | // case 'soup': 59 | // name = @"soupPartViewController"; 60 | // break; 61 | default: 62 | name = @"PartViewController"; 63 | break; 64 | } 65 | return name; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /NTX/PkgPart.h: -------------------------------------------------------------------------------- 1 | 2 | #import 3 | #import "NTK/PackageParts.h" 4 | 5 | /* ----------------------------------------------------------------------------- 6 | P k g P a r t 7 | The base class for all package parts. 8 | This is fine for all non-specialized parts, eg auto, custom. 9 | It holds display information for the part. 10 | ----------------------------------------------------------------------------- */ 11 | 12 | @interface PkgPart : NSObject { 13 | NSImage * _iconImage; 14 | } 15 | @property(readonly) unsigned int partType; 16 | @property(readonly) NSString * partTitle; 17 | @property(readonly) NSString * size; 18 | @property(readonly) NSImage * iconImage; 19 | @property(readonly) Ref rootRef; 20 | @property(readonly) char * data; 21 | 22 | - (id)init:(const PartEntry *)inPart ref:(Ref)inRef data:(char *)inData sequence:(unsigned int)inSeq; 23 | @end 24 | 25 | 26 | /* ----------------------------------------------------------------------------- 27 | P k g F o r m P a r t 28 | The application part. 29 | ----------------------------------------------------------------------------- */ 30 | 31 | @interface PkgFormPart : PkgPart 32 | @property(readonly) NSString * text; 33 | @end 34 | 35 | 36 | /* ----------------------------------------------------------------------------- 37 | P k g B o o k P a r t 38 | The book part. 39 | ----------------------------------------------------------------------------- */ 40 | 41 | @interface PkgBookPart : PkgPart 42 | @property(readonly) NSString * title; 43 | @property(readonly) NSString * isbn; 44 | @property(readonly) NSString * author; 45 | @property(readonly) NSString * copyright; 46 | @property(readonly) NSString * date; 47 | @end 48 | 49 | 50 | /* ----------------------------------------------------------------------------- 51 | P k g S o u p P a r t 52 | The soup part. 53 | ----------------------------------------------------------------------------- */ 54 | 55 | @interface PkgSoupPart : PkgPart 56 | @end 57 | 58 | -------------------------------------------------------------------------------- /NTX/PkgPart.mm: -------------------------------------------------------------------------------- 1 | 2 | #import "PkgPart.h" 3 | #import "NewtonKit.h" 4 | #import "Utilities.h" 5 | 6 | extern NSNumberFormatter * gNumberFormatter; 7 | extern NSDateFormatter * gDateFormatter; 8 | 9 | extern BOOL FromObject(RefArg inObj, Rect * outBounds); 10 | extern void InitDrawing(CGContextRef inContext, int inScreenHeight); 11 | extern void DrawBitmap(RefArg inBitmap, const Rect * inRect, int inTransferMode); 12 | 13 | #define kMinutesSince1904 34714080 14 | 15 | 16 | /*------------------------------------------------------------------------------ 17 | P k g P a r t 18 | ------------------------------------------------------------------------------*/ 19 | @implementation PkgPart 20 | 21 | - (id)init:(const PartEntry *)inPart ref:(Ref)inRef data:(char *)inData sequence:(unsigned int)inSeq { 22 | if (self = [super init]) { 23 | ULong partFlagged = inPart->flags & 0x07; 24 | _partType = inPart->type; 25 | NSString * typeStr = _partType ? [NSString stringWithFormat: @"%c%c%c%c", (_partType >> 24) & 0xFF, (_partType >> 16) & 0xFF, (_partType >> 8) & 0xFF, _partType & 0xFF] : nil; 26 | if (partFlagged == kProtocolPart) 27 | typeStr = typeStr ? [NSString stringWithFormat: @"%@ protocol", typeStr] : @"protocol"; 28 | else if (partFlagged == kRawPart) 29 | typeStr = typeStr ? [NSString stringWithFormat: @"raw %@", typeStr] : @"raw"; 30 | if (typeStr == nil) 31 | typeStr = @"unspecified type"; 32 | _partTitle = [[NSString alloc] initWithFormat: @"Part %d (%@)", inSeq, typeStr]; 33 | _size = [[NSString alloc] initWithFormat: @"%@ bytes", [gNumberFormatter stringFromNumber: [NSNumber numberWithInt:inPart->size]]]; 34 | _iconImage = nil; 35 | 36 | if ((inPart->flags & kNOSPart) != 0) 37 | _rootRef = inRef; 38 | else 39 | _rootRef = NILREF; 40 | 41 | _data = inData; 42 | } 43 | return self; 44 | } 45 | 46 | 47 | - (void) dealloc { 48 | if (_data) 49 | free(_data); 50 | } 51 | 52 | 53 | - (NSImage *) iconImage { // should be in PkgFormPart? 54 | if (_iconImage == nil && NOTNIL(self.rootRef)) { 55 | RefVar icon(GetFrameSlot(self.rootRef, MakeSymbol("iconPro"))); 56 | if (NOTNIL(icon)) 57 | icon = GetFrameSlot(icon, MakeSymbol("unhilited")); 58 | if (ISNIL(icon)) 59 | icon = GetFrameSlot(self.rootRef, MakeSymbol("icon")); 60 | if (NOTNIL(icon)) { 61 | Rect boundsRect; 62 | FromObject(GetFrameSlot(icon, MakeSymbol("bounds")), &boundsRect); 63 | 64 | _iconImage = [[NSImage alloc] initWithSize: NSMakeSize(boundsRect.right, boundsRect.bottom)]; 65 | [_iconImage lockFocus]; 66 | 67 | InitDrawing((CGContextRef)NSGraphicsContext.currentContext.graphicsPort, boundsRect.bottom); 68 | DrawBitmap(icon, &boundsRect, 0/*modeCopy*/); 69 | 70 | [_iconImage unlockFocus]; 71 | } 72 | } 73 | return _iconImage; 74 | } 75 | 76 | @end 77 | 78 | 79 | /*------------------------------------------------------------------------------ 80 | P k g F o r m P a r t 81 | ------------------------------------------------------------------------------*/ 82 | 83 | @implementation PkgFormPart 84 | 85 | - (id)init:(const PartEntry *)inPart ref:(Ref)inRef data:(char *)inData sequence:(unsigned int)inSeq { 86 | if (self = [super init:inPart ref:inRef data:inData sequence:inSeq]) { 87 | _text = MakeNSString(GetFrameSlot(self.rootRef, MakeSymbol("text"))); 88 | // preflight the icon 89 | [self iconImage]; 90 | } 91 | return self; 92 | } 93 | 94 | @end 95 | 96 | 97 | /*------------------------------------------------------------------------------ 98 | P k g B o o k P a r t 99 | ------------------------------------------------------------------------------*/ 100 | 101 | @implementation PkgBookPart 102 | 103 | - (id)init:(const PartEntry *)inPart ref:(Ref)inRef data:(char *)inData sequence:(unsigned int)inSeq { 104 | if (self = [super init:inPart ref:inRef data:inData sequence:inSeq]) { 105 | RefVar book(GetFrameSlot(self.rootRef, MakeSymbol("book"))); 106 | Ref dateRef = GetFrameSlot(book, MakeSymbol("publicationDate")); 107 | if (ISINT(dateRef)) { 108 | NSTimeInterval interval = RVALUE(dateRef); 109 | _date = [gDateFormatter stringFromDate: [NSDate dateWithTimeIntervalSince1970: (interval - kMinutesSince1904)*60]]; 110 | } else { 111 | _date = nil; 112 | } 113 | 114 | _title = MakeNSString(GetFrameSlot(book, MakeSymbol("title"))); 115 | _isbn = MakeNSString(GetFrameSlot(book, MakeSymbol("ISBN"))); 116 | _author = MakeNSString(GetFrameSlot(book, MakeSymbol("author"))); 117 | _copyright = MakeNSString(GetFrameSlot(book, MakeSymbol("copyright"))); 118 | } 119 | return self; 120 | } 121 | 122 | @end 123 | 124 | 125 | /*------------------------------------------------------------------------------ 126 | P k g S o u p P a r t 127 | ------------------------------------------------------------------------------*/ 128 | 129 | @implementation PkgSoupPart 130 | @end 131 | -------------------------------------------------------------------------------- /NTX/PreferenceKeys.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: PreferenceKeys.h 3 | 4 | Contains: Preference keys for the NTX app. 5 | 6 | Written by: Newton Research Group, 2013. 7 | */ 8 | 9 | // Preference Panes 10 | 11 | // Serial 12 | #define kSerialPortPref @"SerialPort" 13 | #define kSerialBaudPref @"BaudRate" 14 | 15 | // Debug 16 | #define kLogToFilePref @"LogToFile" 17 | 18 | 19 | // Not preference keys: 20 | // Notifications 21 | #define kSerialPortChanged @"SerialPortChanged" 22 | #define kEvaluateNewtonScript @"Evaluate" 23 | #define kTellUser @"TellUser" 24 | -------------------------------------------------------------------------------- /NTX/Preferences/GeneralPrefsViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: GeneralPrefsViewController.h 3 | 4 | Contains: General preferences view controller for the NTX app. 5 | 6 | Written by: Newton Research Group, 2015. 7 | */ 8 | 9 | #import 10 | #import "PreferenceKeys.h" 11 | 12 | @interface GeneralPrefsViewController : NSViewController 13 | { 14 | // serial prefs 15 | NSArray * ports; 16 | NSString * serialPort; 17 | NSUInteger serialSpeed; 18 | IBOutlet NSPopUpButton * serialPortPopup; 19 | } 20 | 21 | + (int) preferredSerialPort: (NSString * __strong *) outPort bitRate: (NSUInteger *) outRate; 22 | 23 | // serial prefs 24 | - (IBAction) updateSerialPort: (id) sender; 25 | @end 26 | -------------------------------------------------------------------------------- /NTX/Preferences/GeneralPrefsViewController.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: GeneralPrefsViewController.m 3 | 4 | Contains: General preferences view controller for the NTX app. 5 | 6 | Written by: Newton Research Group, 2015. 7 | */ 8 | 9 | #import "GeneralPrefsViewController.h" 10 | 11 | // we need to know all available transports 12 | #import "MNPSerialEndpoint.h" 13 | 14 | @implementation GeneralPrefsViewController 15 | 16 | /*------------------------------------------------------------------------------ 17 | Create the preferences toolbar. 18 | ------------------------------------------------------------------------------*/ 19 | 20 | - (void)awakeFromNib { 21 | ports = nil; 22 | serialPort = nil; 23 | 24 | if ([MNPSerialEndpoint isAvailable] 25 | && [MNPSerialEndpoint getSerialPorts:&ports] == noErr 26 | && ports.count > 0) { 27 | [GeneralPrefsViewController preferredSerialPort: &serialPort bitRate: &serialSpeed]; 28 | 29 | // load it up with available serial port names 30 | NSUInteger count = ports.count; 31 | NSUInteger serialPortIndex = 999; 32 | [serialPortPopup removeAllItems]; 33 | for (NSUInteger i = 0; i < count; ++i) { 34 | NSString * port = [ports[i] objectForKey:@"name"]; 35 | [serialPortPopup addItemWithTitle:port]; 36 | port = [ports[i] objectForKey:@"path"]; 37 | if ([port isEqualToString:serialPort]) 38 | serialPortIndex = i; 39 | } 40 | if (serialPortIndex == 999) { 41 | // serialPort isn’t known by IOKit -- maybe user has set their own default 42 | // add name, path couplet to ports 43 | NSMutableArray * newPorts = [NSMutableArray arrayWithArray:ports]; 44 | [newPorts addObject:[NSDictionary dictionaryWithObjectsAndKeys:serialPort, @"name", 45 | serialPort, @"path", 46 | nil]]; 47 | ports = [[NSArray alloc] initWithArray:newPorts]; 48 | [serialPortPopup addItemWithTitle:serialPort]; 49 | serialPortIndex = count; 50 | } 51 | [serialPortPopup selectItemAtIndex:serialPortIndex]; 52 | } 53 | } 54 | 55 | 56 | /*------------------------------------------------------------------------------ 57 | Called when the receiver is about to close. 58 | If the serial port has been changed, tell the app so it can reset the 59 | connection using the new port. 60 | Args: notification 61 | Return: -- 62 | ------------------------------------------------------------------------------*/ 63 | 64 | - (void)windowWillClose:(NSNotification *)notification { 65 | // only need to do anything if we have a serial port 66 | if (serialPort != nil) { 67 | if (![serialPort isEqualToString:[NSUserDefaults.standardUserDefaults stringForKey:kSerialPortPref]]) { 68 | [[NSNotificationCenter defaultCenter] postNotificationName:kSerialPortChanged 69 | object:self 70 | userInfo:nil]; 71 | } 72 | } 73 | } 74 | 75 | 76 | #pragma mark General 77 | /*------------------------------------------------------------------------------ 78 | G e n e r a l P r e f e r e n c e s 79 | ------------------------------------------------------------------------------*/ 80 | 81 | + (int)preferredSerialPort:(NSString *__strong *)outPort bitRate:(NSUInteger *)outRate { 82 | NSArray * ports; 83 | 84 | NSUserDefaults * defaults = NSUserDefaults.standardUserDefaults; 85 | NSString * serialPort = [defaults stringForKey:kSerialPortPref]; 86 | 87 | if (serialPort == nil) { 88 | // there’s no serial port preference -- use the first one available 89 | if ([MNPSerialEndpoint isAvailable] 90 | && [MNPSerialEndpoint getSerialPorts:&ports] == noErr 91 | && ports.count > 0) 92 | { 93 | serialPort = [ports[0] objectForKey:@"path"]; 94 | [defaults setObject:serialPort forKey:kSerialPortPref]; 95 | } 96 | } else if ([serialPort rangeOfCharacterFromSet:[NSCharacterSet decimalDigitCharacterSet]].location == 0) { 97 | // serial port pref is numeric, convert it to the string in ports[that index].path and write it back out 98 | if ([MNPSerialEndpoint isAvailable] 99 | && [MNPSerialEndpoint getSerialPorts: &ports] == noErr 100 | && ports.count > 0) { 101 | serialPort = [ports[serialPort.intValue] objectForKey:@"path"]; 102 | [defaults setObject:serialPort forKey:kSerialPortPref]; 103 | } 104 | } 105 | // else assume we’ve got the device path 106 | *outPort = serialPort; 107 | 108 | unsigned int rate = [defaults integerForKey:kSerialBaudPref]; 109 | if (rate == 0) 110 | rate = 38400; 111 | *outRate = rate; 112 | 113 | return 0; // ought to return error code if appropriate 114 | } 115 | 116 | 117 | /*------------------------------------------------------------------------------ 118 | Keep the serial port default in sync with the UI. 119 | Args: sender the user interface element 120 | Return: -- 121 | ------------------------------------------------------------------------------*/ 122 | 123 | - (IBAction)updateSerialPort:(id)sender { 124 | NSInteger i = [(NSPopUpButton *)sender indexOfSelectedItem]; 125 | if (i >= 0) { 126 | NSString * port = [ports[i] objectForKey:@"path"]; 127 | [NSUserDefaults.standardUserDefaults setObject:port forKey:kSerialPortPref]; 128 | } 129 | } 130 | 131 | @end 132 | -------------------------------------------------------------------------------- /NTX/Preferences/Preferences.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NCXPreferences.h 3 | 4 | Contains: Preferences controller for the NTX app. 5 | 6 | Written by: Newton Research Group, 2013. 7 | */ 8 | 9 | #import 10 | #import "PreferenceKeys.h" 11 | 12 | @interface NTXPreferenceController : NSWindowController 13 | { 14 | // preference panes 15 | IBOutlet NSView * fGeneralView, * fUpdateView; 16 | 17 | // serial prefs 18 | NSArray * ports; 19 | NSString * serialPort; 20 | NSUInteger serialSpeed; 21 | IBOutlet NSPopUpButton * serialPortPopup; 22 | 23 | // software update prefs 24 | IBOutlet NSPopUpButton * frequencyPopUp; 25 | IBOutlet NSButton * autoCheck; 26 | } 27 | 28 | + (NTXPreferenceController *) sharedController; 29 | + (int) preferredSerialPort: (NSString * __strong *) outPort bitRate: (NSUInteger *) outRate; 30 | 31 | - (IBAction) showPreferencesPanel: (id) sender; 32 | - (IBAction) setPrefsView: (id) sender; 33 | 34 | // serial prefs 35 | - (IBAction) updateSerialPort: (id) sender; 36 | 37 | // software update prefs 38 | - (IBAction) updateFrequency: (id) sender; 39 | @end 40 | -------------------------------------------------------------------------------- /NTX/ProjectDocument.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ProjectDocument.h 3 | 4 | Abstract: Project document declarations for the Newton Toolkit. 5 | NTX uses WindowsNTK format -- an NSOF flattened project object. 6 | We can also import MacNTK project files, but we don’t save that format. 7 | Project settings are held in a frame Ref object, projectRef. 8 | The project’s file projectItems are mirrored in an NSMutableDictionary. 9 | This is used to populate the source list sidebar and is 10 | modified whan files are added/moved/deleted. 11 | The master projectRef.projectItems Ref is updated before building the project 12 | or flattening it out to disk. 13 | 14 | The document’s projectRef contains: 15 | projectRef: { 16 | ... 17 | projectItems: { <-- this is the frame we want 18 | selectedItem: nil, // NTX extension -- more accurately, last viewed item 19 | sortOrder: 0, 20 | items: [ 21 | { file: { class:'fileReference, fullPath:"/Users/simon/Projects/newton-toolkit/Test/Demo/Playground.ns" }, 22 | type: 5, 23 | isMainLayout: nil }, 24 | ... 25 | ] 26 | } 27 | } 28 | We transform this to MacOS: 29 | projectItems: [ 30 | "selectedItem": 1, 31 | "sortOrder": 0, 32 | "items": [ 33 | [ "url": NSURL, 34 | "type": 5, 35 | "isMainLayout": NO ], 36 | ... 37 | ] 38 | ] 39 | The NTXSourceListViewController represents this dictionary; displays/updates "items" and updates "selectedItem". 40 | 41 | 42 | To do: save Inspector text as attributed string 43 | save changes to files 44 | save window split positions 45 | collapse window subviews properly 46 | don’t skip a line on up-arrow from bottom line 47 | add views for non-NewtonScript file types: .newtonlayout 48 | comms sometimes dropped for no apparent reason 49 | 50 | Written by: Newton Research Group, 2014. 51 | */ 52 | 53 | #import 54 | #import "NTXEditorView.h" 55 | #import "ProjectTypes.h" 56 | #import "ProjectItem.h" 57 | 58 | /* ----------------------------------------------------------------------------- 59 | Types of file we recognise. 60 | ----------------------------------------------------------------------------- */ 61 | extern NSString * const NTXProjectFileType; 62 | extern NSString * const NTXLayoutFileType; 63 | extern NSString * const NTXScriptFileType; 64 | extern NSString * const NTXStreamFileType; 65 | extern NSString * const NTXCodeFileType; 66 | extern NSString * const NTXPackageFileType; 67 | 68 | 69 | /* ----------------------------------------------------------------------------- 70 | N T X P r o j e c t D o c u m e n t 71 | ----------------------------------------------------------------------------- */ 72 | @class NTXProjectWindowController; 73 | 74 | @interface NTXProjectDocument : NSDocument 75 | { 76 | // the project, as flattened to disk 77 | RefStruct _projectRef; 78 | } 79 | @property(readonly) NSString * storyboardName; 80 | @property(assign) Ref projectRef; 81 | // projectRef.projectItems -- the files in .items[] as NTXProjectItem*s 82 | @property(strong) NSMutableDictionary * projectItems; 83 | // those that are user protos 84 | @property(readonly) NSArray * userProtos; 85 | 86 | // package parts we build, of PackagePart class 87 | @property(strong) NSMutableArray * parts; 88 | 89 | @property(strong) NTXProjectWindowController * windowController; 90 | @property(assign) NSRect windowFrame; 91 | @property(copy) NSArray * windowSplits; 92 | 93 | // File menu actions 94 | - (IBAction)saveAllProjectItems:(id)sender; 95 | 96 | // Build menu actions 97 | - (IBAction)buildPackage:(id)sender; 98 | - (IBAction)downloadPackage:(id)sender; 99 | - (IBAction)exportPackage:(id)sender; 100 | 101 | - (NSURL *)buildPkg; // build package/stream 102 | - (NSData *)buildPackageData:(int)alignment; 103 | @end 104 | -------------------------------------------------------------------------------- /NTX/ProjectItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ProjectItem.h 3 | 4 | Abstract: An NTXProjectItem is the Cocoa representation of an item extracted from projectRef.projectItems.items[]. 5 | It contains enough information to be represented in the source list. 6 | The NTXDocument* field is instantiated lazily, when needed. 7 | 8 | Written by: Newton Research, 2012. 9 | */ 10 | 11 | #import 12 | #import "NTXDocument.h" 13 | 14 | /* ----------------------------------------------------------------------------- 15 | N T X P r o j e c t I t e m 16 | It represents a source file: name and icon. 17 | When selected, it shows an editor for its represented file. 18 | ----------------------------------------------------------------------------- */ 19 | 20 | @interface NTXProjectItem : NSObject 21 | { 22 | NTXDocument * _document; // must be public for NTXProjectSettingsItem 23 | } 24 | @property(strong) NSURL * url; // the URL of the document, stored in the project 25 | @property(assign) NSInteger type; 26 | @property(assign) BOOL isMainLayout; // only valid if type == layout 27 | @property(assign) BOOL isExcluded; 28 | @property(readonly) NTXDocument * document; // the document this item represents; it is lazily created from the URL when the item is selected 29 | // derived for UI 30 | @property(assign) NSString * name; // url.lastPathComponent 31 | @property(readonly) BOOL isLayout; // YES if type == layout 32 | @property(readonly) BOOL isProject; // YES if type == project (or any reserved type) 33 | @property(readonly) NSImage * image; // looked up from type 34 | @property(assign) BOOL isContainer; // looked up from type (using private NTX code) 35 | 36 | - (id)initWithURL:(NSURL *)inURL type:(NSInteger)inType; // by default isMainLayout=NO 37 | - (Ref)build; 38 | @end 39 | 40 | 41 | /* ----------------------------------------------------------------------------- 42 | N T X P r o j e c t S e t t i n g s I t e m 43 | ----------------------------------------------------------------------------- */ 44 | @class NTXProjectDocument; 45 | 46 | @interface NTXProjectSettingsItem : NTXProjectItem 47 | - (id) initWithProject:(NTXProjectDocument *)inProject; 48 | @end 49 | 50 | -------------------------------------------------------------------------------- /NTX/ProjectTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ProjectTypes.h 3 | 4 | Contains: Project type declarations for the Newton Toolkit. 5 | 6 | Written by: Newton Research Group, 2014. 7 | */ 8 | 9 | /* ----------------------------------------------------------------------------- 10 | Part type in outputSettings.partType 11 | 0 Application 12 | 1 Book 13 | 2 Auto 14 | 3 Store 15 | 4 Stream 16 | 5 Custom 17 | ----------------------------------------------------------------------------- */ 18 | enum 19 | { 20 | kOutputApplication, 21 | kOutputBook, 22 | kOutputAutoPart, 23 | kOutputStorePart, 24 | kOutputStreamFile, 25 | kOutputCustomPart 26 | }; 27 | 28 | 29 | /* ----------------------------------------------------------------------------- 30 | File type in projectItems.items.type 31 | 0 Layout file (also used for user-proto and print layout files) 32 | 1 Bitmap file 33 | 2 Metafile file (unused) 34 | 3 Sound file 35 | 4 Book file (deprecated in favor of script items) 36 | 5 Script file (NewtonScript source file) 37 | 6 Package file 38 | 7 Stream file 39 | 8 Native C++ code module file 40 | ----------------------------------------------------------------------------- */ 41 | enum 42 | { 43 | kLayoutFileType, 44 | kBitmapFileType, 45 | kMetafileType, 46 | kSoundFileType, 47 | kBookFileType, 48 | kScriptFileType, 49 | kPackageFileType, 50 | kStreamFileType, 51 | kNativeCodeFileType, 52 | 53 | // additional type codes used by NTX 54 | kResourceFileType, 55 | kGroupType, 56 | kProjectFileType 57 | }; 58 | 59 | 60 | 61 | /* ----------------------------------------------------------------------------- 62 | Layout type in layout file layoutSettings. 63 | ----------------------------------------------------------------------------- */ 64 | enum { 65 | kNormalLayoutType, 66 | kPrintLayoutType, 67 | kUserProtoLayoutType 68 | }; 69 | -------------------------------------------------------------------------------- /NTX/ProjectWindowController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ProjectWindowController.h 3 | 4 | Abstract: The NTXProjectWindowController coordinates display of the document selected in the source list for editing. 5 | 6 | Written by: Newton Research, 2015. 7 | */ 8 | 9 | #import "ToolkitProtocolController.h" 10 | #import "SettingsViewController.h" 11 | #import "SourceListViewController.h" 12 | #import "ContentViewController.h" 13 | #import "InspectorViewController.h" 14 | #import "NRProgressBox.h" 15 | #import "stdioDirector.h" 16 | 17 | 18 | /* ----------------------------------------------------------------------------- 19 | N T X P r o j e c t W i n d o w C o n t r o l l e r 20 | ----------------------------------------------------------------------------- */ 21 | 22 | @interface NTXProjectWindowController : NSWindowController 23 | { 24 | // progress 25 | IBOutlet NRProgressBox * progressBox; 26 | } 27 | @property(nonatomic,assign,getter=isConnected) BOOL connected; 28 | @property(nonatomic,strong) NSImage * connectionIcon; 29 | @property(nonatomic,strong) NSProgress * progress; 30 | @property(nonatomic,assign) NSString * progressText; // updating this property will update the window’s progress box 31 | 32 | // source split view controller (split view containing source list) 33 | @property NTXSourceSplitViewController * sourceSplitController; 34 | @property NTXSourceListViewController * sourceListController; 35 | @property NTXInfoViewController * sourceInfoController; 36 | // document editor content controller 37 | @property NTXContentViewController * contentController; 38 | // content split view controller (split view containing TellUser text) 39 | @property NTXInspectorSplitViewController * inspectorSplitController; 40 | @property NTXInspectorViewController * inspector; 41 | 42 | // sidebar 43 | - (void)sourceSelectionDidChange:(NTXProjectItem *)item; 44 | @end 45 | -------------------------------------------------------------------------------- /NTX/ROMResources.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ROMResources.h 3 | 4 | Contains: Built-in resource declarations. 5 | 6 | Written by: Newton Research Group, 2007. 7 | */ 8 | 9 | #if !defined(__ROMRESOURCES__) 10 | #define __ROMRESOURCES__ 1 11 | 12 | #include "ROMSymbols.h" 13 | 14 | #define DEFFRAME(name, ref) \ 15 | extern Ref * RS##name; 16 | #define DEFFRAME2(name, tag1, value1, tag2, value2) \ 17 | extern Ref * RS##name; 18 | #define DEFFRAME3(name, tag1, value1, tag2, value2, tag3, value3) \ 19 | extern Ref * RS##name; 20 | #define DEFFRAME4(name, tag1, value1, tag2, value2, tag3, value3, tag4, value4) \ 21 | extern Ref * RS##name; 22 | #define DEFFRAME5(name, tag1, value1, tag2, value2, tag3, value3, tag4, value4, tag5, value5) \ 23 | extern Ref * RS##name; 24 | #define DEFFRAME6(name, tag1, value1, tag2, value2, tag3, value3, tag4, value4, tag5, value5, tag6, value6) \ 25 | extern Ref * RS##name; 26 | #define DEFFRAME7(name, tag1, value1, tag2, value2, tag3, value3, tag4, value4, tag5, value5, tag6, value6, tag7, value7) \ 27 | extern Ref * RS##name; 28 | #include "FrameDefs.h" 29 | #undef DEFFRAME 30 | #undef DEFFRAME2 31 | #undef DEFFRAME3 32 | #undef DEFFRAME4 33 | #undef DEFFRAME5 34 | #undef DEFFRAME6 35 | #undef DEFFRAME7 36 | 37 | #endif /* __ROMRESOURCES__ */ 38 | -------------------------------------------------------------------------------- /NTX/ROMSymbols.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ROMSymbols.h 3 | 4 | Contains: Built-in symbol declarations. 5 | 6 | Written by: Newton Research Group. 7 | */ 8 | 9 | #if !defined(__ROMSYMBOLS__) 10 | #define __ROMSYMBOLS__ 1 11 | 12 | #define DEFSYM(name) extern Ref RSYM##name; extern Ref * RSSYM##name; 13 | #define DEFSYM_(name, sym) extern Ref RSYM##name; extern Ref * RSSYM##name; 14 | #include "SymbolDefs.h" 15 | #undef DEFSYM 16 | #undef DEFSYM_ 17 | 18 | #define SYMA(name) RA(SYM##name) 19 | 20 | #endif /* __ROMSYMBOLS__ */ 21 | -------------------------------------------------------------------------------- /NTX/Resources/projectfiletype.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | layout 6 | bitmap 7 | meta 8 | sound 9 | book 10 | script 11 | package 12 | stream 13 | nativecode 14 | resource 15 | group 16 | project 17 | 18 | 19 | -------------------------------------------------------------------------------- /NTX/ScriptViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NTXScriptViewController.h 3 | 4 | Abstract: Interface for NTXScriptViewController class. 5 | 6 | Written by: Newton Research, 2014. 7 | */ 8 | 9 | #import 10 | 11 | extern const CGFloat LargeNumberForText; 12 | 13 | @interface NTXScriptViewController : NSViewController 14 | { 15 | NSTextStorage * _textStorage; 16 | } 17 | @property(weak) NSTextStorage * textStorage; 18 | @property IBOutlet NSTextView * textView; 19 | @end 20 | -------------------------------------------------------------------------------- /NTX/ScriptViewController.mm: -------------------------------------------------------------------------------- 1 | /* 2 | File: NTXScriptViewController.mm 3 | 4 | Abstract: Implementation of NTXScriptViewController class. 5 | 6 | Written by: Newton Research, 2014. 7 | */ 8 | 9 | #import "NTXDocument.h" 10 | #import "ScriptViewController.h" 11 | #import "NTXEditorView.h" 12 | 13 | const CGFloat LargeNumberForText = 1.0e7; // Any larger dimensions and the text could become blurry. 14 | 15 | @implementation NTXScriptViewController 16 | 17 | 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | NTXScriptDocument * document = (NTXScriptDocument *)self.representedObject; 22 | self.textStorage = document.textStorage; 23 | } 24 | 25 | 26 | /* No special action is taken, but subclasses can override this to configure the layout manager more specifically. 27 | */ 28 | - (NSLayoutManager *)layoutManagerForTextStorage:(NSTextStorage *)inStorage 29 | { 30 | NSLayoutManager * layoutManager = [[NSLayoutManager alloc] init]; 31 | [inStorage addLayoutManager:layoutManager]; 32 | return layoutManager; 33 | } 34 | 35 | /* The text container is created with very large dimensions so as not to impede the natural flow of the text by forcing it to wrap. The value of LargeNumberForText was not chosen arbitrarily; any larger and the text would begin to look blurry. It's a limitation of floating point numbers and goes all the way down to Postscript. No other special action is taken in setting up the text container, but subclasses can override this to configure it more specifically. 36 | */ 37 | - (NSTextContainer *)textContainerForLayoutManager:(NSLayoutManager *)layoutManager 38 | { 39 | NSTextContainer * textContainer = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(LargeNumberForText, LargeNumberForText)]; 40 | [textContainer setWidthTracksTextView:NO]; 41 | [textContainer setHeightTracksTextView:NO]; 42 | [layoutManager addTextContainer:textContainer]; 43 | return textContainer; 44 | } 45 | 46 | 47 | - (NSTextStorage *)textStorage 48 | { 49 | return _textStorage; 50 | } 51 | 52 | - (void)setTextStorage:(NSTextStorage *)newStorage 53 | { 54 | if (_textStorage != newStorage) 55 | { 56 | [self.textView.layoutManager replaceTextStorage:newStorage]; 57 | _textStorage = newStorage; 58 | } 59 | } 60 | 61 | 62 | #pragma mark - 63 | 64 | - (void)textViewDidChangeSelection:(NSNotification *)inNotification 65 | { 66 | NSTextView * txView = [inNotification object]; 67 | NSFont * txFont = [NSFont fontWithName:@"Menlo" size:11.0]; 68 | [txView setFont:txFont]; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /NTX/SettingsViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: NTXSettingsViewController.h 3 | 4 | Abstract: Interface for NTXProjectViewController class. 5 | 6 | Written by: Newton Research, 2014. 7 | */ 8 | 9 | #import 10 | 11 | @interface NTXPopupCell : NSPopUpButtonCell 12 | //- (void) drawImageWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; 13 | - (void)drawBorderAndBackgroundWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; 14 | @end 15 | 16 | 17 | @interface NTXSettingsViewController : NSViewController 18 | { 19 | NSArray * settings; 20 | IBOutlet NSOutlineView * outlineView; 21 | NSFont * menuFont; 22 | IBOutlet NSMenu * booleanMenu; 23 | IBOutlet NSMenu * partMenu; 24 | IBOutlet NSMenu * platformMenu; 25 | } 26 | @end 27 | -------------------------------------------------------------------------------- /NTX/SourceListViewController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: SourceListViewController.h 3 | 4 | Abstract: The NTXSourceListViewController controls the source list sidebar view. 5 | The source list is an NSOutlineView representing an NSArray of NTXProjectItem. 6 | 7 | projectItems: [ 8 | "selectedItem": 1, 9 | "sortOrder": 0, 10 | "items": [ 11 | [ "url": NSURL, 12 | "type": 5, 13 | "isMainLayout": NO ], 14 | ... 15 | ] 16 | ] 17 | The NTXSourceListViewController represents this dictionary; displays/updates "items" and updates "selectedItem". 18 | 19 | Written by: Newton Research, 2015. 20 | */ 21 | 22 | #import 23 | #import "ProjectItem.h" 24 | 25 | /* ----------------------------------------------------------------------------- 26 | N T X S o u r c e S p l i t V i e w C o n t r o l l e r 27 | We want to be able to (un)collapse the source list and info views. 28 | ----------------------------------------------------------------------------- */ 29 | @interface NTXSourceSplitViewController : NSSplitViewController 30 | { 31 | IBOutlet NSSplitViewItem * sourceListItem; 32 | IBOutlet NSSplitViewItem * infoItem; 33 | } 34 | - (IBAction)toggleSourceList:(id)sender; 35 | - (IBAction)toggleSourceInfo:(id)sender; 36 | @end 37 | 38 | 39 | /* ----------------------------------------------------------------------------- 40 | N T X S o u r c e L i s t V i e w C o n t r o l l e r 41 | A list of files, like Xcode’s. 42 | ----------------------------------------------------------------------------- */ 43 | 44 | @interface NTXSourceListViewController : NSViewController 45 | { 46 | // outline sidebar view 47 | IBOutlet NSOutlineView * sidebarView; 48 | } 49 | - (void)populateSourceList; 50 | @end 51 | 52 | 53 | /* ----------------------------------------------------------------------------- 54 | N T X I n f o V i e w C o n t r o l l e r 55 | Represents info for the selected source file. 56 | ----------------------------------------------------------------------------- */ 57 | 58 | @interface NTXInfoViewController : NSViewController 59 | @end 60 | -------------------------------------------------------------------------------- /NTX/ToolkitProtocolController.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: ToolkitProtocolController.h 3 | 4 | Abstract: Toolkit Protocol controller interface. 5 | The controller knows about the toolkit protocol. 6 | It translates requests for Newton data to toolkit command events 7 | that it passs to the active session. 8 | Responses are passed up to the UI via the NTXNubProtocol. 9 | 10 | Written by: Newton Research, 2012. 11 | */ 12 | 13 | #import 14 | #import "Endpoint.h" 15 | #import "NewtonKit.h" 16 | 17 | 18 | /* ----------------------------------------------------------------------------- 19 | N T X S t r e a m 20 | Byte-stream interface to the connection. 21 | Comms thread adds received bytes to a buffer. 22 | ToolkitProtocol thread (blocking) reads buffer to build events. 23 | ToolkitProtocol thread sends by passing buffer directly to comms thread. 24 | ----------------------------------------------------------------------------- */ 25 | 26 | @interface NTXStream : NSObject 27 | - (void)open; 28 | - (void)close; 29 | - (NewtonErr)read:(char *)inBuf length:(NSUInteger)inLength; // blocking 30 | - (NewtonErr)send:(char *)inBuf length:(NSUInteger)inLength; // blocking; but will never block in practice 31 | // NTXStreamProtocol 32 | - (void)addData:(NSData *)inData; 33 | @end 34 | 35 | 36 | /* ----------------------------------------------------------------------------- 37 | N T X N u b F e e d b a c k 38 | Protocol for reporting received objects. 39 | ----------------------------------------------------------------------------- */ 40 | @protocol NTXNubFeedback 41 | @property(nonatomic,readonly) NSProgress * progress; 42 | @property(nonatomic,assign,getter=isConnected) BOOL connected; 43 | - (void)receivedText:(NSString *)inText; 44 | - (void)receivedObject:(RefArg)inObject; 45 | - (void)receivedScreenshot:(RefArg)inData; 46 | @end 47 | 48 | /* ----------------------------------------------------------------------------- 49 | N T X T o o l k i t P r o t o c o l C o n t r o l l e r 50 | ----------------------------------------------------------------------------- */ 51 | 52 | @interface NTXToolkitProtocolController : NSObject 53 | // state 54 | @property(assign,readonly) BOOL isTethered; // we are tethered between receiving kTConnect -- kTTerminate from Newton 55 | @property(assign) NSUInteger breakLoopDepth; 56 | 57 | // control of the only channel available 58 | + (BOOL)isAvailable; 59 | + (NTXToolkitProtocolController *)bind:(id)inDelegate; 60 | + (void)unbind:(id)inDelegate; 61 | 62 | // Commands 63 | - (void)evaluate:(NSString *)inScript; 64 | - (void)installPackage:(NSURL *)inPackage; 65 | - (void)takeScreenshot; 66 | - (void)disconnect; 67 | 68 | @end 69 | 70 | 71 | // There is one global NTXToolkitProtocolController 72 | extern NTXToolkitProtocolController * gNTXNub; 73 | 74 | extern NSString * const kNubStatusDidChangeNotification; 75 | -------------------------------------------------------------------------------- /NTX/Utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Utilities.h 3 | 4 | Contains: Utility functions for the NTX app. 5 | 6 | Written by: Newton Research Group, 2005. 7 | */ 8 | 9 | #import 10 | #include "NewtonKit.h" 11 | 12 | 13 | extern Ref SetBoundsRect(RefArg ioFrame, const Rect * inBounds); 14 | extern Ref ToObject(const Rect * inBounds); 15 | 16 | extern NSString * MakeNSString(RefArg inStr); 17 | extern Ref MakeString(NSString * inStr); 18 | extern NSDate * MakeNSDate(RefArg inDate); 19 | extern Ref MakeDate(NSDate * inDate); 20 | 21 | extern BOOL IsInternalStore(RefArg inStore); 22 | 23 | extern Ref BuildPath(NSString * inPath); 24 | extern Ref BuildFileList(NSString * inPath, NSArray * inFilter); 25 | extern Ref BuildFileInfo(NSString * inPath, NSString * inFile); 26 | 27 | extern NSString * GetPackageDetails(NSString * inPath, unsigned int * outSize); 28 | 29 | extern NSURL * ApplicationSupportFolder(void); 30 | extern NSURL * ApplicationSupportFile(NSString * inFilename); 31 | extern NSURL * ApplicationLogFile(void); 32 | -------------------------------------------------------------------------------- /NTX/main.m: -------------------------------------------------------------------------------- 1 | 2 | #import "AppDelegate.h" 3 | 4 | #import 5 | #import 6 | #import 7 | 8 | #import 9 | #import 10 | 11 | io_connect_t gRootPort; 12 | 13 | void callback(void * x, io_service_t y, natural_t messageType, void * messageArg) 14 | { 15 | switch (messageType) 16 | { 17 | case kIOMessageSystemWillSleep: 18 | [(NTXController *)[NSApp delegate] applicationWillSleep]; 19 | IOAllowPowerChange(gRootPort, (long) messageArg); 20 | break; 21 | case kIOMessageCanSystemSleep: 22 | if ([(NTXController *)[NSApp delegate] applicationCanSleep]) 23 | IOAllowPowerChange(gRootPort, (long) messageArg); 24 | else 25 | IOCancelPowerChange(gRootPort, (long) messageArg); 26 | break; 27 | /* case kIOMessageSystemHasPoweredOn: 28 | printf("Just had a nice snooze\n"); 29 | break; */ 30 | } 31 | } 32 | 33 | 34 | 35 | int main(int argc, const char * argv[]) 36 | { 37 | IONotificationPortRef notify; 38 | io_object_t anIterator; 39 | 40 | gRootPort = IORegisterForSystemPower(0, ¬ify, callback, &anIterator); 41 | CFRunLoopAddSource(CFRunLoopGetCurrent(), 42 | IONotificationPortGetRunLoopSource(notify), 43 | kCFRunLoopDefaultMode); 44 | 45 | return NSApplicationMain(argc, argv); 46 | } 47 | -------------------------------------------------------------------------------- /NTX/stdioDirector.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: stdioDirector.h 3 | 4 | Contains: Declarations for class that redirects stdout and stderr. 5 | 6 | Written by: Newton Research Group, 2008. 7 | Shamelessly pinched from the Handbrake project. 8 | */ 9 | 10 | #import 11 | 12 | /*------------------------------------------------------------------------------ 13 | This class is used to redirect @c stdout and @c stderr outputs. It is never 14 | created directly; @c redirect_stdout and @c redirect_stderr class methods 15 | should be use instead. 16 | 17 | @note Redirection is done by replacing @c _write functions for @c stdout and 18 | @c stderr streams. Because of this messages written by NSLog(), for 19 | example are not redirected. I consider this a good thing, but if more 20 | universal redirecting is needed, it can be done at file descriptor 21 | level. 22 | ------------------------------------------------------------------------------*/ 23 | 24 | @interface NTXOutputRedirect : NSObject 25 | { 26 | id listener; 27 | // Selector that is called on listener to forward the output. 28 | SEL forwardingSelector; 29 | 30 | // Output stream (@c stdout or @c stderr) redirected by this object. 31 | FILE * stream; 32 | 33 | // Pointer to old write function for the stream. 34 | int (*oldWriteFunc)(void *, const char *, int); 35 | } 36 | 37 | + (id) redirect_stdout; 38 | + (id) redirect_stderr; 39 | 40 | - (void) setListener: (id) inListener; 41 | 42 | @end 43 | 44 | /* 45 | Here is another technique to redirect stderr, but it is done at lower level 46 | which also redirects NSLog() and other writes that are done directly to the 47 | file descriptor. This method is not used by HBOutputRedirect, but should 48 | be easy to implement if needed. Code is untested, but this is shows basic 49 | idea for future reference. 50 | 51 | // Create a pipe 52 | NSPipe *pipe = [[NSPipe alloc] init]; 53 | 54 | // Connect stderr to the writing end of the pipe 55 | dup2([[pipe fileHandleForWriting] fileDescriptor], STDERR_FILENO); 56 | 57 | // Get reading end of the pipe, we can use this to read stderr 58 | NSFileHandle *fh = [pipe fileHandleForReading]; 59 | */ 60 | -------------------------------------------------------------------------------- /NTX/stdioDirector.m: -------------------------------------------------------------------------------- 1 | /* 2 | File: stdioDirector.m 3 | 4 | Contains: Implementation of class that redirects stdout and stderr. 5 | 6 | Written by: Newton Research Group, 2008. 7 | Shamelessly pinched from the Handbrake project. 8 | */ 9 | 10 | #import "stdioDirector.h" 11 | 12 | /// Global pointer to NTXOutputRedirect object that manages redirects for stdout. 13 | static NTXOutputRedirect * g_stdoutDirector = nil; 14 | 15 | /// Global pointer to NTXOutputRedirect object that manages redirects for stderr. 16 | static NTXOutputRedirect * g_stderrDirector = nil; 17 | 18 | @interface NTXOutputRedirect (Private) 19 | - (id) initWithStream: (FILE *) aStream selector: (SEL) aSelector; 20 | - (void) startRedirect; 21 | - (void) stopRedirect; 22 | - (void) forwardOutput: (NSData *) data; 23 | @end 24 | 25 | /** 26 | * Function that replaces stdout->_write and forwards stdout to g_stdoutDirector. 27 | */ 28 | int stdoutwrite(void * inFD, const char * buffer, int size) 29 | { 30 | @autoreleasepool 31 | { 32 | NSData * data = [[NSData alloc] initWithBytes: buffer length: size]; 33 | [g_stdoutDirector performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO]; 34 | } 35 | return size; 36 | } 37 | 38 | /** 39 | * Function that replaces stderr->_write and forwards stderr to g_stderrDirector. 40 | */ 41 | int stderrwrite(void * inFD, const char * buffer, int size) 42 | { 43 | @autoreleasepool 44 | { 45 | NSData * data = [[NSData alloc] initWithBytes:buffer length:size]; 46 | [g_stderrDirector performSelectorOnMainThread:@selector(forwardOutput:) withObject:data waitUntilDone:NO]; 47 | } 48 | return size; 49 | } 50 | 51 | @implementation NTXOutputRedirect 52 | 53 | /** 54 | * Returns NTXOutputRedirect object used to redirect stdout. 55 | */ 56 | + (id) redirect_stdout 57 | { 58 | if (!g_stdoutDirector) 59 | g_stdoutDirector = [[NTXOutputRedirect alloc] initWithStream:stdout selector:@selector(insertText:)]; 60 | 61 | return g_stdoutDirector; 62 | } 63 | 64 | /** 65 | * Returns NTXOutputRedirect object used to redirect stderr. 66 | */ 67 | + (id) redirect_stderr 68 | { 69 | if (!g_stderrDirector) 70 | g_stderrDirector = [[NTXOutputRedirect alloc] initWithStream:stderr selector:@selector(insertText:)]; 71 | 72 | return g_stderrDirector; 73 | } 74 | 75 | 76 | - (void) setListener: (id) inListener 77 | { 78 | if (inListener) 79 | { 80 | listener = inListener; 81 | [self startRedirect]; 82 | } 83 | else 84 | { 85 | [self stopRedirect]; 86 | 87 | if (self == g_stdoutDirector) 88 | g_stdoutDirector = NULL; 89 | else if (self == g_stderrDirector) 90 | g_stderrDirector = NULL; 91 | } 92 | } 93 | 94 | @end 95 | 96 | @implementation NTXOutputRedirect (Private) 97 | 98 | /** 99 | * Private constructor which should not be called from outside. This is used to 100 | * initialize the class at @c stdoutRedirect and @c stderrRedirect. 101 | * 102 | * @param aStream Stream that wil be redirected (stdout or stderr). 103 | * @param aSelector Selector that will be called in listeners to redirect the stream. 104 | * 105 | * @return New NTXOutputRedirect object. 106 | */ 107 | - (id)initWithStream:(FILE *)aStream selector:(SEL)aSelector 108 | { 109 | if (self = [super init]) 110 | { 111 | listener = nil; 112 | forwardingSelector = aSelector; 113 | stream = aStream; 114 | oldWriteFunc = NULL; 115 | } 116 | return self; 117 | } 118 | 119 | /** 120 | * Starts redirecting the stream by redirecting its output to function 121 | * @c stdoutwrite() or @c stderrwrite(). Old _write function is stored to 122 | * @c oldWriteFunc so it can be restored. 123 | */ 124 | - (void)startRedirect 125 | { 126 | if (!oldWriteFunc) 127 | { 128 | oldWriteFunc = stream->_write; 129 | stream->_write = stream == stdout ? stdoutwrite : stderrwrite; 130 | } 131 | } 132 | 133 | /** 134 | * Stops redirecting of the stream by returning the stream's _write function 135 | * to original. 136 | */ 137 | - (void)stopRedirect 138 | { 139 | if (oldWriteFunc) 140 | { 141 | stream->_write = oldWriteFunc; 142 | oldWriteFunc = NULL; 143 | } 144 | } 145 | 146 | /** 147 | * Called from @c stdoutwrite() and @c stderrwrite() to forward the output to 148 | * listeners. 149 | */ 150 | - (void)forwardOutput:(NSData *)data 151 | { 152 | NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; 153 | [listener performSelector:forwardingSelector withObject:string]; 154 | } 155 | 156 | @end 157 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | Newton Toolkit for Mac OS X (NTX) 2 | ==== 3 | The NTX application is intended to be a replacement for NTK. 4 | There is still a lot of work to do! However, you can already use it as a NewtonScript playground. 5 | Try executing the scripts in the Demos folder to get a flavour of what’s possible. (Select text, press fn-return to execute.) 6 | 7 | 8 | BUILDING 9 | ---- 10 | Open the NTX Xcode 8 project. It builds for macOS Sierra, 64-bit. 11 | 12 | 13 | DEPENDENCIES 14 | ---- 15 | The interesting Newton stuff is done by the [NTK.framework](https://github.com/newtonresearch/newton-framework) 16 | which you will need to check out separately if you want to tinker with it. 17 | Update the reference from the NTX project to point to your copy of the NTK.framework. 18 | If modifying the framework, life is a lot easier once you create an Xcode workspace including the two projects 19 | so that changes to the framework are picked up automatically when you build the app. 20 | I don’t know how to express that dependency in GitHub. 21 | 22 | 23 | File types 24 | ---- 25 | Files must have the appropriate extension to be recognised by NTX. 26 | 27 | File type | Extension 28 | --- | --- 29 | Project | .newtonproj 30 | NewtonScript | .newtonscript 31 | Layout | .newtonlayout 32 | Stream | .newtonstream 33 | Package | .newtonpkg 34 | --------------------------------------------------------------------------------