objs/kite_object.h File Reference

#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_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)   ((v)->builtin_data.intvalue)
#define KITE_GET_FLOAT(v)   ((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_symtab_t kite_symtab_t

Functions

KITE_EXPORT kite_object_tkite_new_null (kite_thread_t *thd)
KITE_EXPORT kite_object_tkite_new_integer (kite_thread_t *thd, long val)
KITE_EXPORT kite_object_tkite_new_float (kite_thread_t *thd, double val)
KITE_EXPORT kite_object_tkite_new_string (kite_thread_t *thd, char *val)
KITE_EXPORT kite_object_tkite_new_string_with_length (kite_thread_t *thd, char *val, int length)
KITE_EXPORT kite_object_tkite_new_ident (kite_thread_t *thd, char *val)
KITE_EXPORT kite_object_tkite_new_boolean (kite_thread_t *thd, int val)
KITE_EXPORT kite_object_tkite_new_list (kite_thread_t *thd)
KITE_EXPORT kite_object_tkite_new_method_compiled (kite_thread_t *thd, kite_compiled_func_t func, int numargs)
KITE_EXPORT kite_object_tkite_new_method_compiled_with_docs (kite_thread_t *thd, kite_compiled_func_t func, char *desc, int numargs,...)
KITE_EXPORT kite_object_tkite_new_method_bytecode (kite_thread_t *thd, kite_opcode_t *func, int numargs)
KITE_EXPORT kite_object_tkite_new_method_bytecode_with_docs (kite_thread_t *thd, kite_opcode_t *func, char *desc, int numargs,...)
KITE_EXPORT kite_object_tkite_new_class (kite_thread_t *thd, kite_object_t *parent, char *name)
KITE_EXPORT kite_object_tkite_new_instance (kite_thread_t *thd, kite_object_t *parent)
KITE_EXPORT kite_object_tkite_new_instance_with_constructor (kite_thread_t *thd, kite_object_t *parent, kite_object_t *args)
KITE_EXPORT kite_object_tkite_new_exception (kite_thread_t *thd, char *name, char *message)
KITE_EXPORT void kite_dereference_object (kite_object_t *obj)
KITE_EXPORT kite_object_tkite_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_tkite_get_property (kite_object_t *obj, char *name)
KITE_EXPORT kite_object_tkite_dereference_and_load (kite_thread_t *thd, char *name)
KITE_EXPORT void kite_set_dylib_path (char *path)
kite_symtab_tkite_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_tkite_object_name (kite_thread_t *thd, kite_object_t *obj)
KITE_EXPORT kite_object_tkite_boolean_object (kite_thread_t *thd, kite_object_t *obj)
KITE_EXPORT kite_object_tkite_string_object (kite_thread_t *thd, kite_object_t *obj)
KITE_EXPORT kite_object_tkite_int_object (kite_thread_t *thd, kite_object_t *obj)
KITE_EXPORT kite_object_tkite_float_object (kite_thread_t *thd, kite_object_t *obj)
KITE_EXPORT kite_object_tkite_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 Documentation

#define DYLIB_EXTENSION   ".so"

#define FALSE   0

#define KITE_CLASS_METHOD ( name   ) 

Value:

void name(kite_thread_t *thd, kite_object_t *this, \
               kite_object_t *args)
Define a Kite class method's name and prototype.
Parameters:
name The C function name to give this method.

#define KITE_EXPORT

#define KITE_FIND_ANY_IN_SYMTAB ( ret,
symtab,
 ) 

Value:

