rev 332 - in trunk: include/prothon modules modules/File modules/Prosist modules/Re src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-11 20:46:38 -0400 (Sun, 11 Apr 2004)
New Revision: 332

Added:
   trunk/modules/Prosist/
   trunk/modules/Prosist/Prosist.c
   trunk/modules/Prosist/Prosist.vcproj
Removed:
   trunk/src/thread.c
Modified:
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/modules/File/File.c
   trunk/modules/Re/re.vcproj
   trunk/src/builtins-core.c
   trunk/src/builtins-dict.c
   trunk/src/builtins-string.c
   trunk/src/builtins-thread.c
   trunk/src/builtins-tuple.c
   trunk/src/init.pth
   trunk/src/interp.c
   trunk/src/lock.c
   trunk/src/main.c
   trunk/src/memory_mgr.c
   trunk/src/object.c
   trunk/src/src.vcproj
   trunk/src/symbol.c
Log:
removed old thread.c file, started new "Prosist" module,
a simple persistant object store

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/include/prothon/prothon.h	2004-04-12 00:46:38 UTC (rev 332)
@@ -49,7 +49,7 @@
  * to be bound by the terms and conditions of this License Agreement.
  * ====================================================================
  */
- 
+
 // Prothon.h
  
 #ifndef PROTHON_H
@@ -172,19 +172,19 @@
 
 
 typedef struct obj_s {
-	obj_state_t		state			:3;
-	obj_type_t		data_type		:3;
+	obj_state_t		state			:3; // 2 when not debugging
+	obj_type_t		data_type		:3; // 2 when not debugging
 	u8_t			imm_data_len	:4;
 	access_t		rd_access		:2;	
 	access_t		wr_access		:2;	
+	u8_t			unclonable		:1;
+	u8_t			archived		:1;	
 	u8_t			immutable		:1;
 	u8_t			scanned			:1;	
-	u8_t			archived		:1;	
 	u8_t 			has_attrs		:1;
 	u8_t			del_locked		:1;
-	u8_t			long_wrlock		:1;	
-	u8_t			rdlock_cnt		:6;
-	u8_t			wrlock_req_cnt	:6;
+	u8_t			rdlock_cnt		:6; // 7 when not debugging
+	u8_t			wrlock_req_cnt	:6; // 7 when not debugging
 	apr_uint32_t	wrlock;
 	attr_proto_t	attr_proto;
 	obj_data_t		data;
@@ -384,6 +384,7 @@
 	__SETITEM__,
 	__DELITEM__,
 	__OBJLIST__,
+	__CDATALEN__,
 	__DEL__,
 	LEN,
 	MAX,

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/include/prothon/prothon_dll.h	2004-04-12 00:46:38 UTC (rev 332)
@@ -100,6 +100,7 @@
 	obj_p		(*new_object)(isp ist, obj_p proto);
 	void		(*add_doc_to_obj)(isp ist, obj_p obj, char* str);
 	apr_pool_t* (*get_pr_head_pool)(void);
+	obj_p	    (*dict_keys_values)(isp ist, obj_p dict_obj, int key_flg);
 
 	void*		(*pr_malloc)(size_t nbytes);
 	void*		(*pr_realloc)(void *p, size_t nbytes);
@@ -109,9 +110,6 @@
 	void*		(*obj_realloc)(isp ist, obj_p obj, size_t size);
 	void		(*obj_free)   (isp ist, obj_p obj);
 
-	obj_p* 				OBJ_;
-	sym_id_entry_t* 	sym_id_table;
-
 	int		   (*read_lock)(isp ist, obj_p obj);	
 	void		 (*read_unlock)(isp ist, obj_p obj);	
 	int		  (*write_lock)(isp ist, obj_p obj);		
@@ -121,8 +119,14 @@
 	void		  (*del_unlock)(obj_p obj);	
 	void	   (*set_immutable)(obj_p obj);		
 	void	   (*clr_immutable)(obj_p obj);
-	obj_p	   (*dict_keys_values)(isp ist, obj_p dict_obj, int key_flg);
 
+	void		(*set_obj_rdacc)(obj_p obj, int access);
+	void		(*set_obj_wracc)(obj_p obj, int access);
+	int			(*get_obj_rdacc)(obj_p obj);
+	int			(*get_obj_wracc)(obj_p obj);
+				
+	obj_p* 				OBJ_;
+	sym_id_entry_t* 	sym_id_table;
 } pr_services_t;
 
 
