rev 204 - in trunk: include/prothon modules/Dict modules/File modules/Float modules/List modules/Re modules/String modules/Tuple src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: bcollins
Date: 2004-03-29 23:58:06 -0500 (Mon, 29 Mar 2004)
New Revision: 204

Modified:
   trunk/include/prothon/dict.h
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/modules/Dict/Dict.c
   trunk/modules/File/File.c
   trunk/modules/Float/Float.c
   trunk/modules/List/List.c
   trunk/modules/Re/Re.c
   trunk/modules/String/String.c
   trunk/modules/Tuple/Tuple.c
   trunk/src/Makefile.in
   trunk/src/builtins.c
   trunk/src/main.c
   trunk/src/object.c
   trunk/src/object.h
Log:
Major overhaul of how modules are loaded. There is now no difference
code-wise between a built-in and a loadable module. You can freely move
them between being a loadable, and compiled right into the binary.


Modified: trunk/include/prothon/dict.h
===================================================================
--- trunk/include/prothon/dict.h	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/include/prothon/dict.h	2004-03-30 04:58:06 UTC (rev 204)
@@ -1,4 +1,56 @@
 
+/* ====================================================================
+ * The Prothon License Agreement, Version 1.0
+ *
+ * Copyright (c) 2004 Mark C. Hahn <[email protected]>. All rights
+ * reserved.
+ *
+ * 1. This LICENSE AGREEMENT is between Mark C. Hahn ("MCH"), and the
+ * Individual or Organization ("Licensee") accessing and otherwise using
+ * Prothon software in source or binary form and its associated
+ * documentation.
+ * 
+ * 2. Subject to the terms and conditions of this License Agreement, MCH
+ * hereby grants Licensee a nonexclusive, royalty-free, world-wide license
+ * to reproduce, analyze, test, perform and/or display publicly, prepare
+ * derivative works, distribute, and otherwise use Prothon alone or in any
+ * derivative version, provided, however, that MCH's License Agreement and
+ * MCH's notice of copyright, i.e., "Copyright (c) 2004 Mark C. Hahn; All
+ * Rights Reserved" are retained in Prothon alone or in any derivative
+ * version prepared by Licensee.
+ * 
+ * 3. In the event Licensee prepares a derivative work that is based on or
+ * incorporates Prothon or any part thereof, and wants to make the
+ * derivative work available to others as provided herein, then Licensee
+ * hereby agrees to include in any such work a brief summary of the
+ * changes made to Prothon.
+ * 
+ * 4. MCH is making Prothon available to Licensee on an "AS IS" basis.
+ * MCH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
+ * OF EXAMPLE, BUT NOT LIMITATION, MCH MAKES NO AND DISCLAIMS ANY
+ * REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY
+ * PARTICULAR PURPOSE OR THAT THE USE OF PROTHON WILL NOT INFRINGE ANY
+ * THIRD PARTY RIGHTS.
+ * 
+ * 5. MCH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PROTHON
+ * FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
+ * RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PROTHON, OR ANY
+ * DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+ * 
+ * 6. This License Agreement will automatically terminate upon a material
+ * breach of its terms and conditions.
+ * 
+ * 7. Nothing in this License Agreement shall be deemed to create any
+ * relationship of agency, partnership, or joint venture between MCH and
+ * Licensee.  This License Agreement does not grant permission to use MCH
+ * trademarks or trade name in a trademark sense to endorse or promote
+ * products or services of Licensee, or any third party.
+ * 
+ * 8. By copying, installing or otherwise using Prothon, Licensee agrees
+ * to be bound by the terms and conditions of this License Agreement.
+ * ====================================================================
+ */
+
 // dict.h
 
-#define DEFAULT_INITIAL_DICT_SIZE  8
\ No newline at end of file
+#define DEFAULT_INITIAL_DICT_SIZE  8

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/include/prothon/prothon.h	2004-03-30 04:58:06 UTC (rev 204)
@@ -72,11 +72,17 @@
 #endif
 
 #ifdef WIN32
-#define PR_DECLARE_EXPORT(type)         __declspec(dllexport) type
+#define PR_DECLARE_EXPORT		__declspec(dllexport)
+#define PR_DECLARE_SECTION(name)	#pragma section(name)
+#define PR_PLACE_IN_SECTION(type,name,sect) \
+	__declspec(allocate(sect)) type name
 #define LONG_LONG_FMT			"%I64d"
 #define LONG_LONG_CAST			i64_t
 #else
-#define PR_DECLARE_EXPORT(type)         type
+#define PR_DECLARE_EXPORT
+#define PR_DECLARE_SECTION(name)
+#define PR_PLACE_IN_SECTION(type,name,sect) \
+	type name __attribute__((section(sect), unused))
 #define LONG_LONG_FMT			"%lld"
 #define LONG_LONG_CAST			long long
 #endif
@@ -207,7 +213,7 @@
 //************************* WELL-KNOWN-OBJECTS ********************************
 // these are created at object system initialization
 typedef enum {
-	
+	NO_PROTO=-1,
 // "singleton" objects
 	PR_FALSE,			// 0 False
 	PR_TRUE,			// 1 True
@@ -262,7 +268,7 @@
 	OBJ_ENUM_COUNT
 } obj_enum_t;
 
-obj_p OBJ_[OBJ_ENUM_COUNT];
+extern obj_p OBJ_[OBJ_ENUM_COUNT];
 
 // Use OBJ(OBJNAME) to access well-known objects
 // example:  OBJ(OBJECT) or OBJ(PR_TRUE)
@@ -704,6 +710,20 @@
 // 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);
 