{ \
        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.
Parameters:
[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.
See also:
struct kite_symtab_t

Referenced by kite_exists_operator(), kite_remove_operator(), kite_vm_call_constructor(), and kite_vm_call_operator().

#define KITE_FIND_IN_SYMTAB ( ret,
symtab,
n,
num   ) 

Value:

{ \
        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.
Parameters:
[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.
See also:
struct kite_symtab_t

#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.

Parameters:
[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.
See also:
KITE_FIND_IN_SYMTAB

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.

Parameters:
[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.
See also:
KITE_FIND_IN_SYMTAB

struct kite_symtab_t

Referenced by kite_dereference_and_load(), kite_exists_property(), kite_get_property(), kite_set_property(), and kite_vm_execute_exception().

#define KITE_GET_FLOAT (  )     ((v)->builtin_data.floatvalue)

Retrieves floating-point value for a Kite object.

Parameters:
v The Kite object to retrieve number from.
Warning:
This is only useful for objects of type OBJ_FLOAT No error checking is performed.

#define KITE_GET_INTEGER (  )     ((v)->builtin_data.intvalue)

Retrieves integer value for a Kite object.

Parameters:
v The Kite object to retrieve integer from.
Warning:
This is only useful for objects of types OBJ_INTEGER and OBJ_BOOLEAN. No error checking is performed.

#define KITE_GET_LIST_ELEMENT ( ret,
obj,
 ) 

Value:

{ \
        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.
Parameters:
[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,
 )     KITE_GET_LIST_ELEMENT(ret, args, n)

Retrieve method argument passed in from code.

Parameters:
[out] ret The kite_object_t* to place the result in, or NULL if argument does not exist.
n The argument number to retrieve.

Referenced by KITE_CLASS_METHOD().

#define KITE_GET_OBJECT_TYPE ( val   )     ((val)->type)

Gets the type of the given Kite object.

Parameters:
val The Kite object to operate on.
Returns:
The enum corresponding to the given object's type.

#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.

Parameters:
val The Kite object to operate on.
Returns:
The parent object.

#define KITE_GET_STRING_LENGTH (  )     ((v)->builtin_data.stringvalue.length)

Retrieves string length for a Kite object.

Parameters:
v The Kite object to retrieve string from.
Warning:
This is only useful for objects of type OBJ_STRING and OBJ_IDENT. No error checking is performed.

#define KITE_GET_STRING_VALUE (  )     ((v)->builtin_data.stringvalue.string)

Retrieves string value for a Kite object.

Parameters:
v The Kite object to retrieve string from.
Warning:
This is only useful for objects of type OBJ_STRING and OBJ_IDENT. No error checking is performed.

Referenced by kite_new_string_with_length().

#define KITE_IS_TYPE ( val,
 )     ((val)->type == t)

Checks to determine whether an object is of a given type.

Parameters:
val The Kite object to check.
t The type to check for.
Returns:
TRUE if the type of the given object is equal to t, FALSE otherwise.

#define KITE_LIST_CAR (  )     ((v)->builtin_data.listvalue.car)

Retrieve the head of a list.

Parameters:
v The list to operate on.
Warning:
This is only useful for objects of type OBJ_LIST. No error checking is performed.

#define KITE_LIST_CDR (  )     ((v)->builtin_data.listvalue.cdr)

Retrieve the tail of a list.

Parameters:
v The list to operate on.
Warning:
This is only useful for objects of type OBJ_LIST. No error checking is performed.

#define KITE_MODULE_INITIALIZER ( name   ) 

Value:

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.
Parameters:
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.

Parameters:
name The name of the module.
See also:
KITE_MODULE_INITIALIZER

#define KITE_NO_ARGS   (void)args;

Helper macro to eliminate warnings about "args" not being used.

#define KITE_REMOVE_LIST_ELEMENT ( list,
 ) 

Value:

{ \
        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.
Parameters:
list The list to operate on.
n The list index to replace/insert to.

#define KITE_REPLACE_LIST_ELEMENT ( list,
n,
obj   ) 

Value:

{ \
        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.
Parameters:
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,
 )     KITE_GET_FLOAT(v) = i

Sets floating-point value for a Kite object.

Parameters:
v The Kite object to operate on.
i The value to assign to the object.
Warning:
This is only useful for objects of type OBJ_FLOAT. No error checking is performed.

#define KITE_SET_INTEGER ( v,
 )     KITE_GET_INTEGER(v) = i

Sets integer value for a Kite object.

Parameters:
v The Kite object to operate on.
i The value to assign to the object.
Warning:
This is only useful for objects of type OBJ_INTEGER and OBJ_BOOLEAN. No error checking is performed.

#define KITE_THIS_NOT_USED   (void)this;

Helper macro to eliminate warnings about "this" not being used.

#define TRUE   1


Typedef Documentation

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).

Parameters:
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_symtab_t kite_symtab_t


Function Documentation

KITE_EXPORT void kite_add_method ( kite_thread_t thd,
kite_object_t obj,
char *  name,
kite_object_t method 
)

Add method to object.

Parameters:
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::left, kite_symtab_t::name, kite_function_t::numargs, kite_object_t::object_data, kite_object_t::properties, kite_symtab_t::right, and kite_symtab_t::value.

Referenced by kite_add_operator(), and kite_new_vm().

KITE_EXPORT void kite_add_operator ( kite_thread_t thd,
kite_object_t obj,
int  op,
kite_object_t method 
)

Add operator to object.

Parameters:
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.
See also:
enum kite_operators

References kite_add_method(), kite_remove_operator(), and OP_TO_METHOD.

KITE_EXPORT void kite_add_property ( kite_thread_t thd,
kite_object_t obj,
char *  name,
int  global,
char *  doc 
)

Add property to object.

Parameters:
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::left, kite_symtab_t::name, kite_object_t::object_data, kite_object_t::properties, kite_symtab_t::right, 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.

Parameters:
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.

Parameters:
thd The current thread.
obj The object to operate on.
Returns:
A new Kite object with the proper Boolean value.
Note:
Equivalent to executing obj|bool in Kite.

References kite_object_t::builtin_data, FALSE, kite_object_t::floatvalue, kite_object_t::intvalue, kite_new_boolean(), kite_new_list(), kite_reference_object(), kite_vm_call_method(), kite_vm_pop, kite_object_t::listvalue, 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.

Parameters:
[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::left, kite_symtab_t::name, kite_symtab_t::right, 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.

Parameters:
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::left, kite_symtab_t::name, kite_object_t::parent, kite_symtab_t::right, 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.

Parameters:
thd The current thread.
name The fully-qualified name of the module to load.
Returns:
The module itself, or NULL if a problem occurred.
Note:
If a problem occurred, thd->exception will be non-NULL.

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(), kite_vm_t::root_package, TRUE, kite_symtab_t::value, and kite_thread_t::vm.

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_new_vm(), kite_vm_compile_from_file(), and kite_vm_compile_from_string().

KITE_EXPORT void kite_dereference_object ( kite_object_t obj  ) 

Dereference object.

Parameters:
obj The object to dereference.
Note:
This has no effect if Kite was compiled with GC support. However, do not rely on the GC existing in a user's installed version. This is important to ensure that objects are freed appropriately and not leaked.

References kite_vm_t::gc_begin, kite_vm_t::gc_end, kite_object_t::gc_entry, kite_list_add_begin(), kite_list_remove(), kite_object_t::owner_thread, kite_object_t::refcount, and kite_thread_t::vm.

Referenced by KITE_CLASS_METHOD(), kite_destruct_object_nofree(), kite_destruct_symtab(), kite_handle_signal(), kite_new_exception(), kite_set_property(), kite_symtab_insert(), kite_symtab_remove(), kite_vm_call_method(), kite_vm_execute(), kite_vm_execute_exception(), and kite_vm_execute_user_method().

KITE_EXPORT void kite_destruct_symtab ( kite_thread_t thd,
kite_symtab_t **  symt,
int  ref 
)

Destroy symbol table.

Parameters:
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(), kite_destruct_symtab(), kite_free_vm(), and kite_vm_call_object().

KITE_EXPORT int kite_exists_method ( kite_object_t obj,
char *  name 
)

Determines the existance of a method.

Parameters:
obj The object to operate on.
name The name of the method to check.
Returns:
TRUE if exists, FALSE otherwise.

References KITE_FIND_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.

Parameters:
obj The object to operate on.
op The operator to check for (from kite_operators)
Returns:
TRUE if exists, FALSE otherwise.
See also:
enum kite_operators

References KITE_FIND_ANY_IN_SYMTAB, kite_object_t::object_data, OP_TO_METHOD, and kite_object_t::properties.

KITE_EXPORT int kite_exists_property ( kite_object_t obj,
char *  name 
)

Determines the existance of a property.

Parameters:
obj The object to operate on.
name The name of the property to check.
Returns:
TRUE if exists, FALSE otherwise.

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.

Parameters:
thd The current thread.
obj The object to operate on.
Returns:
A new Kite object with the proper floating-point value.
Note:
Equivalent to executing obj|float in Kite.

References kite_object_t::builtin_data, kite_object_t::intvalue, kite_new_float(), kite_new_list(), kite_reference_object(), kite_vm_call_method(), kite_vm_pop, 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.

Parameters:
obj The object to operate on.
Returns:
The object's documentation string (or NULL if not provided).
Warning:
Do not modify the provided string.

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.

Parameters:
obj The object to operate on.
name The name of the property to retrieve.
Returns:
The object stored within the property, or NULL if the property does not exist.

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.

Parameters:
thd The current thread.
obj The object to operate on.
Returns:
A new Kite object with the proper integer value.
Note:
Equivalent to executing obj|int in Kite.

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(), kite_vm_pop, 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.

Parameters:
thd The current thread.
obj The objet to operate on.
Returns:
The number of items in the list.

References kite_object_t::builtin_data, kite_object_t::listvalue, 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.

Parameters:
thd The current thread.
obj The object to operate on.
Returns:
A new Kite list with a single element: the given object.

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.

Parameters:
thd The associated thread for the object.
val The value to associate with the object.
Returns:
The new object.

References BOOLEAN_OBJECT, kite_object_t::builtin_data, FALSE, kite_vm_t::false_cached, kite_object_t::intvalue, kite_dereference_and_load(), kite_new_instance(), kite_reference_object(), kite_object_t::shareable, TRUE, kite_vm_t::true_cached, kite_object_t::type, and kite_thread_t::vm.

Referenced by kite_boolean_object(), and kite_new_vm().

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_exception ( kite_thread_t thd,
char *  name,
char *  message 
)

Create a new exception object.

Parameters:
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.
Returns:
The new object.

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.

Parameters:
thd The associated thread for the object.
val The value to associate with the object.
Returns:
The new object.

References kite_object_t::builtin_data, FLOAT_OBJECT, kite_object_t::floatvalue, kite_dereference_and_load(), kite_new_instance(), kite_object_t::shareable, and kite_object_t::type.

Referenced by kite_float_object().

KITE_EXPORT kite_object_t* kite_new_ident ( kite_thread_t thd,
char *  val 
)

Create a new identifier object.

Parameters:
thd The associated thread for the object.
val The value to associate with the object.
Returns:
The new object.

References kite_object_t::builtin_data, kite_new_class(), kite_object_t::shareable, kite_object_t::stringvalue, and kite_object_t::type.

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 
)

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)