@@ -238,6 +242,10 @@
 #define clr_immutable		(*services->clr_immutable)	
 #define get_pr_head_pool	(*services->get_pr_head_pool)
 #define dict_keys_values	(*services->dict_keys_values)
+#define set_obj_rdacc		(*services->set_obj_rdacc)
+#define set_obj_wracc		(*services->set_obj_wracc)
+#define get_obj_rdacc		(*services->get_obj_rdacc)
+#define get_obj_wracc		(*services->get_obj_wracc)
 
 #endif // OBJECT_H
 

Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/modules/File/File.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -123,6 +123,7 @@
 	File_OBJ = new_object(ist, NULL);
 	add_doc_to_obj(ist, File_OBJ, "File object prototype");
 	MODULE_ADD_TO_BASE(File);
+	File_OBJ->unclonable = TRUE;
 }
 
 DEF(File, __init__, list6(ist, sym(ist, "path"),    NULL, 
@@ -194,7 +195,7 @@
 	read_unlock(ist, self);
 	set_file_obj(self, parms[1], parms[3], f, (int)(parms[5]->data.i64), flags);
 	read_lock(ist, self);
-
+	self->unclonable = TRUE;
 	return NULL;
 }
 

Added: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/modules/Prosist/Prosist.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -0,0 +1,154 @@
+/* ====================================================================
+ * The Prothon License Agreement, Version 1.1
+ *
+ * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
+ * All rights reserved. 
+ *
+ * 1. This LICENSE AGREEMENT is between Hahn Creative Applications ("HCA"),
+ * 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, HCA
+ * 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 HCA's License Agreement and
+ * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
+ * Applications; 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. HCA is making Prothon available to Licensee on an "AS IS" basis.
+ * HCA MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
+ * OF EXAMPLE, BUT NOT LIMITATION, HCA 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. HCA 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 HCA and
+ * Licensee.  This License Agreement does not grant permission to use HCA
+ * 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.
+ * ====================================================================
+ */
+
+
+// Re.c - regex using POSIX regex()
+
+#include <stdio.h>
+#include <string.h>
+#include <prothon/prothon_dll.h>
+
+typedef struct {
+	apr_file_t*			stream;
+	apr_pool_t*			pool;
+	apr_thread_mutex_t*	mutex;
+} dbdata_t;
+
+typedef dbdata_t* dbdata_p;
+
+MODULE_DECLARE(Prosist);
+MODULE_DECLARE(DB);
+MODULE_DECLARE(ProsistException);
+
+MODULE_START(Prosist)
+{
+	Prosist_OBJ = new_object(ist, NULL);
+	MODULE_SET_DOC(Prosist, "persistant database module for Prothon objects");
+	MODULE_ADD_TO_BASE(Prosist);
+
+	DB_OBJ = new_object(ist, NULL);
+	MODULE_SET_DOC(DB, "Prosist.DB database object prototype");
+	MODULE_ADD_TO_OBJ(DB, Prosist_OBJ, "DB");
+
+	ProsistException_OBJ = new_object(ist, OBJ(EXCEPTION));
+	MODULE_SET_DOC(ProsistException, "Re module error");
+	MODULE_ADD_TO_OBJ(ProsistException, Prosist_OBJ, "ProsistException");
+
+	DB_OBJ->unclonable = TRUE;
+	set_obj_rdacc(DB_OBJ, ACC_USER1);
+}
+
+DEF(DB, __init__, list4(ist, sym(ist, "filename"), NULL, 
+			                 sym(ist, "root_obj"), NULL ) ) {
+    obj_p root_obj;
+	apr_status_t aprerr;
+	dbdata_p dbdatap;
+	char* filename;
+
+	CHECK_TYPE_EXC(parms[1], OBJ(STRING_PROTO), "string");
+
+	read_unlock(ist, self);
+	filename = strch(parms[1]);
+	root_obj = parms[3];
+	set_obj_rdacc(self, ACC_USER1);
+	add_doc_to_obj(ist, self, "Prosist DataBase");
+	self->data_type = OBJ_TYPE_DATAPTR;
+	dbdatap = self->data.ptr = pr_malloc(sizeof(dbdata_t));
+	read_lock(ist, self);
+
+	aprerr = apr_pool_create(&(dbdatap->pool), get_pr_head_pool());
+	IF_APR_ERR("Out of memory creating Prosist DB") return NULL;
+	aprerr = apr_file_open(&(dbdatap->stream), filename, (APR_READ |APR_WRITE | APR_CREATE), APR_OS_DEFAULT, dbdatap->pool);
+	if (aprerr != APR_SUCCESS) {
+		char err_buf[80];
+		raise_exception(ist, OBJ(IOEXCEPTION), "Unable to open file %s: %s",
+				filename, apr_strerror(aprerr, err_buf, sizeof(err_buf)));
+		apr_pool_destroy(dbdatap->pool);
+		return NULL;
+	}
+	return OBJ(NONE);
+}
+
+void db_commit(isp ist, obj_p self){
+}
+
+DEF(DB, commit, NULL) { 
+	db_commit(ist, self);
+	return self;
+}
+
+
+DEF(DB, close, NULL) { 
+	dbdata_p dbdatap = self->data.ptr;
+	if (dbdatap->stream) {
+		db_commit(ist, self);
+		apr_file_close(dbdatap->stream);
+		dbdatap->stream = NULL;
+		apr_pool_destroy(dbdatap->pool);
+	}
+	return self;
+}
+
+DEF(DB, closed_QUES, NULL) { 
+	dbdata_p dbdatap = self->data.ptr;
+	if (dbdatap->stream) return OBJ(PR_FALSE);
+	else                 return OBJ(PR_TRUE);
+}
+
+MAIN_MODULE_INIT(Prosist)
+{
+	MODULE_SUB_INIT(Prosist);
+	MODULE_ADD_SYM(DB, __init__);
+	MODULE_ADD_SYM(DB, commit);
+	MODULE_ADD_SYM(DB, close);
+	MODULE_ADD_SYM(DB, closed_QUES);
+}


Property changes on: trunk/modules/Prosist/Prosist.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/modules/Prosist/Prosist.vcproj
===================================================================
--- trunk/modules/Prosist/Prosist.vcproj	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/modules/Prosist/Prosist.vcproj	2004-04-12 00:46:38 UTC (rev 332)
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="Prosist"
+	ProjectGUID="{ED1B9F21-0026-4156-881C-4F083129E75D}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILE_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				WarnAsError="TRUE"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="apr.lib wsock32.lib"
+				OutputFile="$(OutDir)/Prosist.dll"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
+				IgnoreDefaultLibraryNames="LIBCMTD.lib"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/Prosist.pdb"
+				SubSystem="2"
+				ImportLibrary="$(OutDir)/Prosist.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\include\regex"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PROSIST_EXPORTS"
+				RuntimeLibrary="1"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				WarnAsError="TRUE"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/Prosist.dll"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				ImportLibrary="$(OutDir)/Prosist.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath=".\Prosist.c">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Modified: trunk/modules/Re/re.vcproj
===================================================================
--- trunk/modules/Re/re.vcproj	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/modules/Re/re.vcproj	2004-04-12 00:46:38 UTC (rev 332)
@@ -72,7 +72,7 @@
 				Optimization="2"
 				InlineFunctionExpansion="1"
 				OmitFramePointers="TRUE"
-				AdditionalIncludeDirectories="c:\prothon\include\regex;c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr"
+				AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\include\regex"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;RE_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="1"
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/builtins-core.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -98,11 +98,28 @@
 }
 
 DEF(Object, clone, NULL) {
-	if (self->data_type == OBJ_TYPE_DATAPTR) {
+	obj_p clone;
+	size_t cdata_size = 0;
+	if (self->unclonable) {
 		raise_exception(ist, OBJ(TYPE_EXC), "clone() not supported on this object");
 		return NULL;
 	}
-	return clone_object(ist, self);
+	if (self->data_type == OBJ_TYPE_DATAPTR) {
+		size_t cdata_size;
+		obj_p cdata_len = call_func0(ist, self, SYM(__CDATALEN__));
+		if (!cdata_len) {
+			raise_exception(ist, OBJ(INTERNAL_EXC), "fatal error: __cdatalen__() call failed");
+			return NULL;
+		}
+		cdata_size = (size_t) cdata_len->data.i64;
+		del_unlock(cdata_len);
+	}
+	clone = clone_object(ist, self);
+	if (cdata_size) {
+		clone->data.ptr = pr_malloc(cdata_size);
+		memcpy(clone->data.ptr, self->data.ptr, cdata_size);
+	}
+	return clone;
 }
 
 DEF(Object, has_proto_QUES, FORM_RPARAM) {
@@ -610,13 +627,8 @@
 	MODULE_SET_DOC(Func, "function object prototype");
 }
 
-DEF(Func, clone, NULL) {
-	obj_p clone = clone_object(ist, self);
-	code_p p = self->data.ptr;
-	size_t len = sizeof(code) + p->len * sizeof(code_t);
-	clone->data.ptr = pr_malloc(len);
-	memcpy(clone->data.ptr, p, len);
-	return clone;
+DEF(Func, __cdatalen__, NULL) {
+	return new_int_obj(ist, sizeof(code) + ((code_p)(self->data.ptr))->len * sizeof(code_t));
 }
 
 DEF(Func, __objlist__, FORM_RPARAM) {
@@ -688,6 +700,6 @@
 	MODULE_ADD_SYM(Gen, __gen__);
 
 	MODULE_SUB_INIT(Func);
-	MODULE_ADD_SYM(Func, clone);
+	MODULE_ADD_SYM(Func, __cdatalen__);
 	MODULE_ADD_SYM(Func, __objlist__);
 }

Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/builtins-dict.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -145,12 +145,8 @@
 	return res_obj;
 }
 
-DEF(Dict, clone, NULL) {
-	obj_p clone = clone_object(ist, self);
-	size_t len  = dict_size_bytes(self->data.ptr);
-	clone->data.ptr = pr_malloc(len);
-	memcpy(clone->data.ptr, self->data.ptr, len);
-	return clone;
+DEF(Dict, __cdatalen__, NULL) {
+	return new_int_obj(ist, dict_size_bytes(self->data.ptr));
 }
 
 
@@ -268,7 +264,7 @@
 	MODULE_SUB_INIT(Dict);
 	MODULE_ADD_SYM(Dict, __init__);
 	MODULE_ADD_SYM(Dict, __str__);
-	MODULE_ADD_SYM(Dict, clone);
+	MODULE_ADD_SYM(Dict, __cdatalen__);
 	MODULE_ADD_SYM(Dict, __getitem__);
 	MODULE_ADD_SYM(Dict, __setitem__);
 	MODULE_ADD_SYM(Dict, __delitem__);

Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/builtins-string.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -92,15 +92,8 @@
 	return self;
 }
 
-DEF(String, clone, NULL) {
-	size_t len;
-	obj_p clone = clone_object(ist, self);
-	if (self->data_type == OBJ_TYPE_DATAPTR) {
-		len = sizeof(pr_str_t) + pr_strlen(self) + 1;
-		clone->data.ptr = pr_malloc(len);
-		memcpy(clone->data.ptr, self->data.ptr, len);
-	}
-	return clone;
+DEF(String, __cdatalen__, NULL) {
+	return new_int_obj(ist, sizeof(pr_str_t) + pr_strlen(self) + 1);
 }
 
 DEF(String, __hash__, NULL) {
@@ -317,7 +310,7 @@
 	MODULE_ADD_SYM(String, __bool__QUES);
 	MODULE_ADD_SYM(String, __str__);
 	MODULE_ADD_SYM(String, __hash__);
-	MODULE_ADD_SYM(String, clone);
+	MODULE_ADD_SYM(String, __cdatalen__);
 	MODULE_ADD_SYM(String, cmp);
 	MODULE_ADD_SYM(String, ord);
 	MODULE_ADD_SYM(String, len);

Modified: trunk/src/builtins-thread.c
===================================================================
--- trunk/src/builtins-thread.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/builtins-thread.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -198,6 +198,7 @@
 	Thread_OBJ->data_type = OBJ_TYPE_DATAPTR;
     thread = obj_malloc(Thread_OBJ, sizeof(pr_thread_t));
     memset(thread, 0, sizeof(pr_thread_t));
+	Thread_OBJ->unclonable = TRUE;
 }
 
 
@@ -237,6 +238,7 @@
 	set_attr(ist, self, sym(ist, "name"), name_obj);
 	new_thread_obj(ist, (apr_thread_start_t) user_thread, uthread, self);
 	read_lock(ist, self);
+	self->unclonable = TRUE;
 	return OBJ(NONE);
 }
 
@@ -313,6 +315,7 @@
 
 	set_attr(ist, OBJ(OBJECT), sym(ist,  "Mutex"), Mutex_OBJ);
 	Mutex_OBJ->data_type = OBJ_TYPE_DATAPTR;
+	Mutex_OBJ->unclonable = TRUE;
 }
 
 
