rev 738 - in trunk: include/prothon modules/OS src
SVN User <[email protected]> Thu, 15 Jul 2004 02:25:33 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-07-15 02:25:30 -0400 (Thu, 15 Jul 2004)
New Revision: 738
Modified:
trunk/include/prothon/prothon.h
trunk/modules/OS/OS.c
trunk/src/builtins-file.c
trunk/src/object.c
Log:
changed os.Process to use workDir and workDir to allow string argument
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-07-15 05:46:48 UTC (rev 737)
+++ trunk/include/prothon/prothon.h 2004-07-15 06:25:30 UTC (rev 738)
@@ -340,6 +340,7 @@
MUTEX_PROTO, // Mutex
PARMPTR_PROTO, //
PROP_PROTO, //
+ DIR_PROTO, //
FILE_PROTO, //
TEXTFILE_PROTO, //
Modified: trunk/modules/OS/OS.c
===================================================================
--- trunk/modules/OS/OS.c 2004-07-15 05:46:48 UTC (rev 737)
+++ trunk/modules/OS/OS.c 2004-07-15 06:25:30 UTC (rev 738)
@@ -124,11 +124,12 @@
#define SIGKILL 11 // stolen from APR private.h, is this right???
-DEF(Process, init_, FPARM4(argV, OBJ(NODEF), flags, NEW_INT(0), dir, OBJ(NONE), env, OBJ(NONE))) {
+DEF(Process, init_, FPARM4(argV, OBJ(NODEF), flags, NEW_INT(0), workDir, OBJ(NONE), env, OBJ(NONE))) {
apr_status_t aprerr;
apr_procattr_t* attr;
apr_pool_t* pool;
- obj_p argv_list, env_list=NULL, dir;
+ obj_p argv_list, env_list=NULL;
+ char* dir;
int i, arg_len, env_len, flags;
int stdin_flg=APR_NO_PIPE, stdout_flg=APR_NO_PIPE, stderr_flg=APR_NO_PIPE;
apr_cmdtype_e cmd_type = 0;
@@ -161,8 +162,15 @@
raise_exception(ist, OBJ(VALUE_EXC), "flags can only have one of SHELLCMD, COPYENV, & COPYENVPATH");
return NULL;
}
- dir = parms[5];
- if (dir == OBJ(NONE)) dir = NULL;
+ if (parms[5] == OBJ(NONE)) dir = NULL;
+ else if (has_proto(ist, parms[5], OBJ(STRING_PROTO)))
+ dir = pr2c_strptr(ist, parms[5]);
+ else if (has_proto(ist, parms[5], OBJ(DIR_PROTO)))
+ dir = pr2c_strptr(ist, get_attr(ist, parms[5], sym(ist, "path")));
+ else {
+ raise_exception(ist, OBJ(TYPE_EXC), "workDir must be a String or Dir object");
+ return NULL;
+ }
if (parms[7] != OBJ(NONE)) {
SEQ_OR_PARAM(4, env_list);
env_len = (int) list_len(ist, env_list);
@@ -190,8 +198,7 @@
IF_APR_ERR("error in apr_procattr_io_set") return NULL;
if (dir) {
- char* path = pr2c_strptr(ist, get_attr(ist, dir, sym(ist, "path")));
- aprerr = apr_procattr_dir_set(attr, path);
+ aprerr = apr_procattr_dir_set(attr, dir);
IF_APR_ERR("error in apr_procattr_dir_set") return NULL;
}
if (cmd_type) {
@@ -239,6 +246,7 @@
file_obj->unclonable = TRUE;
set_attr(ist, self, sym(ist, "stdErrPipe"), file_obj);
}
+ return OBJ(NONE);
}
DEF(Process, str_, NULL) {
@@ -290,7 +298,7 @@
list_append(ist, tuple, NEW_INT(exit_why));
return tuple;
} else
- NEW_INT(exitcode);
+ return NEW_INT(exitcode);
}
DEF(Process, kill, FPARM1(sig, NEW_INT(SIGKILL))) {
Modified: trunk/src/builtins-file.c
===================================================================
--- trunk/src/builtins-file.c 2004-07-15 05:46:48 UTC (rev 737)
+++ trunk/src/builtins-file.c 2004-07-15 06:25:30 UTC (rev 738)
@@ -272,7 +272,7 @@
MODULE_START(Dir)
{
- Dir_OBJ = NEW_OBJ(NULL);
+ Dir_OBJ = OBJ(DIR_PROTO);
set_obj_doc(Dir_OBJ, "Directory object prototype");
MODULE_ADD_TO_BASE(Dir);
Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c 2004-07-15 05:46:48 UTC (rev 737)
+++ trunk/src/object.c 2004-07-15 06:25:30 UTC (rev 738)
@@ -237,8 +237,9 @@
OBJ(MUTEX_PROTO) = NEW_OBJ(NULL);
OBJ(PARMPTR_PROTO) = NEW_OBJ(NULL);
OBJ(PROP_PROTO) = NEW_OBJ(NULL);
+ OBJ(DIR_PROTO) = NEW_OBJ(NULL);
OBJ(FILE_PROTO) = NEW_OBJ(NULL);
- OBJ(TEXTFILE_PROTO) = NEW_OBJ(NULL);
+ OBJ(TEXTFILE_PROTO) = NEW_OBJ(OBJ(FILE_PROTO));
OBJ(ROOT_GLOBALS) = NEW_OBJ(NULL);
OBJ(MODULES) = NEW_OBJ(NULL);
OBJ(SYS) = NEW_OBJ(NULL);