root/CRB_dev.h
/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- CRB_FALSE
- CRB_TRUE
- CRB_Boolean
- CRB_BOOLEAN_VALUE
- CRB_INT_VALUE
- CRB_DOUBLE_VALUE
- CRB_STRING_VALUE
- CRB_NATIVE_POINTER_VALUE
- CRB_NULL_VALUE
- CRB_ARRAY_VALUE
- CRB_ASSOC_VALUE
- CRB_CLOSURE_VALUE
- CRB_FAKE_METHOD_VALUE
- CRB_ValueType
- CRB_Closure
- CRB_FakeMethod
- CRB_Value
- CRB_INT_MESSAGE_ARGUMENT
- CRB_DOUBLE_MESSAGE_ARGUMENT
- CRB_STRING_MESSAGE_ARGUMENT
- CRB_CHARACTER_MESSAGE_ARGUMENT
- CRB_POINTER_MESSAGE_ARGUMENT
- CRB_MESSAGE_ARGUMENT_END
- CRB_MessageArgumentType
- CRB_MessageFormat
- CRB_NativeLibInfo
- CRB_NativePointerInfo
#ifndef PUBLIC_CRB_DEV_H_INCLUDED
#define PUBLIC_CRB_DEV_H_INCLUDED
#define PRIVATE_CROWBAR_H_INCLUDED
#include "CRB.h"
typedef enum {
CRB_FALSE = 0,
CRB_TRUE = 1
} CRB_Boolean;
typedef struct CRB_Object_tag CRB_Object;
typedef struct CRB_Array_tag CRB_Array;
typedef struct CRB_String_tag CRB_String;
typedef struct CRB_Assoc_tag CRB_Assoc;
typedef struct CRB_FunctionDefinition_tag CRB_FunctionDefinition;
typedef struct CRB_LocalEnvironment_tag CRB_LocalEnvironment;
typedef enum {
CRB_BOOLEAN_VALUE = 1,
CRB_INT_VALUE,
CRB_DOUBLE_VALUE,
CRB_STRING_VALUE,
CRB_NATIVE_POINTER_VALUE,
CRB_NULL_VALUE,
CRB_ARRAY_VALUE,
CRB_ASSOC_VALUE,
CRB_CLOSURE_VALUE,
CRB_FAKE_METHOD_VALUE
} CRB_ValueType;
typedef struct {
CRB_FunctionDefinition *function;
CRB_Object *environment; /* CRB_ScopeChain */
} CRB_Closure;
typedef struct {
char *method_name;
CRB_Object *object;
} CRB_FakeMethod;
typedef struct {
CRB_ValueType type;
union {
CRB_Boolean boolean_value;
int int_value;
double double_value;
CRB_Object *object;
CRB_Closure closure;
CRB_FakeMethod fake_method;
} u;
} CRB_Value;
typedef enum {
CRB_INT_MESSAGE_ARGUMENT = 1,
CRB_DOUBLE_MESSAGE_ARGUMENT,
CRB_STRING_MESSAGE_ARGUMENT,
CRB_CHARACTER_MESSAGE_ARGUMENT,
CRB_POINTER_MESSAGE_ARGUMENT,
CRB_MESSAGE_ARGUMENT_END
} CRB_MessageArgumentType;
typedef struct {
char *format;
} CRB_MessageFormat;
typedef struct {
CRB_MessageFormat *message_format;
} CRB_NativeLibInfo;
typedef void CRB_NativePointerFinalizeProc(CRB_Interpreter *inter,
CRB_Object *obj);
typedef struct {
char *name;
CRB_NativePointerFinalizeProc *finalizer;
} CRB_NativePointerInfo;
typedef CRB_Value CRB_NativeFunctionProc(CRB_Interpreter *interpreter,
CRB_LocalEnvironment *env,
int arg_count, CRB_Value *args);
/* interface.c */
void CRB_add_native_function(CRB_Interpreter *interpreter,
char *name, CRB_NativeFunctionProc *proc);
void CRB_push_value(CRB_Interpreter *inter, CRB_Value *value);
CRB_Value CRB_pop_value(CRB_Interpreter *inter);
void CRB_shrink_stack(CRB_Interpreter *inter, int shrink_size);
/* nativeif.c */
char *CRB_object_get_string(CRB_Object *obj);
void *CRB_object_get_native_pointer(CRB_Object *obj);
void CRB_object_set_native_pointer(CRB_Object *obj, void *p);
CRB_Value *CRB_array_get(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
CRB_Object *obj, int index);
void CRB_array_set(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
CRB_Object *obj, int index, CRB_Value *value);
/* heap.c */
CRB_Object *CRB_create_crowbar_string(CRB_Interpreter *inter, char *str);
CRB_Object *CRB_create_array(CRB_Interpreter *inter, int size);
CRB_Object *CRB_create_assoc(CRB_Interpreter *inter);
void CRB_array_add(CRB_Interpreter *inter, CRB_Object *obj, CRB_Value *v);
void CRB_array_resize(CRB_Interpreter *inter, CRB_Object *obj, int new_size);
void CRB_array_insert(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
CRB_Object *obj, int pos,
CRB_Value *v, int line_number);
void CRB_array_remove(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
CRB_Object *obj, int pos, int line_number);
CRB_Object *CRB_literal_to_crb_string(CRB_Interpreter *inter, char *str);
CRB_Object *CRB_string_substr(CRB_Interpreter *inter,
CRB_LocalEnvironment *env,
CRB_Object *str,
int form, int len, int line_number);
void CRB_add_assoc_member(CRB_Interpreter *inter, CRB_Object *assoc,
char *name, CRB_Value *value);
CRB_Value *CRB_search_assoc_member(CRB_Object *assoc, char *member_name);
CRB_Object *CRB_create_native_pointer(CRB_Interpreter *inter,
void *pointer,
CRB_NativePointerInfo *info);
CRB_Boolean CRB_check_native_pointer_type(CRB_Object *native_pointer,
CRB_NativePointerInfo *info);
CRB_Object *CRB_create_exception(CRB_Interpreter *inter,
CRB_LocalEnvironment *env,
CRB_Object *message, int line_number);
/* util.c */
char *CRB_value_to_string(CRB_Value *value);
char *CRB_get_type_name(CRB_ValueType type);
char *CRB_get_object_type_name(CRB_Object *obj);
/* error.c */
void CRB_error(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
CRB_NativeLibInfo *info, int line_number,
int error_code, ...);
void
CRB_check_argument_count_func(CRB_Interpreter *inter,
CRB_LocalEnvironment *env,
int line_number, int arg_count,
int expected_count);
#define CRB_check_argument_count(inter, env, arg_count, expected_count)\
(CRB_check_argument_count_func(inter, env, __LINE__, \
arg_count, expected_count))
#endif /* PUBLIC_CRB_DEV_H_INCLUDED */