Next: 4.10.13 nxo_array Up: 4.10 Classes Previous: 4.10.11 nxn Contents Index
Subsections

- 4.10.12.1 API

##
4.10.12 nxo

The nxo class is the basis for the Onyx type system. nxo objects can be any of the following types, as determined by the cw_nxot_t type:

NXOT_NO:
  nxo_no
NXOT_ARRAY:
  nxo_array
NXOT_BOOLEAN:
  nxo_boolean
NXOT_CLASS:
  nxo_class
NXOT_CONDITION:
  nxo_condition
NXOT_DICT:
  nxo_dict
NXOT_FILE:
  nxo_file
NXOT_FINO:
  nxo_fino
NXOT_HANDLE:
  nxo_handle
NXOT_INSTANCE:
  nxo_instance
NXOT_INTEGER:
  nxo_integer
NXOT_MARK:
  nxo_mark
NXOT_MUTEX:
  nxo_mutex
NXOT_NAME:
  nxo_name
NXOT_NULL:
  nxo_null
NXOT_OPERATOR:
  nxo_operator
NXOT_PMARK:
  nxo_pmark
NXOT_REAL:
  nxo_real
NXOT_STACK:
  nxo_stack
NXOT_STRING:
  nxo_string
NXOT_THREAD:
  nxo_thread

Due to limitations of the C programming language, it is the responsibility of the application to do type checking to assure that an incompatible nxo object is not passed to a type-specific function. For example, passing a file nxo to nxo_string_get() is prohibited, and will result in undefined behaviour (including crashes).

Composite objects contain a reference to an nxoe object. For the most part, the application does not need to be aware of this. The only exception is when writing extensions with the handle type. Handle objects need to be able to iterate over the objects they reference internally, and return nxoe references to the garbage collector.

The following functions are applicable to all types of nxo objects.

### 4.10.12.1 API

int32_t nxo_compare(const cw_nxo_t *a_a, const cw_nxo_t *a_b):

  Input(s):
    a_a:
      Pointer to an nxo.
    a_b:
      Pointer to an nxo.
  Output(s):
    retval:
      -1:
        For types which it is meaningful (integer, string), a_a is less than a_b.
      0:
        a_a and a_b are equal.
      1:
        For types which it is meaningful (integer, string), a_a is greater than a_b.
      2:
        Incompatible types, or not the same composite object.
  Exception(s):
    None.
  Description:
    Compare a_a and a_b.

void nxo_dup(cw_nxo_t *a_to, cw_nxo_t *a_from):

  Input(s):
    a_to:
      Pointer to an nxo.
    a_from:
      Pointer to an nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Duplicate a_from to a_to. This does not do a copy of composite objects; rather it creates a new reference to the value of a composite object.

cw_nxot_t nxo_type_get(const cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to an nxo.
  Output(s):
    retval:
      NXOT_NO:
        nxo_no
      NXOT_ARRAY:
        nxo_array
      NXOT_BOOLEAN:
        nxo_boolean
      NXOT_CLASS:
        nxo_class
      NXOT_CONDITION:
        nxo_condition
      NXOT_DICT:
        nxo_dict
      NXOT_FILE:
        nxo_file
      NXOT_FINO:
        nxo_fino
      NXOT_HANDLE:
        nxo_handle
      NXOT_INSTANCE:
        nxo_instance
      NXOT_INTEGER:
        nxo_integer
      NXOT_MARK:
        nxo_mark
      NXOT_MUTEX:
        nxo_mutex
      NXOT_NAME:
        nxo_name
      NXOT_NULL:
        nxo_null
      NXOT_OPERATOR:
        nxo_operator
      NXOT_PMARK:
        nxo_pmark
      NXOT_REAL:
        nxo_real
      NXOT_STACK:
        nxo_stack
      NXOT_STRING:
        nxo_string
      NXOT_THREAD:
        nxo_thread
  Exception(s):
    None.
  Description:
    Return the type of a_nxo.

cw_nxoe_t * nxo_nxoe_get(const cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to an nxo.
  Output(s):
    retval:
      Pointer to the nxoe associated with a_nxo, or NULL if a_nxo is not composite.
  Exception(s):
    None.
  Description:
    Return a pointer to the nxoe associated with a_nxo.

bool nxo_ilocked():

  Input(s):
    a_nxo:
      Pointer to an array, dict, file, stack, or string nxo.
  Output(s):
    retval:
      false:
        a_nxo is not implicitly locked.
      true:
        a_nxo is implicitly locked.
  Exception(s):
    None.
  Description:
    For array, dict, file, stack, or string nxos, return whether a_nxo is implicitly locked.

cw_nxoa_t nxo_attr_get(const cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to an nxo.
  Output(s):
    retval:
      NXOA_LITERAL:
        a_nxo is literal.
      NXOA_EXECUTABLE:
        a_nxo is executable.
  Exception(s):
    None.
  Description:
    Return the attribute for a_nxo.

void nxo_attr_set(cw_nxo_t *a_nxo, cw_nxoa_t a_attr):

  Input(s):
    a_nxo:
      Pointer to an nxo.
    a_attr:
      Value of attribute to set for a_nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set the attribute for a_nxo to a_attr.

Next: 4.10.13 nxo_array Up: 4.10 Classes Previous: 4.10.11 nxn Contents Index