aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2009-10-22 20:03:06 +0000
committermescalinum <mescalinum@users.sourceforge.net>2009-10-22 20:03:06 +0000
commitfb0c2e4416d7a54f5318710b256dd794cc8317c8 (patch)
tree37424c9186c84f936e79a640b81c6e23bcdb9433
parent610f8eabfba4bd606adbb9a8305672f1a7b1c870 (diff)
atoi and atof externals
svn path=/trunk/externals/ffext/; revision=12645
-rw-r--r--atox/Makefile47
-rw-r--r--atox/atox.c53
2 files changed, 100 insertions, 0 deletions
diff --git a/atox/Makefile b/atox/Makefile
new file mode 100644
index 0000000..fc76385
--- /dev/null
+++ b/atox/Makefile
@@ -0,0 +1,47 @@
+#!/usr/bin/make
+
+DEBUG?=0
+OS := $(shell uname -s)
+
+ifeq ($(DEBUG),1)
+ CFLAGS += -O0 -g -ggdb -DDEBUG
+endif
+ifeq ($(OS),Linux)
+ PDSUF = .pd_linux
+ PDBUNDLEFLAGS = -shared -rdynamic
+ LDSOFLAGS = -lm
+endif
+ifeq ($(OS),Darwin)
+ PDSUF = .pd_darwin
+ INCLUDES = -I/Library/Frameworks/Tcl.framework/Headers
+ PDBUNDLEFLAGS = -bundle -flat_namespace -undefined dynamic_lookup
+ LDSOFLAGS = -lm
+endif
+ifeq (MINGW,$(findstring MINGW,$(UNAME)))
+ PDSUF = .dll
+ PDBUNDLEFLAGS = -shared
+ LDSOFLAGS = -lm
+endif
+
+INCLUDES = -I../../pd/src -I/usr/include
+CFLAGS += -Wall -fPIC
+CFLAGS += -DPDSUF=\"$(PDSUF)\"
+ifeq ($(DEBUG),0)
+ CFLAGS += -O2
+endif
+
+all: atoi.pd_linux atof.pd_linux
+
+clean:
+ rm -f *.pd_linux *.o *~ atoi.c atof.c
+
+atoi.c: atox.c
+ sed -e s/ATOX/$*/g $< > $@
+
+atof.c: atox.c
+ sed -e s/ATOX/$*/g $< > $@
+
+.SUFFIXES: .c .o $(PDSUF)
+
+.o$(PDSUF):
+ $(CC) $(PDBUNDLEFLAGS) $(CFLAGS) $(INCLUDES) -o $*$(PDSUF) $< $(LDSOFLAGS)
diff --git a/atox/atox.c b/atox/atox.c
new file mode 100644
index 0000000..6097eb9
--- /dev/null
+++ b/atox/atox.c
@@ -0,0 +1,53 @@
+/* Copyright (c) 2005 Federico Ferri.
+ * Release under the terms of GPL license.
+ * Based on PureData by Miller Puckette and others. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "m_pd.h"
+
+#define buf_sz MAXPDSTRING
+
+typedef struct
+{
+ t_object x_obj;
+ t_outlet *x_out2;
+} t_ATOX;
+
+static t_class *ATOX_class;
+
+static void ATOX_out(t_ATOX *x, t_float f)
+{
+ outlet_float(x->x_obj.ob_outlet, f);
+}
+
+static void ATOX_float(t_ATOX *x, t_float f)
+{
+ ATOX_out(x, f);
+}
+
+static void ATOX_symbol(t_ATOX *x, t_symbol *s)
+{
+ char buf[buf_sz];
+ t_atom a;
+ SETSYMBOL(&a, s);
+ atom_string(&a, buf, buf_sz);
+ ATOX_out(x, ATOX(buf));
+}
+
+static void *ATOX_new(t_floatarg f)
+{
+ t_ATOX *x = (t_ATOX *)pd_new(ATOX_class);
+ outlet_new((t_object *)x, &s_float);
+ return (x);
+}
+
+void ATOX_setup(void)
+{
+ ATOX_class = class_new(gensym("ATOX"),
+ (t_newmethod)ATOX_new, 0,
+ sizeof(t_ATOX), CLASS_DEFAULT,
+ A_DEFSYMBOL, 0);
+ class_addfloat(ATOX_class, ATOX_float);
+ class_addsymbol(ATOX_class, ATOX_symbol);
+}