logo       
Google Custom Search
    AddThis Social Bookmark Button

rev 350 - trunk/src: msg#00106

Subject: rev 350 - trunk/src
Author: mark
Date: 2004-04-14 12:58:43 -0400 (Wed, 14 Apr 2004)
New Revision: 350

Modified:
   trunk/src/builtins-float.c
   trunk/src/builtins-int.c
   trunk/src/builtins-list.c
   trunk/src/builtins-string.c
   trunk/src/builtins-tuple.c
   trunk/src/interp.c
   trunk/src/object.c
Log:
moved type functions into their builtins-xxx.c files

Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c  2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/builtins-float.c  2004-04-14 16:58:43 UTC (rev 350)
@@ -71,6 +71,17 @@
 #define is_Float(objid)                (has_proto_QUES(ist, objid, Float_OBJ))
 #define Float_value(objid)     (objid->data.f64)
 
+//********************************* new_float_obj *****************************
+obj_p new_float_obj(isp ist, double num){
+       obj_p obj = new_object(ist, OBJ(FLOAT_PROTO));
+       obj->data_type = DATA_TYPE_IMMDATA;
+       obj->imm_data_len = 8;
+       obj->data.f64 = num;
+       obj->immutable = TRUE;
+       return obj;
+}
+
+
 MODULE_DECLARE(Float);
 
 

Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c    2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/builtins-int.c    2004-04-14 16:58:43 UTC (rev 350)
@@ -64,6 +64,16 @@
 #include "object.h"
 #include <prothon/prothon_dll.h>
 
+//********************************* new_int_obj *******************************
+obj_p new_int_obj(isp ist, i64_t num){
+       obj_p obj = new_object(ist, OBJ(INT_PROTO));
+       obj->data_type = DATA_TYPE_IMMDATA;
+       obj->imm_data_len = 8;
+       obj->data.i64 = num;
+       obj->immutable = TRUE;
+       return obj;
+}
+
 MODULE_DECLARE(Int);
 MODULE_DECLARE(IntGen);
 

Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c   2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/builtins-list.c   2004-04-14 16:58:43 UTC (rev 350)
@@ -82,6 +82,139 @@
                return list_item(ist, seq, i);
 }
 