Parameters:
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.
Returns:
The new object.
Note:
thd->exception will contain an exception object if the constructor fails.
See also:
struct kite_thread_t

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.

Parameters:
thd The associated thread for the object.
val The value to associate with the object.
Returns:
The new object.

References kite_object_t::builtin_data, kite_vm_t::int_cached, INTEGER_OBJECT, kite_object_t::intvalue, kite_dereference_and_load(), kite_new_instance(), kite_object_t::shareable, kite_object_t::type, and kite_thread_t::vm.

Referenced by kite_handle_signal(), and kite_int_object().

KITE_EXPORT kite_object_t* kite_new_list ( kite_thread_t thd  ) 

KITE_EXPORT kite_object_t* kite_new_method_bytecode ( kite_thread_t thd,
kite_opcode_t func,
int  numargs 
)

Create a new method object (based on Kite bytecode).

Parameters:
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.
Returns:
The new object.

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, kite_object_t::shareable, kite_function_t::this, 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,
kite_opcode_t func,
char *  desc,
int  numargs,
  ... 
)

Create a new method object with documentation strings (based on Kite bytecode).

Parameters:
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.
Returns:
The new object.

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).

Parameters:
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.
Returns:
The new object.

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, kite_object_t::shareable, kite_function_t::this, 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).

