rev 290 - in trunk: include/prothon modules/File modules/Re src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-06 03:56:29 -0400 (Tue, 06 Apr 2004)
New Revision: 290
Modified:
trunk/include/prothon/prothon.h
trunk/include/prothon/prothon_dll.h
trunk/modules/File/File.c
trunk/modules/Re/Re.c
trunk/src/argproc.c
trunk/src/builtins-core.c
trunk/src/builtins-dict.c
trunk/src/builtins-float.c
trunk/src/builtins-int.c
trunk/src/builtins-list.c
trunk/src/builtins-string.c
trunk/src/builtins-tuple.c
trunk/src/init.pth
trunk/src/interp.c
trunk/src/main.c
trunk/src/memory_mgr.c
trunk/src/object.c
trunk/src/object.h
trunk/src/parser_routines.c
trunk/src/symbol.c
trunk/src/sys.c
Log:
set defaults for object access levels, set File access off
for Guest access, set console access to user2,
set running file access to user2
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/include/prothon/prothon.h 2004-04-06 07:56:29 UTC (rev 290)
@@ -83,12 +83,12 @@
//**************************** DEBUG DEFINITIONS *********************************
-#define DEBUG_THREADS
-#define DEBUG_MEM_MGR
-#define TRACE_PARSER
-#define TRACE_INTERPRETER
-#define DUMP_MODULE_CODE
-#define DUMP_OBJECTS_AT_END
+//#define DEBUG_THREADS
+//#define DEBUG_MEM_MGR
+//#define TRACE_PARSER
+//#define TRACE_INTERPRETER
+//#define DUMP_MODULE_CODE
+//#define DUMP_OBJECTS_AT_END
//************************* BASIC TYPE DEFINITIONS ********************************
@@ -423,7 +423,7 @@
// or if you are finished with the object and want it deleted. If you
// do not clear this bit the object will exist forever and cause
// a memory leak. See DELETE LOCKING section below.
-obj_p new_object(obj_p proto);
+obj_p new_object(isp ist, obj_p proto);
// GET_ATTR: Find attr in object that matches a key and return the attr value.
// Searches object for attr with key that matches the given key symbol object.
@@ -521,20 +521,20 @@
char* symch(isp ist, obj_p sym_obj);
// NEW_INT_OBJ: Create a new integer object from a 64-bit C int.
-obj_p new_int_obj(i64_t num);
+obj_p new_int_obj(isp ist, i64_t num);
// NEW_FLOAT_OBJ: Create a new float object from a 64-bit C double.
-obj_p new_float_obj(double num);
+obj_p new_float_obj(isp ist, double num);
// NEW_STRING_OBJ: Create a new string object from a C string.
-obj_p new_string_obj(char* string);
+obj_p new_string_obj(isp ist, char* string);
// NEW_STRING_OBJ_N: Create a new string object from a C string of N chars long.
// Same as new_string_obj but string length is set by n, not null char at end.
-obj_p new_string_n_obj(char* string, size_t n);
+obj_p new_string_n_obj(isp ist, char* string, size_t n);
// NEW_LIST_OBJ: Create a new list object with a given initial size
-obj_p new_list_obj(size_t initial_size);
+obj_p new_list_obj(isp ist, size_t initial_size);
// CLONE_LIST_OBJ: Create a new list object that's a shallow copy of another
obj_p clone_list_obj(isp ist, obj_p list_obj);
@@ -555,21 +555,21 @@
// LISTn: Convenience list create functions
// list1, list2, ... are convenience functions that allow you to create
// new list objects that contain 1 to 6 item objects.
-obj_p list1(obj_p p1);
-obj_p list2(obj_p p1, obj_p p2);
-obj_p list3(obj_p p1, obj_p p2, obj_p p3);
-obj_p list4(obj_p p1, obj_p p2, obj_p p3, obj_p p4);
-obj_p list6(obj_p item1, obj_p item2, obj_p item3, obj_p item4, obj_p item5, obj_p item6 );
+obj_p list1(isp ist, obj_p p1);
+obj_p list2(isp ist, obj_p p1, obj_p p2);
+obj_p list3(isp ist, obj_p p1, obj_p p2, obj_p p3);
+obj_p list4(isp ist, obj_p p1, obj_p p2, obj_p p3, obj_p p4);
+obj_p list6(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4, obj_p item5, obj_p item6 );
// NEW_TUPLE_OBJ: Create a new immutable tuple object
// A tuple is identical to a list except that at the Prothon level it is
// immutable. At the C level this means that you should not modify it
// once you have given it away to other code. It is implemented the same
// way as a list so all the list functions will work on a tuple.
-// This creation function actually calls new_list_obj() and changes the
+// This creation function actually calls new_list_obj(ist, ) and changes the
// proto to TUPLE_PROTO. After calling this you should set all the data
// items with list_append() before releasing the object to other code.
-obj_p new_tuple_obj(int fixed_size);
+obj_p new_tuple_obj(isp ist, int fixed_size);
// NEW_DICT_OBJ: Create a new dictionary object
// A dictionary stores objects much like the attributes are stored except that
@@ -579,7 +579,7 @@
// Make sure the initial size is at least twice as large as the intended number
// of objects you will be adding initially. Expanding a dictionary is an expensive
// operation.
-obj_p new_dict_obj(int initial_size);
+obj_p new_dict_obj(isp ist, int initial_size);
// DICT_ADD: Add a key/value pair to the dictionary. Replace old one if key exists.
// Key equality is determined by the __eq__QUES function on the key objects. The __eq__QUES
@@ -642,7 +642,7 @@
// arugments for the thread_func function.
// Note: thread_func must call register_thread() (see below) immediately after
// starting.
-obj_p new_thread_obj(apr_thread_start_t thread_func, void *thread_data);
+obj_p new_thread_obj(isp ist, apr_thread_start_t thread_func, void *thread_data);
// REGISTER_THREAD: Register a newly started thread
// This tells Prothon that a thread has actually started, releasees the
@@ -674,28 +674,28 @@
// may have the value SLICEPARAM_EMPTY to indicate the default value in the
// slice such as this case: x[:15]. The second and third parameters may have
// the value SLICEPARAM_MISSING to indicate the number of params to include.
-// example: x[1:] -> new_slice_obj(int1, SLICEPARAM_EMPTY, SLICEPARAM_MISSING)
-// where int1 = new_int_obj(1);
+// example: x[1:] -> new_slice_obj(ist, int1, SLICEPARAM_EMPTY, SLICEPARAM_MISSING)
+// where int1 = new_int_obj(ist, 1);
// You can also use OBJ(NONE) instead of SLICEPARAM_EMPTY.
-obj_p new_slice_obj(obj_p ind1, obj_p ind2, obj_p ind3);
+obj_p new_slice_obj(isp ist, obj_p ind1, obj_p ind2, obj_p ind3);
#define SLICEPARAM_EMPTY ((obj_p)3)
#define SLICEPARAM_MISSING ((obj_p)4)
// SLICE1: Convenience macro for creating slice object with one param
// Note that slices for dictionaries should always have only one param.
-#define slice1(ind) new_slice_obj(ind, SLICEPARAM_MISSING, SLICEPARAM_MISSING)
+#define slice1(ind) new_slice_obj(ist, ind, SLICEPARAM_MISSING, SLICEPARAM_MISSING)
// SLICE_ALL: Convenience macro for creating slice object representing entire sequence
-#define SLICE_ALL new_slice_obj(SLICEPARAM_EMPTY, SLICEPARAM_EMPTY, SLICEPARAM_MISSING)
+#define SLICE_ALL new_slice_obj(ist, SLICEPARAM_EMPTY, SLICEPARAM_EMPTY, SLICEPARAM_MISSING)
// NEW_SUPER_OBJ: This represents the reference of a proto of an object
// This is much like a slice in that it indicates how data is to be referenced
// in an object. In this case the data is an attribute of a proto.
// Example: If you are in the function of an object self, and you refer to :x,
// then you are referring to the attribute x in a proto of self. Then
-// to access :x in the proto of self -> get_item(ist, self, new_super_obj(sym(ist, "x")));
-obj_p new_super_obj(obj_p symbol);
+// to access :x in the proto of self -> get_item(ist, self, new_super_obj(ist, sym(ist, "x")));
+obj_p new_super_obj(isp ist, obj_p symbol);
//************************* Prothon C FUNCTION ********************************
// This is the type of C function that the dll author must provide to implement
@@ -727,7 +727,7 @@
// **dictionary args which are supported by putting PARAM_STAR or PARAM_STAR_STAR in
// the label (even) position and the list or dict symbol in the default (odd) position.
// example: in "def func(x, y="3", *z)", the label_def_list would be:
-// list6(NULL, sym(ist, "x"), NULL, sym(ist, "y"), new_string_obj("3"), PARAM_STAR, sym(ist, "z"));
+// list6(ist,NULL, sym(ist, "x"), NULL, sym(ist, "y"), new_string_obj(ist, "3"), PARAM_STAR, sym(ist, "z"));
// If the formal param list is empty, you can put NULL instead of the list.
obj_p new_func_obj(isp ist, pr_func* func_ptr, obj_p label_def_list);
@@ -737,15 +737,15 @@
// "b" is the rparam. The "rparam" label doesn't really matter since the
// call is made positionally.
// see Int.c for example of usage
-#define FORM_RPARAM (list2(SYM(RPARAM),NULL))
+#define FORM_RPARAM (list2(ist, SYM(RPARAM),NULL))
// FORM_PARAM2: same for 2 right params
// example: Cmp(a,b)
-#define FORM_PARAM2 (list4(SYM(PARAM1), NULL, SYM(PARAM2), NULL))
+#define FORM_PARAM2 (list4(ist, SYM(PARAM1), NULL, SYM(PARAM2), NULL))
// FORM_STAR_PARAM: convenience macro for variable number of formal right parameters
// equivalent to func(*poslist)
-#define FORM_STAR_PARAM (list2(PARAM_STAR,SYM(__POSLIST__)))
+#define FORM_STAR_PARAM (list2(ist, PARAM_STAR,SYM(__POSLIST__)))
// CALL_FUNC: Call a function, either Prothon or C based
// This C function provides a way to call any Prothon or C function from C.
@@ -921,6 +921,10 @@
void del_lock (obj_p obj);
void del_unlock(obj_p obj);
+// SU, UN_SU: get super_user access, restore normal access
+#define su(save_int) ((save_int) = ist->access, ist->access = ACC_SYSTEM)
+#define un_su(save_int) (ist->access = (save_int))
+
#ifdef __cplusplus
}
#endif
Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/include/prothon/prothon_dll.h 2004-04-06 07:56:29 UTC (rev 290)
@@ -75,18 +75,18 @@
obj_p (*list_item)(isp ist, obj_p list, int i);
size_t (*list_len)(isp ist, obj_p list);
void (*list_clear)(isp ist, obj_p list_obj);
- obj_p (*list1)(obj_p p1);
- obj_p (*list2)(obj_p p1, obj_p p2);
- obj_p (*list3)(obj_p p1, obj_p p2, obj_p p3);
- obj_p (*list4)(obj_p p1, obj_p p2, obj_p p3, obj_p p4);
- obj_p (*list6)(obj_p p1, obj_p p2, obj_p p3, obj_p p4, obj_p p5, obj_p p6);
- obj_p (*new_hash_obj)(i32_t num);
- obj_p (*new_int_obj)(i64_t num);
- obj_p (*new_float_obj)(double num);
- obj_p (*new_string_obj)(char* string);
- obj_p (*new_string_n_obj)(char* string, size_t n);
- obj_p (*new_tuple_obj)(int fixed_size);
- obj_p (*new_list_obj)(size_t initial_size);
+ obj_p (*list1)(isp ist, obj_p p1);
+ obj_p (*list2)(isp ist, obj_p p1, obj_p p2);
+ obj_p (*list3)(isp ist, obj_p p1, obj_p p2, obj_p p3);
+ obj_p (*list4)(isp ist, obj_p p1, obj_p p2, obj_p p3, obj_p p4);
+ obj_p (*list6)(isp ist, obj_p p1, obj_p p2, obj_p p3, obj_p p4, obj_p p5, obj_p p6);
+ obj_p (*new_hash_obj)(isp ist, i32_t num);
+ obj_p (*new_int_obj)(isp ist, i64_t num);
+ obj_p (*new_float_obj)(isp ist, double num);
+ obj_p (*new_string_obj)(isp ist, char* string);
+ obj_p (*new_string_n_obj)(isp ist, char* string, size_t n);
+ obj_p (*new_tuple_obj)(isp ist, int fixed_size);
+ obj_p (*new_list_obj)(isp ist, size_t initial_size);
obj_p (*clone_list_obj)(isp ist, obj_p list_obj);
obj_p (*new_func_obj)(isp ist, pr_func* func_ptr, obj_p form_lbl_val_list);
obj_p (*call_func)(isp ist, obj_p self, obj_p func_sym, int parm_cnt, obj_p* lbl_val_arr, obj_p dyn_locals);
@@ -94,7 +94,7 @@
obj_p (*sym)(isp ist, char* symbol);
void (*raise_exception)(isp ist, obj_p proto_obj, const char *format, ...)
__attribute__((format(printf,3,4)));
- obj_p (*new_object)(obj_p proto);
+ obj_p (*new_object)(isp ist, obj_p proto);
void (*add_doc_to_obj)(isp ist, obj_p obj, char* str);
apr_pool_t* (*get_pr_head_pool)(void);
@@ -133,43 +133,43 @@
#define MODULE_START(name) \
static void name##_initialize_module(void)
-#define DEF(slf, func, fparam_list) \
+#define DEF(slf, func, fparam_list) \
static obj_p slf##func(isp ist, obj_p self, int pcnt, \
- obj_p* parms, obj_p dlocals); \
-static void slf##func##init(void) { \
- set_attr(ist, slf##_OBJ, sym(ist, #func), \
- new_func_obj(ist, slf##func, fparam_list)); \
-} \
+ obj_p* parms, obj_p dlocals); \
+static void slf##func##init(void) { \
+ set_attr(ist, slf##_OBJ, sym(ist, #func), \
+ new_func_obj(ist, slf##func, fparam_list)); \
+} \
static obj_p slf##func(isp ist, obj_p self, int pcnt, \
obj_p* parms, obj_p dlocals)
-#define MAIN_MODULE_INIT(name) \
-static void name##_module_install(void); \
+#define MAIN_MODULE_INIT(name) \
+static void name##_module_install(void); \
PR_DECLARE_EXPORT void name##_dll_entry(pr_services_t* srvcs) \
-{ \
- services = srvcs; \
- ist = get_ist(ACC_SYSTEM); \
- name##_module_install(); \
-} \
+{ \
+ services = srvcs; \
+ ist = get_ist(ACC_SYSTEM); \
+ name##_module_install(); \
+} \
static void name##_module_install(void)
-#define BUILTIN_LOAD(name) \
-do { \
- extern void name##_dll_entry(void); \
- name##_dll_entry(); \
+#define BUILTIN_LOAD(name) \
+do { \
+ extern void name##_dll_entry(void); \
+ name##_dll_entry(); \
} while(0)
-#define MODULE_ADD_TO_BASE(name) \
-do { \
+#define MODULE_ADD_TO_BASE(name) \
+do { \
set_attr(ist, OBJ(MODULES), sym(ist, #name), \
- name##_OBJ); \
- set_attr(ist, OBJ(OBJECT), sym(ist, #name), \
- name##_OBJ); \
+ name##_OBJ); \
+ set_attr(ist, OBJ(OBJECT), sym(ist, #name), \
+ name##_OBJ); \
} while(0)
-#define MODULE_ADD_TO_OBJ(name, obj, __sym) \
-do { \
+#define MODULE_ADD_TO_OBJ(name, obj, __sym) \
+do { \
set_attr(ist, obj, sym(ist, __sym), name##_OBJ); \
} while(0)
@@ -190,7 +190,7 @@
#define del_attr (*services->del_attr)
#define ins_proto (*services->ins_proto)
#define del_proto (*services->del_proto)
-#define has_proto_QUES (*services->has_proto_QUES)
+#define has_proto_QUES (*services->has_proto_QUES)
#define switch_proto_to (*services->switch_proto_to)
#define list_append (*services->list_append)
#define list_item (*services->list_item)
Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/modules/File/File.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -102,6 +102,8 @@
filep->flags = flags;
file_obj->data_type = OBJ_TYPE_DATAPTR;
file_obj->data.ptr = filep;
+ file_obj->rd_access = ACC_USER1;
+ file_obj->wr_access = ACC_USER1;
}
@@ -111,20 +113,20 @@
{
obj_p file_obj;
- file_obj = new_object(File_OBJ);
+ file_obj = new_object(ist, File_OBJ);
set_file_obj(file_obj, filename, mode, fp, bufsize, flags);
return file_obj;
}
MODULE_START(File)
{
- File_OBJ = new_object(NULL);
+ File_OBJ = new_object(ist, NULL);
MODULE_ADD_TO_BASE(File);
}
-DEF(File, __init__, list6( sym(ist, "path"), NULL,
- sym(ist, "mode"), new_string_obj("r"),
- sym(ist, "bufsize"), new_int_obj(-1) ) ) {
+DEF(File, __init__, list6(ist, sym(ist, "path"), NULL,
+ sym(ist, "mode"), new_string_obj(ist, "r"),
+ sym(ist, "bufsize"), new_int_obj(ist, -1) ) ) {
apr_file_t *f;
apr_status_t aprerr;
apr_pool_t *subpool;
@@ -242,7 +244,7 @@
raise_exception(ist, OBJ(IOEXCEPTION), "fileno called on closed file");
return NULL;
}
- return new_int_obj(_fileno(STREAM(self)));
+ return new_int_obj(ist, _fileno(STREAM(self)));
}
DEF(File, isatty_QUES, NULL) {
@@ -254,7 +256,7 @@
else return OBJ(PR_FALSE);
}
#endif
-DEF(File, read, list2( sym(ist, "size"), new_int_obj(-1))) {
+DEF(File, read, list2(ist, sym(ist, "size"), new_int_obj(ist, -1))) {
int readall = FALSE;
i64_t size_in;
size_t size, total_read=0, num_read;
@@ -281,13 +283,13 @@
return NULL;
}
size_in = parms[1]->data.i64;
- if (!size_in) return new_string_obj("");
+ if (!size_in) return new_string_obj(ist, "");
if (size_in < 0) {
readall = TRUE;
size = BUFSIZE(self);
} else
size = (size_t) size_in;
- str_obj = new_object(OBJ(STRING_PROTO));
+ str_obj = new_object(ist, OBJ(STRING_PROTO));
if (size < IMMEDIATE_DATA_LEN) {
str_obj->data_type = OBJ_TYPE_IMMDATA;
buf = str_obj->data.str;
@@ -334,7 +336,7 @@
return str_obj;
}
-DEF(File, readline, list2( sym(ist, "size"), new_int_obj(-1))) {
+DEF(File, readline, list2(ist, sym(ist, "size"), new_int_obj(ist, -1))) {
int readall = FALSE;
i64_t size_in;
size_t size, total_read;
@@ -361,13 +363,13 @@
return NULL;
}
size_in = parms[1]->data.i64;
- if (!size_in) return new_string_obj("");
+ if (!size_in) return new_string_obj(ist, "");
if (size_in < 0) {
readall = TRUE;
size = BUFSIZE(self);
} else
size = (size_t) size_in;
- str_obj = new_object(OBJ(STRING_PROTO));
+ str_obj = new_object(ist, OBJ(STRING_PROTO));
if (size < IMMEDIATE_DATA_LEN) {
str_obj->data_type = OBJ_TYPE_IMMDATA;
buf = str_obj->data.str;
@@ -412,7 +414,7 @@
return str_obj;
}
-DEF(File, readlines, list2( sym(ist, "size"), new_int_obj(-1))) {
+DEF(File, readlines, list2(ist, sym(ist, "size"), new_int_obj(ist, -1))) {
int readall = FALSE;
i64_t size_in;
size_t size, total_read=0, num_read;
@@ -439,16 +441,16 @@
return NULL;
}
size_in = parms[1]->data.i64;
- if (!size_in) return new_string_obj("");
+ if (!size_in) return new_string_obj(ist, "");
if (size_in < 0) {
readall = TRUE;
size = BUFSIZE(self);
} else
size = (size_t) size_in;
- list_obj = new_list_obj(10);
+ list_obj = new_list_obj(ist, 10);
aprerr = 0;
while (aprerr != APR_EOF && (readall || total_read < size)) {
- str_obj = new_object(OBJ(STRING_PROTO));
+ str_obj = new_object(ist, OBJ(STRING_PROTO));
if (size < IMMEDIATE_DATA_LEN) {
str_obj->data_type = OBJ_TYPE_IMMDATA;
buf = str_obj->data.str;
@@ -498,8 +500,8 @@
return list_obj;
}
-DEF(File, seek, list4( sym(ist, "pos"), NULL,
- sym(ist, "how"), new_int_obj(0) ) ) {
+DEF(File, seek, list4(ist, sym(ist, "pos"), NULL,
+ sym(ist, "how"), new_int_obj(ist, 0) ) ) {
apr_off_t pos;
apr_seek_where_t origin;
apr_status_t aprerr;
@@ -545,10 +547,10 @@
raise_exception(ist, OBJ(IOEXCEPTION), "tell called on closed file");
return NULL;
}
- return new_int_obj(ftell(STREAM(self)));
+ return new_int_obj(ist, ftell(STREAM(self)));
}
#endif
-DEF(File, truncate, list2(sym(ist, "size"), NULL)) {
+DEF(File, truncate, list2(ist, sym(ist, "size"), NULL)) {
apr_status_t aprerr;
char err_buf[1024];
apr_off_t size;
@@ -583,7 +585,7 @@
return OBJ(NONE);
}
-DEF(File, write, list2(sym(ist, "str"), NULL)) {
+DEF(File, write, list2(ist, sym(ist, "str"), NULL)) {
char* str;
apr_size_t size;
apr_status_t aprerr;
@@ -617,7 +619,7 @@
return parms[1];
}
-DEF(File, writelines, list2(sym(ist, "lst"), NULL)) {
+DEF(File, writelines, list2(ist, sym(ist, "lst"), NULL)) {
char* str;
apr_size_t size;
apr_status_t aprerr;
@@ -672,11 +674,11 @@
MODULE_START(Dir)
{
- Dir_OBJ = new_object(NULL);
+ Dir_OBJ = new_object(ist, NULL);
}
-DEF(Dir, __init__, list2(sym(ist, "path"), NULL)) {
- obj_p file_obj = new_string_obj(strch(parms[1]));
+DEF(Dir, __init__, list2(ist, sym(ist, "path"), NULL)) {
+ obj_p file_obj = new_string_obj(ist, strch(parms[1]));
switch_proto_to(ist, file_obj, Dir_OBJ);
return file_obj;
}
@@ -700,22 +702,22 @@
switch (type) {
case __STDIN:
aprerr = apr_file_open_stdin(&fp, subpool);
- mode = new_string_obj("r");
- file = new_string_obj("<stdin>");
+ mode = new_string_obj(ist, "r");
+ file = new_string_obj(ist, "<stdin>");
flags = APR_READ;
break;
case __STDOUT:
aprerr = apr_file_open_stdout(&fp, subpool);
- file = new_string_obj("<stdout>");
- mode = new_string_obj("w");
+ file = new_string_obj(ist, "<stdout>");
+ mode = new_string_obj(ist, "w");
flags = APR_WRITE;
break;
case __STDERR:
aprerr = apr_file_open_stderr(&fp, subpool);
- file = new_string_obj("<stderr>");
- mode = new_string_obj("w");
+ file = new_string_obj(ist, "<stderr>");
+ mode = new_string_obj(ist, "w");
flags = APR_WRITE;
break;
Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/modules/Re/Re.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -72,16 +72,16 @@
MODULE_START(Re)
{
- Re_OBJ = new_object(NULL);
+ Re_OBJ = new_object(ist, NULL);
MODULE_SET_DOC(Re, "module for regular expressions");
MODULE_ADD_TO_BASE(Re);
- ReException_OBJ = new_object(OBJ(EXCEPTION));
+ ReException_OBJ = new_object(ist, OBJ(EXCEPTION));
MODULE_SET_DOC(ReException, "Re module error");
MODULE_ADD_TO_OBJ(ReException, Re_OBJ, "ReException");
- i_flg = new_int_obj(REG_ICASE);
- s_flg = new_int_obj(REG_NEWLINE); // reverse meaning
+ i_flg = new_int_obj(ist, REG_ICASE);
+ s_flg = new_int_obj(ist, REG_NEWLINE); // reverse meaning
set_attr(ist, Re_OBJ, sym(ist, "I"), i_flg);
set_attr(ist, Re_OBJ, sym(ist, "IGNORECASE"), i_flg);
@@ -89,7 +89,7 @@
set_attr(ist, Re_OBJ, sym(ist, "DOTALL"), s_flg);
}
-DEF(Re, compile, list4( sym(ist, "pattern"), NULL,
+DEF(Re, compile, list4(ist, sym(ist, "pattern"), NULL,
sym(ist, "flags"), OBJ(ZERO_INT) ) ) {
obj_p re_obj;
regex_t* e = pr_malloc(sizeof(regex_t));
@@ -122,7 +122,7 @@
raise_exception(ist, ReException_OBJ, "more than 99 groups in regular expression");
return NULL;
}
- re_obj = new_object(ReCompiled_OBJ);
+ re_obj = new_object(ist, ReCompiled_OBJ);
re_obj->data_type = OBJ_TYPE_DATAPTR;
re_obj->data.ptr = e;
set_attr(ist, re_obj, sym(ist, "pattern"), parms[1]);
@@ -133,7 +133,7 @@
MODULE_START(ReCompiled)
{
- ReCompiled_OBJ = new_object(NULL);
+ ReCompiled_OBJ = new_object(ist, NULL);
MODULE_ADD_TO_OBJ(ReCompiled, Re_OBJ, "Re");
MODULE_SET_DOC(ReCompiled, "prototype for compiled regular expressions");
}
@@ -149,7 +149,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "findall s parameter must be a string");
return NULL;
}
- res = new_list_obj(10);
+ res = new_list_obj(ist, 10);
s = strch(parms[1]);
m = pr_malloc((ngrps+1)*sizeof(regmatch_t));
m[0].rm_so = -1; m[0].rm_eo = 0;
@@ -173,18 +173,18 @@
}
if (ngrps == 0) {
sp = m[0].rm_so;
- list_append(ist, res, new_string_n_obj(s+sp, m[0].rm_eo-sp));
+ list_append(ist, res, new_string_n_obj(ist, s+sp, m[0].rm_eo-sp));
} else if (ngrps == 1) {
if ((sp = m[1].rm_so) == -1)
- list_append(ist, res, new_string_obj(""));
+ list_append(ist, res, new_string_obj(ist, ""));
else
- list_append(ist, res, new_string_n_obj(s+sp, m[1].rm_eo-sp));
+ list_append(ist, res, new_string_n_obj(ist, s+sp, m[1].rm_eo-sp));
} else {
- tuple_obj = new_tuple_obj(ngrps);
+ tuple_obj = new_tuple_obj(ist, ngrps);
for (i=1; i <= ngrps; i++) {
sp = m[i].rm_so; ep = m[i].rm_eo;
- if (sp == -1) list_append(ist, tuple_obj, new_string_obj(""));
- else list_append(ist, tuple_obj, new_string_n_obj(s+sp,ep-sp));
+ if (sp == -1) list_append(ist, tuple_obj, new_string_obj(ist, ""));
+ else list_append(ist, tuple_obj, new_string_n_obj(ist, s+sp,ep-sp));
}
list_append(ist, res, tuple_obj);
tuple_obj->immutable = TRUE;
@@ -194,7 +194,7 @@
return res;
}
-DEF( ReCompiled, search, list6( sym(ist, "s"), NULL,
+DEF( ReCompiled, search, list6(ist, sym(ist, "s"), NULL,
sym(ist, "start"), OBJ(ZERO_INT),
sym(ist, "end"), OBJ(MAX_INT) ) ) {
obj_p match_obj, lastindex_obj;
@@ -233,15 +233,15 @@
pr_free(m);
return NULL;
}
- match_obj = new_list_obj((ngrps+1)*2);
+ match_obj = new_list_obj(ist, (ngrps+1)*2);
switch_proto_to(ist, match_obj, ReMatch_OBJ);
for(i=0; i <= numgrps(self); i++) {
if (m[i].rm_so > -1) last_index = i;
- list_append(ist, match_obj, new_int_obj(m[i].rm_so));
- list_append(ist, match_obj, new_int_obj(m[i].rm_eo));
+ list_append(ist, match_obj, new_int_obj(ist, m[i].rm_so));
+ list_append(ist, match_obj, new_int_obj(ist, m[i].rm_eo));
}
pr_free(m);
- if (last_index) lastindex_obj = new_int_obj(last_index);
+ if (last_index) lastindex_obj = new_int_obj(ist, last_index);
else lastindex_obj = OBJ(NONE);
set_attr(ist, match_obj, sym(ist, "re"), self);
set_attr(ist, match_obj, sym(ist, "string"), parms[1]);
@@ -251,7 +251,7 @@
return match_obj;
}
-DEF( ReCompiled, split, list4( sym(ist, "s"), NULL,
+DEF( ReCompiled, split, list4(ist, sym(ist, "s"), NULL,
sym(ist, "maxsplit"), OBJ(ZERO_INT) ) ) {
char* s;
regmatch_t* m;
@@ -267,7 +267,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "split function maxsplit parameter must be an integer");
return NULL;
}
- res = new_list_obj(10);
+ res = new_list_obj(ist, 10);
s = strch(parms[1]);
maxsplit = (int)(parms[3]->data.i64);
m = pr_malloc((ngrps+1)*sizeof(regmatch_t));
@@ -292,18 +292,18 @@
return NULL;
}
if (m[0].rm_so == m[0].rm_eo) continue;
- list_append(ist, res, new_string_n_obj(s+last_split, m[0].rm_so-last_split));
+ list_append(ist, res, new_string_n_obj(ist, s+last_split, m[0].rm_so-last_split));
for(i=1; i <= ngrps; i++) {
if ((sp = m[i].rm_so) == -1)
list_append(ist, res, OBJ(NONE));
else
- list_append(ist, res, new_string_n_obj(s+sp, m[i].rm_eo-sp));
+ list_append(ist, res, new_string_n_obj(ist, s+sp, m[i].rm_eo-sp));
}
last_split = m[0].rm_eo;
if (maxsplit && ++split_count == maxsplit) break;
}
if ((sp=last_split) != (ep=strlen(s)))
- list_append(ist, res, new_string_n_obj(s+sp, ep-sp));
+ list_append(ist, res, new_string_n_obj(ist, s+sp, ep-sp));
pr_free(m);
return res;
}
@@ -392,7 +392,7 @@
return TRUE;
}
-DEF( ReCompiled, sub, list6( sym(ist, "repl"), NULL,
+DEF( ReCompiled, sub, list6(ist, sym(ist, "repl"), NULL,
sym(ist, "s"), NULL,
sym(ist, "count"), OBJ(ZERO_INT) ) ) {
char *repl = "", *orig_s, *p1, *p2, *s, *s_lim, *res;
@@ -415,11 +415,11 @@
raise_exception(ist, OBJ(TYPE_EXC), "sub function count parameter must be an integer");
return NULL;
}
- match_obj = new_list_obj((ngrps+1)*2);
+ match_obj = new_list_obj(ist, (ngrps+1)*2);
switch_proto_to(ist, match_obj, ReMatch_OBJ);
set_attr(ist, match_obj, sym(ist, "re"), self);
set_attr(ist, match_obj, sym(ist, "string"), parms[3]);
- lastindex_obj = new_int_obj(last_index);
+ lastindex_obj = new_int_obj(ist, last_index);
set_attr(ist, match_obj, sym(ist, "lastindex"), lastindex_obj);
arr[0] = 0; arr[1] = match_obj;
if (!repl_is_func)
@@ -459,8 +459,8 @@
list_clear(ist, match_obj);
for(i=0; i <= ngrps; i++) {
if (m[i].rm_so > -1) last_index = i;
- list_append(ist, match_obj, new_int_obj(m[i].rm_so));
- list_append(ist, match_obj, new_int_obj(m[i].rm_eo));
+ list_append(ist, match_obj, new_int_obj(ist, m[i].rm_so));
+ list_append(ist, match_obj, new_int_obj(ist, m[i].rm_eo));
}
lastindex_obj->data.i64 = last_index;
if (repl_is_func) {
@@ -494,7 +494,7 @@
strncat(res, orig_s+last_split, strlen(orig_s)-last_split);
res[size] = 0;
}
- res_obj = new_string_obj(res);
+ res_obj = new_string_obj(ist, res);
del_unlock(match_obj);
pr_free(res);
pr_free(m);
@@ -513,7 +513,7 @@
MODULE_START(ReMatch)
{
- ReMatch_OBJ = new_object(NULL);
+ ReMatch_OBJ = new_object(ist, NULL);
MODULE_SET_DOC(ReMatch, "prototype for regular expression match objects");
MODULE_ADD_TO_OBJ(ReMatch, Re_OBJ, "Match");
}
@@ -522,7 +522,7 @@
return parms[1];
}
-DEF(ReMatch, start, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, start, list2(ist, sym(ist, "groupid"),OBJ(ZERO_INT))) {
u32_t grp;
if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "start function groupid parameter must be an integer");
@@ -536,7 +536,7 @@
return list_item(ist, self, 2*grp);
}
-DEF(ReMatch, end, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, end, list2(ist, sym(ist, "groupid"),OBJ(ZERO_INT))) {
u32_t grp;
if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "end function groupid parameter must be an integer");
@@ -550,7 +550,7 @@
return list_item(ist, self, 2*grp+1);
}
-DEF(ReMatch, span, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, span, list2(ist, sym(ist, "groupid"),OBJ(ZERO_INT))) {
u32_t grp;
obj_p res;
if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
@@ -562,7 +562,7 @@
raise_exception(ist, ReException_OBJ, "span function groupid parameter value invalid");
return NULL;
}
- res = new_tuple_obj(2);
+ res = new_tuple_obj(ist, 2);
list_append(ist, res, list_item(ist, self, 2*grp ));
list_append(ist, res, list_item(ist, self, 2*grp+1));
res->immutable = TRUE;
@@ -585,12 +585,12 @@
orig_s_obj = get_attr(ist, self, sym(ist, "string")); if_exc_return NULL;
orig_s = strch(orig_s_obj);
if (unescape(ist, self, orig_s, &p1, &p2, &s, &s_lim)) return NULL;
- res = new_string_obj(s);
+ res = new_string_obj(ist, s);
pr_free(s);
return res;
}
-DEF( ReMatch, group, list4( sym(ist, "groupid"), OBJ(ZERO_INT),
+DEF( ReMatch, group, list4(ist, sym(ist, "groupid"), OBJ(ZERO_INT),
PARAM_STAR, sym(ist, "groupids") ) ) {
int i, j, llen, ngrps = ((int)list_len(ist, self))/2, sp, ep;
char* orig_s;
@@ -626,33 +626,33 @@
sp = (int)(list_item(ist, self, j*2 )->data.i64);
ep = (int)(list_item(ist, self, j*2+1)->data.i64);
if (sp == -1) return OBJ(NONE);
- else return new_string_n_obj(orig_s+sp, ep-sp);
+ else return new_string_n_obj(ist, orig_s+sp, ep-sp);
} else {
- res = new_tuple_obj(llen);
+ res = new_tuple_obj(ist, llen);
for (i=0; i < llen; i++) {
obj_p item = list_item(ist, parms[3], i);
j = (int)(item->data.i64);
sp = (int)(list_item(ist, self, j*2 )->data.i64);
ep = (int)(list_item(ist, self, j*2+1)->data.i64);
if (sp == -1) list_append(ist, res, OBJ(NONE));
- else list_append(ist, res, new_string_n_obj(orig_s+sp, ep-sp));
+ else list_append(ist, res, new_string_n_obj(ist, orig_s+sp, ep-sp));
}
res->immutable = TRUE;
return res;
}
}
-DEF( ReMatch, groups, list2(sym(ist, "default"), OBJ(NONE))) {
+DEF( ReMatch, groups, list2(ist, sym(ist, "default"), OBJ(NONE))) {
int i, ngrps = (int)list_len(ist, self)/2, sp, ep;
char* orig_s;
- obj_p orig_s_obj, res = new_tuple_obj(ngrps);
+ obj_p orig_s_obj, res = new_tuple_obj(ist, ngrps);
orig_s_obj = get_attr(ist, self, sym(ist, "string")); if_exc_return NULL;
orig_s = strch(orig_s_obj);
for (i=0; i < ngrps; i++) {
sp = (int)(list_item(ist, self, i*2 )->data.i64);
ep = (int)(list_item(ist, self, i*2+1)->data.i64);
if (sp == -1) list_append(ist, res, parms[1]);
- else list_append(ist, res, new_string_n_obj(orig_s+sp, ep-sp));
+ else list_append(ist, res, new_string_n_obj(ist, orig_s+sp, ep-sp));
}
res->immutable = TRUE;
return res;
Modified: trunk/src/argproc.c
===================================================================
--- trunk/src/argproc.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/argproc.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -73,7 +73,7 @@
}
obj_p parse_argv(isp ist, char* p) {
- obj_p argv = new_list_obj(4);
+ obj_p argv = new_list_obj(ist, 4);
char* p1;
while(*p) {
if (*p == '\'') {
@@ -82,10 +82,10 @@
printf ("Unterminated quote in command-line parameter\n");
return NULL;
}
- list_append(ist, argv, new_string_n_obj(p+1, p1-p-1));
+ list_append(ist, argv, new_string_n_obj(ist, p+1, p1-p-1));
} else {
for (p1=p; *p1 && *p1 != ' ' && *p1 != '\t'; p1++);
- list_append(ist, argv, new_string_n_obj(p, p1-p));
+ list_append(ist, argv, new_string_n_obj(ist, p, p1-p));
}
for (p = p1; *p && (*p == ' ' || *p == '\t'); p++);
}
@@ -95,21 +95,21 @@
obj_p arginit(isp ist, int argc, char* argv[]) {
int i, past_c_args = FALSE;
obj_p thread_argv, argv_obj = NULL;
- obj_p thread_list = new_list_obj(4), res = new_object(NULL);
+ obj_p thread_list = new_list_obj(ist, 4), res = new_object(ist, NULL);
char *p, buf[10];
for (i=1; i < argc; i++) {
if (!past_c_args && argv[i][0] != '-') {
- argv_obj = new_list_obj(argc - i);
+ argv_obj = new_list_obj(ist, argc - i);
set_attr(ist, res, sym(ist, "argv"), argv_obj);
past_c_args = TRUE;
}
if (past_c_args)
- list_append(ist, argv_obj, new_string_obj(argv[i]));
+ list_append(ist, argv_obj, new_string_obj(ist, argv[i]));
else {
for (p=argv[i]; *p == '-'; p++);
switch (*p) {
case 'd':
- set_attr(ist, res, sym(ist, "debug"), new_string_obj(argv[i]));
+ set_attr(ist, res, sym(ist, "debug"), new_string_obj(ist, argv[i]));
break;
case 'm':
if (++i == argc) goto err;
@@ -131,7 +131,7 @@
break;
case 'c':
if (++i == argc) goto err;
- set_attr(ist, res, sym(ist, "code"), new_string_obj(argv[i]));
+ set_attr(ist, res, sym(ist, "code"), new_string_obj(ist, argv[i]));
break;
case 'v':
case 'V':
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-core.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -102,7 +102,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "clone() not supported on this object");
return NULL;
}
- return clone_object(self);
+ return clone_object(ist, self);
}
DEF(Object, has_proto_QUES, FORM_RPARAM) {
@@ -186,11 +186,11 @@
apr_snprintf(str, sizeof(str), "<Object:%lx:%s>", (unsigned long)(uintptr_t)self, p);
else
apr_snprintf(str, sizeof(str), "<Object:%lx>", (unsigned long)(uintptr_t)self);
- return new_string_obj(str);
+ return new_string_obj(ist, str);
}
DEF(Object, __hash__, NULL) {
- return new_hash_obj((i32_t)(uintptr_t) self);
+ return new_hash_obj(ist, (i32_t)(uintptr_t) self);
}
DEF(Object, __eq__QUES, FORM_RPARAM) {
@@ -246,15 +246,15 @@
size_t alen, asize;
attr_p attrp;
obj_p dict_obj;
- if (!self->has_attrs) return new_dict_obj(0);
+ if (!self->has_attrs) return new_dict_obj(ist, 0);
attrp = self->attr_proto.attrs;
asize = attr_asize(attrp);
alen = attr_alen(attrp);
- dict_obj = new_dict_obj((int)alen);
+ dict_obj = new_dict_obj(ist, (int)alen);
for (i=0; i < (int) asize; i++) {
if (attr_ap(attrp,i)->attr.key > 0)
dict_add( ist, dict_obj,
- new_string_obj(keych(ist, attr_ap(attrp,i)->attr.key)),
+ new_string_obj(ist, keych(ist, attr_ap(attrp,i)->attr.key)),
attr_ap(attrp,i)->attr.value );
}
return dict_obj;
@@ -270,13 +270,13 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "False"), False_OBJ);
}
-DEF(False, __str__, NULL) { return new_string_obj("False"); }
+DEF(False, __str__, NULL) { return new_string_obj(ist, "False"); }
DEF(False, __bool__QUES, NULL) { return False_OBJ; }
DEF(False, cmp, FORM_RPARAM) {
if (parms[1] == False_OBJ)
- return new_int_obj(0);
+ return new_int_obj(ist, 0);
else
- return new_int_obj(-1);
+ return new_int_obj(ist, -1);
}
@@ -289,15 +289,15 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "True"), True_OBJ);
}
-DEF(True, __str__, NULL) { return new_string_obj("True"); }
+DEF(True, __str__, NULL) { return new_string_obj(ist, "True"); }
DEF(True, __bool__QUES, NULL) { return True_OBJ; }
DEF(True, cmp, FORM_RPARAM) {
if (parms[1] == OBJ(PR_FALSE))
- return new_int_obj(1);
+ return new_int_obj(ist, 1);
else if (parms[1] == True_OBJ)
- return new_int_obj(0);
+ return new_int_obj(ist, 0);
else
- return new_int_obj(-1);
+ return new_int_obj(ist, -1);
}
@@ -310,7 +310,7 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "None"), None_OBJ);
}
-DEF(None, __str__, NULL) { return new_string_obj("None"); }
+DEF(None, __str__, NULL) { return new_string_obj(ist, "None"); }
DEF(None, __bool__QUES, NULL) { return OBJ(PR_FALSE); }
// ***************************** EXCEPTION ************************************
@@ -321,22 +321,22 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "Exception"), Exception_OBJ);
/* Other exception objects dependent on this one */
- OBJ(INTERNAL_EXC) = new_object(Exception_OBJ);
- OBJ(PARSEERROR_EXC) = new_object(Exception_OBJ);
- OBJ(INTERPRETER_EXC) = new_object(Exception_OBJ);
- OBJ(ASSERTION_EXC) = new_object(Exception_OBJ);
- OBJ(NAME_EXC) = new_object(Exception_OBJ);
- OBJ(INDEX_EXC) = new_object(Exception_OBJ);
- OBJ(FUNCNOTFOUND_EXC) = new_object(Exception_OBJ);
- OBJ(TYPE_EXC) = new_object(Exception_OBJ);
- OBJ(MUTABLE_EXC) = new_object(Exception_OBJ);
- OBJ(DIVIDEZERO_EXC) = new_object(Exception_OBJ);
- OBJ(OUTOFMEMORY_EXC) = new_object(Exception_OBJ);
- OBJ(IOEXCEPTION) = new_object(Exception_OBJ);
- OBJ(FILENOTFOUND_EXC) = new_object(OBJ(IOEXCEPTION));
- OBJ(STOP_ITERATION_EXC) = new_object(Exception_OBJ);
- OBJ(LOCK_EXC) = new_object(Exception_OBJ);
- OBJ(PERMISSION_EXC) = new_object(Exception_OBJ);
+ OBJ(INTERNAL_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(PARSEERROR_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(INTERPRETER_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(ASSERTION_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(NAME_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(INDEX_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(FUNCNOTFOUND_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(TYPE_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(MUTABLE_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(DIVIDEZERO_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(OUTOFMEMORY_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(IOEXCEPTION) = new_object(ist, Exception_OBJ);
+ OBJ(FILENOTFOUND_EXC) = new_object(ist, OBJ(IOEXCEPTION));
+ OBJ(STOP_ITERATION_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(LOCK_EXC) = new_object(ist, Exception_OBJ);
+ OBJ(PERMISSION_EXC) = new_object(ist, Exception_OBJ);
/* And their doc entries */
add_doc_to_obj(ist, OBJ(INTERNAL_EXC), "Internal Prothon Error");
@@ -423,7 +423,7 @@
}
strcat(res, rdelim);
- ret_obj = new_string_obj(res);
+ ret_obj = new_string_obj(ist, res);
pr_free(res);
return ret_obj;
@@ -456,7 +456,7 @@
}
if (slice_len == 1) {
if (seq_type == SEQ_TYPE_STRING) {
- return new_string_n_obj(self_str+index1, 1);
+ return new_string_n_obj(ist, self_str+index1, 1);
} else
return list_item(ist, self, index1);
}
@@ -494,12 +494,12 @@
exp_len = max(exp_len, 0);
switch(seq_type) {
case SEQ_TYPE_TUPLE:
- res = new_tuple_obj(exp_len);
+ res = new_tuple_obj(ist, exp_len);
for(i = index1; i < index2; i += index3)
list_append(ist, res, list_item(ist, self, i));
break;
case SEQ_TYPE_LIST:
- res = new_list_obj(exp_len);
+ res = new_list_obj(ist, exp_len);
for(i = index1; i < index2; i += index3)
list_append(ist, res, list_item(ist, self, i));
break;
@@ -508,7 +508,7 @@
char* s = pr_malloc(exp_len+2);
for(i = index1, j=0; i < index2; i += index3, j++)
s[j] = self_str[i];
- res = new_string_n_obj(s, j);
+ res = new_string_n_obj(ist, s, j);
pr_free(s);
} break;
}
@@ -519,12 +519,12 @@
exp_len = max(exp_len, 0)+1;
switch(seq_type) {
case SEQ_TYPE_TUPLE:
- res = new_tuple_obj(exp_len);
+ res = new_tuple_obj(ist, exp_len);
for(i = index1; i > index2; i += index3)
list_append(ist, res, list_item(ist, self, i));
break;
case SEQ_TYPE_LIST:
- res = new_list_obj(exp_len);
+ res = new_list_obj(ist, exp_len);
for(i = index1; i > index2; i += index3)
list_append(ist, res, list_item(ist, self, i));
break;
@@ -533,7 +533,7 @@
char* s = pr_malloc(exp_len+2);
for(i = index1, j=0; i > index2; i += index3, j++)
s[j] = self_str[i];
- res = new_string_n_obj(s, j);
+ res = new_string_n_obj(ist, s, j);
} break;
}
}
@@ -550,7 +550,7 @@
}
DEF(Func, clone, NULL) {
- obj_p clone = clone_object(self);
+ obj_p clone = clone_object(ist, self);
code* p = self->data.ptr;
size_t len = sizeof(code) + p->len * sizeof(code_t);
clone->data.ptr = pr_malloc(len);
Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-dict.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -139,14 +139,14 @@
}
strcat(res, "}");
- res_obj = new_string_obj(res);
+ res_obj = new_string_obj(ist, res);
pr_free(res);
return res_obj;
}
DEF(Dict, clone, NULL) {
- obj_p clone = clone_object(self);
+ obj_p clone = clone_object(ist, self);
size_t len = dict_size_bytes(self->data.ptr);
clone->data.ptr = pr_malloc(len);
memcpy(clone->data.ptr, self->data.ptr, len);
@@ -205,7 +205,7 @@
raise_exception(ist, OBJ(INTERPRETER_EXC), "slice not allowed in dictionary indexing");
return NULL;
}
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
hash_in = hash_value(call_func(ist, key_in, SYM(__HASH__), 0, NULL, NULL));
if (ist->exception_obj) {
write_unlock(ist, self); read_lock(ist, self);
@@ -230,7 +230,7 @@
}
DEF(Dict, __gen__, NULL) {
- obj_p list_obj, gen_obj = new_object(DictGen_OBJ);
+ obj_p list_obj, gen_obj = new_object(ist, DictGen_OBJ);
gen_obj->data_type = OBJ_TYPE_DATAPTR;
gen_obj->data.ptr = list_obj = dict_keys(ist, self);
@@ -242,7 +242,7 @@
MODULE_START(DictGen)
{
- DictGen_OBJ = new_object(NULL);
+ DictGen_OBJ = new_object(ist, NULL);
}
DEF(DictGen, next, NULL) {
Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-float.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -76,9 +76,9 @@
MODULE_START(Float)
{
- Float_OBJ = OBJ(FLOAT_PROTO) = new_object(NULL);
-// Imag_OBJ = OBJ(IMAG_PROTO) = new_object(NULL);
- OBJ(IMAG_PROTO) = new_object(NULL);
+ Float_OBJ = OBJ(FLOAT_PROTO) = new_object(ist, NULL);
+// Imag_OBJ = OBJ(IMAG_PROTO) = new_object(ist, NULL);
+ OBJ(IMAG_PROTO) = new_object(ist, NULL);
add_doc_to_obj(ist, OBJ(FLOAT_PROTO), "Float number object prototype");
add_doc_to_obj(ist, OBJ(IMAG_PROTO), "Imaginary number object prototype");
@@ -115,16 +115,16 @@
if (flt == 0.0) flt = 1.0;
while (flt < 100.0) flt *= 10.0;
while (flt > 1e9) flt /= 10.0;
- return new_hash_obj((i32_t)flt);
+ return new_hash_obj(ist, (i32_t)flt);
}
DEF(Float, __abs__, NULL) {
double num = Float_value(self);
- return new_float_obj(num < 0 ? -num : num);
+ return new_float_obj(ist, num < 0 ? -num : num);
}
DEF(Float, __neg__, NULL){
- return new_float_obj( - Float_value(self) );
+ return new_float_obj(ist, - Float_value(self) );
}
DEF(Float, __pos__, NULL){
@@ -145,7 +145,7 @@
return OBJ(NONE);
}
}
- return new_float_obj(Float_value(self) + float_other);
+ return new_float_obj(ist, Float_value(self) + float_other);
}
DEF(Float, __div__, FORM_RPARAM){
@@ -166,7 +166,7 @@
raise_exception(ist, OBJ(DIVIDEZERO_EXC), NULL);
return NULL;
}
- return new_float_obj(Float_value(self) / float_other);
+ return new_float_obj(ist, Float_value(self) / float_other);
}
DEF(Float, __rdiv__, FORM_RPARAM){
@@ -185,7 +185,7 @@
raise_exception(ist, OBJ(DIVIDEZERO_EXC), NULL);
return NULL;
}
- return new_float_obj(float_other / Float_value(self));
+ return new_float_obj(ist, float_other / Float_value(self));
}
DEF(Float, __mul__, FORM_RPARAM){
@@ -202,7 +202,7 @@
return NULL;
}
}
- return new_float_obj(Float_value(self) * float_other);
+ return new_float_obj(ist, Float_value(self) * float_other);
}
DEF(Float, __sub__, FORM_RPARAM){
@@ -219,7 +219,7 @@
return NULL;
}
}
- return new_float_obj(Float_value(self) - float_other);
+ return new_float_obj(ist, Float_value(self) - float_other);
}
DEF(Float, __rsub__, FORM_RPARAM){
@@ -234,7 +234,7 @@
return NULL;
}
}
- return new_float_obj(float_other - Float_value(self));
+ return new_float_obj(ist, float_other - Float_value(self));
}
DEF(Float, __pow__, FORM_RPARAM){
@@ -251,7 +251,7 @@
return NULL;
}
}
- return new_float_obj(pow(Float_value(self), float_other));
+ return new_float_obj(ist, pow(Float_value(self), float_other));
}
DEF(Float, __rpow__, FORM_RPARAM){
@@ -266,7 +266,7 @@
return NULL;
}
}
- return new_float_obj(pow(float_other, Float_value(self)));
+ return new_float_obj(ist, pow(float_other, Float_value(self)));
}
@@ -285,11 +285,11 @@
}
}
if (Float_value(self) == float_other)
- return new_float_obj(0);
+ return new_float_obj(ist, 0);
else if (Float_value(self) > float_other)
- return new_int_obj(1);
+ return new_int_obj(ist, 1);
else
- return new_int_obj(-1);
+ return new_int_obj(ist, -1);
}
DEF(Float, __rcmp__, FORM_RPARAM){
@@ -305,11 +305,11 @@
}
}
if (Float_value(self) == float_other)
- return new_float_obj(0);
+ return new_float_obj(ist, 0);
else if (Float_value(self) < float_other)
- return new_int_obj(1);
+ return new_int_obj(ist, 1);
else
- return new_int_obj(-1);
+ return new_int_obj(ist, -1);
}
DEF(Float, __eq__QUES, FORM_RPARAM){
@@ -332,7 +332,7 @@
DEF(Float, __str__, NULL){
char str[1024];
apr_snprintf(str, sizeof(str), "%g", Float_value(self));
- return new_string_obj(str);
+ return new_string_obj(ist, str);
}
DEF(Float, __covers__QUES, FORM_RPARAM) {
@@ -342,9 +342,9 @@
DEF(Float, __coerce__, FORM_RPARAM) {
if (has_proto_QUES(ist, parms[1], OBJ(INT_PROTO)))
- return new_float_obj((double)(parms[1]->data.i64));
+ return new_float_obj(ist, (double)(parms[1]->data.i64));
else if (has_proto_QUES(ist, parms[1], Float_OBJ))
- return new_float_obj(parms[1]->data.f64);
+ return new_float_obj(ist, parms[1]->data.f64);
else
raise_exception(ist, OBJ(TYPE_EXC), "This object cannot be coerced to a Float");
return NULL;
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-int.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -84,9 +84,9 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "Int"), Int_OBJ);
/* Dependent objects */
- OBJ(ZERO_INT) = new_int_obj(0);
- OBJ(MAX_INT) = new_int_obj(MAX_INT_VAL);
- OBJ(LONG_PROTO) = new_string_obj("0");
+ OBJ(ZERO_INT) = new_int_obj(ist, 0);
+ OBJ(MAX_INT) = new_int_obj(ist, MAX_INT_VAL);
+ OBJ(LONG_PROTO) = new_string_obj(ist, "0");
clr_immutable(OBJ(LONG_PROTO));
add_doc_to_obj(ist, OBJ(LONG_PROTO), "Long integer number object prototype");
set_immutable(OBJ(LONG_PROTO));
@@ -110,16 +110,16 @@
DEF(Int, __hash__, NULL) {
i32_t i32 = (i32_t) Int_value(self);
- return new_hash_obj((((i32*i32)<<(i32 & 16))+i32)*17);
+ return new_hash_obj(ist, (((i32*i32)<<(i32 & 16))+i32)*17);
}
DEF(Int, __abs__, NULL){
i64_t num = Int_value(self);
- return new_int_obj(num < 0 ? -num : num);
+ return new_int_obj(ist, num < 0 ? -num : num);
}
DEF(Int, __neg__, NULL){
- return new_int_obj( - Int_value(self) );
+ return new_int_obj(ist, - Int_value(self) );
}
DEF(Int, __pos__, NULL){
@@ -134,7 +134,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "Integer cannot be added to this object");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) + Int_value(other));
+ return new_int_obj(ist, Int_value(self) + Int_value(other));
}
DEF(Int, __div__, FORM_RPARAM){
@@ -165,7 +165,7 @@
raise_exception(ist, OBJ(DIVIDEZERO_EXC), NULL);
return NULL;
}
- return new_int_obj(Int_value(self) / Int_value(other));
+ return new_int_obj(ist, Int_value(self) / Int_value(other));
}
DEF(Int, __mod__, FORM_RPARAM) {
@@ -180,7 +180,7 @@
raise_exception(ist, OBJ(DIVIDEZERO_EXC), "modulo by zero");
return NULL;
}
- return new_int_obj(Int_value(self) % Int_value(other));
+ return new_int_obj(ist, Int_value(self) % Int_value(other));
}
DEF(Int, __mul__, FORM_RPARAM) {
@@ -191,7 +191,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "Integer cannot be multiplied by this object");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) * Int_value(other));
+ return new_int_obj(ist, Int_value(self) * Int_value(other));
}
DEF(Int, __sub__, FORM_RPARAM) {
@@ -202,7 +202,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "This object cannot be subtracted from an Integer");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) - Int_value(other));
+ return new_int_obj(ist, Int_value(self) - Int_value(other));
}
DEF(Int, __pow__, FORM_RPARAM){
@@ -224,11 +224,11 @@
return OBJ(NONE);
}
if (Int_value(self) == Int_value(other))
- return new_int_obj(0);
+ return new_int_obj(ist, 0);
else if (Int_value(self) > Int_value(other))
- return new_int_obj(1);
+ return new_int_obj(ist, 1);
else
- return new_int_obj(-1);
+ return new_int_obj(ist, -1);
}
DEF(Int, __eq__QUES, FORM_RPARAM){
@@ -242,7 +242,7 @@
else return OBJ(PR_FALSE);
}
DEF(Int, __invert__, NULL){
- return new_int_obj( ~ Int_value(self) );
+ return new_int_obj(ist, ~ Int_value(self) );
}
DEF(Int, __xor__, FORM_RPARAM) {
@@ -251,7 +251,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be xor'd with an Integer");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) ^ Int_value(other));
+ return new_int_obj(ist, Int_value(self) ^ Int_value(other));
}
DEF(Int, __and__, FORM_RPARAM) {
@@ -260,7 +260,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be and'd with an Integer");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) & Int_value(other));
+ return new_int_obj(ist, Int_value(self) & Int_value(other));
}
DEF(Int, __or__, FORM_RPARAM) {
@@ -269,7 +269,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be or'd with an Integer");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) | Int_value(other));
+ return new_int_obj(ist, Int_value(self) | Int_value(other));
}
DEF(Int, __rshift__, FORM_RPARAM) {
@@ -278,7 +278,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be shifted with an Integer");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) >> Int_value(other));
+ return new_int_obj(ist, Int_value(self) >> Int_value(other));
}
DEF(Int, __lshift__, FORM_RPARAM) {
@@ -287,17 +287,17 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be shifted with an Integer");
return OBJ(NONE);
}
- return new_int_obj(Int_value(self) << Int_value(other));
+ return new_int_obj(ist, Int_value(self) << Int_value(other));
}
DEF(Int, __str__, NULL){
char str[24];
apr_snprintf(str, sizeof(str), "%"APR_INT64_T_FMT, (i64_t)Int_value(self));
- return new_string_obj(str);
+ return new_string_obj(ist, str);
}
DEF(Int, __gen__, NULL) {
- obj_p gen_obj = new_int_obj(0);
+ obj_p gen_obj = new_int_obj(ist, 0);
gen_obj->immutable = FALSE;
gen_obj->attr_proto.proto = IntGen_OBJ;
set_attr(ist, gen_obj, SYM_LIMIT, self);
@@ -307,13 +307,13 @@
DEF(Int, chr, NULL) {
char s[1];
s[0] = (char) Int_value(self);
- return new_string_n_obj(s, 1);
+ return new_string_n_obj(ist, s, 1);
}
MODULE_START(IntGen)
{
- IntGen_OBJ = new_object(NULL);
+ IntGen_OBJ = new_object(ist, NULL);
MODULE_SET_DOC(Int, "number generator object prototype");
}
@@ -329,8 +329,8 @@
raise_exception(ist, OBJ(STOP_ITERATION_EXC), NULL);
return NULL;
}
- res = new_int_obj(Int_value(self));
- read_unlock(ist, self); write_lock(ist, self);
+ res = new_int_obj(ist, Int_value(self));
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
Int_value(self)++;
write_unlock(ist, self); read_lock(ist, self);
return res;
Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-list.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -77,7 +77,7 @@
if (has_proto_QUES(ist, seq, OBJ(STRING_PROTO))) {
s[0] = strch(seq)[i];
s[1] = 0;
- return new_string_obj(s);
+ return new_string_obj(ist, s);
} else
return list_item(ist, seq, i);
}
@@ -122,7 +122,7 @@
obj_p slice = parms[1], value = parms[3];
i64_t i, new_len, exp_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
size_t val_len, self_len, slice_len = list_len(ist, slice);
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
self_len = listlen(self);
slice_item1 = list_item(ist, slice,0);
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
@@ -236,7 +236,7 @@
obj_p slice = parms[1];
i64_t i, new_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
size_t exp_len, self_len, slice_len = list_len(ist, slice);
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
self_len = listlen(self);
slice_item1 = list_item(ist, slice,0);
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
@@ -359,9 +359,9 @@
}
times = (int)parms[1]->data.i64;
size = len*times;
- if(times == 0) return new_list_obj(0);
+ if(times == 0) return new_list_obj(ist, 0);
if(times == 1) return self;
- res = new_object(List_OBJ);
+ res = new_object(ist, List_OBJ);
lstp = res->data.ptr = pr_malloc(list_sizeof(size));
if(!lstp) {
raise_exception(ist, OBJ(OUTOFMEMORY_EXC), "memory allocation failed for list multiplication");
@@ -377,7 +377,7 @@
DEF(List, append_BANG, FORM_RPARAM) {
list_p lstp;
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
lstp = self->data.ptr;
if(lstplen(lstp) == lstpsize(lstp)) {
lstpsize(lstp) *= LIST_GROWTH_FACTOR;
@@ -392,7 +392,7 @@
DEF(List, extend_BANG, FORM_RPARAM) {
list_p selfp, otherp;
size_t self_len, other_len;
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
if (!has_proto_QUES(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto_QUES(ist, parms[1], List_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "extend parameter must be a tuple or list");
return NULL;
@@ -420,7 +420,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "index (i) parameter must be an integer");
return NULL;
}
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
index = (int)parms[1]->data.i64;
selfp = self->data.ptr;
self_len = lstplen(selfp);
@@ -447,7 +447,7 @@
i64_t i;
size_t self_len;
list_p selfp;
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
selfp = self->data.ptr;
self_len = lstplen(selfp);
for (i=0; i < self_len; i++) {
@@ -467,7 +467,7 @@
return self;
}
-DEF(List, pop_BANG, list2(SYM(RPARAM),OBJ(NONE))) {
+DEF(List, pop_BANG, list2(ist, SYM(RPARAM),OBJ(NONE))) {
i64_t index;
size_t self_len;
list_p selfp;
@@ -476,7 +476,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "pop index (i) parameter must be an integer");
return NULL;
}
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
selfp = self->data.ptr;
self_len = lstplen(selfp);
if (parms[1] == OBJ(NONE))
@@ -501,7 +501,7 @@
size_t self_len;
list_p selfp;
list_item_t *p1, *p2;
- read_unlock(ist, self); write_lock(ist, self);
+ read_unlock(ist, self); if_wrlock(self){read_lock(ist, self); return NULL;}
selfp = self->data.ptr;
self_len = lstplen(selfp);
p1 = selfp->item;
Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-string.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -94,7 +94,7 @@
DEF(String, clone, NULL) {
size_t len;
- obj_p clone = clone_object(self);
+ obj_p clone = clone_object(ist, self);
if (self->data_type == OBJ_TYPE_DATAPTR) {
len = sizeof(pr_str_t) + pr_strlen(self) + 1;
clone->data.ptr = pr_malloc(len);
@@ -107,7 +107,7 @@
i32_t res = 0x9a7c5e3;
char *p;
for(p=strch(self); *p; p++) res += 131 * (*p);
- return new_hash_obj(res);
+ return new_hash_obj(ist, res);
}
DEF(String, __objlist__, FORM_RPARAM) {
@@ -131,12 +131,12 @@
DEF(String, cmp, FORM_RPARAM){
obj_p other = parms[1];
if (self == other)
- return new_int_obj(0);
+ return new_int_obj(ist, 0);
if (!is_String(other)) {
raise_exception(ist, OBJ(TYPE_EXC), "Cannot compare a string and non-string");
return NULL;
}
- return new_int_obj(strcmp(strch(self), strch(other)));
+ return new_int_obj(ist, strcmp(strch(self), strch(other)));
}
DEF(String, __add__, FORM_RPARAM){
@@ -146,7 +146,7 @@
if (!is_String(other)) other = call_func0(ist, other, SYM(__STR__));
slen = pr_strlen(self); olen = pr_strlen(other);
tlen = slen + olen;
- obj = new_object(String_OBJ);
+ obj = new_object(ist, String_OBJ);
if (tlen < IMMEDIATE_DATA_LEN) {
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = (int) tlen;
@@ -173,10 +173,10 @@
return NULL;
}
times = (size_t) parms[1]->data.i64;
- if(times == 0) return new_string_obj("");
+ if(times == 0) return new_string_obj(ist, "");
if(times == 1) return self;
tlen = len*times+1;
- obj = new_object(String_OBJ);
+ obj = new_object(ist, String_OBJ);
if (tlen < IMMEDIATE_DATA_LEN) {
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = (int) tlen;
@@ -199,7 +199,7 @@
}
DEF(String, __gen__, NULL) {
- obj_p gen_obj = new_object(StringGen_OBJ);
+ obj_p gen_obj = new_object(ist, StringGen_OBJ);
gen_obj->data_type = OBJ_TYPE_DATAPTR;
gen_obj->data.ptr = strch(self);
set_attr(ist, gen_obj, sym(ist, "saved_string"), self);
@@ -207,7 +207,7 @@
}
DEF(String, ord, NULL) {
- return new_int_obj((int)(*strch(self)));
+ return new_int_obj(ist, (int)(*strch(self)));
}
DEF(String, join, FORM_RPARAM) {
@@ -222,8 +222,8 @@
}
list = parms[1];
llen = (int) list_len(ist, parms[1]);
- if (!llen) return new_string_obj("");
- str_list = new_list_obj(llen);
+ if (!llen) return new_string_obj(ist, "");
+ str_list = new_list_obj(ist, llen);
self_str = strch(self);
self_len = pr_strlen(self);
tlen = 0;
@@ -233,7 +233,7 @@
tlen += pr_strlen(str_obj);
if (i != llen-1) tlen += self_len;
}
- obj = new_object(String_OBJ);
+ obj = new_object(ist, String_OBJ);
if (tlen < IMMEDIATE_DATA_LEN) {
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = (int) tlen;
@@ -278,23 +278,23 @@
}
DEF(String, len, NULL) {
- return new_int_obj(pr_strlen(self));
+ return new_int_obj(ist, pr_strlen(self));
}
MODULE_START(StringGen)
{
- StringGen_OBJ = new_object(NULL);
+ StringGen_OBJ = new_object(ist, NULL);
}
DEF(StringGen, next, NULL) {
int ch;
obj_p res = NULL;
char* res_str;
- write_lock(ist, self);
+ wrlock_rtrn(self) NULL;
if ((ch = *strch(self))) {
((char*)(self->data.ptr))++;
- res = new_object(String_OBJ);
+ res = new_object(ist, String_OBJ);
res_str = (char*)obj_malloc(res, 2);
res_str[0] = ch;
res_str[1] = 0;
Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/builtins-tuple.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -132,10 +132,10 @@
tgt_item = list_item(ist, tgt_list, i);
res = call_func1(ist, self_item, SYM(CMP), tgt_item); if_exc_return NULL;
if (res->data.i64)
- return new_int_obj(res->data.i64);
+ return new_int_obj(ist, res->data.i64);
}
- if (llen < tlen) return new_int_obj(-1);
- if (llen > tlen) return new_int_obj(+1);
+ if (llen < tlen) return new_int_obj(ist, -1);
+ if (llen > tlen) return new_int_obj(ist, +1);
return OBJ(ZERO_INT);
}
@@ -204,12 +204,12 @@
times = (int)parms[1]->data.i64;
size = len*times;
if(times == 0) {
- obj_p res = new_tuple_obj(0);
+ obj_p res = new_tuple_obj(ist, 0);
res ->immutable = TRUE;
return res;
}
if(times == 1) return self;
- res = new_object(OBJ(TUPLE_PROTO));
+ res = new_object(ist, OBJ(TUPLE_PROTO));
lstp = res->data.ptr = pr_malloc(list_sizeof(size));
if(!lstp) {
raise_exception(ist, OBJ(OUTOFMEMORY_EXC), "memory allocation failed for tuple multiplication");
@@ -224,7 +224,7 @@
}
DEF(Tuple, len, NULL) {
- return new_int_obj(list_len(ist, self));
+ return new_int_obj(ist, list_len(ist, self));
}
DEF(Tuple, min, NULL) {
@@ -264,14 +264,14 @@
cnt++;
if_exc_return NULL;
}
- return new_int_obj(cnt);
+ return new_int_obj(ist, cnt);
}
DEF(Tuple, index, FORM_RPARAM) {
int i, llen = (int) list_len(ist, self);
for (i=0; i < llen; i++) {
if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__QUES), parms[1]) == OBJ(PR_TRUE))
- return new_int_obj(i);
+ return new_int_obj(ist, i);
if_exc_return NULL;
}
raise_exception(ist, OBJ(INDEX_EXC), "item not found in index search");
@@ -283,7 +283,7 @@
}
DEF(Tuple, __gen__, NULL) {
- obj_p list_obj, gen_obj = new_object(Tgen_OBJ);
+ obj_p list_obj, gen_obj = new_object(ist, Tgen_OBJ);
gen_obj->data_type = OBJ_TYPE_DATAPTR;
gen_obj->data.ptr = list_obj = clone_list_obj(ist, self);
listlen(list_obj) = 0;
@@ -294,7 +294,7 @@
//*************************** TUPLE GENERATOR OBJECT **************************
MODULE_START(Tgen)
{
- Tgen_OBJ = new_object(NULL);
+ Tgen_OBJ = new_object(ist, NULL);
}
DEF(Tgen, next, NULL) {
Modified: trunk/src/init.pth
===================================================================
--- trunk/src/init.pth 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/init.pth 2004-04-06 07:56:29 UTC (rev 290)
@@ -5,8 +5,8 @@
# these are added to Sys.path
-c:\prothon\modules\file\release
-c:\prothon\modules\re\release
+c:\prothon\modules\file\debug
+c:\prothon\modules\re\debug
# this is executed before Main1 as module PthMod1
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/interp.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -167,11 +167,11 @@
if (pstate == 2) goto fparmerr;
pstate = 2;
fparam_proc_state->free_pos_list_key = value;
- fparam_proc_state->free_pos_list_obj = new_list_obj(10);
+ fparam_proc_state->free_pos_list_obj = new_list_obj(ist, 10);
} else if (label == PARAM_STAR_STAR) {
pstate = 3;
fparam_proc_state->free_label_list_key = value;
- fparam_proc_state->free_label_list_obj = new_list_obj(10);
+ fparam_proc_state->free_label_list_obj = new_list_obj(ist, 10);
} else {
if (value) pstate = 1;
clist_append(fparam_proc_state->lbl_val_list, label);
@@ -289,7 +289,7 @@
ist->exception_obj = 0;
fstk_obj = get_attr(ist, orig_excobj, sym(ist, "frame_stack"));
if (!fstk_obj)
- set_attr(ist, orig_excobj, sym(ist, "frame_stack"), (fstk_obj = new_list_obj(10)));
+ set_attr(ist, orig_excobj, sym(ist, "frame_stack"), (fstk_obj = new_list_obj(ist, 10)));
srcmap = frame->code->srcmap;
for (i = 0; i < clist_len(srcmap); i += 3) {
pc = clist_num(srcmap, i);
@@ -298,10 +298,10 @@
col = clist_num(srcmap, i+2);
}
if (frame->code->file_path)
- str_obj = new_string_obj(frame->code->file_path);
+ str_obj = new_string_obj(ist, frame->code->file_path);
list_append(ist, fstk_obj, str_obj);
- list_append(ist, fstk_obj, new_int_obj(line));
- list_append(ist, fstk_obj, new_int_obj(col));
+ list_append(ist, fstk_obj, new_int_obj(ist, line));
+ list_append(ist, fstk_obj, new_int_obj(ist, col));
ist->exception_obj = orig_excobj;
}
@@ -642,7 +642,7 @@
break;
case OP_PUSH_SUPER_REF:
fr_push(frame->self);
- fr_push(new_super_obj(fr_data(1)));
+ fr_push(new_super_obj(ist, fr_data(1)));
break;
case OP_PUSH_GLOBAL_REF:
fr_push(frame->globals);
@@ -701,7 +701,7 @@
}
} break;
case OP_NEWTUPLE: {
- obj_p tuple_obj = new_tuple_obj(param);
+ obj_p tuple_obj = new_tuple_obj(ist, param);
fr_sp -= param;
listlen(tuple_obj) = param;
for (i=0; i < param; i++)
@@ -709,14 +709,14 @@
fr_push(tuple_obj);
} break;
case OP_NEWLIST: {
- obj_p list_obj = new_list_obj(param);
+ obj_p list_obj = new_list_obj(ist, param);
fr_sp -= param;
for (i=0; i<param; i++)
list_append(ist, list_obj, fr_stack[fr_sp+i]);
fr_push(list_obj);
} break;
case OP_NEWDICT: {
- obj_p dict_obj = new_dict_obj(param);
+ obj_p dict_obj = new_dict_obj(ist, param);
fr_sp -= param;
for (i=0; i < param; i+=2) {
dict_add(ist, dict_obj, fr_stack[fr_sp+i], fr_stack[fr_sp+i+1]);
@@ -727,7 +727,7 @@
case OP_NEWSLICE: {
obj_p ret;
fr_sp -= 3;
- ret = new_slice_obj(fr_stack[fr_sp], fr_stack[fr_sp+1], fr_stack[fr_sp+2]);
+ ret = new_slice_obj(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], fr_stack[fr_sp+2]);
fr_push(ret);
break;
}
@@ -735,7 +735,7 @@
case OP_DEF: {
int fparams_len = fr_data_int(1)*2;
obj_p func = call_func0(ist, fr_data(2), SYM(CLONE));
- obj_p fparams_obj = new_list_obj(fparams_len);
+ obj_p fparams_obj = new_list_obj(ist, fparams_len);
fr_sp -= fparams_len+2;
assert(sizeof(list_item_t) == sizeof(obj_p));
memcpy( ((list_p)(obj_data_p(fparams_obj)))->item,
@@ -766,7 +766,7 @@
case OP_LAMBDA: {
int fparams_len = fr_data_int(1)*2;
obj_p func = fr_data(2);
- obj_p fparams_obj = new_list_obj(fparams_len);
+ obj_p fparams_obj = new_list_obj(ist, fparams_len);
fr_sp -= fparams_len;
memcpy( ((list_p)(obj_data_p(fparams_obj)))->item,
fr_stack+fr_sp, fparams_len*sizeof(list_item_t) );
@@ -877,7 +877,7 @@
obj_p new_locals;
exec_frame_t* new_frame;
if (intrp_exobj) break;
- new_locals = new_object(NULL);
+ new_locals = new_object(ist, NULL);
new_frame = new_exec_frame( ist,
frame->globals, // self
NULL, NULL,
@@ -899,7 +899,7 @@
fr_push(func_obj);
} else {
memmove(fr_stack+fr_sp+2, fr_stack+fr_sp+1, (param*2) * sizeof(obj_p));
- fr_stack[fr_sp] = new_object(fr_stack[fr_sp]);
+ fr_stack[fr_sp] = new_object(ist, fr_stack[fr_sp]);
fr_stack[fr_sp+1] = fr_stack[fr_sp];
fr_stack[fr_sp+2] = SYM(__INIT__);
fr_sp++;
@@ -967,7 +967,7 @@
obj_p new_locals;
exec_frame_t* new_frame;
if (intrp_exobj) break;
- new_locals = new_object(NULL);
+ new_locals = new_object(ist, NULL);
new_frame = new_exec_frame( ist,
fr_stack[fr_sp], // self
NULL, NULL,
@@ -995,7 +995,7 @@
if (intrp_exobj) break;
if (value) {
memmove(&fr_stack[fr_sp+3], &fr_stack[fr_sp+2], param*2*sizeof(obj_p));
- fr_stack[fr_sp] = new_object(value);
+ fr_stack[fr_sp] = new_object(ist, value);
fr_stack[fr_sp+1] = fr_stack[fr_sp];
fr_stack[fr_sp+2] = SYM(__INIT__);
fr_sp++;
@@ -1199,7 +1199,7 @@
}
} else {
func_obj = self;
- self = new_object(NULL);
+ self = new_object(ist, NULL);
}
if (func_obj->data_type == OBJ_TYPE_FUNCPTR) {
int i;
@@ -1226,7 +1226,7 @@
return 0;
}
frame = ist->frame;
- new_locals = new_object(NULL);
+ new_locals = new_object(ist, NULL);
new_frame = new_exec_frame( ist, self, NULL, NULL, dyn_locals, new_locals, func_obj, NULL );
new_frame->called_from_c = TRUE;
ist->frame->next_frame = new_frame;
@@ -1324,7 +1324,7 @@
new_frame = new_exec_frame( ist, frame->self, frame->globals,
frame->syn_locals, frame->dyn_locals, frame->locals, NULL, code );
else {
- new_locals = new_object(NULL);
+ new_locals = new_object(ist, NULL);
new_frame = new_exec_frame( ist, OBJ(ROOT_GLOBALS), OBJ(ROOT_GLOBALS),
new_locals, new_locals, new_locals, NULL, code );
}
@@ -1347,18 +1347,19 @@
parse_state* state;
char full_doc[1024], *name;
code* code;
+ int i;
if (!module)
module = get_attr(ist, OBJ(MODULES), module_name);
if (!module)
- module = new_object(NULL);
-
+ module = new_object(ist, NULL);
+ su(i);
set_attr(ist, OBJ(MODULES), module_name, module);
+ un_su(i);
if (exec_string)
state = parse_file_or_string(ist, NULL, exec_string);
else
state = parse_file_or_string(ist, filename, NULL);
-
catch_exception(ist, OBJ(FILENOTFOUND_EXC), NULL); if_exc_return FALSE;
if (!state || !(code = (state->parse_results)))
@@ -1376,7 +1377,7 @@
apr_snprintf(full_doc, sizeof(full_doc), "%s%s", name, comment);
add_doc_to_obj(ist, module, full_doc);
frame = ist->frame;
- new_locals = new_object(NULL);
+ new_locals = new_object(ist, NULL);
set_attr(ist, module, SYM(__LOCALS__), new_locals);
new_frame = new_exec_frame( ist, module, module, dest_module, dyn_locals, new_locals, NULL, code );
new_frame->called_from_c = TRUE;
@@ -1394,7 +1395,7 @@
//******************************** main_thread ***********************************
void *main_thread(apr_thread_t *handle, void *argv){
isp ist = get_ist(ACC_USER2);
- int main_index=1;
+ int i, main_index=1;
obj_p main_sym, module, thread_obj;
pr_thread_p thread_p;
char* filename = strch(list_item(ist, (obj_p)argv, 0));
@@ -1417,9 +1418,11 @@
apr_snprintf(name, sizeof(name), "Main%d", main_index);
main_sym = sym(ist, name);
if (!get_attr(ist, OBJ(MODULES), main_sym)) {
- module = new_object(OBJ(ROOT_GLOBALS));
+ module = new_object(ist, OBJ(ROOT_GLOBALS));
+ su(i);
set_attr(ist, OBJ(MODULES), main_sym, module);
- set_attr(ist, thread_obj, sym(ist, "name"), new_string_obj(name));
+ set_attr(ist, thread_obj, sym(ist, "name"), new_string_obj(ist, name));
+ un_su(i);
thread_p->main_id = main_index;
break;
}
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/main.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -110,7 +110,7 @@
static apr_pool_t *thread_pool = NULL;
//********************************* new_thread_obj ****************************
-obj_p new_thread_obj(apr_thread_start_t thread_func, void *thread_data)
+obj_p new_thread_obj(isp ist, apr_thread_start_t thread_func, void *thread_data)
{
apr_status_t aprerr;
apr_thread_t *new_thread = NULL;
@@ -137,7 +137,7 @@
* calls register_thread(). */
pr_lock(&thread_registry_lock);
- new_thread_object = new_object(OBJ(THREAD_PROTO));
+ new_thread_object = new_object(ist, OBJ(THREAD_PROTO));
new_thread_object->data_type = OBJ_TYPE_DATAPTR;
new_thread_object->data.ptr = pr_malloc(sizeof(pr_thread_t));
memset(new_thread_object->data.ptr, 0, sizeof(pr_thread_t));
@@ -223,7 +223,7 @@
main_argv_obj = get_attr(ist, sys_argv_obj, sym(ist, "argv"));
if (main_argv_obj && list_len(ist, main_argv_obj)) {
- main1_thread_obj = new_thread_obj((apr_thread_start_t)main_thread, main_argv_obj);
+ main1_thread_obj = new_thread_obj(ist, (apr_thread_start_t)main_thread, main_argv_obj);
main1_thread_ptr = main1_thread_obj->data.ptr;
}
@@ -231,14 +231,14 @@
if (threads) {
int i;
for (i = 0; i < (int) list_len(ist, threads); i++)
- new_thread_obj((apr_thread_start_t)main_thread, list_item(ist, threads, i));
+ new_thread_obj(ist, (apr_thread_start_t)main_thread, list_item(ist, threads, i));
}
- new_thread_obj((apr_thread_start_t)mem_mgr_thread, NULL);
+ new_thread_obj(ist, (apr_thread_start_t)mem_mgr_thread, NULL);
#ifdef DEBUG_THREADS
SetThreadName("main");
- new_thread_obj((apr_thread_start_t)torture_scan_thread, torture_scan_num_ptr);
+ new_thread_obj(ist, (apr_thread_start_t)torture_scan_thread, torture_scan_num_ptr);
#endif
#ifdef DEBUG_THREADS
@@ -248,18 +248,25 @@
/* Grab this lock, so we know all threads are started */
pr_lock(&thread_registry_lock); pr_unlock(&thread_registry_lock);
- if (!main_threads_started)
+ if (!main_threads_started) {
+ ist->access = ACC_USER2;
console(ist);
- else {
+ ist->access = ACC_SYSTEM;
+ } else {
while(main_threads_running) {
apr_sleep(PAUSE_MS*1000);
if (cmd_line_option_i_flg && (!main1_thread_ptr || !main1_thread_ptr->running)) {
+ ist->access = ACC_USER2;
console(ist);
+ ist->access = ACC_SYSTEM;
cmd_line_option_i_flg = FALSE;
}
}
- if (cmd_line_option_i_flg)
+ if (cmd_line_option_i_flg) {
+ ist->access = ACC_USER2;
console(ist);
+ ist->access = ACC_SYSTEM;
+ }
}
#ifdef DEBUG_THREADS
Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/memory_mgr.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -110,7 +110,7 @@
//********************************* mem_mgr_thread ******************************
void *mem_mgr_thread(apr_thread_t *handle, void *dummy) {
isp ist = get_ist(ACC_SYSTEM);
- obj_p mm_obj_list = new_list_obj(100);
+ obj_p mm_obj_list = new_list_obj(ist, 100);
obj_p mm_obj_act_param[2];
int last_obj_del_count = 0, last_obj_count = 0;
Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/object.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -175,31 +175,31 @@
dll_services.dict_keys_values = dict_keys_values;
/* Setup the core objects. Order counts here */
- OBJ(OBJECT) = new_object(NULL);
+ OBJ(OBJECT) = new_object(ist, NULL);
OBJ(OBJECT)->attr_proto.proto = OBJ(OBJECT);
- OBJ(SEQ_PROTO) = new_object(NULL);
- OBJ(TUPLE_PROTO) = new_object(OBJ(SEQ_PROTO));
- OBJ(LIST_PROTO) = new_object(OBJ(TUPLE_PROTO));
- OBJ(SYMBOL_PROTO) = new_object(NULL);
+ OBJ(SEQ_PROTO) = new_object(ist, NULL);
+ OBJ(TUPLE_PROTO) = new_object(ist, OBJ(SEQ_PROTO));
+ OBJ(LIST_PROTO) = new_object(ist, OBJ(TUPLE_PROTO));
+ OBJ(SYMBOL_PROTO) = new_object(ist, NULL);
- OBJ(HASH_PROTO) = new_object(NULL);
- OBJ(SLICE_PROTO) = new_object(NULL);
- OBJ(SUPER_PROTO) = new_object(NULL);
- OBJ(THREAD_PROTO) = new_object(NULL);
- OBJ(ROOT_GLOBALS) = new_object(NULL);
- OBJ(MODULES) = new_object(NULL);
- OBJ(PR_FALSE) = new_object(NULL);
- OBJ(PR_TRUE) = new_object(NULL);
- OBJ(NONE) = new_object(NULL);
- OBJ(EXCEPTION) = new_object(NULL);
- OBJ(GEN_PROTO) = new_object(NULL);
- OBJ(INT_PROTO) = new_object(NULL);
- OBJ(STRING_PROTO) = new_object(NULL);
- OBJ(DICT_PROTO) = new_object(NULL);
- OBJ(FUNC_PROTO) = new_object(NULL);
+ OBJ(HASH_PROTO) = new_object(ist, NULL);
+ OBJ(SLICE_PROTO) = new_object(ist, NULL);
+ OBJ(SUPER_PROTO) = new_object(ist, NULL);
+ OBJ(THREAD_PROTO) = new_object(ist, NULL);
+ OBJ(ROOT_GLOBALS) = new_object(ist, NULL);
+ OBJ(MODULES) = new_object(ist, NULL);
+ OBJ(PR_FALSE) = new_object(ist, NULL);
+ OBJ(PR_TRUE) = new_object(ist, NULL);
+ OBJ(NONE) = new_object(ist, NULL);
+ OBJ(EXCEPTION) = new_object(ist, NULL);
+ OBJ(GEN_PROTO) = new_object(ist, NULL);
+ OBJ(INT_PROTO) = new_object(ist, NULL);
+ OBJ(STRING_PROTO) = new_object(ist, NULL);
+ OBJ(DICT_PROTO) = new_object(ist, NULL);
+ OBJ(FUNC_PROTO) = new_object(ist, NULL);
- OBJ(SYMBOLS) = new_list_obj(SYM_ENUM_COUNT+100);
+ OBJ(SYMBOLS) = new_list_obj(ist, SYM_ENUM_COUNT+100);
init_symbol(ist);
@@ -216,12 +216,15 @@
}
//********************************* new_object ********************************
-obj_p new_object(obj_p proto){
+obj_p new_object(isp ist, obj_p proto){
obj_p obj = pr_malloc(sizeof(obj_t));
memset(obj, 0, sizeof(obj_t));
if (!proto) proto = OBJ(OBJECT);
- //obj->rd_access = ACC_SYSTEM;
- //obj->wr_access = ACC_SYSTEM;
+ obj->rd_access = ACC_GUEST;
+ if (ist)
+ obj->wr_access = ist->access;
+ else
+ obj->wr_access = ACC_SYSTEM;
obj->attr_proto.proto = proto;
lock_init(obj->wrlock);
obj->del_locked = TRUE;
@@ -235,10 +238,10 @@
//********************************* clone_object ******************************
// clones everything but data pointed to by data.ptr
-obj_p clone_object(obj_p obj) {
+obj_p clone_object(isp ist, obj_p obj) {
obj_p clone;
attr_p new_attrp, attrp;
- clone = new_object(NULL);
+ clone = new_object(ist, NULL);
memcpy(clone, obj, sizeof(*obj)-sizeof(obj->next_obj));
clone->archived = FALSE;
clone->del_locked = TRUE;
@@ -284,7 +287,7 @@
{
if (!proto_obj)
proto_obj = OBJ(EXCEPTION);
- ist->exception_obj = new_object(proto_obj);
+ ist->exception_obj = new_object(ist, proto_obj);
if (format) {
char err_buf[512];
va_list ap;
@@ -293,6 +296,7 @@
apr_vsnprintf(err_buf, sizeof(err_buf), format, ap);
va_end(ap);
+ ist->exception_obj->wr_access = ACC_GUEST;
add_doc_to_obj(ist, ist->exception_obj, err_buf);
}
}
@@ -337,7 +341,7 @@
//********************************* del_attr *******************************
int del_attr(isp ist, obj_p obj, obj_p key) {
- write_lock(ist, obj);
+ wrlock_rtrn(obj) FALSE;
if (obj->has_attrs){
attr_p ptr, attrs = obj->attr_proto.attrs;
attr_key_t i, akey, tgt = key->data.key;
@@ -405,7 +409,7 @@
attr_p attrs, ptr, hole=0;
attr_key_t i, akey, tgt = key->data.key;
assert((tgt%3)==0);
- write_lock(ist, obj);
+ wrlock_rtrn(obj);
if (obj->has_attrs) attrs = obj->attr_proto.attrs;
else attrs = add_attrs(obj);
if (((attr_alen(attrs) * 100) / attr_asize(attrs)) > ATTRS_MAX_PERCENT_FULL)
@@ -426,7 +430,7 @@
//********************************* switch_proto_to ****************************
void switch_proto_to(isp ist, obj_p obj, obj_p new_proto) {
attr_p attrs;
- write_lock(ist, obj);
+ wrlock_rtrn(obj);
if (!(obj->has_attrs)) {
obj->attr_proto.proto = new_proto;
write_unlock(ist, obj);
@@ -443,7 +447,7 @@
int ins_proto(isp ist, obj_p obj, obj_p proto, int pos){
attr_p attrs;
i32_t i, len;
- write_lock(ist, obj);
+ wrlock_rtrn(obj) FALSE;
if (obj->has_attrs) attrs = obj->attr_proto.attrs;
else attrs = add_attrs(obj);
len = attr_blen(attrs);
@@ -472,7 +476,7 @@
int del_proto(isp ist, obj_p obj, obj_p proto) {
attr_p attrs;
i32_t i, len;
- write_lock(ist, obj);
+ wrlock_rtrn(obj) FALSE;
if (!obj->has_attrs) {
write_unlock(ist, obj);
return FALSE;
@@ -562,7 +566,7 @@
clist_item(pao_list,i) = 0;
k++;
}
- list_obj = new_list_obj(clist_len(pao_list)-k);
+ list_obj = new_list_obj(ist, clist_len(pao_list)-k);
for (i=0; i < clist_len(pao_list); i++)
if ((proto = clist_item(pao_list, i)))
list_append(ist, list_obj, proto);
@@ -729,7 +733,7 @@
//********************************* obj_realloc *******************************
void* obj_realloc(isp ist, obj_p obj, size_t size){
- write_lock(ist, obj);
+ wrlock_rtrn(obj) NULL;
if(obj->data_type == OBJ_TYPE_DATAPTR){
if(size <= sizeof(obj_data_t)){
char* ptr = obj->data.ptr;
@@ -755,7 +759,7 @@
//********************************* obj_free **********************************
void obj_free(isp ist, obj_p obj) {
- write_lock(ist, obj);
+ wrlock_rtrn(obj);
if(obj->data_type == OBJ_TYPE_DATAPTR)
pr_free(obj->data.ptr);
obj->data.ptr = NULL;
@@ -764,8 +768,8 @@
}
//********************************* new_int_obj *******************************
-obj_p new_int_obj(i64_t num){
- obj_p obj = new_object(OBJ(INT_PROTO));
+obj_p new_int_obj(isp ist, i64_t num){
+ obj_p obj = new_object(ist, OBJ(INT_PROTO));
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = 8;
obj->data.i64 = num;
@@ -774,8 +778,8 @@
}
//********************************* new_float_obj *****************************
-obj_p new_float_obj(double num){
- obj_p obj = new_object(OBJ(FLOAT_PROTO));
+obj_p new_float_obj(isp ist, double num){
+ obj_p obj = new_object(ist, OBJ(FLOAT_PROTO));
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = 8;
obj->data.f64 = num;
@@ -785,14 +789,14 @@
//********************************* new_string_obj ****************************
// this cannot be used with binary data, for C strings only
-// for binary data with embedded nulls use new_string_n_obj()
-obj_p new_string_obj(char* str){
+// for binary data with embedded nulls use new_string_n_obj(ist, )
+obj_p new_string_obj(isp ist, char* str){
obj_p obj;
pr_str_p obj_str;
size_t len;
if(!str) return NULL;
len = strlen(str);
- obj = new_object(OBJ(STRING_PROTO));
+ obj = new_object(ist, OBJ(STRING_PROTO));
if (len < IMMEDIATE_DATA_LEN) {
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = (int) len;
@@ -807,11 +811,11 @@
}
//********************************* new_string_n_obj **************************
-obj_p new_string_n_obj(char* str, size_t len){
+obj_p new_string_n_obj(isp ist, char* str, size_t len){
obj_p obj;
pr_str_p obj_str;
if(!str) return NULL;
- obj = new_object(OBJ(STRING_PROTO));
+ obj = new_object(ist, OBJ(STRING_PROTO));
if (len < IMMEDIATE_DATA_LEN) {
obj->data_type = OBJ_TYPE_IMMDATA;
obj->imm_data_len = (int) len;
@@ -828,8 +832,8 @@
}
//********************************* new_hash_obj ******************************
-obj_p new_hash_obj(i32_t num) {
- obj_p hash_obj = new_object(OBJ(HASH_PROTO));
+obj_p new_hash_obj(isp ist, i32_t num) {
+ obj_p hash_obj = new_object(ist, OBJ(HASH_PROTO));
hash_obj->data_type = OBJ_TYPE_IMMDATA;
hash_obj->imm_data_len = 4;
hash_obj->data.i32[0] = num & HASH_MASK;
@@ -847,8 +851,8 @@
}
//********************************* new_tuple_obj *****************************
-obj_p new_tuple_obj(int fixed_size) {
- obj_p tuple_obj = new_list_obj(fixed_size);
+obj_p new_tuple_obj(isp ist, int fixed_size) {
+ obj_p tuple_obj = new_list_obj(ist, fixed_size);
assert(!(tuple_obj->has_attrs));
tuple_obj->attr_proto.proto = OBJ(TUPLE_PROTO);
return tuple_obj;
@@ -924,8 +928,8 @@
}
//********************************* new_slice_obj *****************************
-obj_p new_slice_obj(obj_p ind1, obj_p ind2, obj_p ind3) {
- obj_p slice_obj = new_list_obj(3);
+obj_p new_slice_obj(isp ist, obj_p ind1, obj_p ind2, obj_p ind3) {
+ obj_p slice_obj = new_list_obj(ist, 3);
assert(!(slice_obj->has_attrs));
slice_obj->attr_proto.proto = OBJ(SLICE_PROTO);
if (ind1 == SLICEPARAM_EMPTY)
@@ -949,8 +953,8 @@
}
//********************************* new_super_obj *****************************
-obj_p new_super_obj(obj_p symbol){
- obj_p super_obj = new_object(OBJ(SUPER_PROTO));
+obj_p new_super_obj(isp ist, obj_p symbol){
+ obj_p super_obj = new_object(ist, OBJ(SUPER_PROTO));
super_obj->data_type = OBJ_TYPE_DATAPTR;
super_obj->data.ptr = symbol;
super_obj->immutable = TRUE;
@@ -959,8 +963,8 @@
//********************************* new_list_obj ******************************
-obj_p new_list_obj(size_t initial_size){
- obj_p list_obj = new_object(OBJ(LIST_PROTO));
+obj_p new_list_obj(isp ist, size_t initial_size){
+ obj_p list_obj = new_object(ist, OBJ(LIST_PROTO));
list_p lstp = list_obj->data.ptr =
pr_malloc(list_sizeof(max(initial_size,2)));
list_obj->data_type = OBJ_TYPE_DATAPTR;
@@ -977,7 +981,7 @@
rdlock_rtrn(list_obj) NULL;
llen = listlen(list_obj);
size = list_sizeof(llen);
- res = clone_object(list_obj);
+ res = clone_object(ist, list_obj);
res->data.ptr = list_ptr = pr_malloc(size);
lstpsize(list_ptr) = llen;
lstplen(list_ptr) = llen;
@@ -998,7 +1002,7 @@
//********************************* list_clear **********************************
void list_clear(isp ist, obj_p list_obj) {
- write_lock(ist, list_obj);
+ wrlock_rtrn(list_obj);
listlen(list_obj) = 0;
write_unlock(ist, list_obj);
}
@@ -1015,7 +1019,7 @@
//********************************* list_append *******************************
obj_p list_append(isp ist, obj_p list_obj, obj_p item){
list_p lstp;
- write_lock(ist, list_obj);
+ wrlock_rtrn(list_obj) NULL;
lstp = list_obj->data.ptr;
if(lstplen(lstp) == lstpsize(lstp)) {
lstpsize(lstp) *= LIST_GROWTH_FACTOR;
@@ -1041,38 +1045,38 @@
}
//********************************* list1 *************************************
-obj_p list1(obj_p item1){
- obj_p list_obj = new_list_obj(1);
+obj_p list1(isp ist, obj_p item1){
+ obj_p list_obj = new_list_obj(ist, 1);
list_append_no_lock(list_obj, item1);
return list_obj;
}
//********************************* list2 *************************************
-obj_p list2(obj_p item1, obj_p item2){
- obj_p list_obj = new_list_obj(2);
+obj_p list2(isp ist, obj_p item1, obj_p item2){
+ obj_p list_obj = new_list_obj(ist, 2);
list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, item2);
return list_obj;
}
//********************************* list3 *************************************
-obj_p list3(obj_p item1, obj_p item2, obj_p item3){
- obj_p list_obj = new_list_obj(3);
+obj_p list3(isp ist, obj_p item1, obj_p item2, obj_p item3){
+ obj_p list_obj = new_list_obj(ist, 3);
list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, item2);
list_append_no_lock(list_obj, item3);
return list_obj;
}
//********************************* list4 *************************************
-obj_p list4(obj_p item1, obj_p item2, obj_p item3, obj_p item4){
- obj_p list_obj = new_list_obj(4);
+obj_p list4(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4){
+ obj_p list_obj = new_list_obj(ist, 4);
list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, item2);
list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, item4);
return list_obj;
}
//********************************* list6 *************************************
-obj_p list6(obj_p item1, obj_p item2, obj_p item3, obj_p item4, obj_p item5, obj_p item6){
- obj_p list_obj = new_list_obj(6);
+obj_p list6(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4, obj_p item5, obj_p item6){
+ obj_p list_obj = new_list_obj(ist, 6);
list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, item2);
list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, item4);
list_append_no_lock(list_obj, item5); list_append_no_lock(list_obj, item6);
@@ -1080,8 +1084,8 @@
}
//********************************* new_dict_obj ******************************
-obj_p new_dict_obj(int initial_size){
- obj_p dict_obj = new_object(OBJ(DICT_PROTO));
+obj_p new_dict_obj(isp ist, int initial_size){
+ obj_p dict_obj = new_object(ist, OBJ(DICT_PROTO));
dict_p dict;
initial_size = max(initial_size, DEFAULT_INITIAL_DICT_SIZE);
dict = obj_malloc(dict_obj, (DICT_OVERHEAD+initial_size)*sizeof(dict_t));
@@ -1102,7 +1106,7 @@
obj_p key, rp[2];
dict_p dict, dp, hole=NULL;
rp[0]=0; rp[1]=key_in;
- write_lock(ist, dict_obj);
+ wrlock_rtrn(dict_obj) FALSE;
hash_in = hash_value(call_func(ist, key_in, SYM(__HASH__), 0, NULL, NULL));
dict_wr_chk();
dict = (dict_p) obj_data_p(dict_obj);
@@ -1176,7 +1180,7 @@
dict = dict_d(dict_obj);
size = dictsize(dict);
len = dictlen(dict);
- list_obj = new_list_obj((int)dictlen(dict));
+ list_obj = new_list_obj(ist, (int)dictlen(dict));
for(i=0; i < size; i++)
if ((dp=dictptr(dict,i))->entry.hash > 0) {
assert (cnt++ < len);
@@ -1195,15 +1199,15 @@
char* ns = pr_malloc(strlen(str)+1);
strcpy(ns, str);
ns[strlen(str)-1] = 0;
- set_attr(ist, obj, SYM(__DOC__), new_string_obj(ns));
+ set_attr(ist, obj, SYM(__DOC__), new_string_obj(ist, ns));
pr_free(ns);
} else
- set_attr(ist, obj, SYM(__DOC__), new_string_obj(str));
+ set_attr(ist, obj, SYM(__DOC__), new_string_obj(ist, str));
}
//********************************* new_func_obj ******************************
obj_p new_func_obj(isp ist, pr_func* func_ptr, obj_p label_values_list) {
- obj_p func_obj = new_object(OBJ(FUNC_PROTO));
+ obj_p func_obj = new_object(ist, OBJ(FUNC_PROTO));
func_obj->data_type = OBJ_TYPE_FUNCPTR;
func_obj->data.ptr = func_ptr;
if (label_values_list)
Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/object.h 2004-04-06 07:56:29 UTC (rev 290)
@@ -127,15 +127,15 @@
#endif
void object_store_init(isp ist, int nop2);
-obj_p new_object(obj_p proto);
-obj_p clone_object(obj_p obj);
+obj_p new_object(isp ist, obj_p proto);
+obj_p clone_object(isp ist, obj_p obj);
void free_object(obj_p obj);
void set_item(isp ist, obj_p value, obj_p ref_self, obj_p ref_key);
void del_item(isp ist, obj_p ref_self, obj_p ref_key);
-obj_p new_float_obj(double num);
-obj_p new_hash_obj(i32_t num);
+obj_p new_float_obj(isp ist, double num);
+obj_p new_hash_obj(isp ist, i32_t num);
char* numonly(char* s, char* buf);
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/parser_routines.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -920,7 +920,7 @@
add_code_to(clist_item(params,i), res, &k);
if (self)
add_code_to(self, res, &k);
- func = new_object(OBJ(FUNC_PROTO));
+ func = new_object(INTRP, OBJ(FUNC_PROTO));
code_len = blen * sizeof(code_t);
memmove(obj_malloc(func, code_len), body, code_len);
switch (flg) {
@@ -1039,7 +1039,7 @@
}
code* int_to_obj(void* param, i64_t num){
code* res;
- obj_p obj = new_object(OBJ(INT_PROTO));
+ obj_p obj = new_object(INTRP, OBJ(INT_PROTO));
*((i64_t*) obj_malloc(obj, sizeof(i64_t))) = num;
res = new_code(param, 2, 1, 1, OP_PUSH);
res->code_data[0].bytecode.param = 2;
@@ -1049,7 +1049,7 @@
}
code* float_to_obj(void* param, double num, int imag_flag){
code* res;
- obj_p obj = new_object(
+ obj_p obj = new_object(INTRP,
(imag_flag == NEW_IMAG? OBJ(IMAG_PROTO) : OBJ(FLOAT_PROTO)) );
*((double*) obj_malloc(obj, sizeof(double))) = num;
res = new_code(param, 2, 1, 1, OP_PUSH);
@@ -1062,7 +1062,7 @@
code* p = new_code(param, 2, 1, 1, OP_PUSH);
pr_str_p obj_str;
size_t len = strlen(str);
- obj_p obj = new_object(
+ obj_p obj = new_object(INTRP,
(long_flag == NEW_LONG? OBJ(LONG_PROTO) : OBJ(STRING_PROTO)) );
if (len < IMMEDIATE_DATA_LEN) {
obj->data_type = OBJ_TYPE_IMMDATA;
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/symbol.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -211,7 +211,8 @@
//********************************* sym ***************************************
obj_p sym(isp ist, char* s_in) {
- obj_p sym;
+ obj_p sym;
+ int i;
size_t len = strlen(s_in);
char* s = pr_malloc(len+1);
strcpy(s, s_in);
@@ -224,7 +225,7 @@
pr_free(s);
return sym;
}
- sym = new_object(OBJ(SYMBOL_PROTO));
+ sym = new_object(ist, OBJ(SYMBOL_PROTO));
sym->data_type = OBJ_TYPE_IMMDATA;
sym->imm_data_len = 4;
if (!(next_key = (next_key+3) & 0x7fffffff)) {
@@ -235,8 +236,11 @@
symbol_tree = ins_trie(symbol_tree, s, sym);
if (!STRING_SYM) STRING_SYM = sym;
pr_unlock(&symbol_tree_lock);
- set_attr(ist, sym, STRING_SYM, new_string_obj(s));
+ set_attr(ist, sym, STRING_SYM, new_string_obj(ist, s));
+ sym->wr_access = ACC_SYSTEM;
+ su(i);
list_append(ist, OBJ(SYMBOLS), sym);
+ un_su(i);
pr_free(s);
return sym;
}
Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c 2004-04-06 02:35:08 UTC (rev 289)
+++ trunk/src/sys.c 2004-04-06 07:56:29 UTC (rev 290)
@@ -130,7 +130,7 @@
if (!strcmp(full_path, item))
return;
}
- list_append(ist, list, new_string_obj(full_path));
+ list_append(ist, list, new_string_obj(ist, full_path));
}
obj_p load_sys_module(isp ist, char* prog_path, obj_p argv_obj) {
@@ -143,8 +143,8 @@
apr_file_t *file_pth;
apr_pool_t *mod_pool = NULL;
- sys_path = new_list_obj(10);
- sys_module = new_object(OBJ(OBJECT));
+ sys_path = new_list_obj(ist, 10);
+ sys_module = new_object(ist, OBJ(OBJECT));
set_attr(ist, OBJ(MODULES),sym(ist, "Sys"), sys_module);
set_attr(ist, OBJ(OBJECT), sym(ist, "Sys"), sys_module);
add_doc_to_obj(ist, sys_module, "Sys: a built-in module of system attributes");
@@ -173,7 +173,7 @@
path[len-1] = 0;
strcpy(home, path);
have_home = TRUE;
- set_attr(ist, sys_module, sym(ist, "prothonhome"), new_string_obj(home));
+ set_attr(ist, sys_module, sym(ist, "prothonhome"), new_string_obj(ist, home));
}
}
if (!have_home) {
@@ -184,40 +184,40 @@
#endif
strcpy(home, path);
have_home = TRUE;
- set_attr(ist, sys_module, sym(ist, "prothonhome"), new_string_obj(home));
+ set_attr(ist, sys_module, sym(ist, "prothonhome"), new_string_obj(ist, home));
}
- vers_tuple = new_tuple_obj(3);
- list_append(ist, vers_tuple, new_string_obj(PROTHON_VERSION_NUMBER));
- list_append(ist, vers_tuple, new_string_obj(numonly(PROTHON_VERSION_BUILD, path)));
- list_append(ist, vers_tuple, new_string_obj(PROTHON_VERSION_DATE));
+ vers_tuple = new_tuple_obj(ist, 3);
+ list_append(ist, vers_tuple, new_string_obj(ist, PROTHON_VERSION_NUMBER));
+ list_append(ist, vers_tuple, new_string_obj(ist, numonly(PROTHON_VERSION_BUILD, path)));
+ list_append(ist, vers_tuple, new_string_obj(ist, PROTHON_VERSION_DATE));
vers_tuple->immutable = TRUE;
set_attr(ist, sys_module, sym(ist, "version"), vers_tuple);
- set_attr(ist, sys_module, sym(ist, "maxint"), new_int_obj(MAX_INT_VAL));
+ set_attr(ist, sys_module, sym(ist, "maxint"), new_int_obj(ist, MAX_INT_VAL));
set_attr(ist, sys_module, sym(ist, "modules"), OBJ(MODULES));
set_attr( ist, sys_module, sym(ist, "exit"),
- new_func_obj(ist, sys_exit, list2(sym(ist,"num"),new_int_obj(1))) );
+ new_func_obj(ist, sys_exit, list2(ist, sym(ist,"num"),new_int_obj(ist, 1))) );
#if defined(WIN32)
- set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("win32"));
+ set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(ist, "win32"));
#elif defined(HAVE_SYS_UTSNAME_H)
{
struct utsname uts;
if (uname(&uts)) {
- set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("unknown"));
+ set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(ist, "unknown"));
} else {
char plt_buf[1024];
apr_snprintf(plt_buf, sizeof(plt_buf), "%s %s (%s)",
uts.sysname, uts.release, uts.machine);
- set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(plt_buf));
+ set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(ist, plt_buf));
}
}
#else
- set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("unknown"));
+ set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(ist, "unknown"));
#endif
- set_attr(ist, sys_module, sym(ist, "ps1"), new_string_obj(">>> "));
- set_attr(ist, sys_module, sym(ist, "ps2"), new_string_obj("... "));
- set_attr(ist, sys_module, sym(ist, "execpath"), new_string_obj(prog_path));
+ set_attr(ist, sys_module, sym(ist, "ps1"), new_string_obj(ist, ">>> "));
+ set_attr(ist, sys_module, sym(ist, "ps2"), new_string_obj(ist, "... "));
+ set_attr(ist, sys_module, sym(ist, "execpath"), new_string_obj(ist, prog_path));
set_attr(ist, sys_module, sym(ist, "argv"), argv_obj);
if (!APR_STATUS_IS_SUCCESS(apr_pool_create(&mod_pool, NULL)))
@@ -257,7 +257,7 @@
for (e=p; *e > ' '; e++);
if (p == e) continue;
*e = 0;
- list_append(ist, sys_path, new_string_obj(p));
+ list_append(ist, sys_path, new_string_obj(ist, p));
}
apr_file_close(file_pth);
}