@@ -325,6 +328,7 @@
 	self->data_type = OBJ_TYPE_DATAPTR;
 	aprerr = apr_thread_mutex_create((apr_thread_mutex_t**)(&self->data.ptr), APR_THREAD_MUTEX_UNNESTED, subpool);
 	IF_APR_ERR("error creating mutex in apr_thread_mutex_create") return NULL;
+	self->unclonable = TRUE;
 	return OBJ(NONE);
 }
 

Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/builtins-tuple.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -278,8 +278,8 @@
 	return NULL;
 }
 
-DEF(Tuple, clone, NULL) {
-	return clone_list_obj(ist, self);
+DEF(Tuple, __cdatalen__, NULL) {
+	return new_int_obj(ist, list_sizeof(listsize(self)));
 }
 
 DEF(Tuple, __gen__, NULL) {
@@ -316,13 +316,13 @@
 {
 	MODULE_SUB_INIT(Tuple);
 	MODULE_ADD_SYM(Tuple, __init__);	
+	MODULE_ADD_SYM(Tuple, __cdatalen__);	
 	MODULE_ADD_SYM(Tuple, __str__);	
 	MODULE_ADD_SYM(Tuple, len);
 	MODULE_ADD_SYM(Tuple, min);
 	MODULE_ADD_SYM(Tuple, max);
 	MODULE_ADD_SYM(Tuple, cmp);
 	MODULE_ADD_SYM(Tuple, __eq__QUES);
-	MODULE_ADD_SYM(Tuple, clone);	
 	MODULE_ADD_SYM(Tuple, count);
 	MODULE_ADD_SYM(Tuple, index);
 	MODULE_ADD_SYM(Tuple, __getitem__);

Modified: trunk/src/init.pth
===================================================================
--- trunk/src/init.pth	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/init.pth	2004-04-12 00:46:38 UTC (rev 332)
@@ -7,6 +7,7 @@
 
 c:\prothon\modules\file\debug
 c:\prothon\modules\re\debug
+c:\prothon\modules\prosist\debug
 
 # this is executed before Main1 as module PthMod1
 
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/interp.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -1068,7 +1068,9 @@
 							symch(ist, fr_data(1)));
 					break;
 				}
+				su(i);
 				set_attr(ist, frame->globals, fr_data(1), obj);
+				un_su(i);
 			}	break;
 			case OP_IMPORT_ATTR_AS: {
 				obj_p obj = fr_tos;
@@ -1081,7 +1083,9 @@
 						break;
 					}
 				}