Parameters:
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.
Returns:
The new object.

References kite_append_list(), kite_new_ident(), kite_new_list(), kite_new_method_compiled(), kite_set_arginfo(), and kite_set_docstring().

Referenced by kite_new_vm().

KITE_EXPORT kite_object_t* kite_new_null ( kite_thread_t thd  ) 

Create a new null object.

Parameters:
thd The associated thread for the object.
Returns:
The new object.

References kite_dereference_and_load(), kite_new_instance(), kite_reference_object(), kite_vm_t::null_cached, NULL_OBJECT, kite_object_t::shareable, kite_object_t::type, and kite_thread_t::vm.

Referenced by kite_handle_signal(), kite_new_vm(), and kite_vm_execute().

KITE_EXPORT kite_object_t* kite_new_string ( kite_thread_t thd,
char *  val 
)

Create a new string object.

Parameters:
thd The associated thread for the object.
val The value to associate with the object.
Returns:
The new object.

References kite_object_t::builtin_data, kite_dereference_and_load(), kite_new_instance(), kite_object_t::shareable, 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).

Parameters:
thd The associated thread for the object.
val The value to associate with the object.
length The length of the string.
Returns:
The new object.

References kite_object_t::builtin_data, kite_dereference_and_load(), KITE_GET_STRING_VALUE, kite_new_instance(), kite_object_t::shareable, STRING_OBJECT, kite_object_t::stringvalue, and kite_object_t::type.

