2.x: Newt now supports two _package slots for NewtPack:
- _ImportTable
- array -- normally value of UnitsImport (which is created by
:DeclareUnit). set this for an application that uses (imports) objects from
other (exporting) packages, e.g., MooUser. NewtPack uses this information to
save appropriate object references; if _ImportTable is missing or nil,
NewtPack copies the entire object into the new package (just like older
NewtPack) rather than create a reference (to the original object). (Note: if
_ImportTable is [], NewtPack generates an import table as it discovers
imported objects -- this might be useful if you access constant objects via
a a regular Newt library, e.g., created in NTK from a developer's stream
file; you know the names of the objects from documentation, but not the unit
information (like unit name or object mapping)).
- _ExportTable
- array -- normally value of :DefineUnit.
set this for an autopart (or application) that exports objects for use by
other (importing) packages, e.g., MooUnit. If this is in an autopart, you do
not need to include partData since NewtPack saves the object references
within the export table.
2.x: Newt provides the following new development-time methods (see moounit.txt for further documentation):
- :DeclareUnit(unitName, majorVersion, minorVersion, memberIndexes, pkgStr)
- this declares unit information for both import and export. same as NTK
except unitName=nil to reset (erase) all import info; pkgStr (name of the
package containing the exported units) must be provided for UnitReference to
work. this adds an entry to the "UnitsImport" array; you can import multiple
units into a single package.
- :UnitReference(unitName, memberName) //or :UR(...)
- returns (imported) object reference (assumes DeclareUnit ran after exported package is installed).
in Newt, these would typically occur to initialize slot values at build-time (not used inside run-time methods)
- :DefineUnit(unitName, members)
- sets up export array. value typically assigned to _ExportTable.
If your package has multiple parts, each can have its own export.