Return base namespace if this namespace is an overlay.
Return choice API for given spec. Callers should prefer the slot over the type since the slot determines maybe and multi-choice flags. Raise exception if Spec.isChoice is false.
Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:
this < that => <0
this == that => 0
this > that => >0
This method may also be accessed via the <
<=
<=>
>=
and >
shortcut operators. If not overridden the default
implementation compares the toStr
representations. Also see docLang.
Examples:
3.compare(8) => -1
8.compare(3) => 1
8.compare(8) => 0
3 <=> 8 => -1 // shortcut for 3.compare(8)
Compile a Xeto data file into an in-memory value. All dependencies are resolved against this namespace. Raise exception if there are any syntax or semantic errors. If the file contains a scalar value or one dict, then it is returned as the value. If the file contains two or more dicts then return a Dict[] of the instances.
Options
Optional
opts: DictConvenience for compileData but always returns data as list of dicts. If the data is not a Dict nor list of Dicts, then raise an exception.
Optional
opts: DictBase64 digest for this namespace based on its lib versions
Load a list of versions asynchronously and return result of either a XetoLib or Err (is error on server)
Load given version synchronously. If the libary can not be loaed then raise exception to the caller of this method.
Optional
out: OutStreamIterate all the instances in libs In remote namespace this only iterates loaded libs.
Iterate all the top-level types in libs. In remote namespace this only iterates loaded libs.
Compare this object to the specified for equality. This
method may be accessed via the == and != shortcut operators.
If not overridden the default implementation compares for
reference equality using the === operator. If this method
is overridden, then hash() must also be overridden such that
any two objects which return true for equals() must return
the same value for hash(). This method must accept null
and
return false.
Return if the given instance fits the spec via structural typing. Options:
graph
: marker to also check graph of references such as
required pointsignoreRefs
: marker to ignore if refs resolve to valid targethaystack
: marker tag to use Haystack level data fidelityOptional
opts: DictOptional
checked: booleanReturn a unique hashcode for this object. If a class overrides hash() then it must ensure if equals() returns true for any two objects then they have same hash code.
Return if this namespace contains the given lib name. This is true if version will return non-null regardless of libStatus.
Create default instance for the given spec. Raise exception if spec is abstract.
Options:
graph
: marker tag to instantiate graph of recs (will
auto-generate ids)abstract
: marker to supress error if spec is abstractid
: Ref tag to include in new instancehaystack
: marker tag to use Haystack level data fidelityReturn true if the every library in this namespace has been
loaded (successfully or unsuccessfully). This method
returns false is any libs have a load status of notLoaded
.
Many operations require a namespace to be fully loaded.
Return true if this an overlay namespace overlaid on base.
Get the given library by name synchronously. If this is a Java environment, then the library will be compiled on its first access. If the library cannot be compiled then an exception is always raised regardless of checked flag. If this is a JS environment then the library must already have been loaded, otherwise raise exception if checked is true. Use libAsync to load a library in JS environment.
Optional
checked: booleanException for a library with lib status of err
, or null
otherwise. Raise exception is library not included in this
namespace.
Get or load list of libraries asynchronously by the given dotted names. This method automatically also loads the dependency chain. Once loaded then invoke callback with libraries or err. If a lib cannot be loaded then it is excluded from the callback list (so its possible the results list is not the same size as the names list).
List all libraries. On first call, this will force all libraries to be loaded synchronously. Any libs which cannot be compiled will log an error and be excluded from this list. If isAllLoaded is true then this call can also be in JS environments, otherwise you must use the libsAllAsync call to fully load all libraries into memory.
Load all libraries asynchronosly. Once this operation
completes successfully the isAllLoaded
method will return true
and the libs method
may be used even in JS environments. Note that an error is
reported only if the entire load failed. Individual libs
which cannot be loaded will logged on server, and be
excluded from the final libs list.
Return load status for the given library name:
notLoaded
: library is included but has not been loaded yetok
: library is included and loaded successfullyerr
: library is included but could not be loadedOptional
checked: booleanGet an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Return a string representation of this object.
Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:
a->x a.trap("x", null)
a->x() a.trap("x", null)
a->x = b a.trap("x", [b])
a->x(b) a.trap("x", [b])
a->x(b, c) a.trap("x", [b, c])
The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.
Get or load type by the given qualified name. If the type's lib is not loaded, it is loaded synchronously.
Optional
checked: booleanOptional
checked: booleanLookup the version info for a library name in this namespace.
Optional
checked: booleanList the library name and versions in this namespace.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Write instance data in Xeto text format to an output stream. If the value is a Dict[], then it is flattened in the output. Use compileData to read data from Xeto text format.
Lookup the extended meta for the given spec qname. This is
a merge of the spec's own meta along with any instance dicts
in the namespace with a local id of "xmeta-{lib}-{spec}".
Only libs currently loaded are considered for the result.
If the spec is not defined then return null or raise an
exception based on checked flag. For example to register
extended meta data on the ph::Site
spec you would create an
instance dict with the local name of xmeta-ph-Site
.
Optional
checked: booleanLookup the extended meta for an enum spec. This returns a SpecEnum instance with resolved extended meta for all the enum items via a merge of all libs with instances named "xmeta-{lib}-{spec}-enum".
Optional
checked: booleanStatic
echoWrite x.toStr
to standard output followed by newline. If x
is null then print "null". If no argument is provided then
print an empty line.
Optional
x: JsObjStatic
make
LibNamespace implementation base class