+				su(i);
 				set_attr(ist, frame->globals, fr_data(param-1), obj);
+				un_su(i);
 			}	break;
 			case OP_PRINT: {
 				int i;

Modified: trunk/src/lock.c
===================================================================
--- trunk/src/lock.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/lock.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -170,7 +170,6 @@
 		free_wrlock(obj);
 		return FALSE;
 	}
-	obj->long_wrlock = TRUE;
 	return TRUE;
 }
 
@@ -206,7 +205,6 @@
 		apr_thread_mutex_unlock(write_mutex);
 		obj->rdlock_cnt += sav_cnt;
 	}
-	obj->long_wrlock = TRUE;
 	return FALSE;
 }
 
@@ -215,7 +213,6 @@
 	int write_ready_flag;
 	if (obj->immutable) return;
 	assert(obj->wrlock);
-	obj->long_wrlock = FALSE;
 	obj->archived = FALSE;
 	obj->state = OBJ_STATE_NEW_OR_MARKED;
 	if (mem_mgr_phase == MM_PHASE_MARKING && obj->scanned) {

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/main.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -95,12 +95,6 @@
 	char buf[1024];
 	int cmd_line_option_i_flg, mem_mgr_count;
 
-#ifdef DEBUG_THREADS
-	int torture_scan_num_ptr[]={1,2,3,4,5};
-	extern int torture_scan_thread_count;
-	extern void *torture_scan_thread(apr_thread_t *handle, void* thread_number_ptr);
-#endif
-
 	if ((aprerr = apr_app_initialize(&argc, (char const * const **)&argv, NULL))) {
 		char buf[1024];
 		printf("APR init error: %s\n", apr_strerror(aprerr, buf, 1024));
@@ -155,7 +149,6 @@
 
 #ifdef DEBUG_THREADS
 	SetThreadName("main");
-	new_thread_obj(ist, (apr_thread_start_t)torture_scan_thread, torture_scan_num_ptr, NULL);
 #endif
 
 #ifdef DEBUG_THREADS
@@ -199,10 +192,7 @@
 	while(!mem_mgr_terminated && ++mem_mgr_count < MEMMGR_TIMEOUT) apr_sleep(PAUSE_MS*1000);
 
 #ifdef DEBUG_THREADS
-	printf("Memory manager terminated, now stopping torture threads ...\n");
-	*torture_scan_num_ptr = 0;
-	while(torture_scan_thread_count) apr_sleep(PAUSE_MS*1000);
-	printf("All torture threads terminated, shutting down\n");
+	printf("Memory manager terminated, shutting down\n");
 #endif
 	
 #ifdef DUMP_OBJECTS_AT_END

Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/memory_mgr.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -94,14 +94,12 @@
 		}
 		apr_thread_mutex_unlock(write_mutex);
 	}
