4.10.35 nxo_thread
Keywords: onyx

Next: 4.10.36 ql Up: 4.10 Classes Previous: 4.10.34 nxo_string Contents Index
Subsections

- 4.10.35.1 API

##
4.10.35 nxo_thread

The nxo_thread class is a subclass of the nxo class.

The threadp class is a helper class that contains scanner position information. The threadp state is used when recording syntax errors.

### 4.10.35.1 API

void nxo_threadp_new(cw_nxo_threadp_t *a_threadp):

  Input(s):
    a_threadp:
      Pointer to space for a threadp.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Constructor.

void nxo_threadp_delete(cw_nxo_threadp_t *a_threadp, cw_nxo_t *a_thread):

  Input(s):
    a_threadp:
      Pointer to a threadp.
    a_thread:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Destructor.

void nxo_threadp_origin_get(const cw_nxo_threadp_t *a_threadp, const char **r_origin, uint32_t *r_olen):

  Input(s):
    a_threadp:
      Pointer to space for a threadp.
    r_origin:
      Pointer to a string pointer.
    r_olen:
      Pointer to an unsigned integer.
  Output(s):
    *r_origin:
      A pointer to a string that represents the origin of a_nxo.
    *r_olen:
      The length of the string pointed to by *r_origin.
  Exception(s):
    None.
  Description:
    Retrieve the origin.

void nxo_threadp_origin_set(cw_nxo_threadp_t *a_threadp, const char *a_origin, uint32_t a_olen):

  Input(s):
    a_threadp:
      Pointer to space for a threadp.
    a_origin:
      Pointer to a string that represents the origin of a_nxo.
    a_olen:
      The length of the string pointed to bya_origin.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set the origin. This function does not make a copy of a_origin, so the string must exist for the entire time that a_threadp retains a reference to the string.

void nxo_threadp_position_get(const cw_nxo_threadp_t *a_threadp, uint32_t *r_line, uint32_t *r_column):

  Input(s):
    a_threadp:
      Pointer to space for a threadp.
    r_line:
      Pointer to a location to store a line number.
    r_column:
      Pointer to a location to store a column number.
  Output(s):
    *r_line:
      Line number.
    *r_column:
      Column number.
  Exception(s):
    None.
  Description:
    Retrieve the line number and column number.

void nxo_threadp_position_set(cw_nxo_threadp_t *a_threadp, uint32_t a_line, uint32_t a_column):

  Input(s):
    a_threadp:
      Pointer to space for a threadp.
    a_line:
      Line number.
    a_column:
      Column number.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set the line number and column number.

void nxo_thread_new(cw_nxo_t *a_nxo, cw_nx_t *a_nx):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_nx:
      Pointer to an nx.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Constructor.