kite_symtab_t* kite_new_symtab (  ) 

Create a new symbol table object.

Returns:
Symbol table object.

KITE_EXPORT kite_object_t* kite_object_name ( kite_thread_t thd,
kite_object_t obj 
)

Find the fully-qualified name of the object.

Parameters:
thd The current thread.
obj The object to operate on.
Returns:
A new Kite object with the fully qualified name.

References kite_object_t::inherit_from, kite_new_string(), kite_object_t::name, and kite_object_t::object_data.

Referenced by kite_string_object(), and kite_vm_execute_exception().

KITE_EXPORT kite_object_t* kite_reference_object ( kite_object_t obj  ) 

KITE_EXPORT void kite_remove_method ( kite_thread_t thd,
kite_object_t obj,
char *  name,
int  numargs 
)

Removes method from the given object.

Parameters:
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.

Parameters:
thd The current thread.
obj The object to operate on.
op The operator to remove (from kite_operators)
See also:
enum kite_operators

References kite_symtab_t::global, KITE_FIND_ANY_IN_SYMTAB, kite_remove_method(), kite_object_t::object_data, OP_TO_METHOD, 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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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(), kite_object_t::object_data, kite_object_t::parent, 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.

Parameters:
thd The current thread.
obj The object to operate on.
Returns:
A new Kite object with the proper string value.
Note:
Equivalent to executing obj|str in Kite.

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(), kite_vm_pop, 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.

Parameters:
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(), kite_symtab_t::left, kite_symtab_t::name, and kite_symtab_t::right.

Referenced by kite_add_method(), kite_add_property(), kite_copy_symtab_elements(), kite_loader_register(), kite_symtab_insert(), and kite_vm_call_object().

KITE_EXPORT void kite_symtab_remove ( kite_thread_t thd,
kite_symtab_t **  symt,
char *  name,
int  num 
)

Remove entry from symbol table.

Parameters:
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::left, kite_symtab_t::name, kite_symtab_t::right, and kite_symtab_t::value.

Referenced by kite_remove_method(), kite_remove_property(), and kite_symtab_remove().


Generated on Sun Feb 8 19:42:48 2009 for Kite by  doxygen 1.5.6