rev 374 - in trunk: . include/prothon modules/File modules/OS modules/Prosist modules/Re modules/SQLite src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-17 15:17:18 -0400 (Sat, 17 Apr 2004)
New Revision: 374
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/include/prothon/prothon_dll.h
trunk/modules/File/File.c
trunk/modules/OS/OS.c
trunk/modules/Prosist/Prosist.c
trunk/modules/Re/Re.c
trunk/modules/SQLite/SQLite.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-thread.c
trunk/src/builtins-tuple.c
trunk/src/interp.c
trunk/src/object.c
trunk/src/symbol.c
trunk/src/sys.c
Log:
started work on DBM, added new macros NEW_OBJ, NEW_INT
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/STATUS.txt 2004-04-17 19:17:18 UTC (rev 374)
@@ -4,6 +4,8 @@
--- add support for APR_BINARY in File.c ('b' flag)
--- support any object that supports file methods in stdxxx (duck std)
+--- move PARAM_STAR and PARAM_STAR_STAR to right side of pair
+
--- finish Prosist
--- help() in interactive console()
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/include/prothon/prothon.h 2004-04-17 19:17:18 UTC (rev 374)
@@ -404,8 +404,8 @@
MAX,
MIN,
COPY,
- __STORPROXY__,
- __NEWVIASTORPROXY__,
+ __TOSTORPROXY__,
+ __FROMSTORPROXY__,
SYM_ENUM_COUNT
} sym_enum_t;
@@ -460,6 +460,7 @@
// do not clear this bit the object will exist forever and cause
// a memory leak. See DELETE LOCKING section below.
obj_p new_object(isp ist, obj_p proto);
+#define NEW_OBJ(proto) new_object(ist, 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.
@@ -567,6 +568,7 @@
// NEW_INT_OBJ: Create a new integer object from a 64-bit C int.
obj_p new_int_obj(isp ist, i64_t num);
+#define NEW_INT(num) new_int_obj(ist, num)
// NEW_FLOAT_OBJ: Create a new float object from a 64-bit C double.
obj_p new_float_obj(isp ist, double num);
@@ -744,7 +746,7 @@
// 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(ist, int1, SLICEPARAM_EMPTY, SLICEPARAM_MISSING)
-// where int1 = new_int_obj(ist, 1);
+// where int1 = NEW_INT(1);
// You can also use OBJ(NONE) instead of SLICEPARAM_EMPTY.
obj_p new_slice_obj(isp ist, obj_p ind1, obj_p ind2, obj_p ind3);
@@ -810,6 +812,53 @@
#define FPARM4(lab1, val1, lab2, val2, lab3, val3, lab4, val4) \
list8(ist, sym(ist, #lab1), val1, sym(ist, #lab2), val2, sym(ist, #lab3), val3, sym(ist, #lab4), val4)
+// xxx_PARAM: Convenience macro for validation and assignment of params
+// index is 1..n where 1 is first parameter and n is last
+#define INT_32_PARAM(index, var) \
+ if (!has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(INT_PROTO))) { \
+ raise_exception(ist, OBJ(TYPE_EXC), \
+ "expected a integer in parameter " #index); \
+ return NULL; \
+ } \
+ (var) = (int) parms[((index)-1)*2+1]->data.i64
+#define INT_64_PARAM(index, var) \
+ if (!has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(INT_PROTO))) { \
+ raise_exception(ist, OBJ(TYPE_EXC), \
+ "expected a integer in parameter " #index); \
+ return NULL; \
+ } \
+ (var) = parms[((index)-1)*2+1]->data.i64
+#define FLOAT__PARAM(index, var) \
+ if (!has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(FLOAT_PROTO))) { \
+ raise_exception(ist, OBJ(TYPE_EXC), \
+ "expected a float in parameter " #index); \
+ return NULL; \
+ } \
+ (var) = parms[((index)-1)*2+1]->data.f64
+#define STRING_PARAM(index, var) \
+ if (!has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(STRING_PROTO))) { \
+ raise_exception(ist, OBJ(TYPE_EXC), \
+ "expected a string in parameter " #index); \
+ return NULL; \
+ } \
+ (var) = strch(parms[((index)-1)*2+1])
+#define SEQ_NS_PARAM(index, var) \
+ if ( has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(STRING_PROTO)) || \
+ !has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(SEQ_PROTO))) { \
+ raise_exception(ist, OBJ(TYPE_EXC), \
+ "expected a Tuple or List in parameter " #index); \
+ return NULL; \
+ } \
+ (var) = parms[((index)-1)*2+1]
+#define SEQ_OR_PARAM(index, var) \
+ if ( has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(STRING_PROTO)) || \
+ !has_proto_QUES(ist, parms[((index)-1)*2+1], OBJ(SEQ_PROTO))) { \
+ list = new_list_obj(ist, 1); \
+ list_append(ist, list, parms[((index)-1)*2+1]); \
+ (var) = list; \
+ } else \
+ (var) = parms[((index)-1)*2+1]
+
// FORM_RPARAM: convenience macro for single formal right parameter
// Defines a formal label/default-value list that matches func(rparam).
// This is the call made in a binary operation such a a+b. "a" is self and
@@ -867,6 +916,7 @@
// objects to decide which objects they cover by offering the __covers__QUES function.
#define covers(o1, o2) (call_func1((ist), (o1), SYM(__COVERS__), (o2)) == OBJ(PR_TRUE))
+
//********************************* EXCEPTIONS ******************************************
// Exceptions are raised by calling raise_exception(ist, proto, doc). Proto is a proto
// exception proto object (or NULL to default to OBJ(EXCEPTION)). Doc is an
Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/include/prothon/prothon_dll.h 2004-04-17 19:17:18 UTC (rev 374)
@@ -187,6 +187,13 @@
check_exceptions(ist); \
} while(0)
+#define MODULE_CONSTANT_DECLARE(module, name) obj_p module##_##name
+
+#define MODULE_CONSTANT_INT(module, name, val) \
+ module##_##name = NEW_INT(val); \
+ set_obj_id(module##_##name, module, name); \
+ set_attr(ist, module##_OBJ, sym(ist, #name), module##_##name)
+
#define MODULE_SUB_INIT(name) \
name##_initialize_module(); \
check_exceptions(ist);
Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/modules/File/File.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -78,9 +78,7 @@
#define OPEN(obj) (((obj) != File_OBJ) && STREAM(obj))
MODULE_DECLARE(File);
-MODULE_DECLARE(Dir);
-
static void set_file_obj(obj_p file_obj, obj_p filename, obj_p mode,
apr_file_t *fp, int bufsize,
apr_int32_t flags)
@@ -113,50 +111,35 @@
{
obj_p file_obj;
- file_obj = new_object(ist, File_OBJ);
+ file_obj = NEW_OBJ(File_OBJ);
set_file_obj(file_obj, filename, mode, fp, bufsize, flags);
return file_obj;
}
MODULE_START(File)
{
- File_OBJ = new_object(ist, NULL);
+ File_OBJ = NEW_OBJ(NULL);
set_obj_doc(File_OBJ, "File object prototype");
MODULE_ADD_TO_BASE(File);
File_OBJ->unclonable = TRUE;
}
-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) ) ) {
+DEF(File, __init__, FPARM3( path, NULL,
+ mode, new_string_obj(ist, "r"),
+ bufsize, NEW_INT(-1) ) ) {
apr_file_t *f;
apr_status_t aprerr;
apr_pool_t *subpool;
apr_int32_t flags = 0;
- char *file, *mode;
char err_buf[1024];
+ char *path, *mode;
+ int bufsize;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "File init path parameter must be a string");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[3], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "File init mode parameter must be a string");
- return NULL;
- }
- if (!strlen(strch(parms[1])) || !strlen(strch(parms[3]))) {
- raise_exception(ist, OBJ(TYPE_EXC), "File and mode parameters cannot be empty");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[5], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "File init bufsize parameter must be an integer");
- return NULL;
- }
+ STRING_PARAM(1, path);
+ STRING_PARAM(2, mode);
+ INT_32_PARAM(3, bufsize);
- file = strch(parms[1]);
- mode = strch(parms[3]);
-
if ((mode[0] != 'r' && mode[0] != 'w' && mode[0] != 'a') ||
(mode[1] != '+' && mode[1] != '\0')) {
raise_exception(ist, OBJ(TYPE_EXC), "File mode `%s' is not valid", mode);
@@ -183,10 +166,10 @@
return NULL;
}
- aprerr = apr_file_open(&f, file, flags, APR_OS_DEFAULT, subpool);
+ aprerr = apr_file_open(&f, path, flags, APR_OS_DEFAULT, subpool);
if (aprerr != APR_SUCCESS) {
- raise_exception(ist, OBJ(IOEXCEPTION), "Unable to open file %s: %s",
- file, apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+ raise_exception(ist, OBJ(IOEXCEPTION), "Unable to open path %s: %s",
+ path, apr_strerror(aprerr, err_buf, sizeof(err_buf)));
apr_pool_destroy(subpool);
return NULL;
}
@@ -194,7 +177,7 @@
/* set_file_obj() modified the object, and thus calls write_lock.
* We need to unlock in order to avoid a deadlock */
read_unlock(ist, self);
- set_file_obj(self, parms[1], parms[3], f, (int)(parms[5]->data.i64), flags);
+ set_file_obj(self, parms[1], parms[3], f, bufsize, flags);
read_lock(ist, self);
self->unclonable = TRUE;
return NULL;
@@ -247,7 +230,7 @@
raise_exception(ist, OBJ(IOEXCEPTION), "fileNo called on closed file");
return NULL;
}
- return new_int_obj(ist, _fileno(STREAM(self)));
+ return NEW_INT(_fileno(STREAM(self)));
}
DEF(File, isATty_QUES, NULL) {
@@ -259,20 +242,18 @@
else return OBJ(PR_FALSE);
}
#endif
-DEF(File, read, list2(ist, sym(ist, "size"), new_int_obj(ist, -1))) {
+DEF(File, read, FPARM1(size, NEW_INT(-1))) {
int readall = FALSE;
- i64_t size_in;
size_t size, total_read=0, num_read;
obj_p str_obj;
pr_str_p obj_str;
char* buf;
apr_status_t aprerr;
char err_buf[1024];
+ i64_t size_in;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
- return NULL;
- }
+ INT_64_PARAM(1, size_in);
+
if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "read can only be called on a File object");
return NULL;
@@ -285,14 +266,13 @@
raise_exception(ist, OBJ(IOEXCEPTION), "read called on file opened without read perms");
return NULL;
}
- size_in = parms[1]->data.i64;
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(ist, OBJ(STRING_PROTO));
+ str_obj = NEW_OBJ(OBJ(STRING_PROTO));
if (size < IMMEDIATE_DATA_LEN) {
str_obj->data_type = DATA_TYPE_IMMDATA;
buf = str_obj->data.str;
@@ -339,20 +319,18 @@
return str_obj;
}
-DEF(File, readLine, list2(ist, sym(ist, "size"), new_int_obj(ist, -1))) {
+DEF(File, readLine, FPARM1(size, NEW_INT(-1))) {
int readall = FALSE;
- i64_t size_in;
size_t size, total_read;
obj_p str_obj;
pr_str_p obj_str;
char* buf;
apr_status_t aprerr;
char err_buf[1024];
+ i64_t size_in;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
- return NULL;
- }
+ INT_64_PARAM(1, size_in);
+
if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "readLine can only be called on a File object");
return NULL;
@@ -365,14 +343,13 @@
raise_exception(ist, OBJ(IOEXCEPTION), "readLine called on file opened without read perms");
return NULL;
}
- size_in = parms[1]->data.i64;
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(ist, OBJ(STRING_PROTO));
+ str_obj = NEW_OBJ(OBJ(STRING_PROTO));
if (size < IMMEDIATE_DATA_LEN) {
str_obj->data_type = DATA_TYPE_IMMDATA;
buf = str_obj->data.str;
@@ -417,20 +394,18 @@
return str_obj;
}
-DEF(File, readLines, list2(ist, sym(ist, "size"), new_int_obj(ist, -1))) {
+DEF(File, readLines, FPARM1(size, NEW_INT(-1))) {
int readall = FALSE;
- i64_t size_in;
size_t size, total_read=0, num_read;
obj_p str_obj, list_obj;
pr_str_p obj_str;
char* buf;
apr_status_t aprerr;
char err_buf[1024];
+ i64_t size_in;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
- return NULL;
- }
+ INT_64_PARAM(1, size_in);
+
if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "readLines can only be called on a File object");
return NULL;
@@ -443,7 +418,6 @@
raise_exception(ist, OBJ(IOEXCEPTION), "readLines called on file opened without read perms");
return NULL;
}
- size_in = parms[1]->data.i64;
if (!size_in) return new_string_obj(ist, "");
if (size_in < 0) {
readall = TRUE;
@@ -453,7 +427,7 @@
list_obj = new_list_obj(ist, 10);
aprerr = 0;
while (aprerr != APR_EOF && (readall || total_read < size)) {
- str_obj = new_object(ist, OBJ(STRING_PROTO));
+ str_obj = NEW_OBJ(OBJ(STRING_PROTO));
if (size < IMMEDIATE_DATA_LEN) {
str_obj->data_type = DATA_TYPE_IMMDATA;
buf = str_obj->data.str;
@@ -503,21 +477,17 @@
return list_obj;
}
-DEF(File, seek, list4(ist, sym(ist, "pos"), NULL,
- sym(ist, "how"), new_int_obj(ist, 0) ) ) {
+DEF(File, seek, FPARM2( pos, NULL,
+ how, NEW_INT(0) ) ) {
apr_off_t pos;
apr_seek_where_t origin;
apr_status_t aprerr;
char err_buf[1024];
+ i64_t pos_in, how;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file seek pos parameter must be an integer");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file seek how parameter must be an integer");
- return NULL;
- }
+ INT_64_PARAM(1, pos_in);
+ INT_64_PARAM(3, how);
+
if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "seek can only be called on a File object");
return NULL;
@@ -526,8 +496,8 @@
raise_exception(ist, OBJ(IOEXCEPTION), "seek called on closed file");
return NULL;
}
- pos = (apr_off_t)(parms[1]->data.i64);
- switch(parms[3]->data.i64) {
+ pos = (apr_off_t)pos_in;
+ switch(how) {
case 0: origin = APR_SET; break;
case 1: origin = APR_CUR; break;
case 2: origin = APR_END; break;
@@ -550,18 +520,17 @@
raise_exception(ist, OBJ(IOEXCEPTION), "tell called on closed file");
return NULL;
}
- return new_int_obj(ist, ftell(STREAM(self)));
+ return NEW_INT(ftell(STREAM(self)));
}
#endif
-DEF(File, truncate, list2(ist, sym(ist, "size"), NULL)) {
+DEF(File, truncate, FPARM1(size, NULL)) {
apr_status_t aprerr;
char err_buf[1024];
apr_off_t size;
+ i64_t size_in;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file truncate size parameter must be an integer");
- return NULL;
- }
+ INT_64_PARAM(1, size_in);
+
if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "truncate can only be called on a File object");
return NULL;
@@ -573,11 +542,11 @@
/* XXX Need a way to check for upper bounds portably. This can be
* different on 64-bit systems, or systems which support LFS */
- if (parms[1]->data.i64 < 0) {
+ if (size_in < 0) {
raise_exception(ist, OBJ(TYPE_EXC), "file truncate size value out of range");
return NULL;
}
- size = (apr_off_t)(parms[1]->data.i64);
+ size = (apr_off_t)(size_in);
aprerr = apr_file_trunc(STREAM(self), size);
if(aprerr != APR_SUCCESS) {
@@ -588,16 +557,15 @@
return OBJ(NONE);
}
-DEF(File, write, list2(ist, sym(ist, "str"), NULL)) {
- char* str;
+DEF(File, write, FPARM1(str, NULL)) {
apr_size_t size;
apr_status_t aprerr;
char err_buf[1024];
+ char* str;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "file write str parameter must be a string");
- return NULL;
- }
+ STRING_PARAM(1, str);
+ size = pr_strlen(parms[1]);
+
if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "write can only be called from a File object");
return NULL;
@@ -610,8 +578,6 @@
raise_exception(ist, OBJ(IOEXCEPTION), "write called on file opened without write perms");
return NULL;
}
- str = strch(parms[1]);
- size = pr_strlen(parms[1]);
aprerr = apr_file_write(STREAM(self), str, &size);
if (aprerr != APR_SUCCESS) {
@@ -622,7 +588,7 @@
return parms[1];
}
-DEF(File, writeLines, list2(ist, sym(ist, "lst"), NULL)) {
+DEF(File, writeLines, FPARM1(lst, NULL)) {
char* str;
apr_size_t size;
apr_status_t aprerr;
@@ -686,22 +652,7 @@
return parms[1];
}
-MODULE_START(Dir)
-{
- Dir_OBJ = new_object(ist, NULL);
-}
-DEF(Dir, __init__, list2(ist, sym(ist, "path"), NULL)) {
- obj_p file_obj = new_string_obj(ist, strch(parms[1]));
- switch_proto(ist, file_obj, Dir_OBJ);
- return file_obj;
-}
-
-DEF(Dir, __objList__, NULL) {
- return parms[1];
-}
-
-
#define __STDIN 0
#define __STDOUT 1
#define __STDERR 2
@@ -768,10 +719,6 @@
//MODULE_ADD_SYM(File, tell);
MODULE_ADD_SYM(File, __objList__);
- MODULE_SUB_INIT(Dir);
- MODULE_ADD_SYM(Dir, __objList__);
- MODULE_ADD_SYM(Dir, __init__);
-
/* Create base file objects for std{in,out,err} */
aprerr = apr_pool_create(&std_pool, get_pr_head_pool());
/* Need some kind of error return! */
Modified: trunk/modules/OS/OS.c
===================================================================
--- trunk/modules/OS/OS.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/modules/OS/OS.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -61,7 +61,7 @@
MODULE_START(OS)
{
- OS_OBJ = new_object(ist, NULL);
+ OS_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(OS, "Operating System specific routines");
set_obj_id(OS_OBJ, *, OS);
MODULE_ADD_TO_BASE(OS);
@@ -69,12 +69,12 @@
DEF(OS, system, FPARM1(cmd, NULL)) {
if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- ist->exception_obj = new_object(ist, OBJ(TYPE_EXC));
+ ist->exception_obj = NEW_OBJ(OBJ(TYPE_EXC));
ist->exception_obj->wr_access = ACC_GUEST;
set_obj_doc(ist->exception_obj, "object is not of type string");
return NULL;
}
- return new_int_obj(ist, system(strch(parms[1])));
+ return NEW_INT(system(strch(parms[1])));
}
MAIN_MODULE_INIT(OS)
Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/modules/Prosist/Prosist.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -109,15 +109,15 @@
MODULE_START(Prosist)
{
- Prosist_OBJ = new_object(ist, NULL);
+ Prosist_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(Prosist, "persistant database module for Prothon objects");
MODULE_ADD_TO_BASE(Prosist);
- DB_OBJ = new_object(ist, NULL);
+ DB_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(DB, "Prosist.DB database object prototype");
MODULE_ADD_TO_OBJ(DB, Prosist_OBJ, "DB");
- ProsistException_OBJ = new_object(ist, OBJ(EXCEPTION));
+ ProsistException_OBJ = NEW_OBJ(OBJ(EXCEPTION));
MODULE_SET_DOC(ProsistException, "Re module error");
MODULE_ADD_TO_OBJ(ProsistException, Prosist_OBJ, "ProsistException");
Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/modules/Re/Re.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -72,17 +72,17 @@
MODULE_START(Re)
{
- Re_OBJ = new_object(ist, NULL);
+ Re_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(Re, "module for regular expressions");
set_obj_id(Re_OBJ, *, Re);
MODULE_ADD_TO_BASE(Re);
- ReException_OBJ = new_object(ist, OBJ(EXCEPTION));
+ ReException_OBJ = NEW_OBJ(OBJ(EXCEPTION));
MODULE_SET_DOC(ReException, "Re module error");
MODULE_ADD_TO_OBJ(ReException, Re_OBJ, "ReException");
- i_flg = new_int_obj(ist, REG_ICASE);
- s_flg = new_int_obj(ist, REG_NEWLINE); // reverse meaning
+ i_flg = NEW_INT(REG_ICASE);
+ s_flg = NEW_INT(REG_NEWLINE); // reverse meaning
set_attr(ist, Re_OBJ, sym(ist, "I"), i_flg);
set_attr(ist, Re_OBJ, sym(ist, "IGNORECASE"), i_flg);
@@ -90,23 +90,19 @@
set_attr(ist, Re_OBJ, sym(ist, "DOTALL"), s_flg);
}
-DEF(Re, compile, list4(ist, sym(ist, "pattern"), NULL,
- sym(ist, "flags"), OBJ(ZERO_INT) ) ) {
+DEF(Re, compile, FPARM2( pattern, NULL,
+ flags, OBJ(ZERO_INT) ) ) {
obj_p re_obj;
regex_t* e = pr_malloc(sizeof(regex_t));
int flags_in, flags=0, err;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "Re.compile pattern parameter must be a string");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "Re.compile flags parameter must be an integer");
- return NULL;
- }
- flags_in = (int) (parms[3]->data.i64);
+ char* pattern;
+
+ STRING_PARAM(1, pattern);
+ INT_32_PARAM(2, flags_in);
+
flags = flags_in & REG_ICASE;
if (!(flags_in & REG_NEWLINE)) flags |= REG_NEWLINE;
- if ((err = regcomp(e, strch(parms[1]), PROTO_FLAGS|flags))) {
+ if ((err = regcomp(e, pattern, PROTO_FLAGS|flags))) {
size_t buf_size;
char msg[1024];
if ((buf_size = regerror(err, NULL, msg, 1024)) > 1024) {
@@ -123,7 +119,7 @@
raise_exception(ist, ReException_OBJ, "more than 99 groups in regular expression");
return NULL;
}
- re_obj = new_object(ist, ReCompiled_OBJ);
+ re_obj = NEW_OBJ(ReCompiled_OBJ);
re_obj->data_type = DATA_TYPE_DATAPTR;
re_obj->data.ptr = e;
set_attr(ist, re_obj, sym(ist, "pattern"), parms[1]);
@@ -134,7 +130,7 @@
MODULE_START(ReCompiled)
{
- ReCompiled_OBJ = new_object(ist, NULL);
+ ReCompiled_OBJ = NEW_OBJ(NULL);
MODULE_ADD_TO_OBJ(ReCompiled, Re_OBJ, "Re");
set_obj_id(ReCompiled_OBJ, Re, Re);
MODULE_SET_DOC(ReCompiled, "prototype for compiled regular expressions");
@@ -147,12 +143,10 @@
regoff_t sp, ep;
int i, err, ngrps = numgrps(self);
regex_t* e = self->data.ptr;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "findAll s parameter must be a string");
- return NULL;
- }
+
+ STRING_PARAM(1, s);
+
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;
while(TRUE) {
@@ -196,31 +190,24 @@
return res;
}
-DEF( ReCompiled, search, list6(ist, sym(ist, "s"), NULL,
- sym(ist, "start"), OBJ(ZERO_INT),
- sym(ist, "end"), OBJ(MAX_INT) ) ) {
+DEF( ReCompiled, search, FPARM3( s, NULL,
+ start, OBJ(ZERO_INT),
+ end, OBJ(MAX_INT) ) ) {
obj_p match_obj, lastindex_obj;
int err;
unsigned int i, last_index=0, ngrps = numgrps(self);
char* s;
regmatch_t* m;
regex_t* e = self->data.ptr;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "Re.search s parameter must be a string");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "Re.search start parameter must be an integer");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[5], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "Re.search end parameter must be an integer");
- return NULL;
- }
- s = strch(parms[1]);
+ i64_t start, end;
+
+ STRING_PARAM(1, s);
+ INT_64_PARAM(2, start);
+ INT_64_PARAM(3, end);
+
m = pr_malloc((ngrps+1) * sizeof(regmatch_t));
- m[0].rm_so = (parms[3]->data.i64 > 0 ? (regoff_t)(parms[3]->data.i64) : 0);
- m[0].rm_eo = (parms[5]->data.i64 < strlen(s) ? (regoff_t)(parms[5]->data.i64) : (regoff_t)strlen(s));
+ m[0].rm_so = (start > 0 ? (regoff_t)(start) : 0);
+ m[0].rm_eo = (end < strlen(s) ? (regoff_t)(end) : (regoff_t)strlen(s));
if ((err = regexec(e, s, ngrps+1, m, 0))) {
size_t buf_size;
char msg[1024];
@@ -239,11 +226,11 @@
switch_proto(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(ist, m[i].rm_so));
- list_append(ist, match_obj, new_int_obj(ist, m[i].rm_eo));
+ list_append(ist, match_obj, NEW_INT(m[i].rm_so));
+ list_append(ist, match_obj, NEW_INT(m[i].rm_eo));
}
pr_free(m);
- if (last_index) lastindex_obj = new_int_obj(ist, last_index);
+ if (last_index) lastindex_obj = NEW_INT(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]);
@@ -253,25 +240,19 @@
return match_obj;
}
-DEF( ReCompiled, split, list4(ist, sym(ist, "s"), NULL,
- sym(ist, "maxsplit"), OBJ(ZERO_INT) ) ) {
- char* s;
+DEF( ReCompiled, split, FPARM2( s, NULL,
+ maxsplit, OBJ(ZERO_INT) ) ) {
regmatch_t* m;
obj_p res;
regoff_t sp, ep, last_split;
- int i, split_count=0, maxsplit, err, ngrps = numgrps(self);
regex_t* e = self->data.ptr;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "split function s parameter must be a string");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "split function maxsplit parameter must be an integer");
- return NULL;
- }
+ int i, split_count=0, maxsplit, err, ngrps = numgrps(self);
+ char* s;
+
+ STRING_PARAM(1, s);
+ INT_32_PARAM(2, maxsplit);
+
res = new_list_obj(ist, 10);
- s = strch(parms[1]);
- maxsplit = (int)(parms[3]->data.i64);
m = pr_malloc((ngrps+1)*sizeof(regmatch_t));
m[0].rm_so = -1; m[0].rm_eo = 0;
last_split = 0;
@@ -394,40 +375,36 @@
return TRUE;
}
-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;
+DEF( ReCompiled, sub, FPARM3( repl, NULL,
+ s, NULL,
+ count, OBJ(ZERO_INT) ) ) {
+
size_t size;
regmatch_t* m;
regoff_t last_split;
- int i, last_index=0, repl_is_func=FALSE, count, err, ngrps = numgrps(self);
obj_p lastindex_obj, repl_obj, res_obj, match_obj, arr[2];
regex_t* e = self->data.ptr;
+ char *repl = "", *orig_s, *p1, *p2, *s, *s_lim, *res;
+ int i, last_index=0, repl_is_func=FALSE, count, err, ngrps = numgrps(self);
+
if ( !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)) &&
!(repl_is_func=has_proto_QUES(ist, parms[1], OBJ(FUNC_PROTO))) ) {
raise_exception(ist, OBJ(TYPE_EXC), "sub repl parameter must be a string or function");
return NULL;
}
- if (!has_proto_QUES(ist, parms[3], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "sub function s parameter must be a string");
- return NULL;
- }
- if (!has_proto_QUES(ist, parms[5], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "sub function count parameter must be an integer");
- return NULL;
- }
+
+ STRING_PARAM(2, orig_s);
+ INT_32_PARAM(3, count);
+
match_obj = new_list_obj(ist, (ngrps+1)*2);
switch_proto(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(ist, last_index);
+ lastindex_obj = NEW_INT(last_index);
set_attr(ist, match_obj, sym(ist, "lastindex"), lastindex_obj);
arr[0] = 0; arr[1] = match_obj;
if (!repl_is_func)
repl = strch(parms[1]);
- orig_s = strch(parms[3]);
- count = (int)(parms[5]->data.i64);
m = pr_malloc((ngrps+1)*sizeof(regmatch_t));
m[0].rm_so = -1; m[0].rm_eo = 0;
last_split = 0;
@@ -461,8 +438,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(ist, m[i].rm_so));
- list_append(ist, match_obj, new_int_obj(ist, m[i].rm_eo));
+ list_append(ist, match_obj, NEW_INT(m[i].rm_so));
+ list_append(ist, match_obj, NEW_INT(m[i].rm_eo));
}
lastindex_obj->data.i64 = last_index;
if (repl_is_func) {
@@ -515,7 +492,7 @@
MODULE_START(ReMatch)
{
- ReMatch_OBJ = new_object(ist, NULL);
+ ReMatch_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(ReMatch, "prototype for regular expression match objects");
set_obj_id(ReMatch_OBJ, Re, Match);
MODULE_ADD_TO_OBJ(ReMatch, Re_OBJ, "Match");
@@ -525,13 +502,12 @@
return parms[1];
}
-DEF(ReMatch, start, list2(ist, sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, start, FPARM1(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");
- return NULL;
- }
- grp = (u32_t)(parms[1]->data.i64);
+ i64_t groupid;
+
+ INT_64_PARAM(1, groupid);
+ grp = (u32_t) groupid;
if (grp < 0 || grp >= list_len(ist, self)/2) {
raise_exception(ist, ReException_OBJ, "start function groupid parameter value invalid");
return NULL;
@@ -539,13 +515,12 @@
return list_item(ist, self, 2*grp);
}
-DEF(ReMatch, end, list2(ist, sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, end, FPARM1(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");
- return NULL;
- }
- grp = (u32_t)(parms[1]->data.i64);
+ i64_t groupid;
+
+ INT_64_PARAM(1, groupid);
+ grp = (u32_t) groupid;
if (grp < 0 || grp >= list_len(ist, self)/2) {
raise_exception(ist, ReException_OBJ, "end function groupid parameter value invalid");
return NULL;
@@ -553,14 +528,13 @@
return list_item(ist, self, 2*grp+1);
}
-DEF(ReMatch, span, list2(ist, sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, span, FPARM1(groupid, OBJ(ZERO_INT))) {
u32_t grp;
obj_p res;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "span function groupid parameter must be an integer");
- return NULL;
- }
- grp = (u32_t)(parms[1]->data.i64);
+ i64_t groupid;
+
+ INT_64_PARAM(1, groupid);
+ grp = (u32_t) groupid;
if (grp < 0 || grp >= list_len(ist, self)/2) {
raise_exception(ist, ReException_OBJ, "span function groupid parameter value invalid");
return NULL;
@@ -576,11 +550,9 @@
size_t size;
char *p1, *p2, *s, *s_lim, *orig_s;
obj_p orig_s_obj, res;
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "expand s parameter must be a string");
- return NULL;
- }
- p1 = strch(parms[1]);
+
+ STRING_PARAM(1, p1);
+
size = (strlen(p1) * 2 > 256 ? strlen(p1) * 2 : 256);
s = pr_malloc(size);
s_lim = s + size;
@@ -594,15 +566,13 @@
}
DEF( ReMatch, group, list4(ist, sym(ist, "groupid"), OBJ(ZERO_INT),
- PARAM_STAR, sym(ist, "groupids") ) ) {
+ PARAM_STAR, sym(ist, "groupids") ) ) {
int i, j, llen, ngrps = ((int)list_len(ist, self))/2, sp, ep;
char* orig_s;
obj_p orig_s_obj, res;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
- raise_exception(ist, OBJ(TYPE_EXC), "groupid parameters must be integers");
- return NULL;
- }
- j = (int)(parms[1]->data.i64);
+
+ INT_32_PARAM(1, j);
+
if (j < 0 || j > ngrps) {
raise_exception(ist, OBJ(TYPE_EXC), "groupid value out of range");
return NULL;
@@ -645,7 +615,7 @@
}
}
-DEF( ReMatch, groups, list2(ist, sym(ist, "default"), OBJ(NONE))) {
+DEF( ReMatch, groups, FPARM1(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(ist, ngrps);
Modified: trunk/modules/SQLite/SQLite.c
===================================================================
--- trunk/modules/SQLite/SQLite.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/modules/SQLite/SQLite.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -79,19 +79,19 @@
MODULE_START(SQLite)
{
- SQLite_OBJ = new_object(ist, NULL);
+ SQLite_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(SQLite, "SQLite database wrapper module");
MODULE_ADD_TO_BASE(SQLite);
- Connection_OBJ = new_object(ist, NULL);
+ Connection_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(Connection, "SQLite Connection prototype object");
MODULE_ADD_TO_OBJ(Connection, SQLite_OBJ, "Connection");
- Cursor_OBJ = new_object(ist, NULL);
+ Cursor_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(Cursor, "SQLite Cursor prototype object");
MODULE_ADD_TO_OBJ(Cursor, SQLite_OBJ, "Cursor");
- Error_OBJ = new_object(ist, OBJ(EXCEPTION));
+ Error_OBJ = NEW_OBJ(OBJ(EXCEPTION));
MODULE_SET_DOC(Error, "SQLite db error");
MODULE_ADD_TO_OBJ(Error, SQLite_OBJ, "Error");
@@ -106,7 +106,7 @@
char *filename, *errmsg=NULL;
CHECK_TYPE_EXC(parms[1], OBJ(STRING_PROTO), "string");
filename = strch(parms[1]);
- conn_obj = new_object(ist, Connection_OBJ);
+ conn_obj = NEW_OBJ(Connection_OBJ);
set_obj_doc(conn_obj, "SQLite connection");
conn_obj->unclonable = TRUE;
set_obj_rdacc(conn_obj, ACC_USER1);
@@ -122,7 +122,7 @@
DEF(Connection, cursor, NULL) {
if (self->data.ptr) {
cursor_p cursorp;
- obj_p curs_obj = new_object(ist, Cursor_OBJ);
+ obj_p curs_obj = NEW_OBJ(Cursor_OBJ);
set_obj_doc(curs_obj, "SQLite cursor");
curs_obj->data_type = DATA_TYPE_DATAPTR;
cursorp = curs_obj->data.ptr = pr_malloc(sizeof(cursor_t));
@@ -263,8 +263,8 @@
DEF(Cursor, rowCount, NULL) {
cursor_p cursorp = (cursor_p)(self->data.ptr);
if (cursorp->row_list)
- return new_int_obj(ist, list_len(ist, cursorp->row_list));
- return new_int_obj(ist, -1);
+ return NEW_INT(list_len(ist, cursorp->row_list));
+ return NEW_INT(-1);
}
DEF(Cursor, __objList__, FORM_RPARAM) {
Modified: trunk/src/argproc.c
===================================================================
--- trunk/src/argproc.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/argproc.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -95,7 +95,7 @@
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(ist, 4), res = new_object(ist, NULL);
+ obj_p thread_list = new_list_obj(ist, 4), res = NEW_OBJ(NULL);
char *p, buf[10];
for (i=1; i < argc; i++) {
if (!past_c_args && argv[i][0] != '-') {
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-core.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -170,7 +170,7 @@
}
DEF(Object, readAccess, NULL) {
- return new_int_obj(ist, get_obj_rdacc(self));
+ return NEW_INT(get_obj_rdacc(self));
}
DEF(Object, readAccessStr, NULL) {
@@ -194,7 +194,7 @@
}
DEF(Object, writeAccess, NULL) {
- return new_int_obj(ist, get_obj_wracc(self));
+ return NEW_INT(get_obj_wracc(self));
}
DEF(Object, writeAccessStr, NULL) {
@@ -337,12 +337,12 @@
return parms[1];
}
-DEF(Object, __storProxy__, NULL) {
+DEF(Object, __toStorProxy__, NULL) {
return self;
}
-DEF(Object, __newViaStorProxy__, FORM_RPARAM) {
- return parms[1];
+DEF(Object, __fromStorProxy__, NULL) {
+ return self;
}
@@ -360,9 +360,9 @@
DEF(False, __bool__QUES, NULL) { return False_OBJ; }
DEF(False, cmp, FORM_RPARAM) {
if (parms[1] == False_OBJ)
- return new_int_obj(ist, 0);
+ return NEW_INT(0);
else
- return new_int_obj(ist, -1);
+ return NEW_INT(-1);
}
// ***************************** PR_TRUE *****************************************
@@ -379,11 +379,11 @@
DEF(True, __bool__QUES, NULL) { return True_OBJ; }
DEF(True, cmp, FORM_RPARAM) {
if (parms[1] == OBJ(PR_FALSE))
- return new_int_obj(ist, 1);
+ return NEW_INT(1);
else if (parms[1] == True_OBJ)
- return new_int_obj(ist, 0);
+ return NEW_INT(0);
else
- return new_int_obj(ist, -1);
+ return NEW_INT(-1);
}
DEF(True, __getCmp__, NULL) {
return get_attr(ist, self, SYM(__CMPVALOBJ__));
@@ -420,7 +420,7 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "Exception"), Exception_OBJ);
#define EXCEPTION_DECLARE(proto, exc_const, name, desc_str) \
- OBJ(exc_const) = new_object(ist, proto); \
+ OBJ(exc_const) = NEW_OBJ(proto); \
set_obj_id(OBJ(exc_const), *, name); \
set_obj_doc(OBJ(exc_const), desc_str); \
set_attr(ist, OBJ(OBJECT), sym(ist, #name), OBJ(exc_const))
@@ -640,7 +640,7 @@
}
DEF(Func, __cDataLen__, NULL) {
- return new_int_obj(ist, sizeof(code) + ((code_p)(self->data.ptr))->len * sizeof(code_t));
+ return NEW_INT(sizeof(code) + ((code_p)(self->data.ptr))->len * sizeof(code_t));
}
DEF(Func, __objList__, FORM_RPARAM) {
@@ -687,8 +687,8 @@
MODULE_ADD_SYM(Object, attrs);
MODULE_ADD_SYM(Object, CurrentThread);
MODULE_ADD_SYM(Object, Sleep);
- MODULE_ADD_SYM(Object, __storProxy__);
- MODULE_ADD_SYM(Object, __newViaStorProxy__);
+ MODULE_ADD_SYM(Object, __toStorProxy__);
+ MODULE_ADD_SYM(Object, __fromStorProxy__);
MODULE_SUB_INIT(Seq);
Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-dict.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -66,7 +66,7 @@
//********************************* new_dict_obj ******************************
obj_p new_dict_obj(isp ist, int initial_size){
- obj_p dict_obj = new_object(ist, OBJ(DICT_PROTO));
+ obj_p dict_obj = NEW_OBJ(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));
@@ -315,7 +315,7 @@
}
DEF(Dict, __cDataLen__, NULL) {
- return new_int_obj(ist, dict_size_bytes(self->data.ptr));
+ return NEW_INT(dict_size_bytes(self->data.ptr));
}
@@ -437,7 +437,7 @@
}
DEF(Dict, __iter__, NULL) {
- obj_p list_obj, gen_obj = new_object(ist, DictGen_OBJ);
+ obj_p list_obj, gen_obj = NEW_OBJ(DictGen_OBJ);
gen_obj->data_type = DATA_TYPE_DATAPTR;
gen_obj->data.ptr = list_obj = dict_keys(ist, self);
@@ -449,7 +449,7 @@
MODULE_START(DictGen)
{
- DictGen_OBJ = new_object(ist, NULL);
+ DictGen_OBJ = NEW_OBJ(NULL);
}
DEF(DictGen, next, NULL) {
Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-float.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -73,7 +73,7 @@
//********************************* new_float_obj *****************************
obj_p new_float_obj(isp ist, double num){
- obj_p obj = new_object(ist, OBJ(FLOAT_PROTO));
+ obj_p obj = NEW_OBJ(OBJ(FLOAT_PROTO));
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = 8;
obj->data.f64 = num;
@@ -87,9 +87,9 @@
MODULE_START(Float)
{
- 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);
+ Float_OBJ = OBJ(FLOAT_PROTO) = NEW_OBJ(NULL);
+// Imag_OBJ = OBJ(IMAG_PROTO) = NEW_OBJ(NULL);
+ OBJ(IMAG_PROTO) = NEW_OBJ(NULL);
set_obj_doc(OBJ(FLOAT_PROTO), "Float number object prototype");
set_obj_id(Float_OBJ, *, Float);
@@ -300,9 +300,9 @@
if (Float_value(self) == float_other)
return new_float_obj(ist, 0);
else if (Float_value(self) > float_other)
- return new_int_obj(ist, 1);
+ return NEW_INT(1);
else
- return new_int_obj(ist, -1);
+ return NEW_INT(-1);
}
DEF(Float, __rCmp__, FORM_RPARAM){
@@ -320,9 +320,9 @@
if (Float_value(self) == float_other)
return new_float_obj(ist, 0);
else if (Float_value(self) < float_other)
- return new_int_obj(ist, 1);
+ return NEW_INT(1);
else
- return new_int_obj(ist, -1);
+ return NEW_INT(-1);
}
DEF(Float, __eq__QUES, FORM_RPARAM){
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-int.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -66,7 +66,7 @@
//********************************* new_int_obj *******************************
obj_p new_int_obj(isp ist, i64_t num){
- obj_p obj = new_object(ist, OBJ(INT_PROTO));
+ obj_p obj = NEW_OBJ(OBJ(INT_PROTO));
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = 8;
obj->data.i64 = num;
@@ -95,8 +95,8 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "Int"), Int_OBJ);
/* Dependent objects */
- OBJ(ZERO_INT) = new_int_obj(ist, 0);
- OBJ(MAX_INT) = new_int_obj(ist, MAX_INT_VAL);
+ OBJ(ZERO_INT) = NEW_INT(0);
+ OBJ(MAX_INT) = NEW_INT(MAX_INT_VAL);
OBJ(LONG_PROTO) = new_string_obj(ist, "0");
clr_immutable(OBJ(LONG_PROTO));
set_obj_doc(OBJ(LONG_PROTO), "Long integer number object prototype");
@@ -126,11 +126,11 @@
DEF(Int, __abs__, NULL){
i64_t num = Int_value(self);
- return new_int_obj(ist, num < 0 ? -num : num);
+ return NEW_INT(num < 0 ? -num : num);
}
DEF(Int, __neg__, NULL){
- return new_int_obj(ist, - Int_value(self) );
+ return NEW_INT( - Int_value(self) );
}
DEF(Int, __pos__, NULL){
@@ -145,7 +145,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "Integer cannot be added to this object");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) + Int_value(other));
+ return NEW_INT(Int_value(self) + Int_value(other));
}
DEF(Int, __div__, FORM_RPARAM){
@@ -176,7 +176,7 @@
raise_exception(ist, OBJ(DIVIDEZERO_EXC), NULL);
return NULL;
}
- return new_int_obj(ist, Int_value(self) / Int_value(other));
+ return NEW_INT(Int_value(self) / Int_value(other));
}
DEF(Int, __mod__, FORM_RPARAM) {
@@ -191,7 +191,7 @@
raise_exception(ist, OBJ(DIVIDEZERO_EXC), "modulo by zero");
return NULL;
}
- return new_int_obj(ist, Int_value(self) % Int_value(other));
+ return NEW_INT(Int_value(self) % Int_value(other));
}
DEF(Int, __mul__, FORM_RPARAM) {
@@ -202,7 +202,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "Integer cannot be multiplied by this object");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) * Int_value(other));
+ return NEW_INT(Int_value(self) * Int_value(other));
}
DEF(Int, __sub__, FORM_RPARAM) {
@@ -213,7 +213,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "This object cannot be subtracted from an Integer");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) - Int_value(other));
+ return NEW_INT(Int_value(self) - Int_value(other));
}
DEF(Int, __pow__, FORM_RPARAM){
@@ -235,11 +235,11 @@
return OBJ(NONE);
}
if (Int_value(self) == Int_value(other))
- return new_int_obj(ist, 0);
+ return NEW_INT(0);
else if (Int_value(self) > Int_value(other))
- return new_int_obj(ist, 1);
+ return NEW_INT(1);
else
- return new_int_obj(ist, -1);
+ return NEW_INT(-1);
}
DEF(Int, __eq__QUES, FORM_RPARAM){
@@ -253,7 +253,7 @@
else return OBJ(PR_FALSE);
}
DEF(Int, __invert__, NULL){
- return new_int_obj(ist, ~ Int_value(self) );
+ return NEW_INT( ~ Int_value(self) );
}
DEF(Int, __xor__, FORM_RPARAM) {
@@ -262,7 +262,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be xor'd with an Integer");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) ^ Int_value(other));
+ return NEW_INT(Int_value(self) ^ Int_value(other));
}
DEF(Int, __and__, FORM_RPARAM) {
@@ -271,7 +271,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be and'd with an Integer");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) & Int_value(other));
+ return NEW_INT(Int_value(self) & Int_value(other));
}
DEF(Int, __or__, FORM_RPARAM) {
@@ -280,7 +280,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be or'd with an Integer");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) | Int_value(other));
+ return NEW_INT(Int_value(self) | Int_value(other));
}
DEF(Int, __rShift__, FORM_RPARAM) {
@@ -289,7 +289,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be shifted with an Integer");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) >> Int_value(other));
+ return NEW_INT(Int_value(self) >> Int_value(other));
}
DEF(Int, __lShift__, FORM_RPARAM) {
@@ -298,7 +298,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "object cannot be shifted with an Integer");
return OBJ(NONE);
}
- return new_int_obj(ist, Int_value(self) << Int_value(other));
+ return NEW_INT(Int_value(self) << Int_value(other));
}
DEF(Int, __str__, NULL){
@@ -308,7 +308,7 @@
}
DEF(Int, __iter__, NULL) {
- obj_p gen_obj = new_int_obj(ist, 0);
+ obj_p gen_obj = NEW_INT(0);
gen_obj->immutable = FALSE;
gen_obj->attr_proto.proto = IntGen_OBJ;
set_attr(ist, gen_obj, SYM_LIMIT, self);
@@ -324,7 +324,7 @@
MODULE_START(IntGen)
{
- IntGen_OBJ = new_object(ist, NULL);
+ IntGen_OBJ = NEW_OBJ(NULL);
MODULE_SET_DOC(Int, "number generator object prototype");
}
@@ -340,7 +340,7 @@
raise_exception(ist, OBJ(STOP_ITERATION_EXC), NULL);
return NULL;
}
- res = new_int_obj(ist, Int_value(self));
+ res = NEW_INT(Int_value(self));
def_write_lock(self);
Int_value(self)++;
def_write_unlock(self);
Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-list.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -84,7 +84,7 @@
//********************************* new_list_obj ******************************
obj_p new_list_obj(isp ist, size_t initial_size){
- obj_p list_obj = new_object(ist, OBJ(LIST_PROTO));
+ obj_p list_obj = NEW_OBJ(OBJ(LIST_PROTO));
list_p lstp = list_obj->data.ptr =
pr_malloc(list_sizeof(max(initial_size,2)));
list_obj->data_type = DATA_TYPE_DATAPTR;
@@ -555,7 +555,7 @@
size = len*times;
if(times == 0) return new_list_obj(ist, 0);
if(times == 1) return self;
- res = new_object(ist, List_OBJ);
+ res = NEW_OBJ(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");
Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-string.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -77,7 +77,7 @@
size_t len;
if(!str) return NULL;
len = strlen(str);
- obj = new_object(ist, OBJ(STRING_PROTO));
+ obj = NEW_OBJ(OBJ(STRING_PROTO));
if (len < IMMEDIATE_DATA_LEN) {
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = (int) len;
@@ -96,7 +96,7 @@
obj_p obj;
pr_str_p obj_str;
if(!str) return NULL;
- obj = new_object(ist, OBJ(STRING_PROTO));
+ obj = NEW_OBJ(OBJ(STRING_PROTO));
if (len < IMMEDIATE_DATA_LEN) {
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = (int) len;
@@ -168,12 +168,12 @@
DEF(String, cmp, FORM_RPARAM){
obj_p other = parms[1];
if (self == other)
- return new_int_obj(ist, 0);
+ return NEW_INT(0);
if (!is_String(other)) {
raise_exception(ist, OBJ(TYPE_EXC), "Cannot compare a string and non-string");
return NULL;
}
- return new_int_obj(ist, strcmp(strch(self), strch(other)));
+ return NEW_INT(strcmp(strch(self), strch(other)));
}
DEF(String, __add__, FORM_RPARAM){
@@ -183,7 +183,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(ist, String_OBJ);
+ obj = NEW_OBJ(String_OBJ);
if (tlen < IMMEDIATE_DATA_LEN) {
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = (int) tlen;
@@ -213,7 +213,7 @@
if(times == 0) return new_string_obj(ist, "");
if(times == 1) return self;
tlen = len*times+1;
- obj = new_object(ist, String_OBJ);
+ obj = NEW_OBJ(String_OBJ);
if (tlen < IMMEDIATE_DATA_LEN) {
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = (int) tlen;
@@ -279,7 +279,7 @@
}
DEF(String, __iter__, NULL) {
- obj_p gen_obj = new_object(ist, StringGen_OBJ);
+ obj_p gen_obj = NEW_OBJ(StringGen_OBJ);
gen_obj->data_type = DATA_TYPE_DATAPTR;
gen_obj->data.ptr = strch(self);
set_attr(ist, gen_obj, sym(ist, "saved_string"), self);
@@ -287,7 +287,7 @@
}
DEF(String, ord, NULL) {
- return new_int_obj(ist, (int)(*strch(self)));
+ return NEW_INT((int)(*strch(self)));
}
DEF(String, join, FORM_RPARAM) {
@@ -313,7 +313,7 @@
tlen += pr_strlen(str_obj);
if (i != llen-1) tlen += self_len;
}
- obj = new_object(ist, String_OBJ);
+ obj = NEW_OBJ(String_OBJ);
if (tlen < IMMEDIATE_DATA_LEN) {
obj->data_type = DATA_TYPE_IMMDATA;
obj->imm_data_len = (int) tlen;
@@ -358,7 +358,7 @@
}
DEF(String, len, NULL) {
- return new_int_obj(ist, pr_strlen(self));
+ return NEW_INT(pr_strlen(self));
}
DEF(String, __bool__QUES, NULL) {
@@ -367,7 +367,7 @@
}
DEF(String, __cDataLen__, NULL) {
- return new_int_obj(ist, sizeof(pr_str_t) + pr_strlen(self) + 1);
+ return NEW_INT(sizeof(pr_str_t) + pr_strlen(self) + 1);
}
@@ -375,7 +375,7 @@
MODULE_START(StringGen)
{
- StringGen_OBJ = new_object(ist, NULL);
+ StringGen_OBJ = NEW_OBJ(NULL);
set_attr(ist, OBJ(OBJECT), sym(ist, "StringGen"), StringGen_OBJ);
set_obj_id(StringGen_OBJ, *, StringGen);
}
@@ -387,7 +387,7 @@
wrlock_rtrn(self) NULL;
if ((ch = *strch(self))) {
self->data.ptr = (i64_t *)(((char*)self->data.ptr) + 1);
- res = new_object(ist, String_OBJ);
+ res = NEW_OBJ(String_OBJ);
res_str = (char*)obj_malloc(res, 2);
res_str[0] = ch;
res_str[1] = 0;
Modified: trunk/src/builtins-thread.c
===================================================================
--- trunk/src/builtins-thread.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-thread.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -73,7 +73,7 @@
void thread_init(isp ist) {
obj_p thread_obj;
pr_thread_p thread_ptr;
- thread_obj = new_object(ist, OBJ(THREAD_PROTO));
+ thread_obj = NEW_OBJ(OBJ(THREAD_PROTO));
thread_obj->data_type = DATA_TYPE_DATAPTR;
thread_ptr = thread_obj->data.ptr = pr_malloc(sizeof(pr_thread_t));
memset(thread_obj->data.ptr, 0, sizeof(pr_thread_t));
@@ -131,7 +131,7 @@
pr_lock(&thread_registry_lock);
if (!thread_obj) {
- thread_obj = new_object(ist, OBJ(THREAD_PROTO));
+ thread_obj = NEW_OBJ(OBJ(THREAD_PROTO));
thread_obj->data_type = DATA_TYPE_DATAPTR;
thread_obj->data.ptr = pr_malloc(sizeof(pr_thread_t));
memset(thread_obj->data.ptr, 0, sizeof(pr_thread_t));
@@ -190,10 +190,10 @@
MODULE_SET_DOC(Thread, "thread object prototype");
set_attr(ist, OBJ(OBJECT), sym(ist, "Thread"), Thread_OBJ);
- set_attr(ist, Thread_OBJ, sym(ist, "GUEST"), new_int_obj(ist, ACC_GUEST));
- set_attr(ist, Thread_OBJ, sym(ist, "USER1"), new_int_obj(ist, ACC_USER1));
- set_attr(ist, Thread_OBJ, sym(ist, "USER2"), new_int_obj(ist, ACC_USER2));
- set_attr(ist, Thread_OBJ, sym(ist, "SYSTEM"), new_int_obj(ist, ACC_SYSTEM));
+ set_attr(ist, Thread_OBJ, sym(ist, "GUEST"), NEW_INT( ACC_GUEST));
+ set_attr(ist, Thread_OBJ, sym(ist, "USER1"), NEW_INT( ACC_USER1));
+ set_attr(ist, Thread_OBJ, sym(ist, "USER2"), NEW_INT( ACC_USER2));
+ set_attr(ist, Thread_OBJ, sym(ist, "SYSTEM"), NEW_INT(ACC_SYSTEM));
Thread_OBJ->data_type = DATA_TYPE_DATAPTR;
thread = obj_malloc(Thread_OBJ, sizeof(pr_thread_t));
@@ -205,7 +205,7 @@
DEF(Thread, __init__, list8(ist, sym(ist, "func"), NULL,
sym(ist, "params"), OBJ(NONE),
sym(ist, "name"), OBJ(NONE),
- sym(ist, "access"), new_int_obj(ist, -1) ) ) {
+ sym(ist, "access"), NEW_INT(-1) ) ) {
char buf[30];
obj_p name_obj;
user_thread_p uthread;
@@ -253,7 +253,7 @@
}
DEF(Thread, access, NULL) {
- return new_int_obj(ist, ist->access);
+ return NEW_INT(ist->access);
}
DEF(Thread, setAccess, FORM_RPARAM) {
@@ -299,7 +299,7 @@
}
aprerr = apr_thread_join(&retval, thread_ptr->apr_thread);
IF_APR_ERR("error in thread join") return NULL;
- return new_int_obj(ist, retval);
+ return NEW_INT(retval);
}
DEF(Thread, __objList__, FORM_RPARAM) {
Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/builtins-tuple.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -142,10 +142,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(ist, res->data.i64);
+ return NEW_INT(res->data.i64);
}
- if (llen < tlen) return new_int_obj(ist, -1);
- if (llen > tlen) return new_int_obj(ist, +1);
+ if (llen < tlen) return NEW_INT(-1);
+ if (llen > tlen) return NEW_INT(+1);
return OBJ(ZERO_INT);
}
@@ -219,7 +219,7 @@
return res;
}
if(times == 1) return self;
- res = new_object(ist, OBJ(TUPLE_PROTO));
+ res = NEW_OBJ(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");
@@ -234,7 +234,7 @@
}
DEF(Tuple, len, NULL) {
- return new_int_obj(ist, list_len(ist, self));
+ return NEW_INT(list_len(ist, self));
}
DEF(Tuple, min, NULL) {
@@ -274,14 +274,14 @@
cnt++;
if_exc_return NULL;
}
- return new_int_obj(ist, cnt);
+ return NEW_INT(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(ist, i);
+ return NEW_INT(i);
if_exc_return NULL;
}
raise_exception(ist, OBJ(INDEX_EXC), "item not found in index search");
@@ -289,11 +289,11 @@
}
DEF(Tuple, __cDataLen__, NULL) {
- return new_int_obj(ist, list_sizeof(listsize(self)));
+ return NEW_INT(list_sizeof(listsize(self)));
}
DEF(Tuple, __iter__, NULL) {
- obj_p list_obj, gen_obj = new_object(ist, Tgen_OBJ);
+ obj_p list_obj, gen_obj = NEW_OBJ(Tgen_OBJ);
gen_obj->data_type = DATA_TYPE_DATAPTR;
gen_obj->data.ptr = list_obj = copy_list_obj(ist, self);
listlen(list_obj) = 0;
@@ -304,7 +304,7 @@
//*************************** TUPLE GENERATOR OBJECT **************************
MODULE_START(Tgen)
{
- Tgen_OBJ = new_object(ist, NULL);
+ Tgen_OBJ = NEW_OBJ(NULL);
}
DEF(Tgen, next, NULL) {
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/interp.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -126,7 +126,7 @@
//********************************* new_super_obj *****************************
obj_p new_super_obj(isp ist, obj_p symbol){
- obj_p super_obj = new_object(ist, OBJ(SUPER_PROTO));
+ obj_p super_obj = NEW_OBJ(OBJ(SUPER_PROTO));
super_obj->data_type = DATA_TYPE_DATAPTR;
super_obj->data.ptr = symbol;
super_obj->immutable = TRUE;
@@ -404,8 +404,8 @@
if (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(ist, line));
- list_append(ist, fstk_obj, new_int_obj(ist, col));
+ list_append(ist, fstk_obj, NEW_INT(line));
+ list_append(ist, fstk_obj, NEW_INT(col));
ist->exception_obj = orig_excobj;
}
@@ -739,7 +739,7 @@
case OP_CHAIN_CMP:
fr_sp -= 2;
if (fr_stack[fr_sp+1] == OBJ(PR_TRUE)) {
- obj_p cmp_obj = new_object(ist, OBJ(PR_TRUE));
+ obj_p cmp_obj = NEW_OBJ(OBJ(PR_TRUE));
set_attr(ist, cmp_obj, SYM(__CMPVALOBJ__), fr_stack[fr_sp]);
fr_push(cmp_obj);
} else
@@ -991,7 +991,7 @@
obj_p new_locals, syn_self;
frame_p new_frame;
if (intrp_exobj) break;
- new_locals = new_object(ist, NULL);
+ new_locals = NEW_OBJ(NULL);
syn_self = get_attr(ist, func_obj, SYM(__SELF__)); if (intrp_exobj) break;
new_frame = create_frame( ist, syn_self, NULL, NULL, NULL,
frame->locals, new_locals, func_obj, NULL );
@@ -1010,7 +1010,7 @@
fr_push(func_obj);
} else {
memmove(fr_stack+fr_sp+3, fr_stack+fr_sp+1, (param*2) * sizeof(obj_p));
- fr_stack[fr_sp] = new_object(ist, fr_stack[fr_sp]);
+ fr_stack[fr_sp] = NEW_OBJ(fr_stack[fr_sp]);
fr_stack[fr_sp+1] = fr_stack[fr_sp];
fr_stack[fr_sp+2] = SYM(__INIT__);
fr_sp++;
@@ -1089,7 +1089,7 @@
obj_p new_locals, syn_self;
frame_p new_frame;
if (intrp_exobj) break;
- new_locals = new_object(ist, NULL);
+ new_locals = NEW_OBJ(NULL);
syn_self = get_attr(ist, func_obj, SYM(__SELF__)); if (intrp_exobj) break;
new_frame = create_frame( ist, syn_self, super_flag? frame->self : fr_stack[fr_sp], NULL, NULL,
frame->locals, new_locals, func_obj, NULL );
@@ -1114,7 +1114,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(ist, value);
+ fr_stack[fr_sp] = NEW_OBJ(value);
fr_stack[fr_sp+1] = fr_stack[fr_sp];
fr_stack[fr_sp+2] = SYM(__INIT__);
fr_sp++;
@@ -1309,7 +1309,7 @@
obj_p func_obj;
if (!self) {
func_obj = func_sym;
- self = new_object(ist, NULL);
+ self = NEW_OBJ(NULL);
} else {
func_obj = get_proto_attr(ist, self, func_sym, NULL, NULL); if_exc_return NULL;
if (!func_obj) {
@@ -1347,7 +1347,7 @@
return 0;
}
frame = ist->frame;
- new_locals = new_object(ist, NULL);
+ new_locals = NEW_OBJ(NULL);
syn_self = get_attr(ist, func_obj, SYM(__SELF__));
if (intrp_exobj) {
if (!func_sym) del_unlock(self);
@@ -1451,7 +1451,7 @@
new_frame = create_frame( ist, NULL, frame->self, frame->globals,
frame->syn_locals, frame->dyn_locals, frame->locals, NULL, code );
else {
- new_locals = new_object(ist, NULL);
+ new_locals = NEW_OBJ(NULL);
new_frame = create_frame( ist, NULL, OBJ(ROOT_GLOBALS), OBJ(ROOT_GLOBALS),
new_locals, new_locals, new_locals, NULL, code );
}
@@ -1479,7 +1479,7 @@
if (!module)
module = get_attr(ist, OBJ(MODULES), module_name);
if (!module)
- module = new_object(ist, NULL);
+ module = NEW_OBJ(NULL);
su(i);
set_attr(ist, OBJ(MODULES), module_name, module);
un_su(i);
@@ -1504,7 +1504,7 @@
apr_snprintf(full_doc, sizeof(full_doc), "%s%s", name, comment);
set_obj_doc(module, full_doc);
frame = ist->frame;
- new_locals = new_object(ist, NULL);
+ new_locals = NEW_OBJ(NULL);
set_attr(ist, module, SYM(__LOCALS__), new_locals);
new_frame = create_frame( ist, NULL, module, module, dest_module, dyn_locals, new_locals, NULL, code );
new_frame->called_from_c = TRUE;
@@ -1552,7 +1552,7 @@
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(ist, OBJ(ROOT_GLOBALS));
+ module = NEW_OBJ(OBJ(ROOT_GLOBALS));
su(i);
set_attr(ist, OBJ(MODULES), main_sym, module);
set_attr(ist, OBJ(OBJECT), main_sym, module);
@@ -1614,7 +1614,7 @@
lbl_val_arr[i] = NULL;
lbl_val_arr[i+1] = list_item(ist, uthread->params, i/2);
}
- new_locals = new_object(ist, NULL);
+ new_locals = NEW_OBJ(NULL);
set_attr(ist, thread_obj, SYM(__LOCALS__), new_locals);
syn_self = get_attr(ist, func_obj, SYM(__SELF__));
new_frame = create_frame( ist, syn_self, NULL, thread_obj, NULL, NULL, new_locals, func_obj, NULL );
Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/object.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -180,30 +180,30 @@
dll_services.check_exceptions = check_exceptions;
/* Setup the core objects. Order counts here */
- OBJ(OBJECT) = new_object(ist, NULL);
+ OBJ(OBJECT) = NEW_OBJ(NULL);
OBJ(OBJECT)->attr_proto.proto = OBJ(OBJECT);
- 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(SEQ_PROTO) = NEW_OBJ(NULL);
+ OBJ(TUPLE_PROTO) = NEW_OBJ(OBJ(SEQ_PROTO));
+ OBJ(LIST_PROTO) = NEW_OBJ(OBJ(TUPLE_PROTO));
+ OBJ(SYMBOL_PROTO) = NEW_OBJ(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(MUTEX_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(HASH_PROTO) = NEW_OBJ(NULL);
+ OBJ(SLICE_PROTO) = NEW_OBJ(NULL);
+ OBJ(SUPER_PROTO) = NEW_OBJ(NULL);
+ OBJ(THREAD_PROTO) = NEW_OBJ(NULL);
+ OBJ(MUTEX_PROTO) = NEW_OBJ(NULL);
+ OBJ(ROOT_GLOBALS) = NEW_OBJ(NULL);
+ OBJ(MODULES) = NEW_OBJ(NULL);
+ OBJ(PR_FALSE) = NEW_OBJ(NULL);
+ OBJ(PR_TRUE) = NEW_OBJ(NULL);
+ OBJ(NONE) = NEW_OBJ(NULL);
+ OBJ(EXCEPTION) = NEW_OBJ(NULL);
+ OBJ(GEN_PROTO) = NEW_OBJ(NULL);
+ OBJ(INT_PROTO) = NEW_OBJ(NULL);
+ OBJ(STRING_PROTO) = NEW_OBJ(NULL);
+ OBJ(DICT_PROTO) = NEW_OBJ(NULL);
+ OBJ(FUNC_PROTO) = NEW_OBJ(NULL);
OBJ(SYMBOLS) = new_list_obj(ist, SYM_ENUM_COUNT+100);
@@ -248,7 +248,7 @@
obj_p copy_object(isp ist, obj_p obj) {
obj_p copy;
attr_p new_attrp, attrp;
- copy = new_object(ist, NULL);
+ copy = NEW_OBJ(NULL);
memcpy(copy, obj, sizeof(*obj)-sizeof(obj->next_obj));
copy->archived = FALSE;
copy->del_locked = TRUE;
@@ -325,7 +325,7 @@
{
if (!proto_obj)
proto_obj = OBJ(EXCEPTION);
- ist->exception_obj = new_object(ist, proto_obj);
+ ist->exception_obj = NEW_OBJ(proto_obj);
if (format) {
char *p, err_buf[512];
va_list ap;
@@ -818,7 +818,7 @@
//********************************* new_hash_obj ******************************
obj_p new_hash_obj(isp ist, i32_t num) {
- obj_p hash_obj = new_object(ist, OBJ(HASH_PROTO));
+ obj_p hash_obj = NEW_OBJ(OBJ(HASH_PROTO));
hash_obj->data_type = DATA_TYPE_IMMDATA;
hash_obj->imm_data_len = 4;
hash_obj->data.i32[0] = num & HASH_MASK;
@@ -850,7 +850,7 @@
//********************************* new_C_func_obj ******************************
obj_p new_C_func_obj(isp ist, pr_func* func_ptr, obj_p label_values_list) {
- obj_p func_obj = new_object(ist, OBJ(FUNC_PROTO));
+ obj_p func_obj = NEW_OBJ(OBJ(FUNC_PROTO));
func_obj->data_type = DATA_TYPE_FUNCPTR;
func_obj->data.ptr = func_ptr;
if (label_values_list)
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/symbol.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -148,8 +148,8 @@
{ "max", 0 },
{ "min", 0 },
{ "copy", 0 },
- { "__storProxy__", 0 },
- { "__newViaStorProxy__", 0}
+ { "__toStorProxy__", 0 },
+ { "__fromStorProxy__", 0}
};
typedef struct trie_node_s* trie_p;
@@ -232,7 +232,7 @@
pr_free(s);
return sym;
}
- sym = new_object(ist, OBJ(SYMBOL_PROTO));
+ sym = NEW_OBJ(OBJ(SYMBOL_PROTO));
sym->data_type = DATA_TYPE_IMMDATA;
sym->imm_data_len = 4;
if (!(next_key = (next_key+3) & 0x7fffffff)) {
Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c 2004-04-17 05:12:18 UTC (rev 373)
+++ trunk/src/sys.c 2004-04-17 19:17:18 UTC (rev 374)
@@ -144,7 +144,7 @@
apr_pool_t *mod_pool = NULL;
sys_path = new_list_obj(ist, 10);
- sys_module = new_object(ist, OBJ(OBJECT));
+ sys_module = NEW_OBJ(OBJ(OBJECT));
set_attr(ist, OBJ(MODULES),sym(ist, "Sys"), sys_module);
set_attr(ist, OBJ(OBJECT), sym(ist, "Sys"), sys_module);
set_obj_doc(sys_module, "Sys: a built-in module of system attributes");
@@ -192,10 +192,10 @@
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(ist, MAX_INT_VAL));
+ set_attr(ist, sys_module, sym(ist, "maxint"), NEW_INT(MAX_INT_VAL));
set_attr(ist, sys_module, sym(ist, "modules"), OBJ(MODULES));
set_attr( ist, sys_module, sym(ist, "exit"),
- new_C_func_obj(ist, sys_exit, list2(ist, sym(ist,"num"),new_int_obj(ist, 1))) );
+ new_C_func_obj(ist, sys_exit, list2(ist, sym(ist,"num"),NEW_INT(1))) );
#if defined(WIN32)
set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(ist, "win32"));