Skip to content

Commit

Permalink
tentative new libpd_start_message signature
Browse files Browse the repository at this point in the history
  • Loading branch information
nettoyeurny committed Aug 30, 2011
1 parent 7d38636 commit 44cb8f2
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
5 changes: 2 additions & 3 deletions java/org/puredata/core/PdBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions libpd_wrapper/z_jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libpd_wrapper/z_jni.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions libpd_wrapper/z_libpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion libpd_wrapper/z_libpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions objc/PdBase.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ + (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]);
}
}

+ (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]);
Expand Down
5 changes: 2 additions & 3 deletions python/pylibpd.i
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion samples/test/pdtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 44cb8f2

Please sign in to comment.