#include <stdio.h>
#include <pthread.h>
#include "kite_vm.h"
Go to the source code of this file.
Data Structures | |
struct | kite_function_t |
struct | kite_symtab_t |
struct | kite_basic_object_t |
struct | kite_object_t |
Defines | |
#define | FALSE 0 |
#define | TRUE 1 |
#define | DYLIB_EXTENSION ".so" |
#define | KITE_EXPORT |
#define | KITE_FIND_PROPERTY(ret, obj, name, num) KITE_FIND_IN_SYMTAB(ret, obj->object_data.properties, name, num) |
#define | KITE_FIND_METHOD(ret, obj, name, num) KITE_FIND_IN_SYMTAB(ret, obj->object_data.properties, name, num) |
#define | KITE_FIND_IN_SYMTAB(ret, symtab, n, num) |
#define | KITE_FIND_ANY_IN_SYMTAB(ret, symtab, n) |
#define | KITE_MODULE_INITIALIZER_NAME(name) name ## _load_module |
#define | KITE_MODULE_INITIALIZER(name) |
#define | KITE_CLASS_METHOD(name) |
#define | KITE_NO_ARGS (void)args; |
#define | KITE_THIS_NOT_USED (void)this; |
#define | KITE_GET_METHOD_ARGUMENT(ret, n) KITE_GET_LIST_ELEMENT(ret, args, n) |
#define | KITE_GET_LIST_ELEMENT(ret, obj, n) |
#define | KITE_REPLACE_LIST_ELEMENT(list, n, obj) |
#define | KITE_REMOVE_LIST_ELEMENT(list, n) |
#define | KITE_IS_TYPE(val, t) ((val)->type == t) |
#define | KITE_GET_OBJECT_TYPE(val) ((val)->type) |
#define | KITE_GET_PARENT_OBJECT(val) ((val)->object_data.inherit_from) |
#define | KITE_GET_INTEGER(v) (((kite_basic_object_t*)v)->builtin_data.intvalue) |
#define | KITE_GET_FLOAT(v) (((kite_basic_object_t*)v)->builtin_data.floatvalue) |
#define | KITE_GET_STRING_VALUE(v) ((v)->builtin_data.stringvalue.string) |
#define | KITE_GET_STRING_LENGTH(v) ((v)->builtin_data.stringvalue.length) |
#define | KITE_SET_INTEGER(v, i) KITE_GET_INTEGER(v) = i |
#define | KITE_SET_FLOAT(v, i) KITE_GET_FLOAT(v) = i |
#define | KITE_LIST_CAR(v) ((v)->builtin_data.listvalue.car) |
#define | KITE_LIST_CDR(v) ((v)->builtin_data.listvalue.cdr) |
Typedefs | |
typedef void(* | kite_compiled_func_t )(struct kite_thread_t *thread, struct kite_object_t *this, struct kite_object_t *args) |
typedef struct kite_function_t | kite_function_t |
typedef struct kite_symtab_t | kite_symtab_t |
typedef struct kite_basic_object_t | kite_basic_object_t |
typedef struct kite_object_t | kite_object_t |
Enumerations | |
enum | kite_object_type_t { OBJ_INTEGER, OBJ_FLOAT, OBJ_BOOLEAN, OBJ_NUMBER_OF_BASE_TYPES, OBJ_NULL = OBJ_NUMBER_OF_BASE_TYPES, OBJ_STRING, OBJ_IDENT, OBJ_LIST, OBJ_METHOD, OBJ_CLASS, OBJ_INSTANCE, OBJ_NUMBER_OF_TYPES } |
Functions | |
KITE_EXPORT kite_object_t * | kite_new_null (kite_thread_t *thd) |
KITE_EXPORT kite_object_t * | kite_new_integer (kite_thread_t *thd, long val) |
KITE_EXPORT kite_object_t * | kite_new_float (kite_thread_t *thd, double val) |
KITE_EXPORT kite_object_t * | kite_new_string (kite_thread_t *thd, char *val) |
KITE_EXPORT kite_object_t * | kite_new_string_with_length (kite_thread_t *thd, char *val, int length) |
KITE_EXPORT kite_object_t * | kite_new_ident (kite_thread_t *thd, char *val) |
KITE_EXPORT kite_object_t * | kite_new_boolean (kite_thread_t *thd, int val) |
KITE_EXPORT kite_object_t * | kite_new_list (kite_thread_t *thd) |
KITE_EXPORT kite_object_t * | kite_new_method_compiled (kite_thread_t *thd, kite_compiled_func_t func, int numargs) |
KITE_EXPORT kite_object_t * | kite_new_method_compiled_with_docs (kite_thread_t *thd, kite_compiled_func_t func, char *desc, int numargs,...) |
KITE_EXPORT kite_object_t * | kite_new_method_bytecode (kite_thread_t *thd, struct kite_opcode_t *func, int numargs) |
KITE_EXPORT kite_object_t * | kite_new_method_bytecode_with_docs (kite_thread_t *thd, struct kite_opcode_t *func, char *desc, int numargs,...) |
KITE_EXPORT kite_object_t * | kite_new_class (kite_thread_t *thd, kite_object_t *parent, char *name) |
KITE_EXPORT kite_object_t * | kite_new_instance (kite_thread_t *thd, kite_object_t *parent) |
KITE_EXPORT kite_object_t * | kite_new_instance_with_constructor (kite_thread_t *thd, kite_object_t *parent, kite_object_t *args) |
KITE_EXPORT kite_object_t * | kite_new_exception (kite_thread_t *thd, char *name, char *message) |
KITE_EXPORT void | kite_dereference_object (kite_object_t *obj) |
KITE_EXPORT kite_object_t * | kite_reference_object (kite_object_t *obj) |
KITE_EXPORT void | kite_add_property (kite_thread_t *thd, kite_object_t *obj, char *name, int global, char *doc) |
KITE_EXPORT void | kite_add_method (kite_thread_t *thd, kite_object_t *obj, char *name, kite_object_t *method) |
KITE_EXPORT void | kite_add_operator (kite_thread_t *thd, kite_object_t *obj, int op, kite_object_t *method) |
KITE_EXPORT void | kite_set_docstring (kite_object_t *obj, char *str) |
KITE_EXPORT char * | kite_get_docstring (kite_object_t *obj) |
KITE_EXPORT void | kite_set_arginfo (kite_object_t *obj, kite_object_t *arginfo) |
KITE_EXPORT void | kite_remove_property (kite_thread_t *thd, kite_object_t *obj, char *name, int global) |
KITE_EXPORT void | kite_remove_method (kite_thread_t *thd, kite_object_t *obj, char *name, int numargs) |
KITE_EXPORT void | kite_remove_operator (kite_thread_t *thd, kite_object_t *obj, int op) |
KITE_EXPORT void | kite_set_property (kite_thread_t *thd, kite_object_t *obj, char *name, kite_object_t *value) |
KITE_EXPORT int | kite_exists_property (kite_object_t *obj, char *name) |
KITE_EXPORT int | kite_exists_method (kite_object_t *obj, char *name) |
KITE_EXPORT int | kite_exists_operator (kite_object_t *obj, int op) |
KITE_EXPORT kite_object_t * | kite_get_property (kite_object_t *obj, char *name) |
KITE_EXPORT kite_object_t * | kite_dereference_and_load (kite_thread_t *thd, char *name) |
KITE_EXPORT void | kite_set_dylib_path (char *path) |
kite_symtab_t * | kite_new_symtab () |
KITE_EXPORT void | kite_symtab_insert (kite_thread_t *thd, kite_symtab_t **symt, kite_symtab_t *entry) |
KITE_EXPORT void | kite_symtab_remove (kite_thread_t *thd, kite_symtab_t **symt, char *name, int num) |
KITE_EXPORT void | kite_copy_symtab (kite_symtab_t **ret, kite_symtab_t *symt) |
KITE_EXPORT void | kite_destruct_symtab (kite_thread_t *thd, kite_symtab_t **symt, int ref) |
KITE_EXPORT void | kite_copy_symtab_elements (kite_thread_t *thd, kite_symtab_t **ret, kite_symtab_t *symt, kite_object_t *p) |
KITE_EXPORT kite_object_t * | kite_object_name (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT kite_object_t * | kite_boolean_object (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT kite_object_t * | kite_string_object (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT kite_object_t * | kite_int_object (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT kite_object_t * | kite_float_object (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT kite_object_t * | kite_list_object (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT int | kite_list_count (kite_thread_t *thd, kite_object_t *obj) |
KITE_EXPORT void | kite_append_list (kite_thread_t *thd, kite_object_t *list, kite_object_t *obj) |
#define DYLIB_EXTENSION ".so" |
#define FALSE 0 |
Referenced by kite_gc_destroy_all(), kite_gc_incremental(), kite_new_boolean(), kite_new_class(), and kite_push_stack().
#define KITE_CLASS_METHOD | ( | name | ) |
void name(kite_thread_t *thd, kite_object_t *this, \ kite_object_t *args)
Define a Kite class method's name and prototype.
name | The C function name to give this method. |
#define KITE_EXPORT |
#define KITE_FIND_ANY_IN_SYMTAB | ( | ret, | ||
symtab, | ||||
n | ||||
) |
{ \ ret = symtab; \ while(ret) { \ int r = strcmp(n, ret->name); \ if (!r) { \ break; \ } else if (r < 0) ret = ret->left; \ else ret = ret->right; \ } \ }
Find any property or method for given object and return symbol table object.
[out] | ret | The kite_symtab_t pointer to return the result to. |
symtab | The symbol table to look in. | |
n | The property or method to look for. |
Referenced by kite_exists_operator(), kite_new_ident(), kite_remove_operator(), kite_vm_call_constructor(), and kite_vm_call_operator().
#define KITE_FIND_IN_SYMTAB | ( | ret, | ||
symtab, | ||||
n, | ||||
num | ||||
) |
{ \ ret = symtab; \ while(ret) { \ int r = strcmp(n, ret->name); \ if (!r && ret->global == num) { \ break; \ } else if (r < 0 || (!r && ret->global > num)) ret = ret->left; \ else ret = ret->right; \ } \ }
Find property or method for given object and return symbol table object.
[out] | ret | The kite_symtab_t pointer to return the result to. |
symtab | The symbol table to look in. | |
n | The property or method to look for. | |
num | The number of arguments of the method. For properties, 1 = global and 0 for all others. |
#define KITE_FIND_METHOD | ( | ret, | ||
obj, | ||||
name, | ||||
num | ||||
) | KITE_FIND_IN_SYMTAB(ret, obj->object_data.properties, name, num) |
Find method for given object and return symbol table object.
[out] | ret | The kite_symtab_t pointer to return the result to. |
obj | The object to operate on. | |
name | The name of the method to find. | |
num | The number of arguments of the method. |
Referenced by kite_exists_method(), and kite_vm_call_method().
#define KITE_FIND_PROPERTY | ( | ret, | ||
obj, | ||||
name, | ||||
num | ||||
) | KITE_FIND_IN_SYMTAB(ret, obj->object_data.properties, name, num) |
Find property for given object and return symbol table object.
[out] | ret | The kite_symtab_t pointer to return the result to. |
obj | The object to operate on. | |
name | The name of the property to find. | |
num | 1 for global properties, 0 otherwise. |
Referenced by kite_dereference_and_load(), kite_exists_property(), kite_get_property(), and kite_set_property().
#define KITE_GET_FLOAT | ( | v | ) | (((kite_basic_object_t*)v)->builtin_data.floatvalue) |
Retrieves floating-point value for a Kite object.
v | The Kite object to retrieve number from. |
#define KITE_GET_INTEGER | ( | v | ) | (((kite_basic_object_t*)v)->builtin_data.intvalue) |
Retrieves integer value for a Kite object.
v | The Kite object to retrieve integer from. |
#define KITE_GET_LIST_ELEMENT | ( | ret, | ||
obj, | ||||
n | ||||
) |
{ \ int cur = n - 1; \ ret = obj; \ while(ret && cur > 0) { \ cur--; \ ret = ret->builtin_data.listvalue.cdr; \ } \ if (ret) ret = ret->builtin_data.listvalue.car; \ }
Retrieve an item from a list, given its index.
[out] | ret | The kite_object_t* to place the result in, or NULL if argument does not exist. |
obj | The list to operate on. | |
n | The list index to retrieve. |
#define KITE_GET_METHOD_ARGUMENT | ( | ret, | ||
n | ||||
) | KITE_GET_LIST_ELEMENT(ret, args, n) |
Retrieve method argument passed in from code.
[out] | ret | The kite_object_t* to place the result in, or NULL if argument does not exist. |
n | The argument number to retrieve. |
#define KITE_GET_OBJECT_TYPE | ( | val | ) | ((val)->type) |
Gets the type of the given Kite object.
val | The Kite object to operate on. |
#define KITE_GET_PARENT_OBJECT | ( | val | ) | ((val)->object_data.inherit_from) |
Retrieves the parent (inherited from) object. This is usually the class the current instance was created from, or the inherited class if operating on a class object.
val | The Kite object to operate on. |
#define KITE_GET_STRING_LENGTH | ( | v | ) | ((v)->builtin_data.stringvalue.length) |
Retrieves string length for a Kite object.
v | The Kite object to retrieve string from. |
#define KITE_GET_STRING_VALUE | ( | v | ) | ((v)->builtin_data.stringvalue.string) |
Retrieves string value for a Kite object.
v | The Kite object to retrieve string from. |
Referenced by kite_new_string_with_length().
#define KITE_IS_TYPE | ( | val, | ||
t | ||||
) | ((val)->type == t) |
Checks to determine whether an object is of a given type.
val | The Kite object to check. | |
t | The type to check for. |
#define KITE_LIST_CAR | ( | v | ) | ((v)->builtin_data.listvalue.car) |
Retrieve the head of a list.
v | The list to operate on. |
#define KITE_LIST_CDR | ( | v | ) | ((v)->builtin_data.listvalue.cdr) |
Retrieve the tail of a list.
v | The list to operate on. |
#define KITE_MODULE_INITIALIZER | ( | name | ) |
void KITE_MODULE_INITIALIZER_NAME(name) (kite_thread_t *, kite_object_t *); \ void* name ## _load_module__wrap(kite_thread_t *thd) { \ kite_loader_register(thd, #name, KITE_MODULE_INITIALIZER_NAME(name)); \ return NULL; \ } \ void KITE_MODULE_INITIALIZER_NAME(name) (kite_thread_t *thread, kite_object_t *parent)
Define initializer for a given Kite module. The name should be the name given to the library file during compilation. For example, org.kite.testmodule, located in org/kite/testmodule.so, would result in "testmodule" for name.
name | The name of the module. |
#define KITE_MODULE_INITIALIZER_NAME | ( | name | ) | name ## _load_module |
The name of the method given to the function called by the Kite loader upon loading the module into memory. Not intended for use by user code.
name | The name of the module. |
#define KITE_NO_ARGS (void)args; |
Helper macro to eliminate warnings about "args" not being used.
#define KITE_REMOVE_LIST_ELEMENT | ( | list, | ||
n | ||||
) |
{ \ int cur = n - 1; \ kite_object_t *ret = obj; \ while(ret && cur > 0) { \ cur--; \ ret = ret->builtin_data.listvalue.cdr; \ } \ if (ret) { \ kite_dereference_object(KITE_LIST_CAR(ret)); \ if (KITE_LIST_CDR(ret)) { \ kite_object_t *tmp = KITE_LIST_CDR(ret); \ KITE_LIST_CAR(ret) = KITE_LIST_CAR(KITE_LIST_CDR(ret)); \ KITE_LIST_CDR(ret) = KITE_LIST_CDR(KITE_LIST_CDR(ret)); \ kite_dereference_object(tmp); \ } else { \ KITE_LIST_CAR(ret) = NULL; \ } \ } \ }
Remove an item from a list, given its index.
list | The list to operate on. | |
n | The list index to replace/insert to. |
#define KITE_REPLACE_LIST_ELEMENT | ( | list, | ||
n, | ||||
obj | ||||
) |
{ \ int cur = n - 1; \ kite_object_t *ret = obj; \ while(ret && cur > 0) { \ cur--; \ if (KITE_LIST_CDR(ret) == NULL) { \ kite_append_list(obj->owner_thread, list, kite_new_null(obj->owner_thread)); \ } \ ret = ret->builtin_data.listvalue.cdr; \ } \ if (ret) { \ kite_dereference_object(KITE_LIST_CAR(ret)); \ KITE_LIST_CAR(ret) = kite_reference_object(obj); \ } else { \ kite_append_list(obj->owner_thread, list, obj); \ } \ }
Replace (or insert) an item in a list, given its index.
list | The list to operate on. | |
n | The list index to replace/insert to. | |
obj | The object to replace/insert with. |
#define KITE_SET_FLOAT | ( | v, | ||
i | ||||
) | KITE_GET_FLOAT(v) = i |
Sets floating-point value for a Kite object.
v | The Kite object to operate on. | |
i | The value to assign to the object. |
#define KITE_SET_INTEGER | ( | v, | ||
i | ||||
) | KITE_GET_INTEGER(v) = i |
Sets integer value for a Kite object.
v | The Kite object to operate on. | |
i | The value to assign to the object. |
#define KITE_THIS_NOT_USED (void)this; |
Helper macro to eliminate warnings about "this" not being used.
#define TRUE 1 |
typedef struct kite_basic_object_t kite_basic_object_t |
Representation of an basic object in the Kite object system.
typedef void(* kite_compiled_func_t)(struct kite_thread_t *thread, struct kite_object_t *this, struct kite_object_t *args) |
Function prototype for all compiled (non-Kite written methods).
thread | The currently running thread object. | |
this | The current object. This is the class object if called statically. | |
args | A Kite list containing the method's arguments (0-length if empty). |
typedef struct kite_function_t kite_function_t |
Representation of Kite method (built-in and user provided)
typedef struct kite_object_t kite_object_t |
Representation of an object/class in the Kite object system.
typedef struct kite_symtab_t kite_symtab_t |
enum kite_object_type_t |
KITE_EXPORT void kite_add_method | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
char * | name, | |||
kite_object_t * | method | |||
) |
Add method to object.
thd | The current thread. | |
obj | The object to operate on. | |
name | The name of the new property. | |
method | The method object to add. |
References kite_object_t::builtin_data, kite_symtab_t::docstring, kite_object_t::funcvalue, kite_symtab_t::global, kite_reference_object(), kite_symtab_insert(), kite_symtab_t::name, kite_function_t::numargs, kite_object_t::object_data, kite_object_t::properties, and kite_symtab_t::value.
Referenced by kite_add_operator().
KITE_EXPORT void kite_add_operator | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
int | op, | |||
kite_object_t * | method | |||
) |
Add operator to object.
thd | The current thread. | |
obj | The object to operate on. | |
op | The operator to add (from enum kite_operators) | |
method | The method object to associate with the operator. |
References kite_add_method(), and kite_remove_operator().
KITE_EXPORT void kite_add_property | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
char * | name, | |||
int | global, | |||
char * | doc | |||
) |
Add property to object.
thd | The current thread. | |
obj | The object to operate on. | |
name | The name of the new property. | |
global | 1 for global property, 0 for non-global. | |
doc | Description of property (NULL if not given). |
References kite_symtab_t::docstring, kite_symtab_t::global, kite_exists_property(), kite_symtab_insert(), kite_symtab_t::name, kite_object_t::object_data, kite_object_t::properties, and kite_symtab_t::value.
Referenced by kite_dereference_and_load(), and kite_set_property().
KITE_EXPORT void kite_append_list | ( | kite_thread_t * | thd, | |
kite_object_t * | list, | |||
kite_object_t * | obj | |||
) |
Append an item to the end of a list.
thd | The current thread. | |
list | The list to operate on. | |
obj | The object to insert. |
References kite_object_t::builtin_data, kite_new_list(), kite_reference_object(), and kite_object_t::listvalue.
Referenced by kite_new_method_bytecode_with_docs(), and kite_new_method_compiled_with_docs().
KITE_EXPORT kite_object_t* kite_boolean_object | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Produce Boolean object from the given object.
thd | The current thread. | |
obj | The object to operate on. |
References kite_object_t::builtin_data, kite_object_t::floatvalue, kite_object_t::intvalue, kite_new_boolean(), kite_new_list(), kite_reference_object(), kite_vm_call_method(), kite_object_t::listvalue, OBJ_BOOLEAN, OBJ_FLOAT, OBJ_INSTANCE, OBJ_INTEGER, OBJ_LIST, OBJ_STRING, kite_object_t::stringvalue, TRUE, and kite_object_t::type.
KITE_EXPORT void kite_copy_symtab | ( | kite_symtab_t ** | ret, | |
kite_symtab_t * | symt | |||
) |
Copy entire symbol table.
[out] | ret | The variable to place the new symbol table. |
symt | The symbol table to copy. |
References kite_symtab_t::docstring, kite_symtab_t::global, kite_copy_symtab(), kite_reference_object(), kite_symtab_t::name, and kite_symtab_t::value.
Referenced by kite_copy_symtab().
KITE_EXPORT void kite_copy_symtab_elements | ( | kite_thread_t * | thd, | |
kite_symtab_t ** | ret, | |||
kite_symtab_t * | symt, | |||
kite_object_t * | p | |||
) |
Copy entire symbol table into another possibly existing table, setting parent as appropriate.
thd | The current thread. | |
[in,out] | ret | The symbol table to copy to (*ret = NULL to make a new table) |
symt | The symbol table to copy. | |
p | The new parent for each object copied from the table. |
References kite_symtab_t::docstring, kite_copy_symtab_elements(), kite_reference_object(), kite_symtab_insert(), kite_symtab_t::name, OBJ_BOOLEAN, OBJ_FLOAT, OBJ_INTEGER, kite_object_t::type, and kite_symtab_t::value.
Referenced by kite_copy_symtab_elements().
KITE_EXPORT kite_object_t* kite_dereference_and_load | ( | kite_thread_t * | thd, | |
char * | name | |||
) |
Load a Kite module (compiled or bytecode) into memory.
thd | The current thread. | |
name | The fully-qualified name of the module to load. |
References kite_add_property(), kite_dylib_path, KITE_FIND_PROPERTY, kite_new_class(), kite_new_exception(), kite_new_list(), kite_set_property(), kite_vm_call_method(), TRUE, and kite_symtab_t::value.
Referenced by kite_new_boolean(), kite_new_exception(), kite_new_float(), kite_new_integer(), kite_new_list(), kite_new_method_bytecode(), kite_new_method_compiled(), kite_new_null(), kite_new_string(), kite_new_string_with_length(), kite_vm_call_method(), and kite_vm_call_operator().
KITE_EXPORT void kite_dereference_object | ( | kite_object_t * | obj | ) |
Dereference object.
obj | The object to dereference. |
References kite_list_add_begin(), and kite_list_remove().
Referenced by kite_destruct_object_nofree(), kite_destruct_symtab(), kite_handle_signal(), kite_new_exception(), kite_set_property(), kite_symtab_insert(), kite_symtab_remove(), and kite_vm_call_method().
KITE_EXPORT void kite_destruct_symtab | ( | kite_thread_t * | thd, | |
kite_symtab_t ** | symt, | |||
int | ref | |||
) |
Destroy symbol table.
thd | The current thread. | |
[in,out] | symt | The symbol table to remove. |
ref | If TRUE, dereference objects inside symbol table. |
References kite_dereference_object(), and kite_destruct_symtab().
Referenced by kite_destruct_object_nofree(), and kite_destruct_symtab().
KITE_EXPORT int kite_exists_method | ( | kite_object_t * | obj, | |
char * | name | |||
) |
Determines the existance of a method.
obj | The object to operate on. | |
name | The name of the method to check. |
References KITE_FIND_METHOD, OBJ_METHOD, kite_object_t::type, and kite_symtab_t::value.
KITE_EXPORT int kite_exists_operator | ( | kite_object_t * | obj, | |
int | op | |||
) |
Determines the existance of an operator.
obj | The object to operate on. | |
op | The operator to check for (from kite_operators) |
References KITE_FIND_ANY_IN_SYMTAB, kite_object_t::object_data, and kite_object_t::properties.
KITE_EXPORT int kite_exists_property | ( | kite_object_t * | obj, | |
char * | name | |||
) |
Determines the existance of a property.
obj | The object to operate on. | |
name | The name of the property to check. |
References KITE_FIND_PROPERTY.
Referenced by kite_add_property().
KITE_EXPORT kite_object_t* kite_float_object | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Produce floating-point object from the given object.
thd | The current thread. | |
obj | The object to operate on. |
References kite_object_t::builtin_data, kite_object_t::intvalue, kite_new_float(), kite_new_list(), kite_reference_object(), kite_vm_call_method(), OBJ_BOOLEAN, OBJ_FLOAT, OBJ_INSTANCE, OBJ_INTEGER, OBJ_LIST, OBJ_STRING, kite_object_t::stringvalue, TRUE, and kite_object_t::type.
KITE_EXPORT char* kite_get_docstring | ( | kite_object_t * | obj | ) |
Gets the documentation string for a given object.
obj | The object to operate on. |
References kite_object_t::docstring, and kite_object_t::object_data.
KITE_EXPORT kite_object_t* kite_get_property | ( | kite_object_t * | obj, | |
char * | name | |||
) |
Retrieve the value of a property.
obj | The object to operate on. | |
name | The name of the property to retrieve. |
References KITE_FIND_PROPERTY, kite_reference_object(), and kite_symtab_t::value.
KITE_EXPORT kite_object_t* kite_int_object | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Produce integer object from the given object.
thd | The current thread. | |
obj | The object to operate on. |
References kite_object_t::builtin_data, kite_object_t::floatvalue, kite_object_t::intvalue, kite_new_integer(), kite_new_list(), kite_reference_object(), kite_vm_call_method(), OBJ_BOOLEAN, OBJ_FLOAT, OBJ_INSTANCE, OBJ_INTEGER, OBJ_LIST, OBJ_STRING, kite_object_t::stringvalue, TRUE, and kite_object_t::type.
KITE_EXPORT int kite_list_count | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Find the number of items in a list.
thd | The current thread. | |
obj | The objet to operate on. |
References kite_object_t::builtin_data, kite_object_t::listvalue, OBJ_LIST, and kite_object_t::type.
Referenced by kite_vm_call_constructor(), and kite_vm_call_method().
KITE_EXPORT kite_object_t* kite_list_object | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Produce list object from the given object.
thd | The current thread. | |
obj | The object to operate on. |
References kite_object_t::builtin_data, kite_new_list(), kite_reference_object(), and kite_object_t::listvalue.
Referenced by kite_new_exception().
KITE_EXPORT kite_object_t* kite_new_boolean | ( | kite_thread_t * | thd, | |
int | val | |||
) |
Create a new boolean object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References BOOLEAN_OBJECT, FALSE, kite_dereference_and_load(), kite_reference_object(), and TRUE.
Referenced by kite_boolean_object().
KITE_EXPORT kite_object_t* kite_new_class | ( | kite_thread_t * | thd, | |
kite_object_t * | parent, | |||
char * | name | |||
) |
Create a new Kite class.
thd | The associated thread for this object. | |
parent | The class that this inherits from. | |
name | The new class' name. |
References kite_object_t::builtin_data, FALSE, kite_function_t::funcptr, kite_object_t::funcvalue, kite_object_t::inherit_from, kite_finalize_object(), kite_gc_incremental(), kite_list_add_end(), kite_reference_object(), kite_object_t::name, kite_object_t::object_data, and kite_object_t::type.
Referenced by kite_dereference_and_load(), and kite_new_ident().
KITE_EXPORT kite_object_t* kite_new_exception | ( | kite_thread_t * | thd, | |
char * | name, | |||
char * | message | |||
) |
Create a new exception object.
thd | The thread to associate the exception with. | |
name | The fully-qualified name of the exception (e.g. System.exceptions.FileError) | |
message | The message to associate with the given exception. |
References kite_dereference_and_load(), kite_dereference_object(), kite_list_object(), kite_new_instance_with_constructor(), and kite_new_string().
Referenced by kite_dereference_and_load(), kite_vm_call_method(), and kite_vm_call_operator().
KITE_EXPORT kite_object_t* kite_new_float | ( | kite_thread_t * | thd, | |
double | val | |||
) |
Create a new floating-point object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References FLOAT_OBJECT, and kite_dereference_and_load().
Referenced by kite_float_object().
KITE_EXPORT kite_object_t* kite_new_ident | ( | kite_thread_t * | thd, | |
char * | val | |||
) |
Create a new identifier object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References kite_object_t::builtin_data, kite_symtab_t::global, KITE_FIND_ANY_IN_SYMTAB, kite_new_class(), kite_new_symtab(), kite_symtab_insert(), kite_symtab_t::name, kite_object_t::stringvalue, kite_object_t::type, and kite_symtab_t::value.
Referenced by kite_new_method_bytecode_with_docs(), and kite_new_method_compiled_with_docs().
KITE_EXPORT kite_object_t* kite_new_instance | ( | kite_thread_t * | thd, | |
kite_object_t * | parent | |||
) |
Create a new Kite instance (without initialization)
thd | The associated thread for this object. | |
parent | The class that this instance is associated with. |
References kite_object_t::inherit_from, kite_finalize_object(), kite_gc_incremental(), kite_list_add_end(), kite_reference_object(), kite_object_t::name, kite_object_t::object_data, and kite_object_t::type.
Referenced by kite_new_instance_with_constructor(), kite_new_list(), kite_new_method_bytecode(), kite_new_method_compiled(), kite_new_null(), kite_new_string(), and kite_new_string_with_length().
KITE_EXPORT kite_object_t* kite_new_instance_with_constructor | ( | kite_thread_t * | thd, | |
kite_object_t * | parent, | |||
kite_object_t * | args | |||
) |
Create a new Kite instance (with initialization)
thd | The associated thread for this object. | |
parent | The class that this instance is associated with. | |
args | A list specifying arguments to pass to the constructor. |
References kite_new_instance(), and kite_vm_call_constructor().
Referenced by kite_new_exception().
KITE_EXPORT kite_object_t* kite_new_integer | ( | kite_thread_t * | thd, | |
long | val | |||
) |
Create a new integer object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References INTEGER_OBJECT, and kite_dereference_and_load().
Referenced by kite_handle_signal(), and kite_int_object().
KITE_EXPORT kite_object_t* kite_new_list | ( | kite_thread_t * | thd | ) |
Create a new empty list object.
thd | The associated thread for the object. |
References kite_object_t::builtin_data, kite_dereference_and_load(), kite_new_instance(), LIST_OBJECT, kite_object_t::listvalue, and kite_object_t::type.
Referenced by kite_append_list(), kite_boolean_object(), kite_dereference_and_load(), kite_float_object(), kite_gc_destroy_all(), kite_gc_incremental(), kite_handle_signal(), kite_int_object(), kite_list_object(), kite_new_method_bytecode_with_docs(), kite_new_method_compiled_with_docs(), kite_string_object(), kite_vm_call_method(), and kite_vm_call_operator().
KITE_EXPORT kite_object_t* kite_new_method_bytecode | ( | kite_thread_t * | thd, | |
struct kite_opcode_t * | func, | |||
int | numargs | |||
) |
Create a new method object (based on Kite bytecode).
thd | The associated thread for the object. | |
func | The C function that this method refers to. | |
numargs | The number of arguments this method should take in Kite code. |
References kite_object_t::builtin_data, kite_function_t::funcptr, kite_function_t::functype, kite_object_t::funcvalue, kite_dereference_and_load(), kite_new_instance(), METHOD_OBJECT, kite_function_t::numargs, and kite_object_t::type.
Referenced by kite_new_method_bytecode_with_docs().
KITE_EXPORT kite_object_t* kite_new_method_bytecode_with_docs | ( | kite_thread_t * | thd, | |
struct kite_opcode_t * | func, | |||
char * | desc, | |||
int | numargs, | |||
... | ||||
) |
Create a new method object with documentation strings (based on Kite bytecode).
thd | The associated thread for the object. | |
func | The bytecode that this method refers to. | |
desc | The method's description. | |
numargs | The number of arguments this method should take in Kite code. | |
argname | (for each argument) The name of the argument. | |
argdesc | (for each argument) The description of the argument. |
References kite_append_list(), kite_new_ident(), kite_new_list(), kite_new_method_bytecode(), kite_set_arginfo(), and kite_set_docstring().
KITE_EXPORT kite_object_t* kite_new_method_compiled | ( | kite_thread_t * | thd, | |
kite_compiled_func_t | func, | |||
int | numargs | |||
) |
Create a new method object (based on C-compiled code).
thd | The associated thread for the object. | |
func | The C function that this method refers to. | |
numargs | The number of arguments this method should take in Kite code. |
References kite_object_t::builtin_data, kite_function_t::funcptr, kite_function_t::functype, kite_object_t::funcvalue, kite_dereference_and_load(), kite_new_instance(), METHOD_OBJECT, kite_function_t::numargs, and kite_object_t::type.
Referenced by kite_new_method_compiled_with_docs().
KITE_EXPORT kite_object_t* kite_new_method_compiled_with_docs | ( | kite_thread_t * | thd, | |
kite_compiled_func_t | func, | |||
char * | desc, | |||
int | numargs, | |||
... | ||||
) |
Create a new method object with documentation strings (based on C-compiled code).
thd | The associated thread for the object. | |
func | The C function that this method refers to. | |
desc | The method's description. | |
numargs | The number of arguments this method should take in Kite code. | |
argname | (for each argument) The name of the argument. | |
argdesc | (for each argument) The description of the argument. |
References kite_append_list(), kite_new_ident(), kite_new_list(), kite_new_method_compiled(), kite_set_arginfo(), and kite_set_docstring().
KITE_EXPORT kite_object_t* kite_new_null | ( | kite_thread_t * | thd | ) |
Create a new null object.
thd | The associated thread for the object. |
References kite_dereference_and_load(), kite_new_instance(), kite_reference_object(), NULL_OBJECT, and kite_object_t::type.
Referenced by kite_handle_signal().
KITE_EXPORT kite_object_t* kite_new_string | ( | kite_thread_t * | thd, | |
char * | val | |||
) |
Create a new string object.
thd | The associated thread for the object. | |
val | The value to associate with the object. |
References kite_object_t::builtin_data, kite_dereference_and_load(), kite_new_instance(), STRING_OBJECT, kite_object_t::stringvalue, and kite_object_t::type.
Referenced by kite_new_exception(), kite_object_name(), kite_string_object(), and kite_vm_call_method().
KITE_EXPORT kite_object_t* kite_new_string_with_length | ( | kite_thread_t * | thd, | |
char * | val, | |||
int | length | |||
) |
Create a new string object (with given length).
thd | The associated thread for the object. | |
val | The value to associate with the object. | |
length | The length of the string. |
References kite_object_t::builtin_data, kite_dereference_and_load(), KITE_GET_STRING_VALUE, kite_new_instance(), STRING_OBJECT, kite_object_t::stringvalue, and kite_object_t::type.
kite_symtab_t* kite_new_symtab | ( | ) |
KITE_EXPORT kite_object_t* kite_object_name | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Find the fully-qualified name of the object.
thd | The current thread. | |
obj | The object to operate on. |
References kite_object_t::inherit_from, kite_new_string(), kite_object_t::name, and kite_object_t::object_data.
Referenced by kite_string_object().
KITE_EXPORT kite_object_t* kite_reference_object | ( | kite_object_t * | obj | ) |
Reference object.
obj | The object to dereference. |
References kite_object_t::inherit_from, kite_list_add_end(), kite_list_remove(), kite_reference_object(), and kite_object_t::object_data.
Referenced by kite_add_method(), kite_append_list(), kite_boolean_object(), kite_copy_symtab(), kite_copy_symtab_elements(), kite_float_object(), kite_get_property(), kite_int_object(), kite_list_object(), kite_new_boolean(), kite_new_class(), kite_new_instance(), kite_new_null(), kite_reference_object(), kite_set_arginfo(), kite_set_property(), kite_string_object(), and kite_vm_call_method().
KITE_EXPORT void kite_remove_method | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
char * | name, | |||
int | numargs | |||
) |
Removes method from the given object.
thd | The current thread. | |
obj | The object to operate on. | |
name | The name of the method to remove. | |
numargs | The number of arguments of the method to remove. |
References kite_symtab_remove(), kite_object_t::object_data, and kite_object_t::properties.
Referenced by kite_remove_operator().
KITE_EXPORT void kite_remove_operator | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
int | op | |||
) |
Removes operator from the given object.
thd | The current thread. | |
obj | The object to operate on. | |
op | The operator to remove (from kite_operators) |
References kite_symtab_t::global, KITE_FIND_ANY_IN_SYMTAB, kite_remove_method(), kite_object_t::object_data, and kite_object_t::properties.
Referenced by kite_add_operator().
KITE_EXPORT void kite_remove_property | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
char * | name, | |||
int | global | |||
) |
Removes property from the given object.
thd | The current thread. | |
obj | The object to operate on. | |
name | The name of the property to remove. | |
global | 1 for global properties, 0 otherwise. |
References kite_symtab_remove(), kite_object_t::object_data, and kite_object_t::properties.
KITE_EXPORT void kite_set_arginfo | ( | kite_object_t * | obj, | |
kite_object_t * | arginfo | |||
) |
Sets the argument information for a given method.
obj | The method to operate on. | |
arginfo | A list of arguments. Each element is an identifier containing a name, and the documentation string associated with each identifier contains the description. |
References kite_function_t::arginfo, kite_object_t::builtin_data, kite_object_t::funcvalue, and kite_reference_object().
Referenced by kite_new_method_bytecode_with_docs(), and kite_new_method_compiled_with_docs().
KITE_EXPORT void kite_set_docstring | ( | kite_object_t * | obj, | |
char * | str | |||
) |
Sets the documentation string for a given object.
obj | The object to operate on. | |
str | The documentation string to set. |
References kite_object_t::docstring, and kite_object_t::object_data.
Referenced by kite_new_method_bytecode_with_docs(), and kite_new_method_compiled_with_docs().
KITE_EXPORT void kite_set_dylib_path | ( | char * | path | ) |
Set the dynamic library path.
path | The new dynamic library path (separated by colons). |
References kite_dylib_path.
KITE_EXPORT void kite_set_property | ( | kite_thread_t * | thd, | |
kite_object_t * | obj, | |||
char * | name, | |||
kite_object_t * | value | |||
) |
Sets property to the given object.
thd | The current thread. | |
obj | The object to operate on. | |
name | The name of the property to set. | |
value | The object to set the property to. |
References kite_symtab_t::global, kite_object_t::inherit_from, kite_add_property(), kite_dereference_object(), KITE_FIND_PROPERTY, kite_reference_object(), kite_set_property(), OBJ_BOOLEAN, OBJ_FLOAT, OBJ_INTEGER, kite_object_t::object_data, kite_object_t::type, and kite_symtab_t::value.
Referenced by kite_dereference_and_load(), and kite_set_property().
KITE_EXPORT kite_object_t* kite_string_object | ( | kite_thread_t * | thd, | |
kite_object_t * | obj | |||
) |
Produce string object from the given object.
thd | The current thread. | |
obj | The object to operate on. |
References kite_object_t::builtin_data, kite_object_t::floatvalue, kite_object_t::intvalue, kite_new_list(), kite_new_string(), kite_object_name(), kite_reference_object(), kite_vm_call_method(), OBJ_BOOLEAN, OBJ_FLOAT, OBJ_INSTANCE, OBJ_INTEGER, OBJ_LIST, OBJ_NULL, OBJ_STRING, TRUE, and kite_object_t::type.
KITE_EXPORT void kite_symtab_insert | ( | kite_thread_t * | thd, | |
kite_symtab_t ** | symt, | |||
kite_symtab_t * | entry | |||
) |
Insert entry into symbol table.
thd | The current thread. | |
symt | The symbol table to insert into. | |
entry | The entry to insert. |
References kite_symtab_t::global, kite_dereference_object(), kite_symtab_insert(), and kite_symtab_t::name.
Referenced by kite_add_method(), kite_add_property(), kite_copy_symtab_elements(), kite_loader_register(), kite_new_ident(), and kite_symtab_insert().
KITE_EXPORT void kite_symtab_remove | ( | kite_thread_t * | thd, | |
kite_symtab_t ** | symt, | |||
char * | name, | |||
int | num | |||
) |
Remove entry from symbol table.
thd | The current thread. | |
[in,out] | symt | The symbol table to remove from. |
name | The name of the entry to remove. | |
num | The number of arguments (or global vs non-global property) to remove. |
References kite_symtab_t::docstring, kite_dereference_object(), kite_symtab_remove(), kite_symtab_t::name, and kite_symtab_t::value.
Referenced by kite_remove_method(), kite_remove_property(), and kite_symtab_remove().