-	obj->long_wrlock = TRUE;
 }
 
 //********************************* mm_write_unlock ***************************
 void mm_write_unlock(obj_p obj) {
 	int write_ready_flag;
 	assert(obj->wrlock);
-	obj->long_wrlock = FALSE;
 	write_ready_flag = obj->wrlock_req_cnt;	
 	free_wrlock(obj);
 	if (write_ready_flag)  apr_thread_cond_broadcast(write_cond);

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/object.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -173,7 +173,14 @@
 	dll_services.clr_immutable	  = clr_immutable;
 	dll_services.get_pr_head_pool = get_pr_head_pool;
 	dll_services.dict_keys_values = dict_keys_values;
+	dll_services.set_obj_rdacc    = set_obj_rdacc;
+	dll_services.set_obj_wracc	  = set_obj_wracc;
+	dll_services.get_obj_rdacc	  = get_obj_rdacc;
+	dll_services.get_obj_wracc	  = get_obj_wracc;
 
+
+
+
 	/* Setup the core objects. Order counts here */
 	OBJ(OBJECT)             = new_object(ist, NULL);
 	OBJ(OBJECT)->attr_proto.proto = OBJ(OBJECT);
@@ -247,7 +254,6 @@
 	memcpy(clone, obj, sizeof(*obj)-sizeof(obj->next_obj));
 	clone->archived       = FALSE;
 	clone->del_locked     = TRUE;
-	clone->long_wrlock    = FALSE;
 	clone->rdlock_cnt     = 0;
 	clone->wrlock_req_cnt = 0;
 	clone->wrlock		  = 0;

Modified: trunk/src/src.vcproj
===================================================================
--- trunk/src/src.vcproj	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/src.vcproj	2004-04-12 00:46:38 UTC (rev 332)
@@ -196,9 +196,6 @@
 			<File
 				RelativePath=".\sys.c">
 			</File>
-			<File
-				RelativePath=".\thread.c">
-			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/symbol.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -141,6 +141,7 @@
 	{ "__setitem__",	0 },
 	{ "__delitem__",	0 },
 	{ "__objlist__",	0 },
+	{ "__cdatalen__",	0 },
 	{ "__del__",		0 },
 	{ "len",			0 },
 	{ "max",			0 },

Deleted: trunk/src/thread.c
===================================================================
--- trunk/src/thread.c	2004-04-11 19:10:50 UTC (rev 331)
+++ trunk/src/thread.c	2004-04-12 00:46:38 UTC (rev 332)
@@ -1,125 +0,0 @@
-/* ====================================================================
- * The Prothon License Agreement, Version 1.1
- *
- * Copyright (c) 2004 Hahn Creative Applications, http://hahnca.com.
- * All rights reserved. 
- *
- * 1. This LICENSE AGREEMENT is between Hahn Creative Applications ("HCA"),
- * 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, HCA
- * 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 HCA's License Agreement and
- * HCA's notice of copyright, i.e., "Copyright (c) 2004 Hahn Creative
- * Applications; 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. HCA is making Prothon available to Licensee on an "AS IS" basis.
- * HCA MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY
- * OF EXAMPLE, BUT NOT LIMITATION, HCA 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. HCA 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 HCA and
- * Licensee.  This License Agreement does not grant permission to use HCA
- * 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.
- * ====================================================================
- */
-
-
-// thread.c
-
-#include "object.h"
-#include "interp.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-
-#include <apr_time.h>
-#include <apr.h>
-#include <apr_thread_proc.h>
-#include <apr_strings.h>
-#include <apr_dso.h>
-#include <string.h>
-
-
-#ifdef DEBUG_THREADS
-
-int torture_scan_thread_count = 0;
-
-void *torture_scan_thread(apr_thread_t *handle, void* thread_number_ptr) {
-	isp ist = get_ist(ACC_SYSTEM);
-	obj_p obj = NULL;
-	int scan_num = *((int*)thread_number_ptr);
-
-	register_thread(ist, handle);
-
-	torture_scan_thread_count++;
-	srand( (unsigned)time( NULL ) );
-
-	printf("Torture scan %d started\n", scan_num);
-	{
-		char tname[32];
-		apr_snprintf(tname, sizeof(tname), "tscan%d", scan_num);
-		SetThreadName(tname);
-	}
-
-	while (!obj) {
-		apr_sleep(10);
-		pr_lock(&object_list_lock); 
-		obj = obj_list_root;
-		while(obj && !write_lock_try(ist, obj)) obj = obj->next_obj;
-		pr_unlock(&object_list_lock);
-	}
-	while (*((int*)thread_number_ptr)) {
-		int size = attr_tsize(obj->attr_proto.attrs)+(rand() & 31);
-		int obj_locked = TRUE;
-		if (obj->has_attrs)
-			obj->attr_proto.attrs = pr_realloc( obj->attr_proto.attrs, 
-				 size * sizeof(attr_t) );
-		while(TRUE) {
-			pr_lock(&object_list_lock); 
-			if (obj_locked) {write_unlock(ist, obj); obj_locked = FALSE;}
-			do {obj = obj->next_obj;} while (obj && !write_lock_try(ist, obj));
-			if (obj) break;
-			pr_unlock(&object_list_lock);
-			apr_sleep(10);
-			pr_lock(&object_list_lock); 
-			if (write_lock_try(ist, obj = obj_list_root)) break;
-			pr_unlock(&object_list_lock);
-		}
-		pr_unlock(&object_list_lock);
-	}
-	write_unlock(ist, obj);
-	torture_scan_thread_count--;
-
-	printf("Torture scan %d terminating\n", scan_num);
-
-	return NULL;
-}
-
-#endif
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.