void nxo_thread_start(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    Application dependent.
  Description:
    Start a thread running by calling the start operator such that the top object on ostack will be executed.

void nxo_thread_exit(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Terminate the thread. This has the same effect as a detached thread exiting. Calling this function may is necessary (depending on the application) to allow the thread to be garbage collected, much the same way as the detach and join operators do.

void nxo_thread_thread(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Create a new thread. The new thread calls nxo_thread_start().

void nxo_thread_detach(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Detach a_nxo so that when it exits it can be garbage collected.

void nxo_thread_join(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Wait for a_nxo to exit.

cw_nxo_threadts_t nxo_thread_state(const cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      The current scanner state of a_nxo.
      THREADTS_START:
        Start state.
      THREADTS_COMMENT:
        '%' seen, but no line break yet.
      THREADTS_INTEGER:
        Scanning an integer.
      THREADTS_INTEGER_RADIX:
        Scanning a radix integer.
      THREADTS_REAL_FRAC:
        Scanning the fractional portion of a real.
      THREADTS_REAL_EXP:
        Scanning the exponent porttion of a real.
      THREADTS_STRING:
        Scanning a string.
      THREADTS_STRING_NEWLINE_CONT:
        '\r' seen in a string.
      THREADTS_STRING_PROT_CONT:
        '\\' seen in a string.
      THREADTS_STRING_CRLF_CONT:
        '\' '\r' seen in a string.
      THREADTS_STRING_CTRL_CONT:
        '\' 'c' seen in a string.
      THREADTS_STRING_HEX_CONT:
        '\' 'x' seen in a string.
      THREADTS_STRING_HEX_FINISH:
        First hex digit of a ``\xDD'' string escape sequence seen.
      THREADTS_NAME_START:
        '!', '$', or '~' seen.
      THREADTS_NAME:
        Scanning a name.
  Exception(s):
    None.
  Description:
    Return the current scanner state. In general this is only useful when implementing an interactive environment for which the prompt behaves differently depending on what state the scanner is in. For example the interactive onyx shell needs only to know whether the scanner is in the start state.

bool nxo_thread_deferred(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      false:
        Execution is not deferred.
      true:
        Execution is deferred.
  Exception(s):
    None.
  Description:
    Return whether the scanner is currently in deferred execution mode. See Section 2.2 for information on deferred execution. In general this is only useful when implementing an interactive environment for which the prompt behaves differently depending on what state the scanner is in.

void nxo_thread_reset(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Reset the scanner to the start state, and turn deferral off. This is a dangerous feature that should be used with great care. nxo_no objects should never be visible from inside the interpreter, so the caller must assure that any nxo_no objects are removed before further processing is done in the context of a_nxo.

void nxo_thread_loop(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    None.
  Exception(s):
    Application specific.
  Description:
    Execute the top object on estack. The caller is responsible for placing the object on estack, but it is removed before this function returns.

void nxo_thread_interpret(cw_nxo_t *a_nxo, cw_nxo_threadp_t *a_threadp, const char *a_str, uint32_t a_len):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_threadp:
      A threadp.
    a_str:
      Pointer to a string to interpret.
    a_len:
      Length in bytes of a_str.
  Output(s):
    None.
  Exception(s):
    Application specific.
  Description:
    Interpret the string pointed to by a_str.

void nxo_thread_flush(cw_nxo_t *a_nxo, cw_nxo_threadp_t *a_threadp):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_threadp:
      A threadp.
  Output(s):
    None.
  Exception(s):
    Application specific.
  Description:
    Do the equivalent of interpreting a carriage return in order to force acceptance of the previous token if no whitespace has yet followed.

void nxo_thread_nerror(cw_nxo_t *a_nxo, cw_nxn_t a_nxn):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_nxn:
      An nxn corresponding to the name of an error.
  Output(s):
    None.
  Exception(s):
    Application dependent.
  Description:
    Throw an error.

void nxo_thread_serror(cw_nxo_t *a_nxo, const char a_str, uint32_t a_len):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_str:
      Pointer to a string that represents the name of an error.
    a_len:
      The length of a_str.
  Output(s):
    None.
  Exception(s):
    Application dependent.
  Description:
    Throw an error.

bool nxo_thread_dstack_search(cw_nxo_t *a_nxo, cw_nxo_t *a_key, cw_nxo_t *r_value):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_key:
      Pointer to an nxo.
    r_value:
      Pointer to an nxo.
  Output(s):
    retval:
      false:
        Success.
      true:
        a_key not found on dstack.
    r_value:
      Top value in dstack associated with a_key.
  Exception(s):
    None.
  Description:
    Search dstack for the topmost definition of a_key and dup its value to r_value.

bool nxo_thread_class_hier_search(cw_nxo_t *a_nxo, cw_nxo_t *a_class, cw_nxo_t *a_key, cw_nxo_t *r_value):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_class:
      Pointer to a class nxo.
    a_key:
      Pointer to an nxo.
    r_value:
      Pointer to an nxo.
  Output(s):
    retval:
      false:
        Success.
      true:
        a_key not found on in a_class's class hierarchy.
    r_value:
      Value in a_class's class hierarchy farthest from the base class that is associated with a_key.
  Exception(s):
    None.
  Description:
    Search a_class's class hierarchy for the definition of a_key that is farthest from the base class.

bool nxo_thread_currentlocking(const cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      false:
        Implicit locking deactivated for new objects.
      true:
        Implicit locking activated for new objects.
  Exception(s):
    None.
  Description:
    Return whether implicit locking is activated for new objects.

void nxo_thread_setlocking(cw_nxo_t *a_nxo, bool a_locking):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_locking:
      false:
        Do not implicitly lock new objects.
      true:
        Implicitly lock new objects.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Activate or deactivate implicit locking for new objects.

cw_nxoi_t nxo_thread_maxestack_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Maximum allowable estack depth.
  Exception(s):
    None.
  Description:
    Return a_nxo's maximum allowable estack depth.

void nxo_thread_maxestack_set(cw_nxo_t *a_nxo, cw_nxoi_t a_maxestack):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_maxestack:
      Maximum estack depth.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set a_nxo's maximum allowable estack depth to a_maxestack.

bool nxo_thread_tailopt_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Tail optimization setting.
  Exception(s):
    None.
  Description:
    Return a_nxo's tail optimization setting.

void nxo_thread_tailopt_set(cw_nxo_t *a_nxo, bool a_tailopt):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_tailopt:
      Tail optimization setting.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set a_nxo's tail optimization setting to a_tailopt.

cw_nx_t * nxo_thread_nx_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nx.
  Exception(s):
    None.
  Description:
    Return the nx associated with a_nxo.

cw_nxo_t * nxo_thread_userdict_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the userdict associated with a_nxo.

cw_nxo_t * nxo_thread_errordict_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the errordict associated with a_nxo.

cw_nxo_t * nxo_thread_currenterror_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the currenterror associated with a_nxo.

cw_nxo_t * nxo_thread_ostack_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the ostack associated with a_nxo.

cw_nxo_t * nxo_thread_dstack_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the dstack associated with a_nxo.

cw_nxo_t * nxo_thread_estack_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the estack associated with a_nxo.

cw_nxo_t * nxo_thread_istack_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the istack associated with a_nxo.

cw_nxo_t * nxo_thread_tstack_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the tstack associated with a_nxo.

cw_nxo_t * nxo_thread_stdin_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the stdin associated with a_nxo.

void nxo_thread_stdin_set(cw_nxo_t *a_nxo, cw_nxo_t *a_stdin):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_stdin:
      Pointer to a file nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set a_nxo's stdin to a_stdin.

cw_nxo_t * nxo_thread_stdout_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the stdout associated with a_nxo.

void nxo_thread_stdout_set(cw_nxo_t *a_nxo, cw_nxo_t *a_stdout):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_stdout:
      Pointer to a file nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set a_nxo's stdout to a_stdout.

cw_nxo_t * nxo_thread_stderr_get(cw_nxo_t *a_nxo):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
  Output(s):
    retval:
      Pointer to an nxo that can safely be used without risk of being garbage collected.
  Exception(s):
    None.
  Description:
    Return a pointer to the stderr associated with a_nxo.

void nxo_thread_stderr_set(cw_nxo_t *a_nxo, cw_nxo_t *a_stderr):

  Input(s):
    a_nxo:
      Pointer to a thread nxo.
    a_stderr:
      Pointer to a file nxo.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    Set a_nxo's stderr to a_stderr.

Next: 4.10.36 ql Up: 4.10 Classes Previous: 4.10.34 nxo_string Contents Index