obj_ops.h
#
Various object operations.
Authors#
TheSilvered
Macros#
Nst_obj_eq
#
Synopsis:
#define Nst_obj_eq(ob1, ob2)
Description:
Alias for _Nst_obj_eq
that casts both objects
to Nst_Obj *
.
Nst_obj_ne
#
Synopsis:
#define Nst_obj_ne(ob1, ob2)
Description:
Alias for _Nst_obj_ne
that casts both objects
to Nst_Obj *
.
Nst_obj_gt
#
Synopsis:
#define Nst_obj_gt(ob1, ob2)
Description:
Alias for _Nst_obj_gt
that casts both objects
to Nst_Obj *
.
Nst_obj_lt
#
Synopsis:
#define Nst_obj_lt(ob1, ob2)
Description:
Alias for _Nst_obj_lt
that casts both objects
to Nst_Obj *
.
Nst_obj_ge
#
Synopsis:
#define Nst_obj_ge(ob1, ob2)
Description:
Alias for _Nst_obj_ge
that casts both objects
to Nst_Obj *
.
Nst_obj_le
#
Synopsis:
#define Nst_obj_le(ob1, ob2)
Description:
Alias for _Nst_obj_le
that casts both objects
to Nst_Obj *
.
Nst_obj_add
#
Synopsis:
#define Nst_obj_add(ob1, ob2)
Description:
Alias for _Nst_obj_add
that casts both
objects to Nst_Obj *
.
Nst_obj_sub
#
Synopsis:
#define Nst_obj_sub(ob1, ob2)
Description:
Alias for _Nst_obj_sub
that casts both
objects to Nst_Obj *
.
Nst_obj_mul
#
Synopsis:
#define Nst_obj_mul(ob1, ob2)
Description:
Alias for _Nst_obj_mul
that casts both
objects to Nst_Obj *
.
Nst_obj_div
#
Synopsis:
#define Nst_obj_div(ob1, ob2)
Description:
Alias for _Nst_obj_div
that casts both
objects to Nst_Obj *
.
Nst_obj_pow
#
Synopsis:
#define Nst_obj_pow(ob1, ob2)
Description:
Alias for _Nst_obj_pow
that casts both
objects to Nst_Obj *
.
Nst_obj_mod
#
Synopsis:
#define Nst_obj_mod(ob1, ob2)
Description:
Alias for _Nst_obj_mod
that casts both
objects to Nst_Obj *
.
Nst_obj_bwor
#
Synopsis:
#define Nst_obj_bwor(ob1, ob2)
Description:
Alias for _Nst_obj_bwor
that casts both
objects to Nst_Obj *
.
Nst_obj_bwand
#
Synopsis:
#define Nst_obj_bwand(ob1, ob2)
Description:
Alias for _Nst_obj_bwand
that casts both
objects to Nst_Obj *
.
Nst_obj_bwxor
#
Synopsis:
#define Nst_obj_bwxor(ob1, ob2)
Description:
Alias for _Nst_obj_bwxor
that casts both
objects to Nst_Obj *
.
Nst_obj_bwls
#
Synopsis:
#define Nst_obj_bwls(ob1, ob2)
Description:
Alias for _Nst_obj_bwls
that casts both
objects to Nst_Obj *
.
Nst_obj_bwrs
#
Synopsis:
#define Nst_obj_bwrs(ob1, ob2)
Description:
Alias for _Nst_obj_bwrs
that casts both
objects to Nst_Obj *
.
Nst_obj_lgor
#
Synopsis:
#define Nst_obj_lgor(ob1, ob2)
Description:
Alias for _Nst_obj_lgor
that casts both
objects to Nst_Obj *
.
Nst_obj_lgand
#
Synopsis:
#define Nst_obj_lgand(ob1, ob2)
Description:
Alias for _Nst_obj_lgand
that casts both
objects to Nst_Obj *
.
Nst_obj_lgxor
#
Synopsis:
#define Nst_obj_lgxor(ob1, ob2)
Description:
Alias for _Nst_obj_lgxor
that casts both
objects to Nst_Obj *
.
Nst_obj_cast
#
Synopsis:
#define Nst_obj_cast(ob, type)
Description:
Alias for _Nst_obj_cast
that casts ob
to
Nst_Obj *
and type
to
Nst_TypeObj *
.
Nst_obj_contains
#
Synopsis:
#define Nst_obj_contains(ob1, ob2)
Description:
Alias for _Nst_obj_contains
that casts
both objects to Nst_Obj *
.
Nst_obj_concat
#
Synopsis:
#define Nst_obj_concat(ob1, ob2)
Description:
Alias for _Nst_obj_concat
that casts both
objects to Nst_Obj *
.
Nst_obj_range
#
Synopsis:
#define Nst_obj_range(ob1, ob2, ob3)
Description:
Alias for _Nst_obj_range
that casts all
objects to Nst_Obj *
.
Nst_obj_neg
#
Synopsis:
#define Nst_obj_neg(ob)
Description:
Alias for _Nst_obj_neg
that casts ob
to
Nst_Obj *
.
Nst_obj_len
#
Synopsis:
#define Nst_obj_len(ob)
Description:
Alias for _Nst_obj_len
that casts ob
to
Nst_Obj *
.
Nst_obj_bwnot
#
Synopsis:
#define Nst_obj_bwnot(ob)
Description:
Alias for _Nst_obj_bwnot
that casts ob
to
Nst_Obj *
.
Nst_obj_lgnot
#
Synopsis:
#define Nst_obj_lgnot(ob)
Description:
Alias for _Nst_obj_lgnot
that casts ob
to
Nst_Obj *
.
Nst_obj_stdout
#
Synopsis:
#define Nst_obj_stdout(ob)
Description:
Alias for _Nst_obj_stdout
that casts ob
to Nst_Obj *
.
Nst_obj_stdin
#
Synopsis:
#define Nst_obj_stdin(ob)
Description:
Alias for _Nst_obj_stdin
that casts ob
to
Nst_Obj *
.
Nst_obj_typeof
#
Synopsis:
#define Nst_obj_typeof(ob)
Description:
Alias for _Nst_obj_typeof
that casts ob
to Nst_Obj *
.
Nst_obj_import
#
Synopsis:
#define Nst_obj_import(ob)
Description:
Alias for _Nst_obj_import
that casts ob
to Nst_Obj *
.
Nst_obj_eq_c
#
Synopsis:
#define Nst_obj_eq_c(ob1, ob2)
Description:
Calls Nst_obj_eq
making the result a C bool.
Nst_obj_ne_c
#
Synopsis:
#define Nst_obj_ne_c(ob1, ob2)
Description:
Calls Nst_obj_ne
making the result a C bool.
Functions#
_Nst_obj_eq
#
Synopsis:
Nst_Obj *_Nst_obj_eq(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the ==
operator. Is guaranteed to not fail.
_Nst_obj_ne
#
Synopsis:
Nst_Obj *_Nst_obj_ne(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the !=
operator. Is guaranteed to not fail.
_Nst_obj_gt
#
Synopsis:
Nst_Obj *_Nst_obj_gt(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the >
operator. On failure the error is set.
_Nst_obj_lt
#
Synopsis:
Nst_Obj *_Nst_obj_lt(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the <
operator. On failure the error is set.
_Nst_obj_ge
#
Synopsis:
Nst_Obj *_Nst_obj_ge(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the >=
operator. On failure the error is set.
_Nst_obj_le
#
Synopsis:
Nst_Obj *_Nst_obj_le(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the <=
operator. On failure the error is set.
_Nst_obj_add
#
Synopsis:
Nst_Obj *_Nst_obj_add(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the +
operator. On failure the error is set.
_Nst_obj_sub
#
Synopsis:
Nst_Obj *_Nst_obj_sub(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the -
operator. On failure the error is set.
_Nst_obj_mul
#
Synopsis:
Nst_Obj *_Nst_obj_mul(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the null
operator. On failure the error is set.
_Nst_obj_div
#
Synopsis:
Nst_Obj *_Nst_obj_div(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the /
operator. On failure the error is set.
_Nst_obj_pow
#
Synopsis:
Nst_Obj *_Nst_obj_pow(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the ^
operator. On failure the error is set.
_Nst_obj_mod
#
Synopsis:
Nst_Obj *_Nst_obj_mod(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the %
operator. On failure the error is set.
_Nst_obj_bwor
#
Synopsis:
Nst_Obj *_Nst_obj_bwor(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the |
operator. On failure the error is set.
_Nst_obj_bwand
#
Synopsis:
Nst_Obj *_Nst_obj_bwand(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the &
operator. On failure the error is set.
_Nst_obj_bwxor
#
Synopsis:
Nst_Obj *_Nst_obj_bwxor(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the ^^
operator. On failure the error is set.
_Nst_obj_bwls
#
Synopsis:
Nst_Obj *_Nst_obj_bwls(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the <<
operator. On failure the error is set.
_Nst_obj_bwrs
#
Synopsis:
Nst_Obj *_Nst_obj_bwrs(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the >>
operator. On failure the error is set.
_Nst_obj_lgor
#
Synopsis:
Nst_Obj *_Nst_obj_lgor(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the ||
operator. On failure the error is set.
_Nst_obj_lgand
#
Synopsis:
Nst_Obj *_Nst_obj_lgand(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the &&
operator. On failure the error is set.
_Nst_obj_lgxor
#
Synopsis:
Nst_Obj *_Nst_obj_lgxor(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the &|
operator. On failure the error is set.
_Nst_obj_neg
#
Synopsis:
Nst_Obj *_Nst_obj_neg(Nst_Obj *ob)
Description:
Implements the -:
operator. On failure the error is set.
_Nst_obj_len
#
Synopsis:
Nst_Obj *_Nst_obj_len(Nst_Obj *ob)
Description:
Implements the $
operator. On failure the error is set.
_Nst_obj_bwnot
#
Synopsis:
Nst_Obj *_Nst_obj_bwnot(Nst_Obj *ob)
Description:
Implements the ~
operator. On failure the error is set.
_Nst_obj_lgnot
#
Synopsis:
Nst_Obj *_Nst_obj_lgnot(Nst_Obj *ob)
Description:
Implements the !
operator. On failure the error is set.
_Nst_obj_stdout
#
Synopsis:
Nst_Obj *_Nst_obj_stdout(Nst_Obj *ob)
Description:
Implements the >>>
operator. On failure the error is set.
_Nst_obj_stdin
#
Synopsis:
Nst_Obj *_Nst_obj_stdin(Nst_Obj *ob)
Description:
Implements the <<<
operator. On failure the error is set.
_Nst_obj_typeof
#
Synopsis:
Nst_Obj *_Nst_obj_typeof(Nst_Obj *ob)
Description:
Implements the ?::
operator. On failure the error is set.
_Nst_obj_import
#
Synopsis:
Nst_Obj *_Nst_obj_import(Nst_Obj *ob)
Description:
Implements the |#|
operator. On failure the error is set.
_Nst_repr_str_cast
#
Synopsis:
Nst_Obj *_Nst_repr_str_cast(Nst_Obj *ob)
Description:
Casts an object to its string representation.
All objects can be casted, even custom types, but the function can still fail to allocate memory.
Parameters:
ob
: the object to be casted
Returns:
The new string or NULL
on failure. The error is set.
_Nst_obj_str_cast_seq
#
Synopsis:
Nst_Obj *_Nst_obj_str_cast_seq(Nst_SeqObj *seq_obj, Nst_LList *all_objs)
Description:
Internal cast from sequence to string.
It is recommended to use
Nst_obj_cast(seq_obj, Nst_type()->Str)
, this
is used internally.
Parameters:
seq_obj
: the object to castall_objs
: a list containing all collections encountered up to that point, on the first call it is empty and is populated automatically
Returns:
The new string object or NULL
on failure. The error is set.
_Nst_obj_str_cast_map
#
Synopsis:
Nst_Obj *_Nst_obj_str_cast_map(Nst_MapObj *map_obj, Nst_LList *all_objs)
Description:
Internal cast from map to string.
It is recommended to use
Nst_obj_cast(map_obj, Nst_type()->Str)
, this
is used internally.
Parameters:
map_obj
: the object to castall_objs
: a list containing all collections encountered up to that point, on the first call it is empty and is populated automatically
Returns:
The new string object or NULL
on failure. The error is set.
_Nst_obj_cast
#
Synopsis:
Nst_Obj *_Nst_obj_cast(Nst_Obj *ob, Nst_TypeObj *type)
Description:
Casts an object from a type to another.
Casting an object to Bool
is guaranteed to not fail. All objects can be casted
to Str
but the function can still fail if a memory allocation is unsuccessful.
Parameters:
ob
: the object to be castedtype
: the type to cast the object to
Returns:
The casted object or NULL
on failure. The error is set.
_Nst_obj_contains
#
Synopsis:
Nst_Obj *_Nst_obj_contains(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Implements the <.>
operator. On failure the error is set.
_Nst_obj_concat
#
Synopsis:
Nst_Obj *_Nst_obj_concat(Nst_Obj *ob1, Nst_Obj *ob2)
Description:
Concatenates two objects into a string.
Both objects are casted to Str
before being concatenated.
Parameters:
ob1
: the first objectob2
: the second object
Returns:
The result of the concatenation or NULL
on failure. The error is set.
_Nst_obj_range
#
Synopsis:
Nst_Obj *_Nst_obj_range(Nst_Obj *start, Nst_Obj *stop, Nst_Obj *step)
Description:
Creates a range object given the start, stop and step.
Parameters:
start
: the starting value of the rangestop
: the the excluded stopping index of the rangestep
: the step of the range
Returns:
The new range object or NULL
on failure. The error is set.
_Nst_get_import_path
#
Synopsis:
Nst_StrObj *_Nst_get_import_path(i8 *initial_path, usize path_len)
Description:
Returns the absolute path for a library to import.
If the library is not found on the given path, the standard library directory is checked.
Parameters:
initial_path
: the relative path used to import the librarypath_len
: the length in bytes ofinitial_path
Returns:
The path on success and NULL
on failure. The error is set. This function fails
if the specified library is not found.