00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef rr_common_h
00017 #define rr_common_h
00018
00019 #include "ruby.h"
00020
00021 #include "TObject.h"
00022 #include "TList.h"
00023 #include "TArrayC.h"
00024 #include "TArrayS.h"
00025 #include "TArrayI.h"
00026 #include "TArrayL.h"
00027 #include "TArrayF.h"
00028 #include "TArrayD.h"
00029 #include "TSeqCollection.h"
00030
00031 #include "CallFunc.h"
00032
00033
00034 #ifdef __cplusplus
00035 # ifndef RUBY_METHOD_FUNC
00036 # define VALUEFUNC(f) ((VALUE (*)()) f)
00037 # define VOIDFUNC(f) ((void (*)()) f)
00038 # else
00039 # ifndef ANYARGS
00040 # define VALUEFUNC(f) ((VALUE (*)()) f)
00041 # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
00042 # else
00043 # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
00044 # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
00045 # endif
00046 # endif
00047 #else
00048 # define VALUEFUNC(f) (f)
00049 # define VOIDFUNC(f) (f)
00050 #endif
00051
00052
00053
00054 #define RRNEW(obj, type) obj = rb_class_new_instance (0, NULL, type)
00055
00056 #define RRGRAB(fromobj, type, toobj) \
00057 type *toobj; \
00058 Data_Get_Struct (rb_iv_get (fromobj, "__rr__"), type, toobj)
00059
00060 #define RRCALL(obj, type) \
00061 type *v; \
00062 Data_Get_Struct(rb_iv_get (obj, "__rr__"), type, v); ((type *)(v))
00063
00064 #define RRCALL2(obj, type, ptr) \
00065 type *v; \
00066 Data_Get_Struct(rb_iv_get (obj, "__rr__"), type, v); ptr = v
00067
00068 #define RRMODCALL(obj, modtype, convfunc) \
00069 modtype *v; \
00070 Data_Get_Struct (rb_iv_get (obj, "__rr__"), modtype, v); \
00071 convfunc ((void**)&v, obj); v
00072
00073 #define RRMODCALL2(obj, modtype, convfunc, ptr) \
00074 modtype *v; \
00075 Data_Get_Struct (rb_iv_get (obj, "__rr__"), modtype, v); \
00076 convfunc ((void**)&v, obj); ptr = v
00077
00078
00079 #define RRSTRING(v) (TYPE(v) == T_STRING)
00080 #define RRINT(v) (TYPE(v) == T_FIXNUM)
00081 #define RRFLOAT(v) ((TYPE(v) == T_FLOAT) || (TYPE(v) == T_FIXNUM))
00082 #define RRARRAY(v, kind) (TYPE(v) == T_ARRAY && kind(rb_ary_entry(v, 0)))
00083 #define RRDATA(v) (TYPE(v) == T_OBJECT)
00084 #define RRFUNC(v) (TYPE(v) == T_SYMBOL)
00085 #define RRVOID(v) (v)
00086
00087 extern VALUE cTObject;
00088
00089 VALUE rr_bool (bool q);
00090
00091 VALUE rr_ary_new (TList *l);
00092 VALUE rr_arrayc_new (const TArrayC *a);
00093 VALUE rr_arrays_new (const TArrayS *a);
00094 VALUE rr_arrayi_new (const TArrayI *a);
00095 VALUE rr_arrayl_new (const TArrayL *a);
00096 VALUE rr_arrayf_new (const TArrayF *a);
00097 VALUE rr_arrayd_new (const TArrayD *a);
00098 VALUE rr_seqcollection_new (TSeqCollection *sc);
00099
00100 void * rr_parse_void (VALUE o);
00101
00102
00103 void rr_tattfill_conv(void **ptr, VALUE klass);
00104 void rr_tattline_conv(void **ptr, VALUE klass);
00105 void rr_tattmarker_conv(void **ptr, VALUE klass);
00106 void rr_tattpad_conv(void **ptr, VALUE klass);
00107 void rr_tatttext_conv(void **ptr, VALUE klass);
00108 void rr_tattaxis_conv(void **ptr, VALUE klass);
00109
00110
00111
00112 struct rr_fcn_info {
00113 ID id;
00114 char *name;
00115 };
00116
00117
00118
00119 double rr_ctf1_fcn (double *, double *);
00120 void rr_register_ctf1_fcn (char *name, ID id);
00121
00122
00123
00124 double rr_ctf2_fcn (double *, double *);
00125 void rr_register_ctf2_fcn (char *name, ID id);
00126
00127
00128
00129 struct drr_func_entry {
00130 G__CallFunc *func;
00131 G__ClassInfo *klass;
00132 char *name;
00133 char *cproto;
00134 int rtype;
00135 };
00136
00137 struct drr_func_cache {
00138 struct drr_func_entry *entry;
00139 struct drr_func_cache *next;
00140 struct drr_func_cache *last;
00141 };
00142
00143
00144 struct drr_func_cache * drr_func_cache_init(struct drr_func_entry *entry);
00145 void drr_func_cache_push (struct drr_func_cache *cache, struct drr_func_entry *entry);
00146 struct drr_func_entry * drr_func_cache_find (struct drr_func_cache *cache, char *name);
00147 void drr_func_entry_free (struct drr_func_entry *entry);
00148
00149 static VALUE drr_generic_method(int argc, VALUE argv[], VALUE self);
00150 static VALUE drr_method_missing(int argc, VALUE argv[], VALUE self);
00151
00152 #endif