rev 362 - in trunk: . include/prothon modules/OS pr src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-15 17:47:29 -0400 (Thu, 15 Apr 2004)
New Revision: 362
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/include/prothon/prothon_dll.h
trunk/modules/OS/OS.c
trunk/pr/system-test.pr
trunk/src/init.pth
trunk/src/src.vcproj
Log:
OS module now works in win32, but I had to disable APR to make it work
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/STATUS.txt 2004-04-15 21:47:29 UTC (rev 362)
@@ -1,8 +1,6 @@
----------------------- TO-DO (highest priority first) ------------------------
---- change all varnames to var_names
-
--- add list comprehension
--- add support for APR_BINARY in File.c ('b' flag)
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/include/prothon/prothon.h 2004-04-15 21:47:29 UTC (rev 362)
@@ -66,10 +66,12 @@
//*****************************************************************************
+#ifndef NO_APR
#include <apr.h>
#include <apr_pools.h>
#include <apr_thread_proc.h>
#include <apr_portable.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -94,14 +96,24 @@
//************************* BASIC TYPE DEFINITIONS ********************************
-typedef signed char i8_t;
-typedef apr_int16_t i16_t;
-typedef apr_int32_t i32_t;
-typedef apr_int64_t i64_t;
-typedef apr_byte_t u8_t;
-typedef apr_uint16_t u16_t;
-typedef apr_uint32_t u32_t;
-typedef apr_uint64_t u64_t;
+typedef signed char i8_t;
+#ifdef NO_APR
+typedef short i16_t;
+typedef int i32_t;
+typedef __int64 i64_t;
+typedef unsigned char u8_t;
+typedef unsigned short u16_t;
+typedef unsigned int u32_t;
+typedef unsigned __int64 u64_t;
+#else
+typedef apr_int16_t i16_t;
+typedef apr_int32_t i32_t;
+typedef apr_int64_t i64_t;
+typedef apr_byte_t u8_t;
+typedef apr_uint16_t u16_t;
+typedef apr_uint32_t u32_t;
+typedef apr_uint64_t u64_t;
+#endif
#ifdef WIN32
#define MAX_INT_VAL 0x7fffffffffffffff
@@ -185,7 +197,7 @@
u8_t del_locked :1;
u8_t rdlock_cnt :6; // 7 when not debugging
u8_t wrlock_req_cnt :6; // 7 when not debugging
- apr_uint32_t wrlock;
+ i32_t wrlock;
attr_proto_t attr_proto;
obj_data_t data;
obj_p next_obj;
@@ -209,6 +221,7 @@
typedef user_thread_t* user_thread_p;
+#ifndef NO_APR
typedef struct {
apr_os_thread_t apr_os_thread;
apr_thread_t* apr_thread;
@@ -221,7 +234,7 @@
} pr_thread_t;
typedef pr_thread_t* pr_thread_p;
-
+#endif
//************************* MALLOC FUNCTIONS **********************************
// These behave identical to the standard OS functions, but on segments smaller
// than 64 bytes are much faster than most OS implementations. See prmalloc.c.
@@ -521,6 +534,7 @@
} \
} while(0)
+#ifndef NO_APR
// IF_APR_ERR: Convenience macro for apr call error checking
#define IF_APR_ERR(msg) \
if (aprerr != APR_SUCCESS) { \
@@ -531,8 +545,8 @@
// SWITCH_PROTO_TO: Replace all old protos with a new single proto object
void switch_proto(isp ist, obj_p obj, obj_p new_proto);
+#endif
-
//***************** SPECIFIC OBJECT TYPE FUNCTIONS **************************
// SYM: Create (or access an existing) symbol object from a C string.
@@ -668,6 +682,7 @@
// liberally to make browsing objects easier and to make dumps readable.
void add_doc_to_obj(isp ist, obj_p obj, char* str);
+#ifndef NO_APR
// NEW_THREAD_OBJ: Create a new thread object and start the thread
// thread_func is the C function to execute. thread_data points to
// arugments for the thread_func function.
@@ -685,7 +700,7 @@
// Example thread_func: void *main_thread(apr_thread_t *handle, void *argv);
// The handle parameter is used for this_thread: register_thread(handle);
obj_p register_thread(isp ist, apr_thread_t *this_thread);
-
+#endif
//****************** HIGHER LEVEL OBJECT ACCESS ROUTINES ************************
// xxx_ITEM: These are higher-level access routines for attributes and data
@@ -847,8 +862,10 @@
// both NULL, then it will catch all exception objects. When this function catches the
// exception and returns it, the exception object is no longer raised unless you call
// raise_exception again with that object.
+#ifndef NO_APR
void raise_exception(isp ist, obj_p proto_obj, const char *format, ...)
- __attribute__((format(printf,3,4)));
+ __attribute__((format(printf,3,4)));
+#endif
obj_p catch_exception(isp ist, obj_p proto, obj_p proto_list);
// EXCEPT: Convenience macro to catch all exceptions and return if exception caught
Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/include/prothon/prothon_dll.h 2004-04-15 21:47:29 UTC (rev 362)
@@ -96,11 +96,8 @@
int parm_cnt, obj_p* lbl_val_arr, obj_p dyn_locals );
obj_p (*call_func1_f)(isp ist, obj_p self, obj_p sym, obj_p parm);
obj_p (*sym)(isp ist, char* symbol);
- void (*raise_exception)(isp ist, obj_p proto_obj, const char *format, ...)
- __attribute__((format(printf,3,4)));
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);
@@ -128,6 +125,12 @@
obj_p* OBJ_;
sym_id_entry_t* sym_id_table;
+
+#ifndef NO_APR
+ void (*raise_exception)(isp ist, obj_p proto_obj, const char *format, ...)
+ __attribute__((format(printf,3,4)));
+ apr_pool_t* (*get_pr_head_pool)(void);
+#endif
} pr_services_t;
Modified: trunk/modules/OS/OS.c
===================================================================
--- trunk/modules/OS/OS.c 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/modules/OS/OS.c 2004-04-15 21:47:29 UTC (rev 362)
@@ -50,12 +50,12 @@
* ====================================================================
*/
-
// OS.c - OS routines
#include <stdlib.h>
#include <prothon/prothon_dll.h>
+// note: to build this in windows, define NO_APR
MODULE_DECLARE(OS);
@@ -67,8 +67,12 @@
}
DEF(OS, system, FPARM1(cmd, NULL)) {
- CHECK_TYPE_EXC(parms[1], OBJ(STRING_PROTO), "string");
-
+ 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;
+ add_doc_to_obj(ist, ist->exception_obj, "object is not of type string");
+ return NULL;
+ }
return new_int_obj(ist, system(strch(parms[1])));
}
Modified: trunk/pr/system-test.pr
===================================================================
--- trunk/pr/system-test.pr 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/pr/system-test.pr 2004-04-15 21:47:29 UTC (rev 362)
@@ -2,6 +2,12 @@
import OS
+print
+print 'The following lines should be:'
+print 'hello'
+print '0'
+print
+
ret = OS.system("echo hello")
-
print ret
+print
\ No newline at end of file
Modified: trunk/src/init.pth
===================================================================
--- trunk/src/init.pth 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/src/init.pth 2004-04-15 21:47:29 UTC (rev 362)
@@ -9,6 +9,7 @@
c:\prothon\modules\re\debug
c:\prothon\modules\prosist\debug
c:\prothon\modules\SQLite\debug
+c:\prothon\modules\OS\debug
# this is executed before Main1 as module PthMod1
Modified: trunk/src/src.vcproj
===================================================================
--- trunk/src/src.vcproj 2004-04-15 20:45:53 UTC (rev 361)
+++ trunk/src/src.vcproj 2004-04-15 21:47:29 UTC (rev 362)
@@ -295,6 +295,9 @@
RelativePath="..\pr\strmod.pr">
</File>
<File
+ RelativePath="..\pr\system-test.pr">
+ </File>
+ <File
RelativePath="..\pr\test.pr">
</File>
<File