aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--jim-posix.c12
-rw-r--r--jim-win32.c4
-rw-r--r--jim-win32com.c8
-rw-r--r--jim.c18
-rw-r--r--jim.h7
6 files changed, 36 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 09ed3d1..49145f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-05 13:13 antirez
+
+ * ChangeLog, jim-posix.c: extern int errno declaration removed from
+ the posix extension.
+
2005-03-05 11:45 patthoyts
* jim.c, jim.h: Added Jim_GetAssocData api. This for permitting
diff --git a/jim-posix.c b/jim-posix.c
index 940f0dd..feba435 100644
--- a/jim-posix.c
+++ b/jim-posix.c
@@ -1,7 +1,7 @@
/* Jim - POSIX extension
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
*
- * $Id: jim-posix.c,v 1.10 2005/03/05 12:13:30 antirez Exp $
+ * $Id: jim-posix.c,v 1.11 2005/03/05 12:22:35 antirez Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,10 +124,10 @@ static int Jim_PosixSethostnameCommand(Jim_Interp *interp, int argc,
int Jim_OnLoad(Jim_Interp *interp)
{
Jim_InitExtension(interp, "1.0");
- Jim_CreateCommand(interp, "os.fork", Jim_PosixForkCommand, NULL);
- Jim_CreateCommand(interp, "os.sleep", Jim_PosixSleepCommand, NULL);
- Jim_CreateCommand(interp, "os.getids", Jim_PosixGetidsCommand, NULL);
- Jim_CreateCommand(interp, "os.gethostname", Jim_PosixGethostnameCommand, NULL);
- Jim_CreateCommand(interp, "os.sethostname", Jim_PosixSethostnameCommand, NULL);
+ Jim_CreateCommand(interp, "os.fork", Jim_PosixForkCommand, NULL, NULL);
+ Jim_CreateCommand(interp, "os.sleep", Jim_PosixSleepCommand, NULL, NULL);
+ Jim_CreateCommand(interp, "os.getids", Jim_PosixGetidsCommand, NULL, NULL);
+ Jim_CreateCommand(interp, "os.gethostname", Jim_PosixGethostnameCommand, NULL, NULL);
+ Jim_CreateCommand(interp, "os.sethostname", Jim_PosixSethostnameCommand, NULL, NULL);
return JIM_OK;
}
diff --git a/jim-win32.c b/jim-win32.c
index 4080b86..bee89f9 100644
--- a/jim-win32.c
+++ b/jim-win32.c
@@ -2,7 +2,7 @@
*
* Copyright (C) 2005 Pat Thoyts <patthoyts@users.sourceforge.net>
*
- * $Id: jim-win32.c,v 1.16 2005/03/04 15:37:54 antirez Exp $
+ * $Id: jim-win32.c,v 1.17 2005/03/05 12:22:35 antirez Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -479,7 +479,7 @@ Jim_OnLoad(Jim_Interp *interp)
Jim_InitExtension(interp, "1.0");
#define CMD(name) \
- Jim_CreateCommand(interp, "win32." #name , Win32_ ## name , NULL)
+ Jim_CreateCommand(interp, "win32." #name , Win32_ ## name , NULL, NULL)
CMD(ShellExecute);
CMD(FindWindow);
diff --git a/jim-win32com.c b/jim-win32com.c
index 88f55ee..db5dade 100644
--- a/jim-win32com.c
+++ b/jim-win32com.c
@@ -2,7 +2,7 @@
*
* Windows COM extension.
*
- * $Id: jim-win32com.c,v 1.15 2005/03/04 23:59:45 patthoyts Exp $
+ * $Id: jim-win32com.c,v 1.16 2005/03/05 12:22:35 antirez Exp $
*
* Example:
* load jim-win32com
@@ -602,9 +602,9 @@ Jim_OnLoad(Jim_Interp *interp)
Win32ErrorObj(interp, "CoInitialize", (DWORD)hr));
return JIM_ERR;
}
- Jim_CreateCommand(interp, "ole32.create", Ole32_Create, NULL);
- Jim_CreateCommand(interp, "ole32.invoke", Ole32_Invoke, NULL);
- Jim_CreateCommand(interp, "ole32.foreach", Ole32_Foreach, NULL);
+ Jim_CreateCommand(interp, "ole32.create", Ole32_Create, NULL, NULL);
+ Jim_CreateCommand(interp, "ole32.invoke", Ole32_Invoke, NULL, NULL);
+ Jim_CreateCommand(interp, "ole32.foreach", Ole32_Foreach, NULL, NULL);
return JIM_OK;
}
diff --git a/jim.c b/jim.c
index 0bd42d9..85e37ef 100644
--- a/jim.c
+++ b/jim.c
@@ -1,7 +1,7 @@
/* Jim - A small embeddable Tcl interpreter
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
*
- * $Id: jim.c,v 1.63 2005/03/05 10:45:15 patthoyts Exp $
+ * $Id: jim.c,v 1.64 2005/03/05 12:22:35 antirez Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -2547,6 +2547,9 @@ static void Jim_CommandsHT_ValDestructor(void *interp, void *val)
if (cmdPtr->cmdProc == NULL) {
Jim_DecrRefCount(interp, cmdPtr->argListObjPtr);
Jim_DecrRefCount(interp, cmdPtr->bodyObjPtr);
+ } else if (cmdPtr->delProc != NULL) {
+ /* If it was a C coded command, call the delProc if any */
+ cmdPtr->delProc(cmdPtr->privData);
}
Jim_Free(val);
}
@@ -2563,7 +2566,7 @@ static Jim_HashTableType JimCommandsHashTableType = {
/* ------------------------- Commands related functions --------------------- */
int Jim_CreateCommand(Jim_Interp *interp, const char *cmdName,
- Jim_CmdProc cmdProc, void *privData)
+ Jim_CmdProc cmdProc, void *privData, Jim_DelCmdProc delProc)
{
Jim_HashEntry *he;
Jim_Cmd *cmdPtr;
@@ -2573,6 +2576,7 @@ int Jim_CreateCommand(Jim_Interp *interp, const char *cmdName,
cmdPtr = Jim_Alloc(sizeof(*cmdPtr));
cmdPtr->cmdProc = cmdProc;
cmdPtr->privData = privData;
+ cmdPtr->delProc = delProc;
Jim_AddHashEntry(&interp->commands, cmdName, cmdPtr);
} else {
/* Free the arglist/body objects if it was a Tcl procedure */
@@ -2580,6 +2584,9 @@ int Jim_CreateCommand(Jim_Interp *interp, const char *cmdName,
if (cmdPtr->cmdProc == NULL) {
Jim_DecrRefCount(interp, cmdPtr->argListObjPtr);
Jim_DecrRefCount(interp, cmdPtr->bodyObjPtr);
+ } else if (cmdPtr->delProc != NULL) {
+ /* If it was a C coded command, call the delProc if any */
+ cmdPtr->delProc(cmdPtr->privData);
}
cmdPtr->cmdProc = cmdProc;
cmdPtr->privData = privData;
@@ -2614,6 +2621,9 @@ int Jim_CreateProcedure(Jim_Interp *interp, const char *cmdName,
if (cmdPtr->cmdProc == NULL) {
Jim_DecrRefCount(interp, cmdPtr->argListObjPtr);
Jim_DecrRefCount(interp, cmdPtr->bodyObjPtr);
+ } else if (cmdPtr->delProc != NULL) {
+ /* If it was a C coded command, call the delProc if any */
+ cmdPtr->delProc(cmdPtr->privData);
}
cmdPtr->cmdProc = NULL; /* Not a C coded command */
cmdPtr->arityMin = arityMin;
@@ -2660,7 +2670,7 @@ int Jim_RenameCommand(Jim_Interp *interp, const char *oldName,
Jim_DecrRefCount(interp, cmdPtr->bodyObjPtr);
} else { /* Or C-coded command. */
Jim_CreateCommand(interp, newName, cmdPtr->cmdProc,
- cmdPtr->privData);
+ cmdPtr->privData, cmdPtr->delProc);
}
/* DeleteCommand will incr the proc epoch */
return Jim_DeleteCommand(interp, oldName);
@@ -8923,7 +8933,7 @@ void Jim_RegisterCoreCommands(Jim_Interp *interp)
Jim_CreateCommand(interp,
Jim_CoreCommandsTable[i].name,
Jim_CoreCommandsTable[i].cmdProc,
- NULL);
+ NULL, NULL);
i++;
}
Jim_RegisterCoreProcedures(interp);
diff --git a/jim.h b/jim.h
index 81604fa..a035cb3 100644
--- a/jim.h
+++ b/jim.h
@@ -1,7 +1,7 @@
/* Jim - A small embeddable Tcl interpreter
* Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
*
- * $Id: jim.h,v 1.35 2005/03/05 10:45:15 patthoyts Exp $
+ * $Id: jim.h,v 1.36 2005/03/05 12:22:35 antirez Exp $
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -373,6 +373,7 @@ typedef struct Jim_Var {
/* The cmd structure. */
typedef int (*Jim_CmdProc)(struct Jim_Interp *interp, int argc,
Jim_Obj *const *argv);
+typedef void (*Jim_DelCmdProc)(void *privData);
/* A command is implemented in C if funcPtr is != NULL, otherwise
* it's a Tcl procedure with the arglist and body represented by the
@@ -380,6 +381,7 @@ typedef int (*Jim_CmdProc)(struct Jim_Interp *interp, int argc,
typedef struct Jim_Cmd {
Jim_CmdProc cmdProc; /* Not-NULL for a C command. */
void *privData; /* Only used for C commands. */
+ Jim_DelCmdProc delProc; /* Called when the command is deleted if != NULL */
Jim_Obj *argListObjPtr;
Jim_Obj *bodyObjPtr;
int arityMin; /* Min number of arguments. */
@@ -574,7 +576,8 @@ JIM_STATIC void JIM_API(Jim_FreeInterp) (Jim_Interp *i);
/* commands */
JIM_STATIC void JIM_API(Jim_RegisterCoreCommands) (Jim_Interp *interp);
JIM_STATIC int JIM_API(Jim_CreateCommand) (Jim_Interp *interp,
- const char *cmdName, Jim_CmdProc cmdProc, void *privData);
+ const char *cmdName, Jim_CmdProc cmdProc, void *privData,
+ Jim_DelCmdProc delProc);
JIM_STATIC int JIM_API(Jim_CreateProcedure) (Jim_Interp *interp,
const char *cmdName, Jim_Obj *argListObjPtr, Jim_Obj *bodyObjPtr,
int arityMin, int arityMax);