+//********************************* new_list_obj ******************************
+obj_p new_list_obj(isp ist, size_t initial_size){
+       obj_p list_obj = new_object(ist, OBJ(LIST_PROTO));
+       list_p lstp = list_obj->data.ptr = 
+                     pr_malloc(list_sizeof(max(initial_size,2)));
+       list_obj->data_type = DATA_TYPE_DATAPTR;
+       lstpsize(lstp) = max(initial_size,2);
+       lstplen(lstp)  = 0;
+       return list_obj;
+}
+
+//********************************* clone_list_obj ****************************
+obj_p clone_list_obj(isp ist, obj_p list_obj) {
+       obj_p res;
+       size_t llen, size;
+       list_p list_ptr;
+       rdlock_rtrn(list_obj) NULL;
+       llen = listlen(list_obj);
+       size = list_sizeof(llen);
+       res = copy_object(ist, list_obj);
+       res->data.ptr = list_ptr = pr_malloc(size);
+       lstpsize(list_ptr) = llen;
+       lstplen(list_ptr)  = llen;
+       memcpy( list_ptr->item, ((list_p)(list_obj->data.ptr))->item, 
+                                                 size-sizeof(list_hdr_t) );
+       read_unlock(ist, list_obj);
+       return res;
+}
+
+//********************************* list_len **********************************
+size_t list_len(isp ist, obj_p list_obj){
+       size_t len;
+       rdlock_rtrn(list_obj) 0;
+       len = listlen(list_obj);
+       read_unlock(ist, list_obj);
+       return len;
+}
+
+//********************************* list_clear 
**********************************
+void list_clear(isp ist, obj_p list_obj) {
+       wrlock_rtrn(list_obj);
+       listlen(list_obj) = 0;
+       write_unlock(ist, list_obj);
+}
+
+//********************************* list_item *********************************
+obj_p list_item(isp ist, obj_p list_obj, int i){
+       obj_p res;
+       rdlock_rtrn(list_obj) NULL;
+       res = listitem(list_obj, i);
+       read_unlock(ist, list_obj);
+       return res;
+}
+
+//********************************* list_append *******************************
+obj_p list_append(isp ist, obj_p list_obj, obj_p item){
+       list_p lstp;
+       wrlock_rtrn(list_obj) NULL;
+       lstp = list_obj->data.ptr;
+       if(lstplen(lstp) == lstpsize(lstp)) {
+               lstpsize(lstp) *= LIST_GROWTH_FACTOR;
+               lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
+               list_obj->data.ptr = lstp;
+       }
+       listitem(list_obj, listlen(list_obj)++) = item;
+       write_unlock(ist, list_obj);
+       return list_obj;
+}
+
+//********************************* list_append_no_lock ***********************
+obj_p list_append_no_lock(obj_p list_obj, obj_p item){
+       list_p lstp;
+       lstp = list_obj->data.ptr;
+       if(lstplen(lstp) == lstpsize(lstp)) {
+               lstpsize(lstp) *= LIST_GROWTH_FACTOR;
+               lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
+               list_obj->data.ptr = lstp;
+       }
+       listitem(list_obj, listlen(list_obj)++) = item;
+       return list_obj;
+}
+
+//********************************* list1 *************************************
+obj_p list1(isp ist, obj_p item1){
+       obj_p list_obj = new_list_obj(ist, 1);
+       list_append_no_lock(list_obj, item1);
+       return list_obj;
+}
+
+//********************************* list2 *************************************
+obj_p list2(isp ist, obj_p item1, obj_p item2){
+       obj_p list_obj = new_list_obj(ist, 2);
+       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
+       return list_obj;
+}
+
+//********************************* list3 *************************************
+obj_p list3(isp ist, obj_p item1, obj_p item2, obj_p item3){
+       obj_p list_obj = new_list_obj(ist, 3);
+       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2); 
+       list_append_no_lock(list_obj, item3);
+       return list_obj;
+}
+
+//********************************* list4 *************************************
+obj_p list4(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4){
+       obj_p list_obj = new_list_obj(ist, 4);
+       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
+       list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, 
item4);
+       return list_obj;
+}
+
+//********************************* list6 *************************************
+obj_p list6(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4, 
+                                obj_p item5, obj_p item6 ){
+       obj_p list_obj = new_list_obj(ist, 6);
+       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
+       list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, 
item4);
+       list_append_no_lock(list_obj, item5); list_append_no_lock(list_obj, 
item6);
+       return list_obj;
+}
+
+//********************************* list8 *************************************
+obj_p list8(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4, 
+                                obj_p item5, obj_p item6, obj_p item7, obj_p 
item8 ){
+       obj_p list_obj = new_list_obj(ist, 8);
+       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
+       list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, 
item4);
+       list_append_no_lock(list_obj, item5); list_append_no_lock(list_obj, 
item6);
+       list_append_no_lock(list_obj, item7); list_append_no_lock(list_obj, 
item8);
+       return list_obj;
+}
+
 // ***************************** LIST 
******************************************
 
 MODULE_START(List)

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c 2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/builtins-string.c 2004-04-14 16:58:43 UTC (rev 350)
@@ -66,7 +66,51 @@
 
 #define is_String(objid)        (has_proto_QUES(ist, objid, String_OBJ))
 
