Hi all. Here is a patch that implements a public tcl.lang.Interp.appendElement() method for Jacl and Tcl Blend. The appendElement method is a mapping of the Tcl_AppendElement function from the C implementation. Does anyone see any problem with adding this to the 1.3 development version? It adds a public API so I wanted to get some comments on the change. Mo Dejong Red Hat Inc. Index: diffs.txt =================================================================== RCS file: /home/cvs/external/tcljava/diffs.txt,v retrieving revision 1.6 diff -u -r1.6 diffs.txt --- diffs.txt 2000/03/02 04:08:34 1.6 +++ diffs.txt 2000/03/14 01:22:41 @@ -105,6 +105,7 @@ setResult Tcl_SetObjResult Tcl_SetResult getResult Tcl_GetObjResult + appendElement Tcl_AppendElement resetResult Tcl_ResetResult backgroundError Tcl_BackgroundError addErrorInfo Tcl_AddErrorInfo Index: src/jacl/tcl/lang/Interp.java =================================================================== RCS file: /home/cvs/external/tcljava/src/jacl/tcl/lang/Interp.java,v retrieving revision 1.26 diff -u -r1.26 Interp.java --- Interp.java 2000/03/02 04:08:34 1.26 +++ Interp.java 2000/03/14 01:22:42 @@ -1995,7 +1995,7 @@ *---------------------------------------------------------------------- */ -void +public void appendElement( String string) /* String to convert to list element and * add to result. */ @@ -2008,7 +2008,7 @@ result.preserve(); result = result.takeExclusive(); TclList.append(this, result, TclString.newInstance(string)); - setResult(result.toString()); + setResult(result); result.release(); } Index: src/native/javaInterp.c =================================================================== RCS file: /home/cvs/external/tcljava/src/native/javaInterp.c,v retrieving revision 1.4 diff -u -r1.4 javaInterp.c --- javaInterp.c 1999/08/31 00:46:37 1.4 +++ javaInterp.c 2000/03/14 01:22:42 @@ -419,6 +419,53 @@ /* *---------------------------------------------------------------------- * + * Java_tcl_lang_Interp_appendElement -> Tcl_AppendElement + * + * Convert a string to a valid Tcl list element and append it to the + * result (which is ostensibly a list). + * + * Class: tcl_lang_Interp + * Method: appendElement + * Signature: (Ljava/lang/String;)V + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void JNICALL +Java_tcl_lang_Interp_appendElement( + JNIEnv *env, /* Java environment. */ + jclass interpObj, /* Handle to Interp class. */ + jstring valueStr) /* String to append to result */ +{ + const char * value; + Tcl_Interp *interp = JavaGetInterp(env, interpObj); + JNIEnv *oldEnv; + + if (!value) { + ThrowNullPointerException(env, NULL); + return; + } + + JAVA_LOCK(); + value = (*env)->GetStringUTFChars(env, valueStr, NULL); + Tcl_AppendElement(interp, value); + (*env)->ReleaseStringUTFChars(env, valueStr, value); + + JAVA_UNLOCK(); + + return; +} + + +/* + *---------------------------------------------------------------------- + * * Java_tcl_lang_Interp_setVar -- * * Set a variable to the given string. Index: src/tclblend/tcl/lang/Interp.java =================================================================== RCS file: /home/cvs/external/tcljava/src/tclblend/tcl/lang/Interp.java,v retrieving revision 1.10 diff -u -r1.10 Interp.java --- Interp.java 2000/02/23 22:16:27 1.10 +++ Interp.java 2000/03/14 01:22:42 @@ -741,6 +741,37 @@ public final native void resetResult(); + + +/* + *---------------------------------------------------------------------- + * + * Tcl_AppendElement -- + * + * Convert a string to a valid Tcl list element and append it to the + * result (which is ostensibly a list). + * + * Results: + * None. + * + * Side effects: + * The result in the interpreter given by the first argument is + * extended with a list element converted from string. A separator + * space is added before the converted list element unless the current + * result is empty, contains the single character "{", or ends in " {". + * + * If the string result is empty, the object result is moved to the + * string result, then the object result is reset. + * + *---------------------------------------------------------------------- + */ + +public native void +appendElement( + String string) /* String to convert to list element and + * add to result. */ +throws + TclException; /* *---------------------------------------------------------------------- ---------------------------------------------------------------- The TclJava mailing list is sponsored by Scriptics Corporation. To subscribe: send mail to [EMAIL PROTECTED] with the word SUBSCRIBE as the subject. To unsubscribe: send mail to [EMAIL PROTECTED] with the word UNSUBSCRIBE as the subject. To send to the list, send email to '[EMAIL PROTECTED]'. An archive is available at http://www.mail-archive.com/tcljava@scriptics.com