Module artichoke_backend::sys::specifiers

source ·
Expand description

Format specifiers for mrb_get_args function.

mrb_get_args has the following prototype and returns the number of arguments parsed.

MRB_API mrb_int mrb_get_args(mrb_state *mrb, const char *format, ...)

format must be a C string composed of the following format specifiers:

  string  mruby type     C type                 note
  ----------------------------------------------------------------------------------------------
  o:      Object         `mrb_value`
  C:      class/module   `mrb_value`
  S:      String         `mrb_value`            when ! follows, the value may be nil
  A:      Array          `mrb_value`            when ! follows, the value may be nil
  H:      Hash           `mrb_value`            when ! follows, the value may be nil
  s:      String         `char*`,`mrb_int`      Receive two arguments; s! gives (NULL,0) for nil
  z:      String         `char*`                NUL terminated string; z! gives NULL for nil
  a:      Array          `mrb_value*`,`mrb_int` Receive two arguments; a! gives (NULL,0) for nil
  f:      Float          `mrb_float`
  i:      Integer        `mrb_int`
  b:      Boolean        `mrb_bool`
  n:      Symbol         `mrb_sym`
  d:      Data           `void*`,`mrb_data_type`  2nd argument will be used to check data type so it won't be modified
  I:      Inline struct  `void*`
  &:      Block          `mrb_value`            &! raises exception if no block given
  *:      rest argument  `mrb_value*`,`mrb_int` The rest of the arguments as an array; *! avoid copy of the stack
  |:      optional                              Following arguments are optional
  ?:      optional given `mrb_bool`             true if preceding argument (optional) is given

Constants§

  • Retrieve an Array argument
  • Retrieve a Block argument.
  • Retrieve a Block argument and raise an exception if none is given.
  • Retrieve a Boolean argument.
  • Receive two arguments, a C Array of mrb_values and its length. Usable like:
  • Retrieve a Class argument
  • Retrieve a NUL-terminated CString argument
  • Retrieve a CString and its length. Usable like:
  • Receive two arguments, a void * pointer to data and an mrb_data_type.
  • Retrieve a Float argument.
  • The following args specified are optional.
  • Retrieve a Hash argument
  • Internal, retrieve a void *.
  • Retrieve an Integer argument.
  • Retrieve a Module argument
  • Retrieve an Array argument or nil
  • Retrieve a Hash argument or nil
  • Retrieve a String argument or nil
  • Receive two arguments, a C Array of mrb_values and its length. Gives (NULL, 0) for nil. Usable like:
  • Retrieve a NUL-terminated CString argument. Gives NULL for nil
  • Retrieve a CString and its length. Gives (NULL, 0) for nil. Usable like:
  • Could be used to retrieve any type of argument
  • Retrieve a Boolean indicating whether the previous optional argument was given.
  • Retrieve the rest of arguments as an array; Usable like:
  • Retrieve the rest of arguments as an array; avoid copy of the stack.
  • Retrieve a String argument
  • Retrieve a Symbol argument.