type

Spec

@Js
const mixin Spec : Dict

Xeto data specification.

Spec dict representation:

  • id: Ref "lib:{qname}"
  • spec: Ref "sys::Spec"
  • base: Ref to base type (types only)
  • type: Ref to slot type (slots only)
  • effective meta

methods

base

Base spec from which this spec directly inherits its meta and slots.

eachInherited

Call the given function on this spec and every spec that it inherits from up to sys::Obj.

enum

Return enum item meta.

func

Return function specific APIs.

globals

Get all the effective globals including inherited.

globalsOwn

Globals declared by this spec.

id

Identifier for a spec is always its qualified name

isChoice

Return if this is a spec that inherits from sys::Choice.

isEnum

Is the base sys::Enum

isFunc

Return if this a function spec

isGlobal

Is this a global slot under a parent

isMaybe

Does meta have maybe tag.

isMember

Is this a slot or global under a parent

isMixin

Is this a top level mixin spec

isSlot

Is this a slot under a parent

isType

Is this a top level type spec

isa

Return if this spec inherits from that from a nominal type perspective.

lib

Parent library for spec

member

Convenience for members.get.

members

Get a map with all the inherited slots and globals.

membersOwn

Get a map with all the declared slots and globals.

meta

Get my effective meta; this does not include synthesized tags like spec

metaOwn

Get my own declared meta-data

name

Return simple name scoped by lib or parent.

parent

Parent spec which contains this spec definition and scopes name.

qname

Return fully qualified name of this spec

slot

Convenience for slots.get.

slotOwn

Convenience for slotsOwn.get.

slots

Get the effective inherited children slots.

slotsOwn

Get the declared children slots.

type

Type of this spec.

Slot Details

base

abstract Spec? base()

Base spec from which this spec directly inherits its meta and slots. Returns null if this is sys::Obj itself.

eachInherited

abstract Void eachInherited(|Spec| f)

Call the given function on this spec and every spec that it inherits from up to sys::Obj. Any sys::And compound types are iterated, but not sys::Or types. Note it is possible that the given function may be called on the same spec twice.

enum

abstract SpecEnum enum()

Return enum item meta. Raise exception if isEnum is false.

func

abstract SpecFunc func()

Return function specific APIs. Raise exception if isFunc is false.

globals

abstract SpecMap globals()

Get all the effective globals including inherited. Note that some of the globals may be hidden by slots.

globalsOwn

abstract SpecMap globalsOwn()

Globals declared by this spec.

id

abstract override Ref id()

Identifier for a spec is always its qualified name

isChoice

abstract Bool isChoice()

Return if this is a spec that inherits from sys::Choice. If this spec inherits from a choice via a And/Or type then return false. See Namespace.choice to access SpecChoice API.

isEnum

abstract Bool isEnum()

Is the base sys::Enum

isFunc

abstract Bool isFunc()

Return if this a function spec

isGlobal

abstract Bool isGlobal()

Is this a global slot under a parent

isMaybe

abstract Bool isMaybe()

Does meta have maybe tag. Maybe slots are optional

isMember

abstract Bool isMember()

Is this a slot or global under a parent

isMixin

abstract Bool isMixin()

Is this a top level mixin spec

isSlot

abstract Bool isSlot()

Is this a slot under a parent

isType

abstract Bool isType()

Is this a top level type spec

isa

abstract Bool isa(Spec that)

Return if this spec inherits from that from a nominal type perspective. Nonimal typing matches any of the following conditions:

  • if that matches one of this inherited specs via base
  • if this is maybe and that is None
  • if this is And and that matches any this.ofs
  • if this is Or and that matches all this.ofs (common base)
  • if that is Or and this matches any of that.ofs

lib

abstract Lib lib()

Parent library for spec

member

abstract Spec? member(Str name, Bool checked := true)

Convenience for members.get.

members

abstract SpecMap members()

Get a map with all the inherited slots and globals.

membersOwn

abstract SpecMap membersOwn()

Get a map with all the declared slots and globals.

meta

abstract Dict meta()

Get my effective meta; this does not include synthesized tags like spec

metaOwn

abstract Dict metaOwn()

Get my own declared meta-data

name

abstract Str name()

Return simple name scoped by lib or parent.

parent

abstract Spec? parent()

Parent spec which contains this spec definition and scopes name. Returns null for top level specs in the library.

qname

abstract Str qname()

Return fully qualified name of this spec:

  • Type specs will return "foo.bar::Baz"
  • Global slots will return "foo.bar::baz"
  • Type slots will return "foo.bar::Baz.qux"
  • Derived specs will return "derived123::{name}"

slot

abstract Spec? slot(Str name, Bool checked := true)

Convenience for slots.get.

slotOwn

abstract Spec? slotOwn(Str name, Bool checked := true)

Convenience for slotsOwn.get.

slots

abstract SpecMap slots()

Get the effective inherited children slots.

slotsOwn

abstract SpecMap slotsOwn()

Get the declared children slots.

type

abstract Spec type()

Type of this spec. If this spec is a top level type then return self.