logo       
Google Custom Search
    AddThis Social Bookmark Button

rev 372 - in trunk: include/prothon modules/File modules/OS modules/Prosist: msg#00128

Subject: rev 372 - in trunk: include/prothon modules/File modules/OS modules/Prosist modules/SQLite src
Author: mark
Date: 2004-04-16 22:48:57 -0400 (Fri, 16 Apr 2004)
New Revision: 372

Modified:
   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/SQLite/SQLite.c
   trunk/src/builtins-core.c
   trunk/src/builtins-float.c
   trunk/src/builtins-int.c
   trunk/src/interp.c
   trunk/src/object.c
   trunk/src/symbol.c
   trunk/src/sys.c
Log:
changed doc_obj (add_doc_to_obj) to set_obj_doc,
added set_obj_id which adds an identity name to an
object for identification of objects across runs
of interpreter and different interpreters

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h     2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/include/prothon/prothon.h     2004-04-17 02:48:57 UTC (rev 372)
@@ -247,7 +247,7 @@
 // these are created at object system initialization
 typedef enum {
        NO_PROTO=-1,
-// "singleton" objects
+// "identity" objects
        PR_FALSE,                       // 0 False
        PR_TRUE,                        // 1 True
        OBJECT,                         // 2 Object
@@ -376,7 +376,7 @@
        __GETCMP__,
        __CMPVALOBJ__,
        __ITER__,
-       __NAME__,
+       __ID__,
        __DOC__,
        __HASH__,
        __FPARAMS__,
@@ -681,22 +681,19 @@
 // HASH_VALUE: Integer value of a hash object returned by __hash__ function.
 #define hash_value(hash_obj)  (hash_obj->data.i32[0])
 
-// NAME_OBJ: Add name string (__name__) to object
-// this is used by Prosist, the persistence engine and other documentation,
-// such as the exception stack function names.  This function is somewhat
-// of a replacement for Prothon's lack of class names also.  All Prototypes
-// should be named with this.
-// WARNING:  There should not be more than one object with the same name in 
-// one namespace. Names are meant for singleton objects like prototypes and
-// functions.  You will get an exception if you try certain operations on 
-// objects that have identical names.
-#define name_obj(ist, obj, name) \
-       set_attr(ist, (obj), SYM(__NAME__), new_string_obj(ist, (name)));
+// SET_OBJ_ID: Mark an object as a identity object with a name
+// This is used by Prosist, the persistence engine and other documentation.
+// Any object that has a unique identity across runs of the interpreter
+// and different interpreters should be marked with this flag.
+// Not two objects in the same namespace should have this same name.
+// All Prototypes should be marked with this.
+#define set_obj_id(ist, obj, name) \
+       set_attr(ist, (obj), SYM(__ID__), new_string_obj(ist, (name)));
 
-// DOC_OBJ: Add document string (__doc__) to object
+// SET_OBJ_DOC: Add document string (__doc__) to object
 // This can be used on any object.  It is recommended that it be used
 // liberally to make browsing objects easier and to make dumps readable.
-void doc_obj(isp ist, obj_p obj, char* str);
+void set_obj_doc(isp ist, obj_p obj, char* str);
 
 #ifndef NO_APR
 // NEW_THREAD_OBJ: Create a new thread object and start the thread

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/include/prothon/prothon_dll.h 2004-04-17 02:48:57 UTC (rev 372)
@@ -97,7 +97,7 @@
        obj_p           (*call_func1_f)(isp ist, obj_p self, obj_p sym, obj_p 
parm);
        obj_p           (*sym)(isp ist, char* symbol);
        obj_p           (*new_object)(isp ist, obj_p proto);
-       void            (*doc_obj)(isp ist, obj_p obj, char* str);
+       void            (*set_obj_doc)(isp ist, obj_p obj, char* str);
        obj_p       (*dict_keys_values)(isp ist, obj_p dict_obj, int key_flg);
        obj_p           (*check_exceptions)(isp ist);
 
@@ -197,7 +197,7 @@
 
 
 #define MODULE_SET_DOC(name, docstr)                                   \
-       doc_obj(ist, name##_OBJ, #name ": " docstr);    \
+       set_obj_doc(ist, name##_OBJ, #name ": " docstr);        \
        check_exceptions(ist);
 
 #ifndef OBJECT_H
@@ -234,7 +234,7 @@
 #define list8                          (*services->list8)
 #define raise_exception                (*services->raise_exception)
 #define new_object                     (*services->new_object)
-#define doc_obj                (*services->doc_obj)
+#define set_obj_doc            (*services->set_obj_doc)
 #define pr_malloc                      (*services->pr_malloc)
 #define pr_realloc                     (*services->pr_realloc)
 #define pr_free                                (*services->pr_free)

Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c   2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/modules/File/File.c   2004-04-17 02:48:57 UTC (rev 372)
@@ -121,7 +121,7 @@
 MODULE_START(File)
 {
        File_OBJ = new_object(ist, NULL);
-       doc_obj(ist, File_OBJ, "File object prototype");
+       set_obj_doc(ist, File_OBJ, "File object prototype");
        MODULE_ADD_TO_BASE(File);
        File_OBJ->unclonable = TRUE;
 }

Modified: trunk/modules/OS/OS.c
===================================================================
--- trunk/modules/OS/OS.c       2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/modules/OS/OS.c       2004-04-17 02:48:57 UTC (rev 372)
@@ -70,7 +70,7 @@
        if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
                ist->exception_obj = new_object(ist, OBJ(TYPE_EXC));
                ist->exception_obj->wr_access = ACC_GUEST;
-               doc_obj(ist, ist->exception_obj, "object is not of type 
string");
+               set_obj_doc(ist, ist->exception_obj, "object is not of type 
string");
                return NULL;                                                    
                        
        }
        return new_int_obj(ist, system(strch(parms[1])));

Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c     2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/modules/Prosist/Prosist.c     2004-04-17 02:48:57 UTC (rev 372)
@@ -167,7 +167,7 @@
 
        read_unlock(ist, self);
        set_obj_rdacc(self, ACC_USER1);
-       doc_obj(ist, self, "Prosist DataBase");
+       set_obj_doc(ist, self, "Prosist DataBase");
        set_attr(ist, self, sym(ist, "filename"), parms[1]);
        set_attr(ist, self, sym(ist, "root"), root_obj);
        read_lock(ist, self);

Modified: trunk/modules/SQLite/SQLite.c
===================================================================
--- trunk/modules/SQLite/SQLite.c       2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/modules/SQLite/SQLite.c       2004-04-17 02:48:57 UTC (rev 372)
@@ -107,7 +107,7 @@
        CHECK_TYPE_EXC(parms[1], OBJ(STRING_PROTO), "string");
        filename = strch(parms[1]);
        conn_obj = new_object(ist, Connection_OBJ);
-       doc_obj(ist, conn_obj, "SQLite connection");
+       set_obj_doc(ist, conn_obj, "SQLite connection");
        conn_obj->unclonable = TRUE;
        set_obj_rdacc(conn_obj, ACC_USER1);
        conn_obj->data_type = DATA_TYPE_DATAPTR;
@@ -123,7 +123,7 @@
        if (self->data.ptr) {
                cursor_p cursorp;
                obj_p curs_obj = new_object(ist, Cursor_OBJ);
-               doc_obj(ist, curs_obj, "SQLite cursor");
+               set_obj_doc(ist, curs_obj, "SQLite cursor");
                curs_obj->data_type = DATA_TYPE_DATAPTR;
                cursorp = curs_obj->data.ptr  = pr_malloc(sizeof(cursor_t));
                cursorp->ist      = ist;

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c   2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/builtins-core.c   2004-04-17 02:48:57 UTC (rev 372)
@@ -80,12 +80,12 @@
        Object_OBJ = OBJ(OBJECT);
        MODULE_SET_DOC(Object,  "prototype base for all objects");
 
-       doc_obj(ist, OBJ(SYMBOL_PROTO),  "Symbol object prototype");
-       doc_obj(ist, OBJ(HASH_PROTO),    "Hash object prototype");
-       doc_obj(ist, OBJ(SLICE_PROTO),   "Slice object prototype");
-       doc_obj(ist, OBJ(SUPER_PROTO),   "Super object prototype");
-       doc_obj(ist, OBJ(ROOT_GLOBALS),  "Root_Globals: recursive container of 
all objects");
-       doc_obj(ist, OBJ(MODULES),       "Modules: container of all modules");
+       set_obj_doc(ist, OBJ(SYMBOL_PROTO),  "Symbol object prototype");
+       set_obj_doc(ist, OBJ(HASH_PROTO),    "Hash object prototype");
+       set_obj_doc(ist, OBJ(SLICE_PROTO),   "Slice object prototype");
+       set_obj_doc(ist, OBJ(SUPER_PROTO),   "Super object prototype");
+       set_obj_doc(ist, OBJ(ROOT_GLOBALS),  "Root_Globals: recursive container 
of all objects");
+       set_obj_doc(ist, OBJ(MODULES),       "Modules: container of all 
modules");
 
        set_attr(ist, OBJ(OBJECT), sym(ist, "Root_Globals"),    
OBJ(ROOT_GLOBALS));
        set_attr(ist, OBJ(OBJECT), sym(ist, "Modules"),         OBJ(MODULES));
@@ -339,7 +339,7 @@
 DEF(Object, __creator__, NULL) {
        obj_p name;
        char buf[512];
-       if (name = get_attr(ist, self, SYM(__NAME__))) {
+       if (name = get_attr(ist, self, SYM(__ID__))) {
                apr_snprintf(buf, sizeof(buf), "1:%s", strch(name));
                del_unlock(name);
                return list3(ist, OBJ(NONE), new_string_obj(ist, "Object"), 
new_string_obj(ist, buf));
@@ -361,9 +361,9 @@
 MODULE_START(False)
 {
        False_OBJ = OBJ(PR_FALSE);
-       MODULE_SET_DOC(False, "boolean false singleton value");
+       MODULE_SET_DOC(False, "boolean false identity value");
        set_attr(ist, OBJ(OBJECT), sym(ist, "False"), False_OBJ);
-       name_obj(ist, False_OBJ, "False");
+       set_obj_id(ist, False_OBJ, "False");
 }
 
 DEF(False, __str__,  NULL) { return new_string_obj(ist, "False"); }
@@ -380,9 +380,9 @@
 MODULE_START(True)
 {
        True_OBJ = OBJ(PR_TRUE);
-       MODULE_SET_DOC(True, "boolean true singleton value");
+       MODULE_SET_DOC(True, "boolean true identity value");
        set_attr(ist, OBJ(OBJECT), sym(ist, "True"), True_OBJ);
-       name_obj(ist, True_OBJ, "True");
+       set_obj_id(ist, True_OBJ, "True");
 }
 
 DEF(True, __str__,  NULL)  { return new_string_obj(ist, "True"); }
@@ -406,7 +406,7 @@
        None_OBJ = OBJ(NONE);
        MODULE_SET_DOC(None, "represents empty set");
        set_attr(ist, OBJ(OBJECT), sym(ist, "None"), None_OBJ);
-       name_obj(ist, None_OBJ, "None");
+       set_obj_id(ist, None_OBJ, "None");
 }
 
 DEF(None, __str__,  NULL) {                            
@@ -431,8 +431,8 @@
 
 #define EXCEPTION_DECLARE(proto, exc_const, name, desc_str)                    
                                \
        OBJ(exc_const) = new_object(ist, proto);                                
                                                \
-       doc_obj( ist, OBJ(exc_const), desc_str);                                
                                                \
-       name_obj(ist, OBJ(exc_const), #name);                                   
                                                \
+       set_obj_doc( ist, OBJ(exc_const), desc_str);                            
                                                \
+       set_obj_id(ist, OBJ(exc_const), #name);                                 
                                                \
        set_attr(ist, OBJ(OBJECT), sym(ist, #name), OBJ(exc_const))
 
 /* Other exception objects dependent on this one */
@@ -458,7 +458,7 @@
        char buf[512];
        if (list_len(ist, parms[1]) > 0) {
                apr_snprintf(buf, sizeof(buf), "%s", as_str(ist, list_item(ist, 
parms[1], 0)));
-               doc_obj(ist, self, buf);
+               set_obj_doc(ist, self, buf);
        }
        return OBJ(NONE);
 }

Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c  2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/builtins-float.c  2004-04-17 02:48:57 UTC (rev 372)
@@ -91,8 +91,8 @@
 //     Imag_OBJ  = OBJ(IMAG_PROTO)  = new_object(ist, NULL);
                 OBJ(IMAG_PROTO)  = new_object(ist, NULL);
 
-       doc_obj(ist, OBJ(FLOAT_PROTO),   "Float number object prototype");
-       doc_obj(ist, OBJ(IMAG_PROTO),    "Imaginary number object prototype");
+       set_obj_doc(ist, OBJ(FLOAT_PROTO),   "Float number object prototype");
+       set_obj_doc(ist, OBJ(IMAG_PROTO),    "Imaginary number object 
prototype");
 
        set_attr(ist, OBJ(OBJECT), sym(ist, "Float"),     OBJ(FLOAT_PROTO));
        set_attr(ist, OBJ(OBJECT), sym(ist, "Imaginary"), OBJ(IMAG_PROTO));

Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c    2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/builtins-int.c    2004-04-17 02:48:57 UTC (rev 372)
@@ -98,7 +98,7 @@
        OBJ(MAX_INT)            = new_int_obj(ist, MAX_INT_VAL);
        OBJ(LONG_PROTO)         = new_string_obj(ist, "0");
        clr_immutable(OBJ(LONG_PROTO));
-       doc_obj(ist, OBJ(LONG_PROTO),   "Long integer number object prototype");
+       set_obj_doc(ist, OBJ(LONG_PROTO),       "Long integer number object 
prototype");
        set_immutable(OBJ(LONG_PROTO));
 
        Int_OBJ->data_type    = DATA_TYPE_IMMDATA;

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c  2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/interp.c  2004-04-17 02:48:57 UTC (rev 372)
@@ -1502,7 +1502,7 @@
        }
 #endif
        apr_snprintf(full_doc, sizeof(full_doc), "%s%s", name, comment);
-       doc_obj(ist, module, full_doc);
+       set_obj_doc(ist, module, full_doc);
        frame = ist->frame;
        new_locals = new_object(ist, NULL);
        set_attr(ist, module, SYM(__LOCALS__), new_locals);

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c  2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/object.c  2004-04-17 02:48:57 UTC (rev 372)
@@ -154,7 +154,7 @@
        dll_services.list6                        = list6;              
        dll_services.raise_exception  = raise_exception;
        dll_services.new_object       = new_object;
-       dll_services.doc_obj   = doc_obj;
+       dll_services.set_obj_doc   = set_obj_doc;
        dll_services.obj_malloc           = obj_malloc;
        dll_services.obj_realloc      = obj_realloc;
        dll_services.obj_free             = obj_free;
@@ -209,7 +209,7 @@
 
        init_symbol(ist);
 
-       doc_obj(ist, OBJ(SYMBOLS), "Symbols: list of all symbol objects");
+       set_obj_doc(ist, OBJ(SYMBOLS), "Symbols: list of all symbol objects");
 
        /* Now load the actual modules for the builtin prototypes */
        BUILTIN_LOAD(Core);
@@ -339,7 +339,7 @@
                p = err_buf + strlen(err_buf) - 1;
                while (*p == '.' || *p == ' ' || *p == '\t') { *p = 0; p--; }
 
-               doc_obj(ist, ist->exception_obj, err_buf);
+               set_obj_doc(ist, ist->exception_obj, err_buf);
        }
 }
 
@@ -836,8 +836,8 @@
 }
 
 
-//********************************* doc_obj ***********************************
-void doc_obj(isp ist, obj_p obj, char* str){
+//********************************* set_obj_doc 
***********************************
+void set_obj_doc(isp ist, obj_p obj, char* str){
        if (str[strlen(str)-1] == '\n') {
                char* ns = pr_malloc(strlen(str)+1);
                strcpy(ns, str);

Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c  2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/symbol.c  2004-04-17 02:48:57 UTC (rev 372)
@@ -120,7 +120,7 @@
        { "__getCmp__",         0 }, 
        { "__cmpvalobj__",      0 }, 
        { "__iter__",           0 }, 
-       { "__name__",       0 },
+       { "__id__",       0 },
        { "__doc__",            0 }, 
        { "__hash__",           0 },
        { "__fparams__",        0 },

Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c     2004-04-17 02:29:24 UTC (rev 371)
+++ trunk/src/sys.c     2004-04-17 02:48:57 UTC (rev 372)
@@ -147,7 +147,7 @@
        sys_module = new_object(ist, OBJ(OBJECT));
        set_attr(ist, OBJ(MODULES),sym(ist, "Sys"), sys_module);
        set_attr(ist, OBJ(OBJECT), sym(ist, "Sys"), sys_module);
-       doc_obj(ist, sys_module, "Sys: a built-in module of system attributes");
+       set_obj_doc(ist, sys_module, "Sys: a built-in module of system 
attributes");
        add_path(ist, sys_path, "."); if_exc_return NULL;
 #ifdef PROTHON_DEFAULT_MODDIR
        add_path(ist, sys_path, PROTHON_DEFAULT_MODDIR); if_exc_return NULL;
@@ -162,7 +162,7 @@
                        if (!*s++) break;
                }       
        }
-       doc_obj(ist, sys_path, "path: list of paths to search for modules");
+       set_obj_doc(ist, sys_path, "path: list of paths to search for modules");
        set_attr(ist, sys_module, sym(ist, "path"), sys_path);
        if ((s = getenv("PROTHONHOME"))) {
                for (d=path; *s && *s!=';'; s++, d++) *d = *s;





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>