objs/kite_obj_create.c File Reference

#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <dlfcn.h>
#include "kite_object.h"
#include "kite_gc.h"

Defines

#define NULL_OBJECT   "System.null"
#define INTEGER_OBJECT   "System.integer"
#define FLOAT_OBJECT   "System.float"
#define STRING_OBJECT   "System.string"
#define LIST_OBJECT   "System.list"
#define METHOD_OBJECT   "System.method"
#define BOOLEAN_OBJECT   "System.boolean"

Functions

kite_object_tkite_new_null (kite_thread_t *thd)
kite_object_tkite_new_integer (kite_thread_t *thd, long val)
kite_object_tkite_new_float (kite_thread_t *thd, double val)
kite_object_tkite_new_string (kite_thread_t *thd, char *str)
kite_object_tkite_new_string_with_length (kite_thread_t *thd, char *str, int len)
kite_object_tkite_new_ident (kite_thread_t *thd, char *str)
kite_object_tkite_new_list (kite_thread_t *thd)
kite_object_tkite_new_boolean (kite_thread_t *thd, int val)
kite_object_tkite_new_method_compiled (kite_thread_t *thd, kite_compiled_func_t ptr, int numargs)
kite_object_tkite_new_method_compiled_with_docs (kite_thread_t *thd, kite_compiled_func_t ptr, char *doc, int numargs,...)
kite_object_tkite_new_method_bytecode (kite_thread_t *thd, kite_opcode_t *ptr, int numargs)
kite_object_tkite_new_method_bytecode_with_docs (kite_thread_t *thd, kite_opcode_t *ptr, char *doc, int numargs,...)
kite_object_tkite_new_class (kite_thread_t *thd, kite_object_t *inherits, char *name)
kite_object_tkite_new_instance (kite_thread_t *thd, kite_object_t *class)
kite_object_tkite_new_instance_with_constructor (kite_thread_t *thd, kite_object_t *class, kite_object_t *args)
kite_object_tkite_new_exception (kite_thread_t *thd, char *name, char *msg)
void kite_destruct_object_nofree (kite_thread_t *thd, kite_object_t **obj, int r)
void kite_finalize_object (void *obj, void *cd)
void kite_destruct_object (kite_thread_t *thd, kite_object_t **obj, int r)

Define Documentation

#define BOOLEAN_OBJECT   "System.boolean"

Referenced by kite_new_boolean().

#define FLOAT_OBJECT   "System.float"

Referenced by kite_new_float().

#define INTEGER_OBJECT   "System.integer"

Referenced by kite_new_integer().

#define LIST_OBJECT   "System.list"

Referenced by kite_new_list().

#define METHOD_OBJECT   "System.method"

#define NULL_OBJECT   "System.null"

Referenced by kite_new_null().

#define STRING_OBJECT   "System.string"


Function Documentation

void kite_destruct_object ( kite_thread_t ,
kite_object_t **  ,
int   
)

void kite_destruct_object_nofree ( kite_thread_t ,
kite_object_t **  ,
int   
)

void kite_finalize_object ( void *  ,
void *   
)

Destroy object.

References kite_destruct_object(), and kite_object_t::owner_thread.

Referenced by kite_new_class(), and kite_new_instance().

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_object_t* kite_new_class ( kite_thread_t thd,
kite_object_t parent,
char *  name 
)

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_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_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_object_t* kite_new_instance ( kite_thread_t thd,
kite_object_t parent 
)

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_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_object_t* kite_new_list ( kite_thread_t thd  ) 

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


Generated on Mon Apr 13 23:02:00 2009 for Kite by  doxygen 1.5.6