+//********************************* new_string_obj ****************************
+// this cannot be used with binary data, for C strings only
+// for binary data with embedded nulls use new_string_n_obj(ist, )
+obj_p new_string_obj(isp ist, char* str){
+       obj_p obj;
+       pr_str_p obj_str;
+       size_t len;
+       if(!str) return NULL;
+       len = strlen(str);
+       obj = new_object(ist, OBJ(STRING_PROTO));
+       if (len < IMMEDIATE_DATA_LEN) {
+               obj->data_type    = DATA_TYPE_IMMDATA;
+               obj->imm_data_len = (int) len;
+               strcpy(obj->data.str, str);
+       } else {
+               obj_str = obj_malloc(obj, sizeof(pr_str_t)+len+1);
+               obj_str->len = len;
+               strcpy(&(obj_str->str[0]), str);
+       }
+       obj->immutable = TRUE;
+       return obj;
+}
 
+//********************************* new_string_n_obj **************************
+obj_p new_string_n_obj(isp ist, char* str, size_t len){
+       obj_p obj;
+       pr_str_p obj_str;
+       if(!str) return NULL;
+       obj = new_object(ist, OBJ(STRING_PROTO));
+       if (len < IMMEDIATE_DATA_LEN) {
+               obj->data_type    = DATA_TYPE_IMMDATA;
+               obj->imm_data_len = (int) len;
+               memcpy(obj->data.str, str, len);
+               obj->data.str[len] = 0;
+       } else {
+               obj_str = obj_malloc(obj, sizeof(pr_str_t)+len+1);
+               obj_str->len = len;
+               memcpy(&(obj_str->str[0]), str, len);
+               obj_str->str[len] = 0;
+       }
+       obj->immutable = TRUE;
+       return obj;
+}
+
+
 MODULE_DECLARE(String);
 MODULE_DECLARE(StringGen);
 

Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c  2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/builtins-tuple.c  2004-04-14 16:58:43 UTC (rev 350)
@@ -64,6 +64,15 @@
 #include "object.h"
 #include <prothon/prothon_dll.h>
 
+//********************************* new_tuple_obj *****************************
+obj_p new_tuple_obj(isp ist, int fixed_size) {
+       obj_p tuple_obj = new_list_obj(ist, fixed_size);
+       assert(!(tuple_obj->has_attrs));
+       tuple_obj->attr_proto.proto = OBJ(TUPLE_PROTO);
+       return tuple_obj;
+}
+
+
 MODULE_DECLARE(Tuple);
 MODULE_DECLARE(Tgen);
 

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c  2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/interp.c  2004-04-14 16:58:43 UTC (rev 350)
@@ -124,6 +124,110 @@
 #define ERR 1
 #define OK  0
 
