[Gridflow-cvs] [svn] commit: r3350 - in /trunk/base: grid.h main.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Sun Mar 30 14:07:03 EDT 2008


Author: matju
Date: Sun Mar 30 14:07:02 2008
New Revision: 3350

Log:
remove Ruby interface to BitPacking

Modified:
    trunk/base/grid.h
    trunk/base/main.c

Modified: trunk/base/grid.h
==============================================================================
--- trunk/base/grid.h (original)
+++ trunk/base/grid.h Sun Mar 30 14:07:02 2008
@@ -159,7 +159,8 @@
 #define BUILTIN_SYMBOLS(MACRO) \
 	MACRO(_grid,"grid") MACRO(_bang,"bang") MACRO(_float,"float") \
 	MACRO(_list,"list") MACRO(_sharp,"#") \
-	MACRO(iv_ninlets,"@ninlets") MACRO(iv_noutlets,"@noutlets")
+	MACRO(iv_ninlets,"@ninlets") MACRO(iv_noutlets,"@noutlets") \
+	MACRO(_in,"in") MACRO(_out,"out")
 
 extern struct BuiltinSymbols {
 #define FOO(_sym_,_str_) Symbol _sym_;
@@ -452,10 +453,9 @@
   default: E; RAISE("type '%s' not available here",number_type_table[T].name);}
 
 //****************************************************************
-//BitPacking objects encapsulate optimised loops of conversion
+//BitPacking objects encapsulate optimised loops of bitfield conversion (mostly for I/O)
 struct BitPacking;
-// those are the types of the optimised loops of conversion 
-// inputs are const
+// those are the types of the optimised loops of conversion; inputs are const
 struct Packer {
 #define FOO(S) void (*as_##S)(BitPacking *self, long n, S *in, uint8 *out);
 EACH_INT_TYPE(FOO)
@@ -467,7 +467,7 @@
 #undef FOO
 };
 
-\class BitPacking : CObject {
+struct BitPacking : CObject {
 	Packer   *  packer;
 	Unpacker *unpacker;
 	unsigned int endian; // 0=big, 1=little, 2=same, 3=different
@@ -479,12 +479,6 @@
 		Packer *packer=0, Unpacker *unpacker=0);
 	bool is_le();
 	bool eq(BitPacking *o);
-	\decl void initialize(Ruby foo1, Ruby foo2, Ruby foo3);
-	\decl String   pack2(String ins, String outs=Qnil);
-	\decl String unpack2(String ins, String outs=Qnil);
-	\decl void     pack3(long n, long inqp, long outqp, NumberTypeE nt);
-	\decl void   unpack3(long n, long inqp, long outqp, NumberTypeE nt);
-	\decl String to_s();
 // main entrances to Packers/Unpackers
 	template <class T> void   pack(long n, T *in, uint8 *out);
 	template <class T> void unpack(long n, uint8 *in, T *out);

Modified: trunk/base/main.c
==============================================================================
--- trunk/base/main.c (original)
+++ trunk/base/main.c Sun Mar 30 14:07:02 2008
@@ -320,69 +320,6 @@
 }
 
 /* **************************************************************** */
-\class BitPacking : CObject
-
-\def void initialize(Ruby foo1, Ruby foo2, Ruby foo3) {}
-
-// !@#$ doesn't support number types
-// and the Pt<> look fishy
-\def String pack2 (String ins, String outs=Qnil) {
-	long n = rb_str_len(ins) / sizeof(int32) / size;
-	int32 * in = (int32 *)rb_str_ptr(ins);
-	long bytes2 = n*bytes;
-	Ruby out = outs!=Qnil ? rb_str_resize(outs,bytes2) : rb_str_new("",bytes2);
-	rb_str_modify(out);
-	pack(n,in,(uint8 *)rb_str_ptr(out));
-	return out;
-}
-
-// !@#$ doesn't support number types
-// and the Pt<> look fishy
-\def String unpack2 (String ins, String outs=Qnil) {
-	long n = rb_str_len(argv[0]) / bytes;
-	uint8 * in = (uint8 *)rb_str_ptr(ins);
-	long bytes2 = n*size*sizeof(int32);
-	Ruby out = outs!=Qnil ? rb_str_resize(outs,bytes2) : rb_str_new("",bytes2);
-	rb_str_modify(out);
-	unpack(n,in,(uint8 *)rb_str_ptr(out));
-	return out;
-}
-
-\def void   pack3 (long n, long inqp, long outqp, NumberTypeE nt) {
-#define FOO(T) pack(n,INT2PTR(T,inqp),INT2PTR(uint8,outqp));
-	TYPESWITCH(nt,FOO,)
-#undef FOO
-}
-
-\def void unpack3 (long n, long inqp, long outqp, NumberTypeE nt) {
-#define FOO(T) unpack(n,INT2PTR(uint8,inqp),INT2PTR(T,outqp));
-	TYPESWITCH(nt,FOO,)
-#undef FOO
-}
-
-static Ruby BitPacking_s_new(Ruby argc, Ruby *argv, Ruby qlass) {
-	Ruby keep = rb_ivar_get(mGridFlow, rb_intern("@fobjects"));
-	if (argc!=3) RAISE("bad args");
-	if (TYPE(argv[2])!=T_ARRAY) RAISE("bad mask");
-	int endian = INT(argv[0]);
-	int bytes = INT(argv[1]);
-	Ruby *masks = rb_ary_ptr(argv[2]);
-	uint32 masks2[4];
-	int size = rb_ary_len(argv[2]);
-	if (size<1) RAISE("not enough masks");
-	if (size>4) RAISE("too many masks (%d)",size);
-	for (int i=0; i<size; i++) masks2[i] = NUM2UINT(masks[i]);
-	BitPacking *self = new BitPacking(endian,bytes,size,masks2);
-	Ruby rself = Data_Wrap_Struct(qlass, 0, CObject_free, self);
-	self->rself = rself;
-	rb_hash_aset(keep,rself,Qtrue); // prevent sweeping (leak) (!@#$ WHAT???)
-	rb_funcall2(rself,SI(initialize),argc,argv);
-	return rself;
-}
-
-\classinfo
-\end class BitPacking
-
 void define_many_methods(Ruby rself, int n, MethodDecl *methods) {
 	for (int i=0; i<n; i++) {
 		MethodDecl *md = &methods[i];
@@ -564,12 +501,6 @@
 	SDEF(FObject, new, -1);
 	ID gbi = SI(gf_bridge_init);
 	if (rb_respond_to(rb_cData,gbi)) rb_funcall(rb_cData,gbi,0);
-	Ruby cBitPacking = rb_define_class_under(mGridFlow, "BitPacking", rb_cObject);
-	define_many_methods(cBitPacking, ciBitPacking.methodsn, ciBitPacking.methods);
-	SDEF(BitPacking,new,-1);
-	rb_define_method(rb_cString, "swap32!", (RMethod)String_swap32_f, 0);
-	rb_define_method(rb_cString, "swap16!", (RMethod)String_swap16_f, 0);
-
 	startup_number();
 	startup_grid();
 	startup_flow_objects();



More information about the Gridflow-cvs mailing list