diff --git a/java/org/puredata/core/PdBase.java b/java/org/puredata/core/PdBase.java index 4624ba89d..e3eca9c25 100644 --- a/java/org/puredata/core/PdBase.java +++ b/java/org/puredata/core/PdBase.java @@ -503,8 +503,7 @@ public synchronized native static int sendPolyAftertouch(int channel, public synchronized native static int sendSysRealTime(int port, int value); private static int processArgs(Object[] args) { - int maxArgs = startMessage(); - if (args.length > maxArgs) { + if (startMessage(args.length) != 0) { return -100; } for (Object arg : args) { @@ -526,7 +525,7 @@ private static int processArgs(Object[] args) { private native static void initialize(); - private native static int startMessage(); + private native static int startMessage(int length); private native static void addFloat(float x); diff --git a/libpd_wrapper/z_jni.c b/libpd_wrapper/z_jni.c index 05bf8229c..4517f0907 100644 --- a/libpd_wrapper/z_jni.c +++ b/libpd_wrapper/z_jni.c @@ -398,8 +398,8 @@ JNIEXPORT jint JNICALL Java_org_puredata_core_PdBase_sendSymbol } JNIEXPORT jint JNICALL Java_org_puredata_core_PdBase_startMessage -(JNIEnv *env, jclass cls) { - return libpd_start_message(); +(JNIEnv *env, jclass cls, jint length) { + return libpd_start_message(length); } JNIEXPORT void JNICALL Java_org_puredata_core_PdBase_addFloat diff --git a/libpd_wrapper/z_jni.h b/libpd_wrapper/z_jni.h index 4dfcbc21f..51879a854 100644 --- a/libpd_wrapper/z_jni.h +++ b/libpd_wrapper/z_jni.h @@ -210,10 +210,10 @@ JNIEXPORT void JNICALL Java_org_puredata_core_PdBase_initialize /* * Class: org_puredata_core_PdBase * Method: startMessage - * Signature: ()I + * Signature: (I)I */ JNIEXPORT jint JNICALL Java_org_puredata_core_PdBase_startMessage - (JNIEnv *, jclass); + (JNIEnv *, jclass, jint); /* * Class: org_puredata_core_PdBase diff --git a/libpd_wrapper/z_libpd.c b/libpd_wrapper/z_libpd.c index 42288e6e7..bd8146c9a 100644 --- a/libpd_wrapper/z_libpd.c +++ b/libpd_wrapper/z_libpd.c @@ -192,10 +192,10 @@ int libpd_message(const char *recv, const char *msg, int n, t_atom *v) { static t_atom argv[MAXMSGLENGTH], *curr; static int argc; -int libpd_start_message(void) { +int libpd_start_message(int length) { argc = 0; curr = argv; - return MAXMSGLENGTH; + return (length > MAXMSGLENGTH); } #define ADD_ARG(f) f(curr, x); curr++; argc++; diff --git a/libpd_wrapper/z_libpd.h b/libpd_wrapper/z_libpd.h index e890baadf..a4888dc19 100644 --- a/libpd_wrapper/z_libpd.h +++ b/libpd_wrapper/z_libpd.h @@ -47,7 +47,7 @@ void libpd_set_symbol(t_atom *v, const char *sym); int libpd_list(const char *recv, int argc, t_atom *argv); int libpd_message(const char *recv, const char *msg, int argc, t_atom *argv); -int libpd_start_message(void); +int libpd_start_message(int length); void libpd_add_float(float x); void libpd_add_symbol(const char *sym); int libpd_finish_list(const char *recv); diff --git a/objc/PdBase.m b/objc/PdBase.m index c819950ef..efd5481f8 100644 --- a/objc/PdBase.m +++ b/objc/PdBase.m @@ -165,7 +165,7 @@ + (void)sendSymbol:(NSString *)symbol toReceiver:(NSString *)receiverName { + (void)sendList:(NSArray *)list toReceiver:(NSString *)receiverName { @synchronized(self) { - libpd_start_message(); + if (libpd_start_message([list count])) return; encodeList(list); libpd_finish_list([receiverName cStringUsingEncoding:NSASCIIStringEncoding]); } @@ -173,7 +173,7 @@ + (void)sendList:(NSArray *)list toReceiver:(NSString *)receiverName { + (void)sendMessage:(NSString *)message withArguments:(NSArray *)list toReceiver:(NSString *)receiverName { @synchronized(self) { - libpd_start_message(); + if (libpd_start_message([list count])) return; encodeList(list); libpd_finish_message([receiverName cStringUsingEncoding:NSASCIIStringEncoding], [message cStringUsingEncoding:NSASCIIStringEncoding]); diff --git a/python/pylibpd.i b/python/pylibpd.i index d8e78df99..eead53b33 100644 --- a/python/pylibpd.i +++ b/python/pylibpd.i @@ -45,7 +45,7 @@ int libpd_symbol(const char *dest, const char *sym); %rename(__libpd_add_symbol) libpd_add_symbol; %rename(__libpd_finish_list) libpd_finish_list; %rename(__libpd_finish_message) libpd_finish_message; -int libpd_start_message(); +int libpd_start_message(int); void libpd_add_float(float); void libpd_add_symbol(const char *); int libpd_finish_list(const char *); @@ -96,8 +96,7 @@ SET_CALLBACK(midibyte) import array def __process_args(args): - n = __libpd_start_message(); - if (len(args) > n): return -1 + if __libpd_start_message(len(args)): return -2 for arg in args: if isinstance(arg, str): __libpd_add_symbol(arg) diff --git a/samples/test/pdtest.c b/samples/test/pdtest.c index 3cc5f8050..ad830699b 100644 --- a/samples/test/pdtest.c +++ b/samples/test/pdtest.c @@ -25,7 +25,7 @@ int main(int argc, char **argv) { // block size 64, one tick per buffer // compute audio [; pd dsp 1( - libpd_start_message(); + libpd_start_message(1); // one entry in list libpd_add_float(1.0f); libpd_finish_message("pd", "dsp");