+//********************************* new_super_obj *****************************
+obj_p new_super_obj(isp ist, obj_p symbol){
+       obj_p super_obj = new_object(ist, OBJ(SUPER_PROTO));
+       super_obj->data_type = DATA_TYPE_DATAPTR;
+       super_obj->data.ptr = symbol;
+       super_obj->immutable = TRUE;
+       return super_obj;
+}
+
+//********************************* new_slice_obj *****************************
+obj_p new_slice_obj(isp ist, obj_p ind1, obj_p ind2, obj_p ind3) {
+       obj_p slice_obj = new_list_obj(ist, 3);
+       assert(!(slice_obj->has_attrs));
+       slice_obj->attr_proto.proto = OBJ(SLICE_PROTO);
+       if (ind1 == SLICEPARAM_EMPTY)
+               list_append_no_lock(slice_obj, OBJ(NONE));
+       else
+               list_append_no_lock(slice_obj, ind1);
+       if (ind2 != SLICEPARAM_MISSING) {
+               if (ind2 == SLICEPARAM_EMPTY)
+                       list_append_no_lock(slice_obj, OBJ(NONE));
+               else
+                       list_append_no_lock(slice_obj, ind2);
+               if (ind3 != SLICEPARAM_MISSING) {
+                       if (ind3 == SLICEPARAM_EMPTY)
+                               list_append_no_lock(slice_obj, OBJ(NONE));
+                       else
+                               list_append_no_lock(slice_obj,ind3);
+               }
+       }
+       slice_obj->immutable = TRUE;
+       return slice_obj;
+}
+
+//********************************* get_item ******************************
+obj_p get_item(isp ist, obj_p ref_self, obj_p ref_key){
+       if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+               obj_p res;
+               if_exc_return NULL;
+               res = get_proto_attr(ist, ref_self, ref_key, NULL, NULL);
+               if (!res) {
+                       raise_exception(ist, OBJ(NAME_EXC), "Attribute %s not 
found",
+                                       symch(ist, ref_key));
+               }
+               return res;
+       } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
+               obj_p param[2];  
+               if_exc_return NULL;
+               param[0]=0; param[1]=ref_key;
+        return call_func(ist, ref_self, SYM(__GETITEM__), 2, param, 0);
+       } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
+               if_exc_return NULL;
+        return get_proto_attr(ist, ref_self, ref_key->data.ptr, NULL, 
ref_self);
+       } else {
+               raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference 
type");
+               return NULL;
+       }
+}
+
+//********************************* set_item ******************************
+void set_item(isp ist, obj_p value, obj_p ref_self, obj_p ref_key){
+       if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+               if_exc_return;
+               set_attr(ist, ref_self, ref_key, value);
+       } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
+               obj_p param[4];  
+               param[0]=0; param[1]=ref_key;
+               param[2]=0; param[3]=value;
+        call_func(ist, ref_self, SYM(__SETITEM__), 4, param, 0);
+       } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
+               obj_p proto_obj;
+        get_proto_attr(ist, ref_self, ref_key->data.ptr, &proto_obj, ref_self);
+               if_exc_return;
+               if (!proto_obj) {
+                       obj_p proto_list_obj = proto_list(ist, ref_self); 
if_exc_return;
+                       proto_obj = list_item(ist, proto_list_obj, 1);
+               }
+               set_attr(ist, proto_obj, ref_key->data.ptr, value);
+       } else {
+               raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference 
type");
+               return;
+       }
+}
+
+//********************************* del_item 
***********************************
+void del_item(isp ist, obj_p ref_self, obj_p ref_key){
+       if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+               if_exc_return;
+               del_attr(ist, ref_self, ref_key);
+       } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
+               obj_p param[2];  
+               param[0]=0; param[1]=ref_key;
+        call_func(ist, ref_self, SYM(__DELITEM__), 2, param, 0);
+       } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
+               obj_p proto_obj;
+        get_proto_attr(ist, ref_self, ref_key->data.ptr, &proto_obj, ref_self);
+               if_exc_return;
+               if (proto_obj) del_attr(ist, proto_obj, ref_key->data.ptr);
+       } else {
+               raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference 
type");
+               return;
+       }
+}
+
 //******************************** add_pos_param ******************************
 int add_pos_param(isp ist, fparam_proc_state_t* state, obj_p param){
        if (state->pos_ptr == clist_len(state->lbl_val_list)/2){

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c  2004-04-14 13:47:53 UTC (rev 349)
+++ trunk/src/object.c  2004-04-14 16:58:43 UTC (rev 350)
@@ -815,70 +815,7 @@
        write_unlock(ist, obj);
 }
 
-//********************************* new_int_obj *******************************
-obj_p new_int_obj(isp ist, i64_t num){
-       obj_p obj = new_object(ist, OBJ(INT_PROTO));
-       obj->data_type = DATA_TYPE_IMMDATA;
-       obj->imm_data_len = 8;
-       obj->data.i64 = num;
-       obj->immutable = TRUE;
-       return obj;
-}
 
-//********************************* new_float_obj *****************************
-obj_p new_float_obj(isp ist, double num){
-       obj_p obj = new_object(ist, OBJ(FLOAT_PROTO));
-       obj->data_type = DATA_TYPE_IMMDATA;
-       obj->imm_data_len = 8;
-       obj->data.f64 = num;
-       obj->immutable = TRUE;
-       return obj;
-}
-
-//********************************* new_string_obj ****************************
-// this cannot be used with binary data, for C strings only
-// for binary data with embedded nulls use new_string_n_obj(ist, )
-obj_p new_string_obj(isp ist, char* str){
-       obj_p obj;
-       pr_str_p obj_str;
-       size_t len;
-       if(!str) return NULL;
-       len = strlen(str);
-       obj = new_object(ist, OBJ(STRING_PROTO));
-       if (len < IMMEDIATE_DATA_LEN) {
-               obj->data_type    = DATA_TYPE_IMMDATA;
-               obj->imm_data_len = (int) len;
-               strcpy(obj->data.str, str);
-       } else {
-               obj_str = obj_malloc(obj, sizeof(pr_str_t)+len+1);
-               obj_str->len = len;
-               strcpy(&(obj_str->str[0]), str);
-       }
-       obj->immutable = TRUE;
-       return obj;
-}
-
-//********************************* new_string_n_obj **************************
-obj_p new_string_n_obj(isp ist, char* str, size_t len){
-       obj_p obj;
-       pr_str_p obj_str;
-       if(!str) return NULL;
-       obj = new_object(ist, OBJ(STRING_PROTO));
-       if (len < IMMEDIATE_DATA_LEN) {
-               obj->data_type    = DATA_TYPE_IMMDATA;
-               obj->imm_data_len = (int) len;
-               memcpy(obj->data.str, str, len);
-               obj->data.str[len] = 0;
-       } else {
-               obj_str = obj_malloc(obj, sizeof(pr_str_t)+len+1);
-               obj_str->len = len;
-               memcpy(&(obj_str->str[0]), str, len);
-               obj_str->str[len] = 0;
-       }
-       obj->immutable = TRUE;
-       return obj;
-}
-
 //********************************* new_hash_obj ******************************
 obj_p new_hash_obj(isp ist, i32_t num) {
        obj_p hash_obj = new_object(ist, OBJ(HASH_PROTO));
@@ -898,252 +835,7 @@
        return call_func(ist, self, sym, 2, arr, NULL);
 }
 
-//********************************* new_tuple_obj *****************************
-obj_p new_tuple_obj(isp ist, int fixed_size) {
-       obj_p tuple_obj = new_list_obj(ist, fixed_size);
-       assert(!(tuple_obj->has_attrs));
-       tuple_obj->attr_proto.proto = OBJ(TUPLE_PROTO);
-       return tuple_obj;
-}
 
-//********************************* get_item ******************************
-obj_p get_item(isp ist, obj_p ref_self, obj_p ref_key){
-       if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
-               obj_p res;
-               if_exc_return NULL;
-               res = get_proto_attr(ist, ref_self, ref_key, NULL, NULL);
-               if (!res) {
-                       raise_exception(ist, OBJ(NAME_EXC), "Attribute %s not 
found",
-                                       symch(ist, ref_key));
-               }
-               return res;
-       } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
-               obj_p param[2];  
-               if_exc_return NULL;
-               param[0]=0; param[1]=ref_key;
-        return call_func(ist, ref_self, SYM(__GETITEM__), 2, param, 0);
-       } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
-               if_exc_return NULL;
-        return get_proto_attr(ist, ref_self, ref_key->data.ptr, NULL, 
ref_self);
-       } else {
-               raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference 
type");
-               return NULL;
-       }
-}
-
-//********************************* set_item ******************************
-void set_item(isp ist, obj_p value, obj_p ref_self, obj_p ref_key){
-       if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
-               if_exc_return;
-               set_attr(ist, ref_self, ref_key, value);
-       } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
-               obj_p param[4];  
-               param[0]=0; param[1]=ref_key;
-               param[2]=0; param[3]=value;
-        call_func(ist, ref_self, SYM(__SETITEM__), 4, param, 0);
-       } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
-               obj_p proto_obj;
-        get_proto_attr(ist, ref_self, ref_key->data.ptr, &proto_obj, ref_self);
-               if_exc_return;
-               if (!proto_obj) {
-                       obj_p proto_list_obj = proto_list(ist, ref_self); 
if_exc_return;
-                       proto_obj = list_item(ist, proto_list_obj, 1);
-               }
-               set_attr(ist, proto_obj, ref_key->data.ptr, value);
-       } else {
-               raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference 
type");
-               return;
-       }
-}
-
-//********************************* del_item 
***********************************
-void del_item(isp ist, obj_p ref_self, obj_p ref_key){
-       if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
-               if_exc_return;
-               del_attr(ist, ref_self, ref_key);
-       } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
-               obj_p param[2];  
-               param[0]=0; param[1]=ref_key;
-        call_func(ist, ref_self, SYM(__DELITEM__), 2, param, 0);
-       } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
-               obj_p proto_obj;
-        get_proto_attr(ist, ref_self, ref_key->data.ptr, &proto_obj, ref_self);
-               if_exc_return;
-               if (proto_obj) del_attr(ist, proto_obj, ref_key->data.ptr);
-       } else {
-               raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference 
type");
-               return;
-       }
-}
-
-//********************************* new_slice_obj *****************************
-obj_p new_slice_obj(isp ist, obj_p ind1, obj_p ind2, obj_p ind3) {
-       obj_p slice_obj = new_list_obj(ist, 3);
-       assert(!(slice_obj->has_attrs));
-       slice_obj->attr_proto.proto = OBJ(SLICE_PROTO);
-       if (ind1 == SLICEPARAM_EMPTY)
-               list_append_no_lock(slice_obj, OBJ(NONE));
-       else
-               list_append_no_lock(slice_obj, ind1);
-       if (ind2 != SLICEPARAM_MISSING) {
-               if (ind2 == SLICEPARAM_EMPTY)
-                       list_append_no_lock(slice_obj, OBJ(NONE));
-               else
-                       list_append_no_lock(slice_obj, ind2);
-               if (ind3 != SLICEPARAM_MISSING) {
-                       if (ind3 == SLICEPARAM_EMPTY)
-                               list_append_no_lock(slice_obj, OBJ(NONE));
-                       else
-                               list_append_no_lock(slice_obj,ind3);
-               }
-       }
-       slice_obj->immutable = TRUE;
-       return slice_obj;
-}
-
-//********************************* new_super_obj *****************************
-obj_p new_super_obj(isp ist, obj_p symbol){
-       obj_p super_obj = new_object(ist, OBJ(SUPER_PROTO));
-       super_obj->data_type = DATA_TYPE_DATAPTR;
-       super_obj->data.ptr = symbol;
-       super_obj->immutable = TRUE;
-       return super_obj;
-}
-
-
-//********************************* new_list_obj ******************************
-obj_p new_list_obj(isp ist, size_t initial_size){
-       obj_p list_obj = new_object(ist, OBJ(LIST_PROTO));
-       list_p lstp = list_obj->data.ptr = 
-                     pr_malloc(list_sizeof(max(initial_size,2)));
-       list_obj->data_type = DATA_TYPE_DATAPTR;
-       lstpsize(lstp) = max(initial_size,2);
-       lstplen(lstp)  = 0;
-       return list_obj;
-}
-
-//********************************* clone_list_obj ****************************
-obj_p clone_list_obj(isp ist, obj_p list_obj) {
-       obj_p res;
-       size_t llen, size;
-       list_p list_ptr;
-       rdlock_rtrn(list_obj) NULL;
-       llen = listlen(list_obj);
-       size = list_sizeof(llen);
-       res = copy_object(ist, list_obj);
-       res->data.ptr = list_ptr = pr_malloc(size);
-       lstpsize(list_ptr) = llen;
-       lstplen(list_ptr)  = llen;
-       memcpy( list_ptr->item, ((list_p)(list_obj->data.ptr))->item, 
-                                                 size-sizeof(list_hdr_t) );
-       read_unlock(ist, list_obj);
-       return res;
-}
-
-//********************************* list_len **********************************
-size_t list_len(isp ist, obj_p list_obj){
-       size_t len;
-       rdlock_rtrn(list_obj) 0;
-       len = listlen(list_obj);
-       read_unlock(ist, list_obj);
-       return len;
-}
-
-//********************************* list_clear 
**********************************
-void list_clear(isp ist, obj_p list_obj) {
-       wrlock_rtrn(list_obj);
-       listlen(list_obj) = 0;
-       write_unlock(ist, list_obj);
-}
-
-//********************************* list_item *********************************
-obj_p list_item(isp ist, obj_p list_obj, int i){
-       obj_p res;
-       rdlock_rtrn(list_obj) NULL;
-       res = listitem(list_obj, i);
-       read_unlock(ist, list_obj);
-       return res;
-}
-
-//********************************* list_append *******************************
-obj_p list_append(isp ist, obj_p list_obj, obj_p item){
-       list_p lstp;
-       wrlock_rtrn(list_obj) NULL;
-       lstp = list_obj->data.ptr;
-       if(lstplen(lstp) == lstpsize(lstp)) {
-               lstpsize(lstp) *= LIST_GROWTH_FACTOR;
-               lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
-               list_obj->data.ptr = lstp;
-       }
-       listitem(list_obj, listlen(list_obj)++) = item;
-       write_unlock(ist, list_obj);
-       return list_obj;
-}
-
-//********************************* list_append_no_lock ***********************
-obj_p list_append_no_lock(obj_p list_obj, obj_p item){
-       list_p lstp;
-       lstp = list_obj->data.ptr;
-       if(lstplen(lstp) == lstpsize(lstp)) {
-               lstpsize(lstp) *= LIST_GROWTH_FACTOR;
-               lstp = pr_realloc(lstp, list_sizeof(lstpsize(lstp)));
-               list_obj->data.ptr = lstp;
-       }
-       listitem(list_obj, listlen(list_obj)++) = item;
-       return list_obj;
-}
-
-//********************************* list1 *************************************
-obj_p list1(isp ist, obj_p item1){
-       obj_p list_obj = new_list_obj(ist, 1);
-       list_append_no_lock(list_obj, item1);
-       return list_obj;
-}
-
-//********************************* list2 *************************************
-obj_p list2(isp ist, obj_p item1, obj_p item2){
-       obj_p list_obj = new_list_obj(ist, 2);
-       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
-       return list_obj;
-}
-
-//********************************* list3 *************************************
-obj_p list3(isp ist, obj_p item1, obj_p item2, obj_p item3){
-       obj_p list_obj = new_list_obj(ist, 3);
-       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2); 
-       list_append_no_lock(list_obj, item3);
-       return list_obj;
-}
-
-//********************************* list4 *************************************
-obj_p list4(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4){
-       obj_p list_obj = new_list_obj(ist, 4);
-       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
-       list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, 
item4);
-       return list_obj;
-}
-
-//********************************* list6 *************************************
-obj_p list6(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4, 
-                                obj_p item5, obj_p item6 ){
-       obj_p list_obj = new_list_obj(ist, 6);
-       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
-       list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, 
item4);
-       list_append_no_lock(list_obj, item5); list_append_no_lock(list_obj, 
item6);
-       return list_obj;
-}
-
-//********************************* list8 *************************************
-obj_p list8(isp ist, obj_p item1, obj_p item2, obj_p item3, obj_p item4, 
-                                obj_p item5, obj_p item6, obj_p item7, obj_p 
item8 ){
-       obj_p list_obj = new_list_obj(ist, 8);
-       list_append_no_lock(list_obj, item1); list_append_no_lock(list_obj, 
item2);
-       list_append_no_lock(list_obj, item3); list_append_no_lock(list_obj, 
item4);
-       list_append_no_lock(list_obj, item5); list_append_no_lock(list_obj, 
item6);
-       list_append_no_lock(list_obj, item7); list_append_no_lock(list_obj, 
item8);
-       return list_obj;
-}
-
 //********************************* add_doc_to_obj 
***********************************
 void add_doc_to_obj(isp ist, obj_p obj, char* str){
        if (str[strlen(str)-1] == '\n') {





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