+typedef void (* mod_initcall_t)(void);
+
+/* Declare the start of a new module */
+#define MODULE_START(name)					\
+static isp ist;							\
+static pr_services_t *services;					\
+static obj_p name##_OBJ;					\
+PR_DECLARE_SECTION("._objinit_" #name)				\
+PR_PLACE_IN_SECTION(static mod_initcall_t,initcalls_##name,"._objinit_" #name) = NULL
+
+#define MODULE_END(name)					\
+PR_PLACE_IN_SECTION(static mod_initcall_t,initcalls_##name##_end,"._objinit_" #name) = NULL
+
+
 // DEF: convenience C macro equivalent of Prothon DEF statement
 // Note that pcnt normally doesn't need to be checked to make sure 
 // params are present since formal params are always automatically checked
@@ -711,13 +731,14 @@
 // see Int.c for example of usage
 #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, sym(ist, #func), new_func_obj(ist, slf##func, fparam_list));	\
-	}																					\
+	static void slf##func##init(void) {						\
+		set_attr(ist, slf##_OBJ, sym(ist, #func), 				\
+			 new_func_obj(ist, slf##func, fparam_list));			\
+	}										\
+	PR_PLACE_IN_SECTION(static mod_initcall_t,slf##func##init_ptr,			\
+			"._objinit_" #slf) = slf##func##init;				\
 	static obj_p slf##func(isp ist, obj_p self, int pcnt, obj_p* parms, obj_p dlocals)
 
-/* Call a functions init, declared from DEF() above */
-#define CALL_INIT(slf, func) slf##func##init()
 
 // FORM_RPARAM: convenience macro for single formal right parameter
 // Defines a formal label/default-value list that matches  func(rparam).

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/include/prothon/prothon_dll.h	2004-03-30 04:58:06 UTC (rev 204)
@@ -118,23 +118,37 @@
 
 } pr_services_t;
 
-#ifndef OBJECT_H
+typedef void (* dll_initcall_t)(pr_services_t *);
 
-extern isp ist;
-extern pr_services_t *services;
+#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();								\
+	name##_module_install();							\
+}											\
+PR_DECLARE_SECTION("._module_init")							\
+PR_PLACE_IN_SECTION(static dll_initcall_t,name##dll_entry_ptr, "._module_init") =	\
+	name##_dll_entry;								\
+static void name##_module_install(void)
 
-#define install_module(modname)						\
-static isp ist;								\
-static pr_services_t *services;						\
-static void pr_module_install(void);					\
-PR_DECLARE_EXPORT(void) modname##_dll_entry(pr_services_t* srvcs)	\
-{									\
-	services = srvcs;						\
-	ist = get_ist();						\
-	pr_module_install();						\
-}									\
-static void pr_module_install(void)
+#define MODULE_SUB_INIT(name, proto)			\
+do {							\
+	mod_initcall_t *initcalls = &initcalls_##name;	\
+	if (proto != NO_PROTO)				\
+		name##_OBJ = OBJ(proto);		\
+	else						\
+		name##_OBJ = new_object(NULL);		\
+	initcalls++;					\
+	while (*initcalls) {				\
+		(*initcalls)();				\
+		initcalls++;				\
+	}						\
+} while(0)
 
+#ifndef OBJECT_H
+
 #define get_ist				(*services->get_ist)
 #define get_attr			(*services->get_attr)
 #define set_attr			(*services->set_attr)

Modified: trunk/modules/Dict/Dict.c
===================================================================
--- trunk/modules/Dict/Dict.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/Dict/Dict.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -56,8 +56,10 @@
 #include <stdio.h>
 #include <string.h> 
 
-#define DICT_PROTO_OBJ   OBJ(DICT_PROTO)
+MODULE_START(Dict);
+MODULE_END(Dict);
 
-
-install_module(Dict){
+MAIN_MODULE_INIT(Dict)
+{
+	MODULE_SUB_INIT(Dict, DICT_PROTO);
 }

Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/File/File.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -75,19 +75,20 @@
 #define BUFSIZE(obj) (((pr_file_p)((obj)->data.ptr))->bufsize)
 #define POOL(obj)    (((pr_file_p)((obj)->data.ptr))->pool)
 #define FLAGS(obj)   (((pr_file_p)((obj)->data.ptr))->flags)
-#define OPEN(obj)    (((obj) != FILE_PROTO) && STREAM(obj))
+#define OPEN(obj)    (((obj) != File_OBJ) && STREAM(obj))
 
-static obj_p FILE_PROTO, DIR_PROTO;
+MODULE_START(File);
+MODULE_START(Dir);
 
 static obj_p new_file_object(obj_p filename, obj_p mode,
 			     apr_file_t *fp, int bufsize,
 			     apr_int32_t flags)
 {
-	obj_p file_obj = new_object(FILE_PROTO);
+	obj_p file_obj = new_object(File_OBJ);
 	apr_pool_t *subpool = apr_file_pool_get(fp);
 	pr_file_p filep;
 
-	file_obj = new_object(FILE_PROTO);
+	file_obj = new_object(File_OBJ);
 	set_attr(ist, file_obj, sym(ist, "name"), filename);
 	set_attr(ist, file_obj, sym(ist, "mode"), mode);
 
@@ -106,7 +107,7 @@
 	return file_obj;
 }
 
-DEF( FILE_PROTO, __init__, list6( sym(ist, "path"),    NULL, 
+DEF(File, __init__, list6( sym(ist, "path"),    NULL, 
                                   sym(ist, "mode"),    new_string_obj("r"),
                                   sym(ist, "bufsize"), new_int_obj(-1) ) ) {
 	apr_file_t *f;
@@ -173,11 +174,11 @@
 	return new_file_object(parms[1], parms[3], f, (int)(parms[5]->data.i64), flags);
 }
 
-DEF(FILE_PROTO, __objlist__, FORM_RPARAM) {
+DEF(File, __objlist__, FORM_RPARAM) {
 	return parms[1];
 }
 
-DEF(FILE_PROTO, close, NULL) { 
+DEF(File, close, NULL) { 
 	if (OPEN(self)) {
 		apr_file_close(STREAM(self));
 		STREAM(self) = NULL;
@@ -186,8 +187,8 @@
 	return OBJ(NONE);
 }
 
-DEF(FILE_PROTO, closed, NULL) { 
-	if (!has_proto(ist, self, FILE_PROTO)) {
+DEF(File, closed, NULL) { 
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "closed can only be called on a File object");
 		return NULL;
 	}
@@ -195,8 +196,8 @@
 	else			return OBJ(PR_TRUE);
 }
 
-DEF(FILE_PROTO, flush, NULL) { 
-	if (!has_proto(ist, self, FILE_PROTO)) {
+DEF(File, flush, NULL) { 
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "flush can only be called on a File object");
 		return NULL;
 	}
@@ -211,8 +212,8 @@
 	return OBJ(NONE);
 }
 #if 0
-DEF(FILE_PROTO, fileno, NULL) { 
-	if (!has_proto(ist, self, FILE_PROTO)) {
+DEF(File, fileno, NULL) { 
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "fileno can only be called on a File object");
 		return NULL;
 	}
@@ -223,7 +224,7 @@
 	return new_int_obj(_fileno(STREAM(self)));
 }
 
-DEF(FILE_PROTO, isatty, NULL) { 
+DEF(File, isatty, NULL) { 
 	if (!OPEN(self)) {
 		raise_exception(ist, OBJ(IOEXCEPTION), "isatty called on closed stream");
 		return NULL;
@@ -232,7 +233,7 @@
 	else						return OBJ(PR_FALSE); 
 }
 #endif
-DEF(FILE_PROTO, read, list2( sym(ist, "size"), new_int_obj(-1))) {
+DEF(File, read, list2( sym(ist, "size"), new_int_obj(-1))) {
 	int readall = FALSE;
 	i64_t size_in;
 	size_t size, total_read=0, num_read;
@@ -246,7 +247,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "read can only be called on a File object");
 		return NULL;
 	}
@@ -312,7 +313,7 @@
 	return str_obj;
 }
 
-DEF(FILE_PROTO, readline, list2( sym(ist, "size"), new_int_obj(-1))) {
+DEF(File, readline, list2( sym(ist, "size"), new_int_obj(-1))) {
 	int readall = FALSE;
 	i64_t  size_in;
 	size_t size, total_read;
@@ -326,7 +327,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "readline can only be called on a File object");
 		return NULL;
 	}
@@ -390,7 +391,7 @@
 	return str_obj;
 }
 
-DEF(FILE_PROTO, readlines, list2( sym(ist, "size"), new_int_obj(-1))) {
+DEF(File, readlines, list2( sym(ist, "size"), new_int_obj(-1))) {
 	int readall = FALSE;
 	i64_t  size_in;
 	size_t size, total_read=0, num_read;
@@ -404,7 +405,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "readlines can only be called on a File object");
 		return NULL;
 	}
@@ -476,7 +477,7 @@
 	return list_obj;
 }
 
-DEF( FILE_PROTO, seek, list4( sym(ist, "pos"), NULL,
+DEF( File, seek, list4( sym(ist, "pos"), NULL,
                               sym(ist, "how"), new_int_obj(0) ) ) {
 	apr_off_t pos;
 	apr_seek_where_t origin;
@@ -491,7 +492,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file seek how parameter must be an integer");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "seek can only be called on a File object");
 		return NULL;
 	}
@@ -518,7 +519,7 @@
 	return OBJ(NONE);
 }
 #if 0
-DEF(FILE_PROTO, tell, NULL) {
+DEF(File, tell, NULL) {
 	if (!OPEN(self)) {
 		raise_exception(ist, OBJ(IOEXCEPTION), "tell called on closed file");
 		return NULL;
@@ -526,7 +527,7 @@
 	return new_int_obj(ftell(STREAM(self)));
 }
 #endif
-DEF(FILE_PROTO, truncate, list2(sym(ist, "size"), NULL)) {
+DEF(File, truncate, list2(sym(ist, "size"), NULL)) {
 	apr_status_t aprerr;
 	char err_buf[1024];
 	apr_off_t size;
@@ -535,7 +536,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file truncate size parameter must be an integer");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "truncate can only be called on a File object");
 		return NULL;
 	}
@@ -561,7 +562,7 @@
 	return OBJ(NONE);
 }
 
-DEF(FILE_PROTO, write, list2(sym(ist, "str"), NULL)) {
+DEF(File, write, list2(sym(ist, "str"), NULL)) {
 	char* str;
 	apr_size_t size;
 	apr_status_t aprerr;
@@ -571,7 +572,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file write str parameter must be a string");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "write can only be called on a File object");
 		return NULL;
 	}
@@ -595,7 +596,7 @@
 	return parms[1];
 }
 
-DEF(FILE_PROTO, writelines, list2(sym(ist, "lst"), NULL)) {
+DEF(File, writelines, list2(sym(ist, "lst"), NULL)) {
 	char* str;
 	apr_size_t size;
 	apr_status_t aprerr;
@@ -605,7 +606,7 @@
 		raise_exception(ist, OBJ(TYPE_EXC), "file writelines parameter must be a sequence or a string");
 		return NULL;
 	}
-	if (!has_proto(ist, self, FILE_PROTO)) {
+	if (!has_proto(ist, self, File_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "writelines can only be called on a File object");
 		return NULL;
 	}
@@ -647,13 +648,13 @@
 	return parms[1];
 }
 
-DEF(DIR_PROTO, __init__, list2(sym(ist, "path"), NULL)) {
+DEF(Dir, __init__, list2(sym(ist, "path"), NULL)) {
 	obj_p file_obj = new_string_obj(strch(parms[1]));
-	switch_proto_to(ist, file_obj, DIR_PROTO);
+	switch_proto_to(ist, file_obj, Dir_OBJ);
 	return file_obj;
 }
 
-DEF(DIR_PROTO, __objlist__, NULL) {
+DEF(Dir, __objlist__, NULL) {
 	return parms[1];
 }
 
@@ -700,35 +701,20 @@
 	return new_file_object(file, mode, fp, MIN_BUFSIZE, flags);
 }
 
-install_module(File) {
+MODULE_END(File);
+MODULE_END(Dict);
+
+MAIN_MODULE_INIT(File) {
 	apr_pool_t *std_pool;
 	apr_status_t aprerr;
 	obj_p file_obj;
 
-	FILE_PROTO = new_object(NULL);
-	DIR_PROTO  = new_object(NULL);
+	MODULE_SUB_INIT(File, NO_PROTO);
+	MODULE_SUB_INIT(Dir, NO_PROTO);
 
-	set_attr(ist, OBJ(OBJECT),	sym(ist, "File"), FILE_PROTO);
-	set_attr(ist, OBJ(OBJECT),	sym(ist, "Dir"),  DIR_PROTO);
+	set_attr(ist, OBJ(OBJECT),	sym(ist, "File"), File_OBJ);
+	set_attr(ist, OBJ(OBJECT),	sym(ist, "Dir"),  Dir_OBJ);
 
-	CALL_INIT(FILE_PROTO, __init__);
-	CALL_INIT(FILE_PROTO, __objlist__);
-	CALL_INIT(FILE_PROTO, close);
-	CALL_INIT(FILE_PROTO, closed);
-	CALL_INIT(FILE_PROTO, flush);
-//	CALL_INIT(FILE_PROTO, fileno);
-//	CALL_INIT(FILE_PROTO, isatty);
-	CALL_INIT(FILE_PROTO, seek);
-//	CALL_INIT(FILE_PROTO, tell);
-	CALL_INIT(FILE_PROTO, truncate);
-	CALL_INIT(FILE_PROTO, read);
-	CALL_INIT(FILE_PROTO, readline);
-	CALL_INIT(FILE_PROTO, readlines);
-	CALL_INIT(FILE_PROTO, write);
-	CALL_INIT(FILE_PROTO, writelines);
-	CALL_INIT(DIR_PROTO, __init__);
-	CALL_INIT(DIR_PROTO, __objlist__);
-
 	/* 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! */
@@ -736,9 +722,9 @@
 		return;
 
 	if ((file_obj = __open_std_file(__STDIN, std_pool)))
-		set_attr(ist, FILE_PROTO, sym(ist, "stdin"), file_obj);
+		set_attr(ist, File_OBJ, sym(ist, "stdin"), file_obj);
 	if ((file_obj = __open_std_file(__STDOUT, std_pool)))
-		set_attr(ist, FILE_PROTO, sym(ist, "stdout"), file_obj);
+		set_attr(ist, File_OBJ, sym(ist, "stdout"), file_obj);
 	if ((file_obj = __open_std_file(__STDERR, std_pool)))
-		set_attr(ist, FILE_PROTO, sym(ist, "stderr"), file_obj);
+		set_attr(ist, File_OBJ, sym(ist, "stderr"), file_obj);
 }

Modified: trunk/modules/Float/Float.c
===================================================================
--- trunk/modules/Float/Float.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/Float/Float.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -61,17 +61,20 @@
 #include <prothon/prothon_dll.h>
 
 #define	FLOAT_DATA_SIZE		8
-#define FLOAT_PROTO_OBJ		OBJ(FLOAT_PROTO)
 
-#define is_Float(objid)		(has_proto(ist, objid, FLOAT_PROTO_OBJ))
+#define is_Float(objid)		(has_proto(ist, objid, Float_OBJ))
 #define Float_value(objid)	(objid->data.f64)
 
-DEF(FLOAT_PROTO_OBJ, __bool__, NULL) { 
-	if (Float_value(self) != 0.0 ) return OBJ(PR_TRUE);
-	else						   return OBJ(PR_FALSE);
+MODULE_START(Float);
+
+DEF(Float, __bool__, NULL) { 
+	if (Float_value(self) != 0.0 )
+		return OBJ(PR_TRUE);
+	else
+		return OBJ(PR_FALSE);
 }
 
-DEF(FLOAT_PROTO_OBJ, __hash__, NULL) { 
+DEF(Float, __hash__, NULL) { 
 	double flt = (double) Float_value(self);
 	if (flt < 0) flt = -flt;
 	if (flt == 0.0) flt = 1.0;
@@ -80,20 +83,20 @@
 	return new_hash_obj((i32_t)flt);
 }
 
-DEF(FLOAT_PROTO_OBJ, __abs__, NULL) {
+DEF(Float, __abs__, NULL) {
 	double num = Float_value(self);
 	return new_float_obj(num < 0 ? -num : num);
 }
 
-DEF(FLOAT_PROTO_OBJ, __neg__, NULL){
+DEF(Float, __neg__, NULL){
 	return new_float_obj( - Float_value(self) );
 }
 
-DEF(FLOAT_PROTO_OBJ, __pos__, NULL){
+DEF(Float, __pos__, NULL){
 	return self;
 }
 
-DEF(FLOAT_PROTO_OBJ, __add__, FORM_RPARAM){
+DEF(Float, __add__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -110,7 +113,7 @@
 	return new_float_obj(Float_value(self) + float_other);
 }
 
-DEF(FLOAT_PROTO_OBJ, __div__, FORM_RPARAM){
+DEF(Float, __div__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -131,7 +134,7 @@
 	return new_float_obj(Float_value(self) / float_other);
 }
 
-DEF(FLOAT_PROTO_OBJ, __rdiv__, FORM_RPARAM){
+DEF(Float, __rdiv__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -150,7 +153,7 @@
 	return new_float_obj(float_other / Float_value(self));
 }
 
-DEF(FLOAT_PROTO_OBJ, __mul__, FORM_RPARAM){
+DEF(Float, __mul__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -167,7 +170,7 @@
 	return new_float_obj(Float_value(self) * float_other);
 }
 
-DEF(FLOAT_PROTO_OBJ, __sub__, FORM_RPARAM){
+DEF(Float, __sub__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -184,7 +187,7 @@
 	return new_float_obj(Float_value(self) - float_other);
 }
 
-DEF(FLOAT_PROTO_OBJ, __rsub__, FORM_RPARAM){
+DEF(Float, __rsub__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -199,7 +202,7 @@
 	return new_float_obj(float_other - Float_value(self));
 }
 
-DEF(FLOAT_PROTO_OBJ, __pow__, FORM_RPARAM){
+DEF(Float, __pow__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -216,7 +219,7 @@
 	return new_float_obj(pow(Float_value(self), float_other));
 }
 
-DEF(FLOAT_PROTO_OBJ, __rpow__, FORM_RPARAM){
+DEF(Float, __rpow__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -232,7 +235,7 @@
 }
 
 
-DEF(FLOAT_PROTO_OBJ, cmp, FORM_RPARAM){
+DEF(Float, cmp, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -254,7 +257,7 @@
 		return new_int_obj(-1);
 }
 
-DEF(FLOAT_PROTO_OBJ, __rcmp__, FORM_RPARAM){
+DEF(Float, __rcmp__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -274,7 +277,7 @@
 		return new_int_obj(-1);
 }
 
-DEF(FLOAT_PROTO_OBJ, __eq__, FORM_RPARAM){
+DEF(Float, __eq__, FORM_RPARAM){
 	double float_other;
 	obj_p other = parms[1];
 	if (is_Float(other)) float_other = Float_value(other);
@@ -291,46 +294,30 @@
 	else                                  return OBJ(PR_FALSE);
 }
 
-DEF(FLOAT_PROTO_OBJ, __str__, NULL){
+DEF(Float, __str__, NULL){
 	char str[1024];
 	apr_snprintf(str, sizeof(str), "%g", Float_value(self));
 	return new_string_obj(str);
 }
 
-DEF(FLOAT_PROTO_OBJ, __covers__, FORM_RPARAM) {
+DEF(Float, __covers__, FORM_RPARAM) {
 	if (has_proto(ist, parms[1], OBJ(INT_PROTO))) return OBJ(PR_TRUE);
 	else										   return OBJ(PR_FALSE);
 }
 
-DEF(FLOAT_PROTO_OBJ, __coerce__, FORM_RPARAM) {
+DEF(Float, __coerce__, FORM_RPARAM) {
 	if (has_proto(ist, parms[1], OBJ(INT_PROTO)))
 		return new_float_obj((double)(parms[1]->data.i64));
-	else if (has_proto(ist, parms[1], OBJ(FLOAT_PROTO)))
+	else if (has_proto(ist, parms[1], Float_OBJ))
 		return new_float_obj(parms[1]->data.f64);
 	else
 		raise_exception(ist, OBJ(TYPE_EXC), "This object cannot be coerced to a Float");
 	return NULL;
 }
 
+MODULE_END(Float);
 
-install_module(Float) {
-	CALL_INIT(FLOAT_PROTO_OBJ, __bool__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __hash__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __abs__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __neg__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __pos__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __add__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __div__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __rdiv__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __mul__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __sub__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __rsub__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __pow__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __rpow__);
-	CALL_INIT(FLOAT_PROTO_OBJ, cmp);
-	CALL_INIT(FLOAT_PROTO_OBJ, __rcmp__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __eq__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __str__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __covers__);
-	CALL_INIT(FLOAT_PROTO_OBJ, __coerce__);
+MAIN_MODULE_INIT(Float)
+{
+	MODULE_SUB_INIT(Float, FLOAT_PROTO);
 }

Modified: trunk/modules/List/List.c
===================================================================
--- trunk/modules/List/List.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/List/List.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -58,9 +58,9 @@
 #include <stdio.h>
 #include <string.h> 
 
-#define LIST_PROTO_OBJ   OBJ(LIST_PROTO)
+MODULE_START(List);
 
-DEF(LIST_PROTO_OBJ, __add__, FORM_RPARAM) { 
+DEF(List, __add__, FORM_RPARAM) { 
 	int i;
 	obj_p res = clone_list_obj(ist, self);
 	if (has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO)))
@@ -71,7 +71,7 @@
 	return res;
 }
 
-DEF(LIST_PROTO_OBJ, __mul__, FORM_RPARAM){
+DEF(List, __mul__, FORM_RPARAM){
 	obj_p res;
 	list_p lstp, selfp = ((list_p)(self->data.ptr))+LIST_OVERHEAD;
 	int i, size, times, len = list_len(ist, self);
@@ -83,7 +83,7 @@
 	size  = len*times;
 	if(times == 0) return new_list_obj(0);
 	if(times == 1) return self;
-	res = new_object(OBJ(LIST_PROTO));
+	res = new_object(List_OBJ);
 	lstp = res->data.ptr = pr_malloc((LIST_OVERHEAD+size)*sizeof(list_t));
 	if(!lstp) {
 		raise_exception(ist, OBJ(OUTOFMEMORY_EXC), "memory allocation failed for list multiplication");
@@ -97,7 +97,7 @@
 	return res;
 }
 
-DEF(LIST_PROTO_OBJ, append_BANG, FORM_RPARAM) {
+DEF(List, append_BANG, FORM_RPARAM) {
 	list_p lstp;
 	read_unlock(ist, self);  write_lock(ist, self);
 	lstp = self->data.ptr;
@@ -111,11 +111,11 @@
 	return self;
 }
 
-DEF(LIST_PROTO_OBJ, extend_BANG, FORM_RPARAM) {
+DEF(List, extend_BANG, FORM_RPARAM) {
 	list_p selfp, otherp;
 	int self_len, other_len;
 	read_unlock(ist, self);  write_lock(ist, self);
-	if (!has_proto(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto(ist, parms[1], OBJ(LIST_PROTO))) {
+	if (!has_proto(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto(ist, parms[1], List_OBJ)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "extend parameter must be a tuple or list");
 		return NULL;
 	}
@@ -134,7 +134,7 @@
 	return self;
 }
 
-DEF(LIST_PROTO_OBJ, insert_BANG, FORM_PARAM2) {
+DEF(List, insert_BANG, FORM_PARAM2) {
 	int index, self_len;
 	list_p selfp;
 	if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
@@ -164,7 +164,7 @@
 	return self;
 }
 
-DEF(LIST_PROTO_OBJ, remove_BANG, FORM_RPARAM) {
+DEF(List, remove_BANG, FORM_RPARAM) {
 	int i, self_len;
 	list_p selfp;
 	read_unlock(ist, self);  write_lock(ist, self);
@@ -187,7 +187,7 @@
 	return self;
 }
 
-DEF(LIST_PROTO_OBJ, pop_BANG, list2(SYM(RPARAM),OBJ(NONE))) {
+DEF(List, pop_BANG, list2(SYM(RPARAM),OBJ(NONE))) {
 	int index, self_len;
 	list_p selfp;
 	obj_p res;
@@ -216,7 +216,7 @@
 	return res;
 }
 
-DEF(LIST_PROTO_OBJ, reverse_BANG, NULL) {
+DEF(List, reverse_BANG, NULL) {
 	int self_len;
 	list_p selfp, p1, p2;
 	read_unlock(ist, self);  write_lock(ist, self);
@@ -234,13 +234,9 @@
 	return self;
 }
 
-install_module(List) {
-	CALL_INIT(LIST_PROTO_OBJ, __add__);
-	CALL_INIT(LIST_PROTO_OBJ, __mul__);
-	CALL_INIT(LIST_PROTO_OBJ, append_BANG);
-	CALL_INIT(LIST_PROTO_OBJ, extend_BANG);
-	CALL_INIT(LIST_PROTO_OBJ, insert_BANG);
-	CALL_INIT(LIST_PROTO_OBJ, remove_BANG);
-	CALL_INIT(LIST_PROTO_OBJ, pop_BANG);
-	CALL_INIT(LIST_PROTO_OBJ, reverse_BANG);
+MODULE_END(List);
+
+MAIN_MODULE_INIT(List)
+{
+	MODULE_SUB_INIT(List, LIST_PROTO);
 }

Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/Re/Re.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -63,11 +63,16 @@
 
 #define numgrps(re_obj) (((regex_t*)((re_obj)->data.ptr))->re_nsub)
 
-static obj_p RE_MODULE, RE_PROTO, MATCH_PROTO, RE_EXC; 
+MODULE_START(Re);
+MODULE_START(ReCompiled);
+MODULE_START(ReMatch);
+
+
+static obj_p RE_EXC; 
 static obj_p i_flg, s_flg;
 
 
-DEF( RE_MODULE, compile, list4( sym(ist, "pattern"), NULL, 
+DEF( Re, compile, list4( sym(ist, "pattern"), NULL, 
 								sym(ist, "flags"),   OBJ(ZERO_INT) ) ) {
 	obj_p re_obj;
 	regex_t* e = pr_malloc(sizeof(regex_t));
@@ -100,7 +105,7 @@
 		raise_exception(ist, RE_EXC, "more than 99 groups in regular expression");
 		return NULL;
 	}
-	re_obj = new_object(RE_PROTO);
+	re_obj = new_object(ReCompiled_OBJ);
 	re_obj->data_type = OBJ_TYPE_DATAPTR;
 	re_obj->data.ptr = e;
 	set_attr(ist, re_obj, sym(ist, "pattern"), parms[1]);
@@ -108,7 +113,7 @@
 	return re_obj;
 }
 
-DEF(RE_PROTO, findall, FORM_RPARAM) {
+DEF(ReCompiled, findall, FORM_RPARAM) {
 	char* s;
 	regmatch_t* m;
 	obj_p res, tuple_obj;
@@ -164,7 +169,7 @@
 	return res;
 }
 
-DEF( RE_PROTO, search, list6( sym(ist, "s"),     NULL, 
+DEF( ReCompiled, search, list6( sym(ist, "s"),     NULL, 
 							  sym(ist, "start"), OBJ(ZERO_INT),
 							  sym(ist, "end"),   OBJ(MAX_INT) ) ) {
 	obj_p match_obj, lastindex_obj;
@@ -204,7 +209,7 @@
 		return NULL;
 	}
 	match_obj = new_list_obj((ngrps+1)*2);
-	switch_proto_to(ist, match_obj, MATCH_PROTO);
+	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));
@@ -221,7 +226,7 @@
 	return match_obj;
 }
 
-DEF( RE_PROTO, split, list4( sym(ist, "s"),        NULL, 
+DEF( ReCompiled, split, list4( sym(ist, "s"),        NULL, 
 							 sym(ist, "maxsplit"), OBJ(ZERO_INT) ) ) {
 	char* s;
 	regmatch_t* m;
@@ -362,7 +367,7 @@
 	return TRUE;
 }
 
-DEF( RE_PROTO, sub, list6( sym(ist, "repl"),  NULL, 
+DEF( ReCompiled, sub, list6( sym(ist, "repl"),  NULL, 
 						   sym(ist, "s"),	  NULL, 
 						   sym(ist, "count"), OBJ(ZERO_INT) ) ) {
 	char *repl = "", *orig_s, *p1, *p2, *s, *s_lim, *res;
@@ -386,7 +391,7 @@
 		return NULL;
 	}
 	match_obj = new_list_obj((ngrps+1)*2);
-	switch_proto_to(ist, match_obj, MATCH_PROTO);
+	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);
@@ -470,20 +475,20 @@
 	return res_obj;
 }
 
-DEF(RE_PROTO, __objlist__, FORM_RPARAM) {
+DEF(ReCompiled, __objlist__, FORM_RPARAM) {
 	return parms[1];
 }
 
-DEF(RE_PROTO, __del__, NULL) {
+DEF(ReCompiled, __del__, NULL) {
 	regfree((regex_t*)(self->data.ptr));
 	return OBJ(NONE);
 }
 
-DEF(MATCH_PROTO, __objlist__, FORM_RPARAM) {
+DEF(ReMatch, __objlist__, FORM_RPARAM) {
 	return parms[1];
 }
 
-DEF(MATCH_PROTO, start, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, start, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
 	int grp;
 	if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "start function groupid parameter must be an integer");
@@ -497,7 +502,7 @@
 	return list_item(ist, self, 2*grp);
 }
 
-DEF(MATCH_PROTO, end, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, end, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
 	int grp;
 	if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
 		raise_exception(ist, OBJ(TYPE_EXC), "end function groupid parameter must be an integer");
@@ -511,7 +516,7 @@
 	return list_item(ist, self, 2*grp+1);
 }
 
-DEF(MATCH_PROTO, span, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
+DEF(ReMatch, span, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
 	int grp;
 	obj_p res;
 	if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
@@ -530,7 +535,7 @@
 	return res;
 }
 
-DEF(MATCH_PROTO, expand, FORM_RPARAM) {
+DEF(ReMatch, expand, FORM_RPARAM) {
 	size_t size;
 	char *p1, *p2, *s, *s_lim, *orig_s;
 	obj_p orig_s_obj, res;
@@ -551,7 +556,7 @@
 	return res;
 }
 
-DEF( MATCH_PROTO, group, list4( sym(ist, "groupid"), OBJ(ZERO_INT),
+DEF( ReMatch, group, list4( sym(ist, "groupid"), OBJ(ZERO_INT),
 							    PARAM_STAR,     sym(ist, "groupids") ) ) {
 	int i, j, llen, ngrps = list_len(ist, self)/2, sp, ep;
 	char* orig_s;
@@ -603,7 +608,7 @@
 	}
 }
 
-DEF( MATCH_PROTO, groups, list2(sym(ist, "default"), OBJ(NONE))) {
+DEF( ReMatch, groups, list2(sym(ist, "default"), OBJ(NONE))) {
 	int i, ngrps = list_len(ist, self)/2, sp, ep;
 	char* orig_s;
 	obj_p orig_s_obj, res = new_tuple_obj(ngrps);
@@ -619,43 +624,38 @@
 	return res;
 }
 
-install_module(Re) {
-	RE_MODULE	= new_object(NULL);
-	RE_PROTO	= new_object(NULL);
-	MATCH_PROTO	= new_object(NULL);
-	RE_EXC      = new_object(OBJ(EXCEPTION));
+MODULE_END(Re);
+MODULE_END(ReCompiled);
+MODULE_END(ReMatch);
 
-	add_doc_to_obj(ist, RE_EXC,			"Re module error");
-	add_doc_to_obj(ist, RE_MODULE,		"Re: module for regular expressions");
-	add_doc_to_obj(ist, RE_PROTO,		"Re_proto: prototype for compiled regular expressions");
-	add_doc_to_obj(ist, MATCH_PROTO,	"Match_proto: prototype for regular expression match objects");
+MAIN_MODULE_INIT(Re)
+{
+	MODULE_SUB_INIT(Re, NO_PROTO);
+	MODULE_SUB_INIT(ReCompiled, NO_PROTO);
+	MODULE_SUB_INIT(ReMatch, NO_PROTO);
 
-	set_attr(ist, OBJ(MODULES), sym(ist, "Re"),				RE_MODULE);
-	set_attr(ist, OBJ(OBJECT),  sym(ist, "Re"),				RE_MODULE);
-	set_attr(ist, RE_MODULE,    sym(ist, "Re"),				RE_PROTO);
-	set_attr(ist, RE_MODULE,    sym(ist, "Match"),			MATCH_PROTO);
-	set_attr(ist, RE_MODULE,    sym(ist, "ReException"),	RE_EXC);
+	RE_EXC = new_object(OBJ(EXCEPTION));
 
+	add_doc_to_obj(ist, RE_EXC,
+			"Re module error");
+	add_doc_to_obj(ist, Re_OBJ,
+			"Re: module for regular expressions");
+	add_doc_to_obj(ist, ReCompiled_OBJ,
+			"ReCompiled: prototype for compiled regular expressions");
+	add_doc_to_obj(ist, ReMatch_OBJ,
+			"Match_proto: prototype for regular expression match objects");
+
+	set_attr(ist, OBJ(MODULES), sym(ist, "Re"),	Re_OBJ);
+	set_attr(ist, OBJ(OBJECT),  sym(ist, "Re"),	Re_OBJ);
+	set_attr(ist, Re_OBJ,    sym(ist, "Re"),		ReCompiled_OBJ);
+	set_attr(ist, Re_OBJ,    sym(ist, "Match"),		ReMatch_OBJ);
+	set_attr(ist, Re_OBJ,    sym(ist, "ReException"),	RE_EXC);
+
 	i_flg = new_int_obj(REG_ICASE);
 	s_flg = new_int_obj(REG_NEWLINE);   // reverse meaning
 
-	set_attr(ist, RE_MODULE, sym(ist, "I"),          i_flg);
-	set_attr(ist, RE_MODULE, sym(ist, "IGNORECASE"), i_flg);
-	set_attr(ist, RE_MODULE, sym(ist, "S"),          s_flg);
-	set_attr(ist, RE_MODULE, sym(ist, "DOTALL"),     s_flg);
-
-	CALL_INIT(RE_MODULE, compile);
-	CALL_INIT(RE_PROTO, findall);
-	CALL_INIT(RE_PROTO, search);
-	CALL_INIT(RE_PROTO, split);
-	CALL_INIT(RE_PROTO, sub);
-	CALL_INIT(RE_PROTO, __objlist__);
-	CALL_INIT(RE_PROTO, __del__);
-	CALL_INIT(MATCH_PROTO, __objlist__);
-	CALL_INIT(MATCH_PROTO, start);
-	CALL_INIT(MATCH_PROTO, end);
-	CALL_INIT(MATCH_PROTO, span);
-	CALL_INIT(MATCH_PROTO, expand);
-	CALL_INIT(MATCH_PROTO, group);
-	CALL_INIT(MATCH_PROTO, groups);
+	set_attr(ist, Re_OBJ, sym(ist, "I"),          i_flg);
+	set_attr(ist, Re_OBJ, sym(ist, "IGNORECASE"), i_flg);
+	set_attr(ist, Re_OBJ, sym(ist, "S"),          s_flg);
+	set_attr(ist, Re_OBJ, sym(ist, "DOTALL"),     s_flg);
 }

Modified: trunk/modules/String/String.c
===================================================================
--- trunk/modules/String/String.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/String/String.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -57,37 +57,30 @@
 #include <string.h>
 #include <prothon/prothon_dll.h>
 
-#define STR_PROTO_OBJ	    OBJ(STRING_PROTO)
-#define is_String(objid)	(has_proto(ist, objid, STR_PROTO_OBJ))
+MODULE_START(String);
+MODULE_START(StringGen);
 
-obj_p STRINGGEN_PROTO; 
+#define is_String(objid)	(has_proto(ist, objid, String_OBJ))
 
-DEF(STR_PROTO_OBJ, __eq__, FORM_RPARAM){
+DEF(String, cmp, FORM_RPARAM){
 	obj_p other = parms[1];
-	if (self == other) return OBJ(PR_TRUE);
-	if ( !is_String(other) ||
-         strcmp(strch(self), strch(other)) ) return OBJ(PR_FALSE);
-	else                                     return OBJ(PR_TRUE);
-}
-
-DEF(STR_PROTO_OBJ, cmp, FORM_RPARAM){
-	obj_p other = parms[1];
-	if (self == other) return new_int_obj(0);
+	if (self == other)
+		return new_int_obj(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(strcmp(strch(self), strch(other)));
 }
 
-DEF(STR_PROTO_OBJ, __add__, FORM_RPARAM){
+DEF(String, __add__, FORM_RPARAM){
 	obj_p obj, other = parms[1];
 	pr_str_p obj_str;
 	size_t slen, olen, tlen;
 	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(OBJ(STRING_PROTO));
+	obj = new_object(String_OBJ);
 	if (tlen < IMMEDIATE_DATA_LEN) {
 		obj->data_type    = OBJ_TYPE_IMMDATA;
 		obj->imm_data_len = (int) tlen;
@@ -105,7 +98,7 @@
 	return obj;
 }
 
-DEF(STR_PROTO_OBJ, __mul__, FORM_RPARAM){
+DEF(String, __mul__, FORM_RPARAM){
 	obj_p obj;
 	pr_str_p obj_str;
 	size_t i, times, tlen, len = pr_strlen(self);
@@ -117,7 +110,7 @@
 	if(times == 0) return new_string_obj("");
 	if(times == 1) return self;
 	tlen = len*times+1;
-	obj = new_object(OBJ(STRING_PROTO));
+	obj = new_object(String_OBJ);
 	if (tlen < IMMEDIATE_DATA_LEN) {
 		obj->data_type    = OBJ_TYPE_IMMDATA;
 		obj->imm_data_len = (int) tlen;
@@ -139,22 +132,22 @@
 	return obj;
 }
 
-DEF(STR_PROTO_OBJ, __gen__, NULL) {
-	obj_p gen_obj = new_object(STRINGGEN_PROTO);
+DEF(String, __gen__, NULL) {
+	obj_p gen_obj = new_object(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);
 	return gen_obj;
 }
 
-DEF(STRINGGEN_PROTO, next, NULL) {
+DEF(StringGen, next, NULL) {
 	int ch;
 	obj_p res = NULL;
 	char* res_str;
 	write_lock(ist, self);
 	if ((ch = *strch(self))) {
 		((char*)(self->data.ptr))++;
-		res = new_object(OBJ(STRING_PROTO));
+		res = new_object(String_OBJ);
 		res_str = (char*)obj_malloc(res, 2);
 		res_str[0] = ch; 
 		res_str[1] = 0; 
@@ -164,11 +157,11 @@
 	return res;
 }
 
-DEF(STR_PROTO_OBJ, ord, NULL) {
+DEF(String, ord, NULL) {
 	return new_int_obj((int)(*strch(self)));
 }
 
-DEF(STR_PROTO_OBJ, join, FORM_RPARAM) {
+DEF(String, join, FORM_RPARAM) {
 	char *self_str, *dest_ptr;
 	pr_str_p obj_str;
 	obj_p obj, list, str_list;
@@ -191,7 +184,7 @@
 		tlen += pr_strlen(str_obj); 
 		if (i != llen-1) tlen += self_len;
 	}
-	obj = new_object(OBJ(STRING_PROTO));
+	obj = new_object(String_OBJ);
 	if (tlen < IMMEDIATE_DATA_LEN) {
 		obj->data_type    = OBJ_TYPE_IMMDATA;
 		obj->imm_data_len = (int) tlen;
@@ -221,36 +214,29 @@
 	return obj;
 }
 
-DEF(STR_PROTO_OBJ, __in__, FORM_RPARAM) {
-	if (!has_proto(ist, parms[1], OBJ(STRING_PROTO)))
+DEF(String, __in__, FORM_RPARAM) {
+	if (!has_proto(ist, parms[1], String_OBJ))
 		return call_func1(ist, parms[1], SYM(__RIN__), self);
 	if (strstr(strch(parms[1]), strch(self))) return OBJ(PR_TRUE);
 	else						              return OBJ(PR_FALSE);
 }
 
-DEF(STR_PROTO_OBJ, __notin__, FORM_RPARAM) {
-	if (!has_proto(ist, parms[1], OBJ(STRING_PROTO)))
+DEF(String, __notin__, FORM_RPARAM) {
+	if (!has_proto(ist, parms[1], String_OBJ))
 		return call_func1(ist, parms[1], SYM(__RNOTIN__), self);
 	if (strstr(strch(parms[1]), strch(self))) return OBJ(PR_FALSE);
 	else						              return OBJ(PR_TRUE);
 }
 
-DEF(STR_PROTO_OBJ, len, NULL) {
+DEF(String, len, NULL) {
 	return new_int_obj(pr_strlen(self));
 }
 
-install_module(String) {
-	STRINGGEN_PROTO = new_object(NULL);
+MODULE_END(String);
+MODULE_END(StringGen);
 
-	CALL_INIT(STR_PROTO_OBJ, __eq__);
-	CALL_INIT(STR_PROTO_OBJ, cmp);
-	CALL_INIT(STR_PROTO_OBJ, __add__);
-	CALL_INIT(STR_PROTO_OBJ, __mul__);
-	CALL_INIT(STR_PROTO_OBJ, __gen__);
-	CALL_INIT(STR_PROTO_OBJ, ord);
-	CALL_INIT(STR_PROTO_OBJ, join);
-	CALL_INIT(STR_PROTO_OBJ, __in__);
-	CALL_INIT(STR_PROTO_OBJ, __notin__);
-	CALL_INIT(STR_PROTO_OBJ, len);
-	CALL_INIT(STRINGGEN_PROTO, next);
+MAIN_MODULE_INIT(String)
+{
+	MODULE_SUB_INIT(String, STRING_PROTO);
+	MODULE_SUB_INIT(StringGen, NO_PROTO);
 }

Modified: trunk/modules/Tuple/Tuple.c
===================================================================
--- trunk/modules/Tuple/Tuple.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/modules/Tuple/Tuple.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -58,9 +58,9 @@
 #include <stdio.h>
 #include <string.h>
 
-#define TUPLE_PROTO_OBJ  OBJ(TUPLE_PROTO)
+MODULE_START(Tuple);
 
-DEF(TUPLE_PROTO_OBJ, __rin__, FORM_RPARAM) { 
+DEF(Tuple, __rin__, FORM_RPARAM) { 
 	int i, llen = list_len(ist, self);
 	obj_p item, tgt = parms[1];
 	for(i=0; i < llen; i++) {
@@ -72,7 +72,7 @@
 	return OBJ(PR_FALSE);
 }
 
-DEF(TUPLE_PROTO_OBJ, __rnotin__, FORM_RPARAM) { 
+DEF(Tuple, __rnotin__, FORM_RPARAM) { 
 	int i, llen = list_len(ist, self);
 	obj_p item, tgt = parms[1];
 	for(i=0; i < llen; i++) {
@@ -84,7 +84,7 @@
 	return OBJ(PR_TRUE);
 }
 
-DEF(TUPLE_PROTO_OBJ, __add__, FORM_RPARAM) { 
+DEF(Tuple, __add__, FORM_RPARAM) { 
 	int i;
 	obj_p res = clone_list_obj(ist, self);
 	if (has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO)))
@@ -92,11 +92,11 @@
 			list_append(ist, res, list_item(ist, parms[1], i));
 	else
 		list_append(ist, res, parms[1]);
-	switch_proto_to(ist, res, TUPLE_PROTO_OBJ);
+	switch_proto_to(ist, res, Tuple_OBJ);
 	return res;
 }
 
-DEF(TUPLE_PROTO_OBJ, __mul__, FORM_RPARAM){
+DEF(Tuple, __mul__, FORM_RPARAM){
 	obj_p res;
 	list_p lstp, selfp = ((list_p)(self->data.ptr))+LIST_OVERHEAD;
 	int i, size, times, len = list_len(ist, self);
@@ -126,11 +126,11 @@
 	return res;
 }
 
-DEF(TUPLE_PROTO_OBJ, len, NULL) { 
+DEF(Tuple, len, NULL) { 
 	return new_int_obj(list_len(ist, self));
 }
 
-DEF(TUPLE_PROTO_OBJ, min, NULL) { 
+DEF(Tuple, min, NULL) { 
 	int i, llen = list_len(ist, self);
 	obj_p min_item, cmp_obj;
 	if (llen == 0) return OBJ(NONE);
@@ -145,7 +145,7 @@
 	return min_item;
 }
 
-DEF(TUPLE_PROTO_OBJ, max, NULL) { 
+DEF(Tuple, max, NULL) { 
 	int i, llen = list_len(ist, self);
 	obj_p max_item, cmp_obj;
 	if (llen == 0) return OBJ(NONE);
@@ -160,7 +160,7 @@
 	return max_item;
 }
 
-DEF(TUPLE_PROTO_OBJ, count, FORM_RPARAM) { 
+DEF(Tuple, count, FORM_RPARAM) { 
 	int i, cnt=0, llen = list_len(ist, self);
 	for (i=0; i < llen; i++) {
 		if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__), parms[1]) == OBJ(PR_TRUE))
@@ -170,7 +170,7 @@
 	return new_int_obj(cnt);
 }
 
-DEF(TUPLE_PROTO_OBJ, index, FORM_RPARAM) { 
+DEF(Tuple, index, FORM_RPARAM) { 
 	int i, llen = list_len(ist, self);
 	for (i=0; i < llen; i++) {
 		if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__), parms[1]) == OBJ(PR_TRUE))
@@ -181,15 +181,9 @@
 	return NULL;
 }
 
+MODULE_END(Tuple);
 
-install_module(Tuple) {
-	CALL_INIT(TUPLE_PROTO_OBJ, __rin__);
-	CALL_INIT(TUPLE_PROTO_OBJ, __rnotin__);
-	CALL_INIT(TUPLE_PROTO_OBJ, __add__);
-	CALL_INIT(TUPLE_PROTO_OBJ, __mul__);
-	CALL_INIT(TUPLE_PROTO_OBJ, len);
-	CALL_INIT(TUPLE_PROTO_OBJ, min);
-	CALL_INIT(TUPLE_PROTO_OBJ, max);
-	CALL_INIT(TUPLE_PROTO_OBJ, count);
-	CALL_INIT(TUPLE_PROTO_OBJ, index);
+MAIN_MODULE_INIT(Tuple)
+{
+	MODULE_SUB_INIT(Tuple, TUPLE_PROTO);
 }

Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/src/Makefile.in	2004-03-30 04:58:06 UTC (rev 204)
@@ -8,10 +8,14 @@
 include $(top_builddir)/Rules.mk
 
 TARGET=prothon
-OBJS = argproc.o clist.o lock.o memory_mgr.o parser.o prmalloc.o sys.o \
-	builtins.o interp.o main.o object.o parser_routines.o symbol.o \
-	thread.o getline.o console.o
 
+BUILTIN_MOD_OBJS = builtins.o
+
+# NOTE: main.o must come before any builtins, and object.o must come after
+OBJS = main.o $(BUILTIN_MOD_OBJS) object.o argproc.o clist.o lock.o \
+	memory_mgr.o parser.o prmalloc.o sys.o interp.o parser_routines.o \
+	symbol.o thread.o getline.o console.o
+
 all: $(TARGET)
 
 $(TARGET): $(OBJS)

Modified: trunk/src/builtins.c
===================================================================
--- trunk/src/builtins.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/src/builtins.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -58,72 +58,75 @@
 
 #include <apr_strings.h>
 
+#include <prothon/prothon.h>
+#include "parser.h"
 #include "object.h"
-#include "interp.h"
+#include <prothon/prothon_dll.h>
 
-// ***************************** OBJECT_OBJ *********************************
-#define OBJECT_OBJ   OBJ(OBJECT)
+// ***************************** Object *********************************
 
-static isp ist;
+MODULE_START(Object);
 
-DEF(OBJECT_OBJ, __init__, NULL) {
+DEF(Object, __init__, NULL) {
 	return self;
 }
 
-DEF(OBJECT_OBJ, has_proto, FORM_RPARAM) {
-	if (has_proto(ist, self, parms[1])) return OBJ(PR_TRUE);
-	else						        return OBJ(PR_FALSE); 
+DEF(Object, has_proto, FORM_RPARAM) {
+	if (has_proto(ist, self, parms[1]))
+		return OBJ(PR_TRUE);
+	else
+		return OBJ(PR_FALSE); 
 }
 
-DEF(OBJECT_OBJ, set_proto, FORM_RPARAM) {
+DEF(Object, set_proto, FORM_RPARAM) {
 	read_unlock(ist, self);
 	switch_proto_to(ist, self, parms[1]);
 	read_lock(ist, self);
 	return NULL;
 }
 
-DEF(OBJECT_OBJ, add_proto, FORM_RPARAM) {
+DEF(Object, add_proto, FORM_RPARAM) {
 	read_unlock(ist, self);
 	ins_proto(ist, self, parms[1], 1000);
 	read_lock(ist, self);
 	return NULL;
 }
 
-DEF(OBJECT_OBJ, Len, FORM_RPARAM) {
+DEF(Object, Len, FORM_RPARAM) {
 	return call_func0(ist, parms[1], SYM(LEN));
 }
 
-DEF(OBJECT_OBJ, Cmp, FORM_PARAM2) {
+DEF(Object, Cmp, FORM_PARAM2) {
 	return call_func1(ist, parms[1], SYM(CMP), parms[3]);
 }
 
-DEF(OBJECT_OBJ, Max, FORM_RPARAM) {
+DEF(Object, Max, FORM_RPARAM) {
 	return call_func0(ist, parms[1], SYM(MAX));
 }
 
-DEF(OBJECT_OBJ, Min, FORM_RPARAM) {
+DEF(Object, Min, FORM_RPARAM) {
 	return call_func0(ist, parms[1], SYM(MIN));
 }
 
-DEF(OBJECT_OBJ, __getitem__, FORM_RPARAM) {
+DEF(Object, __getitem__, FORM_RPARAM) {
 	raise_exception(ist, OBJ(TYPE_EXC), "indexing not supported on this object");
 	return NULL;
 }
-DEF(OBJECT_OBJ, __setitem__, FORM_PARAM2) {
+DEF(Object, __setitem__, FORM_PARAM2) {
 	raise_exception(ist, OBJ(TYPE_EXC), "indexing not supported on this object");
 	return NULL;
 }
-DEF(OBJECT_OBJ, __delitem__, FORM_RPARAM) {
+DEF(Object, __delitem__, FORM_RPARAM) {
 	raise_exception(ist, OBJ(TYPE_EXC), "indexing not supported on this object");
 	return NULL;
 }
 
-DEF(OBJECT_OBJ, proto_list, NULL) {
+DEF(Object, proto_list, NULL) {
 	return proto_list(ist, self);
 }
 
-DEF(OBJECT_OBJ, __bool__, NULL) { return OBJ(PR_TRUE); }
-DEF(OBJECT_OBJ, __not__, NULL)
+DEF(Object, __bool__, NULL) { return OBJ(PR_TRUE); }
+DEF(Object, __not__, NULL)
 {
 	if (call_func0(ist, self, SYM(__BOOL__)) == OBJ(PR_TRUE))
 		return OBJ(PR_FALSE);
@@ -131,17 +134,17 @@
 		return OBJ(PR_TRUE);
 }
 
-DEF(OBJECT_OBJ, __is__, FORM_RPARAM) { 
+DEF(Object, __is__, FORM_RPARAM) { 
 	if (self == parms[1]) return OBJ(PR_TRUE);
 	else				  return OBJ(PR_FALSE); 
 }
 
-DEF(OBJECT_OBJ, __isnot__, FORM_RPARAM) { 
+DEF(Object, __isnot__, FORM_RPARAM) { 
 	if (self != parms[1]) return OBJ(PR_TRUE);
 	else				  return OBJ(PR_FALSE); 
 }
 
-DEF(OBJECT_OBJ, __str__, NULL) {
+DEF(Object, __str__, NULL) {
 	char str[1024];
 	obj_p doc = get_attr(ist, self, SYM(__DOC__));
 	char* p = strch(doc);
@@ -152,55 +155,59 @@
 	return new_string_obj(str);
 }
 
-DEF(OBJECT_OBJ, __hash__, NULL) {
+DEF(Object, __hash__, NULL) {
 	return new_hash_obj((i32_t)(uintptr_t) self);
 }
 
-DEF(OBJECT_OBJ, __eq__, FORM_RPARAM) {
+DEF(Object, __eq__, FORM_RPARAM) {
 	obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
-	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) == 0)	return OBJ(PR_TRUE);
-	else											        return OBJ(PR_FALSE);
+	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) == 0)
+		return OBJ(PR_TRUE);
+	else
+		return OBJ(PR_FALSE);
 }
 
-DEF(OBJECT_OBJ, __ne__, FORM_RPARAM) {
-	obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
-	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) != 0)	return OBJ(PR_TRUE);
-	else											        return OBJ(PR_FALSE);
+DEF(Object, __ne__, FORM_RPARAM) {
+	obj_p cmp_obj = call_func1(ist, self, SYM(__EQ__), parms[1]); if_exc_return NULL;
+	if (cmp_obj == OBJ(PR_TRUE))
+		return OBJ(PR_FALSE);
+	else
+		return OBJ(PR_TRUE);
 }
 
-DEF(OBJECT_OBJ, __lt__, FORM_RPARAM) {
+DEF(Object, __lt__, FORM_RPARAM) {
 	obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
 	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) < 0)	return OBJ(PR_TRUE);
 	else											        return OBJ(PR_FALSE);
 }
 
-DEF(OBJECT_OBJ, __le__, FORM_RPARAM) {
+DEF(Object, __le__, FORM_RPARAM) {
 	obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
 	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) <= 0)	return OBJ(PR_TRUE);
 	else											        return OBJ(PR_FALSE);
 }
 
-DEF(OBJECT_OBJ, __gt__, FORM_RPARAM) {
+DEF(Object, __gt__, FORM_RPARAM) {
 	obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
 	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) > 0)	return OBJ(PR_TRUE);
 	else											        return OBJ(PR_FALSE);
 }
 
-DEF(OBJECT_OBJ, __ge__, FORM_RPARAM) {
+DEF(Object, __ge__, FORM_RPARAM) {
 	obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
 	if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) >= 0)	return OBJ(PR_TRUE);
 	else											        return OBJ(PR_FALSE);
 }
 
-DEF(OBJECT_OBJ, __in__, FORM_RPARAM) {
+DEF(Object, __in__, FORM_RPARAM) {
 	return call_func1(ist, parms[1], SYM(__RIN__), self);
 }
 
-DEF(OBJECT_OBJ, __notin__, FORM_RPARAM) {
+DEF(Object, __notin__, FORM_RPARAM) {
 	return call_func1(ist, parms[1], SYM(__RNOTIN__), self);
 }
 
-DEF(OBJECT_OBJ, attrs, NULL) { 
+DEF(Object, attrs, NULL) { 
 	int i;
 	size_t alen, asize;
 	attr_p attrp;
@@ -219,33 +226,50 @@
 	return dict_obj;
 }
 
+MODULE_END(Object);
+
 // ***************************** PR_FALSE *****************************************
-#define PR_FALSE_OBJ    OBJ(PR_FALSE)
-DEF(PR_FALSE_OBJ, __str__,  NULL) { return new_string_obj("False"); }
-DEF(PR_FALSE_OBJ, __bool__, NULL) { return OBJ(PR_FALSE); }
-DEF(PR_FALSE_OBJ, cmp, FORM_RPARAM) { 
-	if (parms[1] == OBJ(PR_FALSE)) return new_int_obj(0); 
-	return new_int_obj(-1); 
+
+MODULE_START(False);
+
+DEF(False, __str__,  NULL) { return new_string_obj("False"); }
+DEF(False, __bool__, NULL) { return False_OBJ; }
+DEF(False, cmp, FORM_RPARAM) { 
+	if (parms[1] == False_OBJ)
+		return new_int_obj(0);
+	else
+		return new_int_obj(-1); 
 }
 
+MODULE_END(False);
+
 // ***************************** PR_TRUE *****************************************
-#define PR_TRUE_OBJ    OBJ(PR_TRUE)
-DEF(PR_TRUE_OBJ, __str__,  NULL)  { return new_string_obj("True"); }
-DEF(PR_TRUE_OBJ, __bool__, NULL)  { return OBJ(PR_TRUE); }
-DEF(PR_TRUE_OBJ, cmp, FORM_RPARAM) { 
-	if (parms[1] == OBJ(PR_FALSE)) return new_int_obj(1); 
-	if (parms[1] == OBJ(PR_TRUE))  return new_int_obj(0); 
-	return new_int_obj(-1); 
+
+MODULE_START(True);
+
+DEF(True, __str__,  NULL)  { return new_string_obj("True"); }
+DEF(True, __bool__, NULL)  { return True_OBJ; }
+DEF(True, cmp, FORM_RPARAM) { 
+	if (parms[1] == OBJ(PR_FALSE))
+		return new_int_obj(1); 
+	else if (parms[1] == True_OBJ)
+		return new_int_obj(0); 
+	else
+		return new_int_obj(-1); 
 }
 
+MODULE_END(True);
+
 // ***************************** NONE *****************************************
-#define NONE_OBJ    OBJ(NONE)
-DEF(NONE_OBJ, __str__,  NULL) { return new_string_obj("None"); }
-DEF(NONE_OBJ, __bool__, NULL) { return OBJ(PR_FALSE); }
 
+MODULE_START(None);
+DEF(None, __str__,  NULL) { return new_string_obj("None"); }
+DEF(None, __bool__, NULL) { return OBJ(PR_FALSE); }
+MODULE_END(None);
+
 // ***************************** EXCEPTION ************************************
-#define EXCEPTION_OBJ    OBJ(EXCEPTION)
-DEF(EXCEPTION_OBJ, __init__,  FORM_STAR_PARAM) {
+MODULE_START(Exception);
+DEF(Exception, __init__,  FORM_STAR_PARAM) {
 	obj_p res;
 	if (list_len(ist, parms[1]) > 0)
 		raise_exception(ist, self, "%s", as_str(ist, list_item(ist, parms[1], 0)));
@@ -255,16 +279,19 @@
 	ist->exception_obj = 0;
 	return res;
 }
+MODULE_END(Exception);
 
 // ***************************** GEN ******************************************
-#define GEN_OBJ OBJ(GEN_PROTO)
-DEF(GEN_OBJ, __gen__, NULL) {
+MODULE_START(Gen);
+DEF(Gen, __gen__, NULL) {
 	return self; 
 }
+MODULE_END(Gen);
 
 // ***************************** SEQUENCE *************************************
-#define SEQ_PROTO_OBJ OBJ(SEQ_PROTO)
 
+MODULE_START(Seq);
+
 static int seq_len(isp ist, obj_p seq) {
 	if (has_proto(ist, seq, OBJ(STRING_PROTO)))
 		return (int) strlen(strch(seq));
@@ -423,38 +450,43 @@
 	return res;
 }
 
+MODULE_END(Seq);
+
 // ***************************** INT *******************************************
-#define INT_OBJ		OBJ(INT_PROTO)
+
+MODULE_START(Int);
+MODULE_START(IntGen);
+
 #define	INT_DATA_SIZE		8
-#define is_Int(objid)		(has_proto(ist, objid, INT_OBJ))
+#define is_Int(objid)		(has_proto(ist, objid, Int_OBJ))
 #define Int_value(objid)	(objid->data.i64)
 
-static obj_p INTGEN_OBJ, SYM_LIMIT;	
+static obj_p SYM_LIMIT;	
 
-DEF(INT_OBJ, __bool__, NULL) { 
+DEF(Int, __bool__, NULL) { 
 	if (Int_value(self)) return OBJ(PR_TRUE);
 	else				 return OBJ(PR_FALSE);
 }
 
-DEF(INT_OBJ, __hash__, NULL) { 
+DEF(Int, __hash__, NULL) { 
 	i32_t i32 = (i32_t) Int_value(self);
 	return new_hash_obj((((i32*i32)<<(i32 & 16))+i32)*17);
 }
 
-DEF(INT_OBJ, __abs__, NULL){
+DEF(Int, __abs__, NULL){
 	i64_t num = Int_value(self);
 	return new_int_obj(num < 0 ? -num : num);
 }
 
-DEF(INT_OBJ, __neg__, NULL){
+DEF(Int, __neg__, NULL){
 	return new_int_obj( - Int_value(self) );
 }
 
-DEF(INT_OBJ, __pos__, NULL){
+DEF(Int, __pos__, NULL){
 	return self;
 }
 
-DEF(INT_OBJ, __add__, FORM_RPARAM){
+DEF(Int, __add__, FORM_RPARAM){
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -465,7 +497,7 @@
 	return new_int_obj(Int_value(self) + Int_value(other));
 }
 
-DEF(INT_OBJ, __div__, FORM_RPARAM){
+DEF(Int, __div__, FORM_RPARAM){
 	obj_p res;
 	obj_p float_self, float_other, other = parms[1];
 	if (!is_Int(other)) {
@@ -481,7 +513,7 @@
 	return res;
 }
 
-DEF(INT_OBJ, __floordiv__, FORM_RPARAM){
+DEF(Int, __floordiv__, FORM_RPARAM){
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -496,7 +528,7 @@
 	return new_int_obj(Int_value(self) / Int_value(other));
 }
 
-DEF(INT_OBJ, __mod__, FORM_RPARAM) {
+DEF(Int, __mod__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -511,7 +543,7 @@
 	return new_int_obj(Int_value(self) % Int_value(other));
 }
 
-DEF(INT_OBJ, __mul__, FORM_RPARAM) {
+DEF(Int, __mul__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -522,7 +554,7 @@
 	return new_int_obj(Int_value(self) * Int_value(other));
 }
 
-DEF(INT_OBJ, __sub__, FORM_RPARAM) {
+DEF(Int, __sub__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -533,7 +565,7 @@
 	return new_int_obj(Int_value(self) - Int_value(other));
 }
 
-DEF(INT_OBJ, __pow__, FORM_RPARAM){
+DEF(Int, __pow__, FORM_RPARAM){
 	obj_p res;
 	obj_p float_self, float_other, other = parms[1];
 	float_self  = call_func1(ist, OBJ(FLOAT_PROTO), SYM(__COERCE__), self);  if_exc_return NULL;
@@ -543,7 +575,7 @@
 	return res;
 }
 
-DEF(INT_OBJ, cmp, FORM_RPARAM){
+DEF(Int, cmp, FORM_RPARAM){
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -559,7 +591,7 @@
 		return new_int_obj(-1);
 }
 
-DEF(INT_OBJ, __eq__, FORM_RPARAM){
+DEF(Int, __eq__, FORM_RPARAM){
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		if (covers(other, self))
@@ -569,11 +601,11 @@
 	if (Int_value(self) == Int_value(other)) return OBJ(PR_TRUE);
 	else                                     return OBJ(PR_FALSE);
 }
-DEF(INT_OBJ, __invert__, NULL){
+DEF(Int, __invert__, NULL){
 	return new_int_obj( ~ Int_value(self) );
 }
 
-DEF(INT_OBJ, __xor__, FORM_RPARAM) {
+DEF(Int, __xor__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "object cannot be xor'd with an Integer");
@@ -582,7 +614,7 @@
 	return new_int_obj(Int_value(self) ^ Int_value(other));
 }
 
-DEF(INT_OBJ, __and__, FORM_RPARAM) {
+DEF(Int, __and__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "object cannot be and'd with an Integer");
@@ -591,7 +623,7 @@
 	return new_int_obj(Int_value(self) & Int_value(other));
 }
 
-DEF(INT_OBJ, __or__, FORM_RPARAM) {
+DEF(Int, __or__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "object cannot be or'd with an Integer");
@@ -600,7 +632,7 @@
 	return new_int_obj(Int_value(self) | Int_value(other));
 }
 
-DEF(INT_OBJ, __rshift__, FORM_RPARAM) {
+DEF(Int, __rshift__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "object cannot be shifted with an Integer");
@@ -609,7 +641,7 @@
 	return new_int_obj(Int_value(self) >> Int_value(other));
 }
 
-DEF(INT_OBJ, __lshift__, FORM_RPARAM) {
+DEF(Int, __lshift__, FORM_RPARAM) {
 	obj_p other = parms[1];
 	if (!is_Int(other)) {
 		raise_exception(ist, OBJ(TYPE_EXC), "object cannot be shifted with an Integer");
@@ -618,21 +650,21 @@
 	return new_int_obj(Int_value(self) << Int_value(other));
 }
 
-DEF(INT_OBJ, __str__, NULL){
+DEF(Int, __str__, NULL){
 	char str[24];
 	apr_snprintf(str, sizeof(str), LONG_LONG_FMT, (LONG_LONG_CAST)Int_value(self));
 	return new_string_obj(str);
 }
 
-DEF (INT_OBJ, __gen__, NULL) {
+DEF (Int, __gen__, NULL) {
 	obj_p gen_obj = new_int_obj(0);
 	gen_obj->unmutable = FALSE;
-	gen_obj->attr_proto.proto = INTGEN_OBJ;
+	gen_obj->attr_proto.proto = IntGen_OBJ;
 	set_attr(ist, gen_obj, SYM_LIMIT, self);
 	return gen_obj;
 }
 
-DEF (INTGEN_OBJ, next, NULL) {
+DEF (IntGen, next, NULL) {
 	obj_p limit, res;
 	if ( !(limit=get_attr(ist, self, SYM_LIMIT)) ||
 		  Int_value(self) == Int_value(limit) ) {
@@ -651,80 +683,92 @@
 	return res;
 }
 
-DEF(INT_OBJ, chr, NULL){
+DEF(Int, chr, NULL){
 	char s[1];
 	s[0] = (char) Int_value(self);
 	return new_string_n_obj(s, 1);
 }
 
+MODULE_END(Int);
+MODULE_END(IntGen);
+
 // ***************************** STRING_PROTO *********************************
-#define STRING_OBJ   OBJ(STRING_PROTO)
 
-DEF(STRING_OBJ, __str__, NULL) {
+MODULE_START(String);
+
+DEF(String, __str__, NULL) {
 	return self;
 }
 
-DEF(STRING_OBJ, __hash__, NULL) {
+DEF(String, __hash__, NULL) {
 	i32_t res = 0x9a7c5e3;
 	char *p;
 	for(p=strch(self); *p; p++) res += 131 * (*p);
 	return new_hash_obj(res);
 }
 
-DEF(STRING_OBJ, __objlist__, FORM_RPARAM) {
+DEF(String, __objlist__, FORM_RPARAM) {
 	return parms[1];
 }
 
-DEF(STRING_OBJ, __getitem__, FORM_RPARAM) {
+DEF(String, __getitem__, FORM_RPARAM) {
 	return get_sequence_item(ist, self, parms[1], SEQ_TYPE_STRING);
 }
 
-DEF(STRING_OBJ, __setitem__, FORM_RPARAM) {
+DEF(String, __setitem__, FORM_RPARAM) {
 	raise_exception(ist, OBJ(MUTABLE_EXC), "strings may not be modifed");
 	return NULL;
 }
 
-DEF(STRING_OBJ, __delitem__, NULL) {
+DEF(String, __delitem__, NULL) {
 	raise_exception(ist, OBJ(MUTABLE_EXC), "strings may not be modifed");
 	return NULL;
 }
 
+MODULE_END(String);
 
+
 // ***************************** TUPLE ******************************************
-#define TUPLE_OBJ OBJ(TUPLE_PROTO)
-DEF(TUPLE_OBJ, __str__, NULL) {
+
+MODULE_START(Tuple);
+
+DEF(Tuple, __str__, NULL) {
 	return str_tuple_list(ist, self, "(", ")");
 }
 
-DEF(TUPLE_OBJ, __getitem__, FORM_RPARAM) {
+DEF(Tuple, __getitem__, FORM_RPARAM) {
 	return get_sequence_item(ist, self, parms[1], SEQ_TYPE_TUPLE);
 }
 
-DEF(TUPLE_OBJ, __setitem__, FORM_RPARAM) {
+DEF(Tuple, __setitem__, FORM_RPARAM) {
 	raise_exception(ist, OBJ(MUTABLE_EXC), "tuples may not be modifed");
 	return NULL;
 }
 
-DEF(TUPLE_OBJ, __delitem__, NULL) {
+DEF(Tuple, __delitem__, NULL) {
 	raise_exception(ist, OBJ(MUTABLE_EXC), "tuples may not be modifed");
 	return NULL;
 }
 
-DEF(TUPLE_OBJ, __objlist__, FORM_RPARAM) {
+DEF(Tuple, __objlist__, FORM_RPARAM) {
 	return self;
 }
 
+MODULE_END(Tuple);
+
 // ***************************** LIST ******************************************
-#define LIST_OBJ OBJ(LIST_PROTO)
-DEF(LIST_OBJ, __str__, NULL) {
+
+MODULE_START(List);
+
+DEF(List, __str__, NULL) {
 	return str_tuple_list(ist, self, "[", "]");
 }
 
-DEF(LIST_OBJ, __getitem__, FORM_RPARAM) {
+DEF(List, __getitem__, FORM_RPARAM) {
 	return get_sequence_item(ist, self, parms[1], SEQ_TYPE_LIST);
 }
 
-DEF(LIST_OBJ, __setitem__, FORM_PARAM2) {
+DEF(List, __setitem__, FORM_PARAM2) {
 	obj_p slice_item1, slice_item2, slice_item3;
 	obj_p slice = parms[1], value = parms[3];
 	int i, j, new_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
@@ -753,7 +797,7 @@
 			return NULL;
 		}
 	}
-	if ( !has_proto(ist, value, OBJ(LIST_PROTO)) && 
+	if ( !has_proto(ist, value, List_OBJ) && 
 		 !has_proto(ist, value, OBJ(TUPLE_PROTO)) &&
 		 !has_proto(ist, value, OBJ(STRING_PROTO)) ) {
 		raise_exception(ist, OBJ(TYPE_EXC), "list slices may only be replaced with a sequence");
@@ -834,7 +878,7 @@
 	return NULL;
 }
 
-DEF(LIST_OBJ, __delitem__, FORM_RPARAM) {
+DEF(List, __delitem__, FORM_RPARAM) {
 	obj_p slice_item1, slice_item2, slice_item3;
 	obj_p slice = parms[1];
 	int i, j, new_len, index1 = 0, index2 = 0, index3 = 0, slice1_empty=FALSE, slice2_empty=FALSE;
@@ -936,10 +980,13 @@
 	return NULL;
 }
 
+MODULE_END(List);
 
 // ***************************** DICT ******************************************
-#define DICT_OBJ OBJ(DICT_PROTO)
-DEF(DICT_OBJ, __str__, NULL) {
+
+MODULE_START(Dict);
+
+DEF(Dict, __str__, NULL) {
 	int i;
 	size_t len = dict_len(ist, self);
 	char* res = pr_malloc(3); 
@@ -962,7 +1009,7 @@
 	return res_obj;
 }
 
-DEF(DICT_OBJ, __objlist__, FORM_RPARAM) {
+DEF(Dict, __objlist__, FORM_RPARAM) {
 	size_t i, size, len;
 	dict_p dict, dp;
 	dict = dict_d(self);
@@ -976,7 +1023,7 @@
 	return parms[1];
 }
 
-DEF(DICT_OBJ, __getitem__, FORM_RPARAM) {
+DEF(Dict, __getitem__, FORM_RPARAM) {
 	obj_p res;
 	if (list_len(ist, parms[1]) > 1) {
 		raise_exception(ist, OBJ(INTERPRETER_EXC), "slice not allowed in dictionary indexing");	
@@ -990,7 +1037,7 @@
 	return res;
 }
 
-DEF(DICT_OBJ, __setitem__, FORM_PARAM2) {
+DEF(Dict, __setitem__, FORM_PARAM2) {
 	if (list_len(ist, parms[1]) > 1) {
 		raise_exception(ist, OBJ(INTERPRETER_EXC), "slice not allowed in dictionary indexing");	
 		return NULL;
@@ -1001,7 +1048,7 @@
 	return NULL;
 }
 
-DEF(DICT_OBJ, __delitem__, FORM_RPARAM) {
+DEF(Dict, __delitem__, FORM_RPARAM) {
 	i32_t i, hash_in;
 	obj_p key, key_in, rp[2];
 	dict_p dict, dp;
@@ -1034,112 +1081,36 @@
 	return NULL;
 }
 
+MODULE_END(Dict);
+
 // ***************************** FUNC ******************************************
-#define FUNC_OBJ OBJ(FUNC_PROTO)
 
-DEF(FUNC_OBJ, __objlist__, FORM_RPARAM) {
+MODULE_START(Func);
+DEF(Func, __objlist__, FORM_RPARAM) {
 	return parms[1];
 }
+MODULE_END(Func);
 
 // ***************************** INIT_BUILTINS ********************************
-void init_builtins() {
-	ist  = get_ist();
 
-	CALL_INIT(OBJECT_OBJ, __init__);
-	CALL_INIT(OBJECT_OBJ, __getitem__);
-	CALL_INIT(OBJECT_OBJ, __setitem__);
-	CALL_INIT(OBJECT_OBJ, __delitem__);
-	CALL_INIT(OBJECT_OBJ, has_proto);
-	CALL_INIT(OBJECT_OBJ, set_proto);
-	CALL_INIT(OBJECT_OBJ, add_proto);
-	CALL_INIT(OBJECT_OBJ, Len);
-	CALL_INIT(OBJECT_OBJ, Cmp);
-	CALL_INIT(OBJECT_OBJ, Min);
-	CALL_INIT(OBJECT_OBJ, Max);
-	CALL_INIT(OBJECT_OBJ, proto_list);
-	CALL_INIT(OBJECT_OBJ, __bool__);
-	CALL_INIT(OBJECT_OBJ, __not__);
-	CALL_INIT(OBJECT_OBJ, __is__);
-	CALL_INIT(OBJECT_OBJ, __isnot__);
-	CALL_INIT(OBJECT_OBJ, __str__);
-	CALL_INIT(OBJECT_OBJ, __hash__);
-	CALL_INIT(OBJECT_OBJ, __eq__);
-	CALL_INIT(OBJECT_OBJ, __ne__);
-	CALL_INIT(OBJECT_OBJ, __lt__);
-	CALL_INIT(OBJECT_OBJ, __le__);
-	CALL_INIT(OBJECT_OBJ, __gt__);
-	CALL_INIT(OBJECT_OBJ, __ge__);
-	CALL_INIT(OBJECT_OBJ, __in__);
-	CALL_INIT(OBJECT_OBJ, __notin__);
+MAIN_MODULE_INIT(Builtins)
+{
+	MODULE_SUB_INIT(Object, OBJECT);
+	MODULE_SUB_INIT(False, PR_FALSE);
+	MODULE_SUB_INIT(True, PR_TRUE);
+	MODULE_SUB_INIT(None, NONE);
+	MODULE_SUB_INIT(Exception, EXCEPTION);
+	MODULE_SUB_INIT(Gen, GEN_PROTO);
+	MODULE_SUB_INIT(String, STRING_PROTO);
+	MODULE_SUB_INIT(Tuple, TUPLE_PROTO);
+	MODULE_SUB_INIT(List, LIST_PROTO);
+	MODULE_SUB_INIT(Dict, DICT_PROTO);
+	MODULE_SUB_INIT(Seq, SEQ_PROTO);
+	MODULE_SUB_INIT(Func, FUNC_PROTO);
 	CALL_INIT(OBJECT_OBJ, attrs);
 
-	CALL_INIT(PR_FALSE_OBJ, __str__);
-	CALL_INIT(PR_FALSE_OBJ, __bool__);
-	CALL_INIT(PR_FALSE_OBJ, cmp);
-
-	CALL_INIT(PR_TRUE_OBJ, __str__);
-	CALL_INIT(PR_TRUE_OBJ, __bool__);
-	CALL_INIT(PR_TRUE_OBJ, cmp);
-
-	CALL_INIT(NONE_OBJ, __str__);
-	CALL_INIT(NONE_OBJ, __bool__);
-
-	CALL_INIT(EXCEPTION_OBJ, __init__);
-	
-	CALL_INIT(GEN_OBJ, __gen__);
-
-	CALL_INIT(STRING_OBJ, __str__);
-	CALL_INIT(STRING_OBJ, __hash__);
-	CALL_INIT(STRING_OBJ, __objlist__);
-	CALL_INIT(STRING_OBJ, __getitem__);
-	CALL_INIT(STRING_OBJ, __setitem__);
-	CALL_INIT(STRING_OBJ, __delitem__);
-
-	CALL_INIT(TUPLE_OBJ, __str__);
-	CALL_INIT(TUPLE_OBJ, __objlist__);
-	CALL_INIT(TUPLE_OBJ, __getitem__);
-	CALL_INIT(TUPLE_OBJ, __setitem__);
-	CALL_INIT(TUPLE_OBJ, __delitem__);
-
-	CALL_INIT(LIST_OBJ, __str__);
-	CALL_INIT(LIST_OBJ, __getitem__);
-	CALL_INIT(LIST_OBJ, __setitem__);
-	CALL_INIT(LIST_OBJ, __delitem__);
-
-	CALL_INIT(DICT_OBJ, __str__);
-	CALL_INIT(DICT_OBJ, __getitem__);
-	CALL_INIT(DICT_OBJ, __setitem__);
-	CALL_INIT(DICT_OBJ, __delitem__);
-	CALL_INIT(DICT_OBJ, __objlist__);
-
-	CALL_INIT(FUNC_OBJ, __objlist__);
-
-	INTGEN_OBJ = new_object(NULL);
 	SYM_LIMIT = sym(ist, "limit");
 
-	CALL_INIT(INT_OBJ, __str__);
-	CALL_INIT(INT_OBJ, __bool__);
-	CALL_INIT(INT_OBJ, __hash__);
-	CALL_INIT(INT_OBJ, cmp);
-	CALL_INIT(INT_OBJ, __eq__);
-	CALL_INIT(INT_OBJ, __abs__);
-	CALL_INIT(INT_OBJ, __neg__);
-	CALL_INIT(INT_OBJ, __pos__);
-	CALL_INIT(INT_OBJ, __add__);
-	CALL_INIT(INT_OBJ, __sub__);
-	CALL_INIT(INT_OBJ, __mul__);
-	CALL_INIT(INT_OBJ, __div__);
-	CALL_INIT(INT_OBJ, __floordiv__);
-	CALL_INIT(INT_OBJ, __mod__);
-	CALL_INIT(INT_OBJ, __pow__);
-	CALL_INIT(INT_OBJ, __invert__);
-	CALL_INIT(INT_OBJ, __xor__);
-	CALL_INIT(INT_OBJ, __and__);
-	CALL_INIT(INT_OBJ, __or__);
-	CALL_INIT(INT_OBJ, __lshift__);
-	CALL_INIT(INT_OBJ, __rshift__);
-	CALL_INIT(INT_OBJ, chr);
-	CALL_INIT(INT_OBJ, __gen__);
-
-	CALL_INIT(INTGEN_OBJ, next);
+	MODULE_SUB_INIT(Int, INT_PROTO);
+	MODULE_SUB_INIT(IntGen, NO_PROTO);
 }

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/src/main.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -59,6 +59,7 @@
 #include <stdlib.h>
 
 #include "object.h"
+#include <prothon/prothon_dll.h>
 #include "memory_mgr.h"
 #include "parser.h"
 #include "interp.h"
@@ -72,6 +73,8 @@
 
 extern int yydebug;
 
+PR_PLACE_IN_SECTION(dll_initcall_t,start_dll_entry_ptr, "._module_init") = 0;
+
 static apr_pool_t *apr_root_pool = NULL;
 
 //**************************** get_pr_head_pool *******************************

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/src/object.c	2004-03-30 04:58:06 UTC (rev 204)
@@ -76,6 +76,9 @@
 }
 #endif
 
+PR_PLACE_IN_SECTION(static dll_initcall_t,end_dll_entry_ptr, "._module_init") = 0;
+extern dll_initcall_t start_dll_entry_ptr;
+
 obj_p            obj_list_root;
 DECLARE_PR_LOCK(object_list_lock);
 pr_services_t dll_services;
@@ -112,6 +115,7 @@
 void object_store_init(isp ist, int nop2){
 	apr_status_t aprerr;
 	char buf[1024];
+	dll_initcall_t *dll_initcalls = &start_dll_entry_ptr;
 
 	if ((aprerr = apr_thread_cond_create(&obj_wrlock_cond, get_pr_head_pool())) ||
 	    (aprerr = apr_thread_cond_create(&write_cond, get_pr_head_pool()))) {
@@ -287,7 +291,12 @@
 	set_attr(ist, OBJ(OBJECT),	sym(ist, "List"),		 OBJ(LIST_PROTO));
 	set_attr(ist, OBJ(OBJECT),	sym(ist, "Dict"),		 OBJ(DICT_PROTO));
 
-	init_builtins();
+	/* Load all of our builtin dll's */
+	dll_initcalls++;
+	while (*dll_initcalls) {
+		(*dll_initcalls)(&dll_services);
+		dll_initcalls++;
+	}
 }
 
 //********************************* new_object ********************************

Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h	2004-03-30 04:53:09 UTC (rev 203)
+++ trunk/src/object.h	2004-03-30 04:58:06 UTC (rev 204)
@@ -113,7 +113,6 @@
 #define dictitem(dict,i)	(dictptr(dict,i)->entry.value)
 
 void init_symbol(isp ist);
-void init_builtins();
 
 extern pr_services_t dll_services;
 
@@ -175,6 +174,8 @@
 obj_p arginit(isp its, int argc, char* argv[]);
 void sysinit(isp ist, char* prog_path, obj_p argv_obj);
 
+isp get_ist(void);
+
 obj_p load_sys_module(isp ist, char* prog_path, obj_p argv_obj);
 #define get_sys_path_list()  \
 	get_attr(ist, get_attr(ist, OBJ(MODULES), sym(ist, "Sys")), sym(ist, "path"))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.