Max 5 API Reference
00001 /* 00002 * obex_util.h 00003 * 00004 * Copyright 2006 Cycling '74. All rights reserved. 00005 * 00006 */ 00007 00008 #ifndef __OBEX_UTIL_H__ 00009 #define __OBEX_UTIL_H__ 00010 00011 #ifdef __cplusplus 00012 extern "C" { 00013 #endif // __cplusplus 00014 00015 00016 // symbol macros which may be swapped to use common symbol pointers for performance 00017 #define USESYM(x) gensym(#x) 00018 //#define USESYM(x) _sym_##x 00019 00020 // macros for attributes 00021 // class attributes are almost universally attr_offset, except for class static attributes 00022 00023 00024 /** 00025 Create a char attribute and add it to a Max class. 00026 00027 @ingroup attr 00028 @param c The class pointer. 00029 @param attrname The name of this attribute as a C-string. 00030 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00031 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00032 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00033 */ 00034 #define CLASS_ATTR_CHAR(c,attrname,flags,structname,structmember) \ 00035 class_addattr((c),attr_offset_new(attrname,USESYM(char),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00036 00037 00038 /** 00039 Create a long integer attribute and add it to a Max class. 00040 00041 @ingroup attr 00042 @param c The class pointer. 00043 @param attrname The name of this attribute as a C-string. 00044 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00045 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00046 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00047 */ 00048 #define CLASS_ATTR_LONG(c,attrname,flags,structname,structmember) \ 00049 class_addattr((c),attr_offset_new(attrname,USESYM(long),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00050 00051 00052 /** 00053 Create a 32-bit float attribute and add it to a Max class. 00054 00055 @ingroup attr 00056 @param c The class pointer. 00057 @param attrname The name of this attribute as a C-string. 00058 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00059 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00060 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00061 */ 00062 #define CLASS_ATTR_FLOAT(c,attrname,flags,structname,structmember) \ 00063 class_addattr((c),attr_offset_new(attrname,USESYM(float32),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00064 00065 00066 /** 00067 Create a 64-bit float attribute and add it to a Max class. 00068 00069 @ingroup attr 00070 @param c The class pointer. 00071 @param attrname The name of this attribute as a C-string. 00072 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00073 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00074 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00075 */ 00076 #define CLASS_ATTR_DOUBLE(c,attrname,flags,structname,structmember) \ 00077 class_addattr((c),attr_offset_new(attrname,USESYM(float64),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00078 00079 00080 /** 00081 Create a #t_symbol* attribute and add it to a Max class. 00082 00083 @ingroup attr 00084 @param c The class pointer. 00085 @param attrname The name of this attribute as a C-string. 00086 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00087 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00088 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00089 */ 00090 #define CLASS_ATTR_SYM(c,attrname,flags,structname,structmember) \ 00091 class_addattr((c),attr_offset_new(attrname,USESYM(symbol),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00092 00093 00094 /** 00095 Create a #t_atom attribute and add it to a Max class. 00096 00097 @ingroup attr 00098 @param c The class pointer. 00099 @param attrname The name of this attribute as a C-string. 00100 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00101 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00102 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00103 */ 00104 #define CLASS_ATTR_ATOM(c,attrname,flags,structname,structmember) \ 00105 class_addattr((c),attr_offset_new(attrname,USESYM(atom),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00106 00107 00108 /** 00109 Create a #t_object* attribute and add it to a Max class. 00110 00111 @ingroup attr 00112 @param c The class pointer. 00113 @param attrname The name of this attribute as a C-string. 00114 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00115 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00116 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00117 */ 00118 #define CLASS_ATTR_OBJ(c,attrname,flags,structname,structmember) \ 00119 class_addattr((c),attr_offset_new(attrname,USESYM(object),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))) 00120 00121 00122 00123 00124 /** 00125 Create an array-of-chars attribute of fixed length, and add it to a Max class. 00126 00127 @ingroup attr 00128 @param c The class pointer. 00129 @param attrname The name of this attribute as a C-string. 00130 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00131 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00132 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00133 @param size The number of chars in the array. 00134 */ 00135 #define CLASS_ATTR_CHAR_ARRAY(c,attrname,flags,structname,structmember,size) \ 00136 class_addattr((c),attr_offset_array_new(attrname,USESYM(char),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00137 00138 00139 /** 00140 Create an array-of-long-integers attribute of fixed length, and add it to a Max class. 00141 00142 @ingroup attr 00143 @param c The class pointer. 00144 @param attrname The name of this attribute as a C-string. 00145 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00146 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00147 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00148 @param size The number of longs in the array. 00149 */ 00150 #define CLASS_ATTR_LONG_ARRAY(c,attrname,flags,structname,structmember,size) \ 00151 class_addattr((c),attr_offset_array_new(attrname,USESYM(long),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00152 00153 00154 /** 00155 Create an array-of-32bit-floats attribute of fixed length, and add it to a Max class. 00156 00157 @ingroup attr 00158 @param c The class pointer. 00159 @param attrname The name of this attribute as a C-string. 00160 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00161 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00162 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00163 @param size The number of floats in the array. 00164 */ 00165 #define CLASS_ATTR_FLOAT_ARRAY(c,attrname,flags,structname,structmember,size) \ 00166 class_addattr((c),attr_offset_array_new(attrname,USESYM(float32),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00167 00168 00169 /** 00170 Create an array-of-64bit-floats attribute of fixed length, and add it to a Max class. 00171 00172 @ingroup attr 00173 @param c The class pointer. 00174 @param attrname The name of this attribute as a C-string. 00175 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00176 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00177 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00178 @param size The number of doubles in the array. 00179 */ 00180 #define CLASS_ATTR_DOUBLE_ARRAY(c,attrname,flags,structname,structmember,size) \ 00181 class_addattr((c),attr_offset_array_new(attrname,USESYM(float64),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00182 00183 00184 /** 00185 Create an array-of-symbols attribute of fixed length, and add it to a Max class. 00186 00187 @ingroup attr 00188 @param c The class pointer. 00189 @param attrname The name of this attribute as a C-string. 00190 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00191 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00192 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00193 @param size The number of items in the #t_symbol* array. 00194 */ 00195 #define CLASS_ATTR_SYM_ARRAY(c,attrname,flags,structname,structmember,size) \ 00196 class_addattr((c),attr_offset_array_new(attrname,USESYM(symbol),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00197 00198 00199 /** 00200 Create an array-of-atoms attribute of fixed length, and add it to a Max class. 00201 00202 @ingroup attr 00203 @param c The class pointer. 00204 @param attrname The name of this attribute as a C-string. 00205 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00206 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00207 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00208 @param size The number of items in the #t_atom array. 00209 */ 00210 #define CLASS_ATTR_ATOM_ARRAY(c,attrname,flags,structname,structmember,size) \ 00211 class_addattr((c),attr_offset_array_new(attrname,USESYM(atom),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00212 00213 00214 /** 00215 Create an array-of-objects attribute of fixed length, and add it to a Max class. 00216 00217 @ingroup attr 00218 @param c The class pointer. 00219 @param attrname The name of this attribute as a C-string. 00220 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00221 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00222 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00223 @param size The number of items in the #t_object* array. 00224 */ 00225 #define CLASS_ATTR_OBJ_ARRAY(c,attrname,flags,structname,structmember,size) \ 00226 class_addattr((c),attr_offset_array_new(attrname,USESYM(object),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 00227 00228 00229 00230 00231 /** 00232 Create an array-of-chars attribute of variable length, and add it to a Max class. 00233 00234 @ingroup attr 00235 @param c The class pointer. 00236 @param attrname The name of this attribute as a C-string. 00237 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00238 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00239 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00240 @param sizemember The actual number of items in the char array at any given moment. 00241 @param maxsize The maximum number of items in the char array, i.e. the number of members allocated for the array in the struct. 00242 */ 00243 #define CLASS_ATTR_CHAR_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00244 class_addattr((c),attr_offset_array_new(attrname,USESYM(char),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00245 00246 00247 /** 00248 Create an array-of-long-integers attribute of variable length, and add it to a Max class. 00249 00250 @ingroup attr 00251 @param c The class pointer. 00252 @param attrname The name of this attribute as a C-string. 00253 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00254 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00255 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00256 @param sizemember The actual number of items in the long array at any given moment. 00257 @param maxsize The maximum number of items in the long array, i.e. the number of members allocated for the array in the struct. 00258 */ 00259 #define CLASS_ATTR_LONG_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00260 class_addattr((c),attr_offset_array_new(attrname,USESYM(long),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00261 00262 00263 /** 00264 Create an array-of-32bit-floats attribute of variable length, and add it to a Max class. 00265 00266 @ingroup attr 00267 @param c The class pointer. 00268 @param attrname The name of this attribute as a C-string. 00269 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00270 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00271 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00272 @param sizemember The actual number of items in the float array at any given moment. 00273 @param maxsize The maximum number of items in the float array, i.e. the number of members allocated for the array in the struct. 00274 */ 00275 #define CLASS_ATTR_FLOAT_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00276 class_addattr((c),attr_offset_array_new(attrname,USESYM(float32),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00277 00278 00279 /** 00280 Create an array-of-64bit-floats attribute of variable length, and add it to a Max class. 00281 00282 @ingroup attr 00283 @param c The class pointer. 00284 @param attrname The name of this attribute as a C-string. 00285 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00286 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00287 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00288 @param sizemember The actual number of items in the double array at any given moment. 00289 @param maxsize The maximum number of items in the double array, i.e. the number of members allocated for the array in the struct. 00290 */ 00291 #define CLASS_ATTR_DOUBLE_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00292 class_addattr((c),attr_offset_array_new(attrname,USESYM(float64),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00293 00294 00295 /** 00296 Create an array-of-symbols attribute of variable length, and add it to a Max class. 00297 00298 @ingroup attr 00299 @param c The class pointer. 00300 @param attrname The name of this attribute as a C-string. 00301 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00302 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00303 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00304 @param sizemember The actual number of items in the #t_symbol* array at any given moment. 00305 @param maxsize The maximum number of items in the #t_symbol* array, i.e. the number of members allocated for the array in the struct. 00306 */ 00307 #define CLASS_ATTR_SYM_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00308 class_addattr((c),attr_offset_array_new(attrname,USESYM(symbol),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00309 00310 00311 /** 00312 Create an array-of-atoms attribute of variable length, and add it to a Max class. 00313 00314 @ingroup attr 00315 @param c The class pointer. 00316 @param attrname The name of this attribute as a C-string. 00317 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00318 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00319 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00320 @param sizemember The actual number of items in the #t_atom array at any given moment. 00321 @param maxsize The maximum number of items in the #t_atom array, i.e. the number of members allocated for the array in the struct. 00322 */ 00323 #define CLASS_ATTR_ATOM_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00324 class_addattr((c),attr_offset_array_new(attrname,USESYM(atom),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00325 00326 00327 /** 00328 Create an array-of-objects attribute of variable length, and add it to a Max class. 00329 00330 @ingroup attr 00331 @param c The class pointer. 00332 @param attrname The name of this attribute as a C-string. 00333 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00334 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00335 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00336 @param sizemember The actual number of items in the #t_object* array at any given moment. 00337 @param maxsize The maximum number of items in the #t_object* array, i.e. the number of members allocated for the array in the struct. 00338 */ 00339 #define CLASS_ATTR_OBJ_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 00340 class_addattr((c),attr_offset_array_new(attrname,USESYM(object),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 00341 00342 00343 00344 00345 // "struct" attributes are just like class attributes, but the struct member name is the same as the attribute name 00346 // we use CMacro "stringification" in this case 00347 00348 // scalar variants 00349 00350 /** 00351 Create a char attribute and add it to a Max class. 00352 The name of the attribute is automatically determined by the name of the struct member. 00353 00354 @ingroup attr 00355 @param c The class pointer. 00356 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00357 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00358 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00359 */ 00360 #define STRUCT_ATTR_CHAR(c,flags,structname,structmember) CLASS_ATTR_CHAR(c,#structmember,flags,structname,structmember) 00361 00362 00363 /** 00364 Create a long integer attribute and add it to a Max class. 00365 The name of the attribute is automatically determined by the name of the struct member. 00366 00367 @ingroup attr 00368 @param c The class pointer. 00369 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00370 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00371 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00372 */ 00373 #define STRUCT_ATTR_LONG(c,flags,structname,structmember) CLASS_ATTR_LONG(c,#structmember,flags,structname,structmember) 00374 00375 00376 /** 00377 Create a 32bit float attribute and add it to a Max class. 00378 The name of the attribute is automatically determined by the name of the struct member. 00379 00380 @ingroup attr 00381 @param c The class pointer. 00382 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00383 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00384 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00385 */ 00386 #define STRUCT_ATTR_FLOAT(c,flags,structname,structmember) CLASS_ATTR_FLOAT(c,#structmember,flags,structname,structmember) 00387 00388 00389 /** 00390 Create a 64bit float attribute and add it to a Max class. 00391 The name of the attribute is automatically determined by the name of the struct member. 00392 00393 @ingroup attr 00394 @param c The class pointer. 00395 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00396 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00397 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00398 */ 00399 #define STRUCT_ATTR_DOUBLE(c,flags,structname,structmember) CLASS_ATTR_DOUBLE(c,#structmember,flags,structname,structmember) 00400 00401 00402 /** 00403 Create a #t_symbol* attribute and add it to a Max class. 00404 The name of the attribute is automatically determined by the name of the struct member. 00405 00406 @ingroup attr 00407 @param c The class pointer. 00408 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00409 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00410 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00411 */ 00412 #define STRUCT_ATTR_SYM(c,flags,structname,structmember) CLASS_ATTR_SYM(c,#structmember,flags,structname,structmember) 00413 00414 00415 /** 00416 Create a #t_atom attribute and add it to a Max class. 00417 The name of the attribute is automatically determined by the name of the struct member. 00418 00419 @ingroup attr 00420 @param c The class pointer. 00421 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00422 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00423 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00424 */ 00425 #define STRUCT_ATTR_ATOM(c,flags,structname,structmember) CLASS_ATTR_ATOM(c,#structmember,flags,structname,structmember) 00426 00427 00428 /** 00429 Create a #t_object* attribute and add it to a Max class. 00430 The name of the attribute is automatically determined by the name of the struct member. 00431 00432 @ingroup attr 00433 @param c The class pointer. 00434 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00435 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00436 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00437 */ 00438 #define STRUCT_ATTR_OBJ(c,flags,structname,structmember) CLASS_ATTR_OBJ(c,#structmember,flags,structname,structmember) 00439 00440 00441 00442 // fixed size array variants 00443 00444 /** 00445 Create an array-of-chars attribute of fixed length, and add it to a Max class. 00446 The name of the attribute is automatically determined by the name of the struct member. 00447 00448 @ingroup attr 00449 @param c The class pointer. 00450 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00451 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00452 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00453 @param size The number of items in the char array. 00454 */ 00455 #define STRUCT_ATTR_CHAR_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_CHAR_ARRAY(c,#structmember,flags,structname,structmember,size) 00456 00457 00458 /** 00459 Create an array-of-long-integers attribute of fixed length, and add it to a Max class. 00460 The name of the attribute is automatically determined by the name of the struct member. 00461 00462 @ingroup attr 00463 @param c The class pointer. 00464 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00465 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00466 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00467 @param size The number of items in the long array. 00468 */ 00469 #define STRUCT_ATTR_LONG_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_LONG_ARRAY(c,#structmember,flags,structname,structmember,size) 00470 00471 00472 /** 00473 Create an array-of-32bit-floats attribute of fixed length, and add it to a Max class. 00474 The name of the attribute is automatically determined by the name of the struct member. 00475 00476 @ingroup attr 00477 @param c The class pointer. 00478 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00479 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00480 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00481 @param size The number of items in the floats array. 00482 */ 00483 #define STRUCT_ATTR_FLOAT_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_FLOAT_ARRAY(c,#structmember,flags,structname,structmember,size) 00484 00485 00486 /** 00487 Create an array-of-64bit-floats attribute of fixed length, and add it to a Max class. 00488 The name of the attribute is automatically determined by the name of the struct member. 00489 00490 @ingroup attr 00491 @param c The class pointer. 00492 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00493 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00494 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00495 @param size The number of items in the double array. 00496 */ 00497 #define STRUCT_ATTR_DOUBLE_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_DOUBLE_ARRAY(c,#structmember,flags,structname,structmember,size) 00498 00499 00500 /** 00501 Create an array-of-symbols attribute of fixed length, and add it to a Max class. 00502 The name of the attribute is automatically determined by the name of the struct member. 00503 00504 @ingroup attr 00505 @param c The class pointer. 00506 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00507 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00508 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00509 @param size The number of items in the #t_symbol* array. 00510 */ 00511 #define STRUCT_ATTR_SYM_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_SYM_ARRAY(c,#structmember,flags,structname,structmember,size) 00512 00513 00514 /** 00515 Create an array-of-atoms attribute of fixed length, and add it to a Max class. 00516 The name of the attribute is automatically determined by the name of the struct member. 00517 00518 @ingroup attr 00519 @param c The class pointer. 00520 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00521 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00522 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00523 @param size The number of items in the #t_atom array. 00524 */ 00525 #define STRUCT_ATTR_ATOM_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_ATOM_ARRAY(c,#structmember,flags,structname,structmember,size) 00526 00527 00528 /** 00529 Create an array-of-objects attribute of fixed length, and add it to a Max class. 00530 The name of the attribute is automatically determined by the name of the struct member. 00531 00532 @ingroup attr 00533 @param c The class pointer. 00534 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00535 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00536 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00537 @param size The number of items in the #t_object* array. 00538 */ 00539 #define STRUCT_ATTR_OBJ_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_OBJ_ARRAY(c,#structmember,flags,structname,structmember,size) 00540 00541 00542 00543 00544 // variable size array variants 00545 00546 /** 00547 Create an array-of-chars attribute of variable length, and add it to a Max class. 00548 The name of the attribute is automatically determined by the name of the struct member. 00549 00550 @ingroup attr 00551 @param c The class pointer. 00552 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00553 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00554 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00555 @param sizemember The actual number of items in the char array at any given moment. 00556 @param maxsize The maximum number of items in the char array, i.e. the number of members allocated for the array in the struct. 00557 */ 00558 #define STRUCT_ATTR_CHAR_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_CHAR_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00559 00560 00561 /** 00562 Create an array-of-long-integers attribute of variable length, and add it to a Max class. 00563 The name of the attribute is automatically determined by the name of the struct member. 00564 00565 @ingroup attr 00566 @param c The class pointer. 00567 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00568 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00569 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00570 @param sizemember The actual number of items in the long array at any given moment. 00571 @param maxsize The maximum number of items in the long array, i.e. the number of members allocated for the array in the struct. 00572 */ 00573 #define STRUCT_ATTR_LONG_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_LONG_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00574 00575 00576 /** 00577 Create an array-of-32bit-floats attribute of variable length, and add it to a Max class. 00578 The name of the attribute is automatically determined by the name of the struct member. 00579 00580 @ingroup attr 00581 @param c The class pointer. 00582 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00583 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00584 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00585 @param sizemember The actual number of items in the float array at any given moment. 00586 @param maxsize The maximum number of items in the float array, i.e. the number of members allocated for the array in the struct. 00587 */ 00588 #define STRUCT_ATTR_FLOAT_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_FLOAT_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00589 00590 00591 /** 00592 Create an array-of-64bit-floats attribute of variable length, and add it to a Max class. 00593 The name of the attribute is automatically determined by the name of the struct member. 00594 00595 @ingroup attr 00596 @param c The class pointer. 00597 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00598 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00599 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00600 @param sizemember The actual number of items in the double array at any given moment. 00601 @param maxsize The maximum number of items in the double array, i.e. the number of members allocated for the array in the struct. 00602 */ 00603 #define STRUCT_ATTR_DOUBLE_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_DOUBLE_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00604 00605 00606 /** 00607 Create an array-of-symbols attribute of variable length, and add it to a Max class. 00608 The name of the attribute is automatically determined by the name of the struct member. 00609 00610 @ingroup attr 00611 @param c The class pointer. 00612 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00613 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00614 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00615 @param sizemember The actual number of items in the #t_symbol* array at any given moment. 00616 @param maxsize The maximum number of items in the #t_symbol* array, i.e. the number of members allocated for the array in the struct. 00617 */ 00618 #define STRUCT_ATTR_SYM_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_SYM_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00619 00620 00621 /** 00622 Create an array-of-atoms attribute of variable length, and add it to a Max class. 00623 The name of the attribute is automatically determined by the name of the struct member. 00624 00625 @ingroup attr 00626 @param c The class pointer. 00627 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00628 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00629 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00630 @param sizemember The actual number of items in the #t_atom array at any given moment. 00631 @param maxsize The maximum number of items in the #t_atom array, i.e. the number of members allocated for the array in the struct. 00632 */ 00633 #define STRUCT_ATTR_ATOM_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_ATOM_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00634 00635 00636 /** 00637 Create an array-of-objects attribute of variable length, and add it to a Max class. 00638 The name of the attribute is automatically determined by the name of the struct member. 00639 00640 @ingroup attr 00641 @param c The class pointer. 00642 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00643 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 00644 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 00645 @param sizemember The actual number of items in the #t_object* array at any given moment. 00646 @param maxsize The maximum number of items in the #t_object* array, i.e. the number of members allocated for the array in the struct. 00647 */ 00648 #define STRUCT_ATTR_OBJ_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_OBJ_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 00649 00650 00651 00652 00653 // class static variants 00654 #define STATIC_ATTR_ATOMS class_addattr_atoms 00655 #define STATIC_ATTR_PARSE class_addattr_parse 00656 #define STATIC_ATTR_FORMAT class_addattr_format 00657 00658 00659 /** 00660 Create a shared (static/global) char attribute and add it to a Max class. 00661 00662 @ingroup attr 00663 @param c The class pointer. 00664 @param attrname The name of this attribute as a C-string. 00665 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00666 @param val Pointer to the value. 00667 */ 00668 #define STATIC_ATTR_CHAR(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(char),flags,"c",val) 00669 00670 00671 /** 00672 Create a shared (static/global) long integer attribute and add it to a Max class. 00673 00674 @ingroup attr 00675 @param c The class pointer. 00676 @param attrname The name of this attribute as a C-string. 00677 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00678 @param val Pointer to the value. 00679 */ 00680 #define STATIC_ATTR_LONG(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(long),flags,"l",val) 00681 00682 00683 /** 00684 Create a shared (static/global) 32bit float attribute and add it to a Max class. 00685 00686 @ingroup attr 00687 @param c The class pointer. 00688 @param attrname The name of this attribute as a C-string. 00689 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00690 @param val Pointer to the value. 00691 */ 00692 #define STATIC_ATTR_FLOAT(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(float32),flags,"f",val) 00693 00694 00695 /** 00696 Create a shared (static/global) 64bit float attribute and add it to a Max class. 00697 00698 @ingroup attr 00699 @param c The class pointer. 00700 @param attrname The name of this attribute as a C-string. 00701 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00702 @param val Pointer to the value. 00703 */ 00704 #define STATIC_ATTR_DOUBLE(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(float64),flags,"d",val) 00705 00706 00707 /** 00708 Create a shared (static/global) #t_symbol* attribute and add it to a Max class. 00709 00710 @ingroup attr 00711 @param c The class pointer. 00712 @param attrname The name of this attribute as a C-string. 00713 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00714 @param val Pointer to the value. 00715 */ 00716 #define STATIC_ATTR_SYM(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(symbol),flags,"s",val) 00717 00718 00719 /** 00720 Create a shared (static/global) #t_atom attribute and add it to a Max class. 00721 00722 @ingroup attr 00723 @param c The class pointer. 00724 @param attrname The name of this attribute as a C-string. 00725 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00726 @param val Pointer to the value. 00727 */ 00728 #define STATIC_ATTR_ATOM(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(atom),flags,"a",val) 00729 00730 00731 /** 00732 Create a shared (static/global) #t_object* attribute and add it to a Max class. 00733 00734 @ingroup attr 00735 @param c The class pointer. 00736 @param attrname The name of this attribute as a C-string. 00737 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00738 @param val Pointer to the value. 00739 */ 00740 #define STATIC_ATTR_OBJ(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(object),flags,"o",val) 00741 00742 00743 00744 00745 /** 00746 Create a shared (static/global) array-of-chars attribute of fixed length, and add it to a Max class. 00747 00748 @ingroup attr 00749 @param c The class pointer. 00750 @param attrname The name of this attribute as a C-string. 00751 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00752 @param count The number of items in the char array. 00753 @param vals Pointer to the values. 00754 */ 00755 #define STATIC_ATTR_CHAR_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(char),flags,"C",count,vals) 00756 00757 00758 /** 00759 Create a shared (static/global) array-of-long-integers attribute of fixed length, and add it to a Max class. 00760 00761 @ingroup attr 00762 @param c The class pointer. 00763 @param attrname The name of this attribute as a C-string. 00764 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00765 @param count The number of items in the long array. 00766 @param vals Pointer to the values. 00767 */ 00768 #define STATIC_ATTR_LONG_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(long),flags,"L",count,vals) 00769 00770 00771 /** 00772 Create a shared (static/global) array-of-32bit-floats attribute of fixed length, and add it to a Max class. 00773 00774 @ingroup attr 00775 @param c The class pointer. 00776 @param attrname The name of this attribute as a C-string. 00777 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00778 @param count The number of items in the float array. 00779 @param vals Pointer to the values. 00780 */ 00781 #define STATIC_ATTR_FLOAT_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(float32),flags,"F",count,vals) 00782 00783 00784 /** 00785 Create a shared (static/global) array-of-64bit-floats attribute of fixed length, and add it to a Max class. 00786 00787 @ingroup attr 00788 @param c The class pointer. 00789 @param attrname The name of this attribute as a C-string. 00790 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00791 @param count The number of items in the double array. 00792 @param vals Pointer to the values. 00793 */ 00794 #define STATIC_ATTR_DOUBLE_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(float64),flags,"D",count,vals) 00795 00796 00797 /** 00798 Create a shared (static/global) array-of-symbols attribute of fixed length, and add it to a Max class. 00799 00800 @ingroup attr 00801 @param c The class pointer. 00802 @param attrname The name of this attribute as a C-string. 00803 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00804 @param count The number of items in the #t_symbol* array. 00805 @param vals Pointer to the values. 00806 */ 00807 #define STATIC_ATTR_SYM_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(symbol),flags,"S",count,vals) 00808 00809 00810 /** 00811 Create a shared (static/global) array-of-atoms attribute of fixed length, and add it to a Max class. 00812 00813 @ingroup attr 00814 @param c The class pointer. 00815 @param attrname The name of this attribute as a C-string. 00816 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00817 @param count The number of items in the #t_atom array. 00818 @param vals Pointer to the values. 00819 */ 00820 #define STATIC_ATTR_ATOM_ARRAY STATIC_ATTR_ATOMS // these are really the same, included for consistency 00821 00822 00823 /** 00824 Create a shared (static/global) array-of-objects attribute of fixed length, and add it to a Max class. 00825 00826 @ingroup attr 00827 @param c The class pointer. 00828 @param attrname The name of this attribute as a C-string. 00829 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00830 @param count The number of items in the #t_object* array. 00831 @param vals Pointer to the values. 00832 */ 00833 #define STATIC_ATTR_OBJ_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(object),flags,"O",count,vals) 00834 00835 00836 00837 00838 // object versions, creates new object local attribute 00839 #define OBJ_ATTR_ATOMS object_addattr_atoms 00840 #define OBJ_ATTR_PARSE object_addattr_parse 00841 #define OBJ_ATTR_FORMAT object_addattr_format 00842 00843 00844 /** 00845 Create an instance-local char attribute and add it to a Max class. 00846 00847 @ingroup attr 00848 @param x The object pointer. 00849 @param attrname The name of this attribute as a C-string. 00850 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00851 @param val Pointer to the value. 00852 */ 00853 #define OBJ_ATTR_CHAR(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(char),flags,"c",val) 00854 00855 00856 /** 00857 Create an instance-local long integer attribute and add it to a Max class. 00858 00859 @ingroup attr 00860 @param x The object pointer. 00861 @param attrname The name of this attribute as a C-string. 00862 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00863 @param val Pointer to the value. 00864 */ 00865 #define OBJ_ATTR_LONG(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(long),flags,"l",val) 00866 00867 00868 /** 00869 Create an instance-local 32bit float attribute and add it to a Max class. 00870 00871 @ingroup attr 00872 @param x The object pointer. 00873 @param attrname The name of this attribute as a C-string. 00874 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00875 @param val Pointer to the value. 00876 */ 00877 #define OBJ_ATTR_FLOAT(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(float32),flags,"f",val) 00878 00879 00880 /** 00881 Create an instance-local 64bit float attribute and add it to a Max class. 00882 00883 @ingroup attr 00884 @param x The object pointer. 00885 @param attrname The name of this attribute as a C-string. 00886 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00887 @param val Pointer to the value. 00888 */ 00889 #define OBJ_ATTR_DOUBLE(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(float64),flags,"d",val) 00890 00891 00892 /** 00893 Create an instance-local #t_symbol* attribute and add it to a Max class. 00894 00895 @ingroup attr 00896 @param x The object pointer. 00897 @param attrname The name of this attribute as a C-string. 00898 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00899 @param val Pointer to the value. 00900 */ 00901 #define OBJ_ATTR_SYM(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(symbol),flags,"s",val) 00902 00903 00904 /** 00905 Create an instance-local #t_atom attribute and add it to a Max class. 00906 00907 @ingroup attr 00908 @param x The object pointer. 00909 @param attrname The name of this attribute as a C-string. 00910 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00911 @param val Pointer to the value. 00912 */ 00913 #define OBJ_ATTR_ATOM(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(atom),flags,"a",val) 00914 00915 00916 /** 00917 Create an instance-local #t_object* attribute and add it to a Max class. 00918 00919 @ingroup attr 00920 @param x The object pointer. 00921 @param attrname The name of this attribute as a C-string. 00922 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00923 @param val Pointer to the value. 00924 */ 00925 #define OBJ_ATTR_OBJ(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(object),flags,"o",val) 00926 00927 00928 00929 00930 /** 00931 Create an instance-local array-of-chars attribute of fixed length, and add it to the object. 00932 00933 @ingroup attr 00934 @param x The object pointer. 00935 @param attrname The name of this attribute as a C-string. 00936 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00937 @param count The number of items in the char array. 00938 @param vals Pointer to the values. 00939 */ 00940 #define OBJ_ATTR_CHAR_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(char),flags,"C",count,vals) 00941 00942 00943 /** 00944 Create an instance-local array-of-long-integers attribute of fixed length, and add it to the object. 00945 00946 @ingroup attr 00947 @param x The object pointer. 00948 @param attrname The name of this attribute as a C-string. 00949 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00950 @param count The number of items in the long array. 00951 @param vals Pointer to the values. 00952 */ 00953 #define OBJ_ATTR_LONG_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(long),flags,"L",count,vals) 00954 00955 00956 /** 00957 Create an instance-local array-of-32bit-floats attribute of fixed length, and add it to the object. 00958 00959 @ingroup attr 00960 @param x The object pointer. 00961 @param attrname The name of this attribute as a C-string. 00962 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00963 @param count The number of items in the float array. 00964 @param vals Pointer to the values. 00965 */ 00966 #define OBJ_ATTR_FLOAT_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(float32),flags,"F",count,vals) 00967 00968 00969 /** 00970 Create an instance-local array-of-64bit-floats attribute of fixed length, and add it to the object. 00971 00972 @ingroup attr 00973 @param x The object pointer. 00974 @param attrname The name of this attribute as a C-string. 00975 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00976 @param count The number of items in the double array. 00977 @param vals Pointer to the values. 00978 */ 00979 #define OBJ_ATTR_DOUBLE_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(float64),flags,"D",count,vals) 00980 00981 00982 /** 00983 Create an instance-local array-of-symbols attribute of fixed length, and add it to the object. 00984 00985 @ingroup attr 00986 @param x The object pointer. 00987 @param attrname The name of this attribute as a C-string. 00988 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 00989 @param count The number of items in the #t_symbol* array. 00990 @param vals Pointer to the values. 00991 */ 00992 #define OBJ_ATTR_SYM_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(symbol),flags,"S",count,vals) 00993 00994 00995 /** 00996 Create an instance-local array-of-atoms attribute of fixed length, and add it to the object. 00997 00998 @ingroup attr 00999 @param x The object pointer. 01000 @param attrname The name of this attribute as a C-string. 01001 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 01002 @param count The number of items in the #t_atom array. 01003 @param vals Pointer to the values. 01004 */ 01005 #define OBJ_ATTR_ATOM_ARRAY OBJ_ATTR_ATOMS // these are really the same, included for consistency 01006 01007 01008 /** 01009 Create an instance-local array-of-objects attribute of fixed length, and add it to the object. 01010 01011 @ingroup attr 01012 @param x The object pointer. 01013 @param attrname The name of this attribute as a C-string. 01014 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 01015 @param count The number of items in the #t_object* array. 01016 @param vals Pointer to the values. 01017 */ 01018 #define OBJ_ATTR_OBJ_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(object),flags,"O",count,vals) 01019 01020 01021 01022 01023 01024 /** 01025 Specify custom accessor methods for an attribute. 01026 If you specify a non-NULL value for the setter or getter, 01027 then the function you specify will be called to set or get the attribute's value 01028 rather than using the built-in accessor. 01029 01030 @ingroup attr 01031 @param c The class pointer. 01032 @param attrname The name of the attribute as a C-string. 01033 @param getter An appropriate getter method as discussed in @ref attribute_accessors, 01034 or NULL to use the default getter. 01035 @param setter An appropriate setter method as discussed in @ref attribute_accessors, 01036 or NULL to use the default setter. 01037 */ 01038 #define CLASS_ATTR_ACCESSORS(c,attrname,getter,setter) \ 01039 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01040 object_method(theattr,gensym("setmethod"),USESYM(get),getter); \ 01041 object_method(theattr,gensym("setmethod"),USESYM(set),setter); } 01042 01043 01044 /** 01045 Add flags to an attribute. 01046 01047 @ingroup attr 01048 @param c The class pointer. 01049 @param attrname The name of the attribute as a C-string. 01050 @param flags Any flags you wish to add to this attribute, as defined in #e_max_attrflags. 01051 */ 01052 #define CLASS_ATTR_ADD_FLAGS(c,attrname,flags) \ 01053 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01054 long oldflags = object_method(theattr,gensym("getflags")); \ 01055 object_method(theattr,gensym("setflags"),oldflags|(flags)); } 01056 01057 01058 /** 01059 Remove flags from an attribute. 01060 01061 @ingroup attr 01062 @param c The class pointer. 01063 @param attrname The name of the attribute as a C-string. 01064 @param flags Any flags you wish to remove from this attribute, as defined in #e_max_attrflags. 01065 */ 01066 #define CLASS_ATTR_REMOVE_FLAGS(c,attrname,flags) \ 01067 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01068 long oldflags = object_method(theattr,gensym("getflags")); \ 01069 object_method(theattr,gensym("setflags"),oldflags&(~(flags))); } 01070 01071 01072 /** 01073 Add a filter to the attribute to limit the lower bound of a value. 01074 The limiting will be performed by the default attribute accessor. 01075 01076 @ingroup attr 01077 @param c The class pointer. 01078 @param attrname The name of the attribute as a C-string. 01079 @param minval The minimum acceptable value to which the attribute will be limited. 01080 @see CLASS_ATTR_FILTER_MAX 01081 @see CLASS_ATTR_FILTER_CLIP 01082 @see CLASS_ATTR_MIN 01083 */ 01084 #define CLASS_ATTR_FILTER_MIN(c,attrname,minval) \ 01085 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01086 attr_addfilter_clip(theattr,minval,0,1,0); } 01087 01088 01089 /** 01090 Add a filter to the attribute to limit the upper bound of a value. 01091 The limiting will be performed by the default attribute accessor. 01092 01093 @ingroup attr 01094 @param c The class pointer. 01095 @param attrname The name of the attribute as a C-string. 01096 @param maxval The maximum acceptable value to which the attribute will be limited. 01097 @see CLASS_ATTR_FILTER_MIN 01098 @see CLASS_ATTR_FILTER_CLIP 01099 @see CLASS_ATTR_MAX 01100 */ 01101 #define CLASS_ATTR_FILTER_MAX(c,attrname,maxval) \ 01102 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01103 attr_addfilter_clip(theattr,0,maxval,0,1); } 01104 01105 01106 /** 01107 Add a filter to the attribute to limit both the lower and upper bounds of a value. 01108 The limiting will be performed by the default attribute accessor. 01109 01110 @ingroup attr 01111 @param c The class pointer. 01112 @param attrname The name of the attribute as a C-string. 01113 @param minval The maximum acceptable value to which the attribute will be limited. 01114 @param maxval The maximum acceptable value to which the attribute will be limited. 01115 @see 01116 */ 01117 #define CLASS_ATTR_FILTER_CLIP(c,attrname,minval,maxval) \ 01118 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01119 attr_addfilter_clip(theattr,minval,maxval,1,1); } 01120 01121 01122 /** 01123 Create a new attribute that is an alias of an existing attribute. 01124 01125 @ingroup attr 01126 @param c The class pointer. 01127 @param attrname The name of the actual attribute as a C-string. 01128 @param aliasname The name of the new alias attribute. 01129 */ 01130 #define CLASS_ATTR_ALIAS(c,attrname,aliasname) \ 01131 { t_object *thealias; \ 01132 t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 01133 thealias = object_clone(theattr); \ 01134 object_method(thealias,USESYM(setname),gensym(aliasname)); \ 01135 class_addattr(c,thealias); \ 01136 CLASS_ATTR_ATTR_PARSE(c,aliasname,"alias",USESYM(symbol),0,attrname); } 01137 01138 01139 01140 01141 // macros for attribute of attributes 01142 #define CLASS_ATTR_ATTR_ATOMS class_attr_addattr_atoms 01143 #define CLASS_ATTR_ATTR_PARSE class_attr_addattr_parse 01144 #define CLASS_ATTR_ATTR_FORMAT class_attr_addattr_format 01145 01146 01147 /** 01148 Add a new attribute to the specified attribute to specify a default value. 01149 The default value will be automatically set when the object is created only if your object uses a dictionary constructor 01150 with the #CLASS_FLAG_NEWDICTIONARY flag. 01151 01152 @ingroup attr 01153 @param c The class pointer. 01154 @param attrname The name of the attribute as a C-string. 01155 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01156 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01157 */ 01158 #define CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr) \ 01159 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); CLASS_ATTR_ATTR_PARSE(c,attrname,"default",(t_symbol *)object_method(theattr,USESYM(gettype)),flags,parsestr); } 01160 01161 01162 /** 01163 Add a new attribute to the specified attribute to indicate that the specified attribute should be saved with the patcher. 01164 01165 @ingroup attr 01166 @param c The class pointer. 01167 @param attrname The name of the attribute as a C-string. 01168 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01169 */ 01170 #define CLASS_ATTR_SAVE(c,attrname,flags) \ 01171 CLASS_ATTR_ATTR_PARSE(c,attrname,"save",USESYM(long),flags,"1") 01172 01173 01174 /** 01175 A convenience wrapper for both #CLASS_ATTR_DEFAULT and #CLASS_ATTR_SAVE. 01176 01177 @ingroup attr 01178 @param c The class pointer. 01179 @param attrname The name of the attribute as a C-string. 01180 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01181 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01182 @see CLASS_ATTR_DEFAULT 01183 @see CLASS_ATTR_SAVE 01184 */ 01185 #define CLASS_ATTR_DEFAULT_SAVE(c,attrname,flags,parsestr) \ 01186 { CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); } 01187 01188 01189 /** 01190 Add a new attribute to the specified attribute to specify a default value, based on Max's Object Defaults. 01191 If a value is present in Max's Object Defaults, then that value will be used as the default value. 01192 Otherwise, use the default value specified here. 01193 The default value will be automatically set when the object is created only if your object uses a dictionary constructor 01194 with the #CLASS_FLAG_NEWDICTIONARY flag. 01195 01196 @ingroup attr 01197 @param c The class pointer. 01198 @param attrname The name of the attribute as a C-string. 01199 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01200 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01201 */ 01202 #define CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr) \ 01203 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); CLASS_ATTR_ATTR_PARSE(c,attrname,"defaultname",(t_symbol *)object_method(theattr,USESYM(gettype)),flags,parsestr); } 01204 01205 01206 /** 01207 A convenience wrapper for both #CLASS_ATTR_DEFAULTNAME and #CLASS_ATTR_SAVE. 01208 01209 @ingroup attr 01210 @param c The class pointer. 01211 @param attrname The name of the attribute as a C-string. 01212 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01213 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01214 @see CLASS_ATTR_DEFAULTNAME 01215 @see CLASS_ATTR_SAVE 01216 */ 01217 #define CLASS_ATTR_DEFAULTNAME_SAVE(c,attrname,flags,parsestr) \ 01218 { CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); } 01219 01220 01221 /** 01222 Add a new attribute to the specified attribute to specify a lower range. 01223 The values will not be automatically limited. 01224 01225 @ingroup attr 01226 @param c The class pointer. 01227 @param attrname The name of the attribute as a C-string. 01228 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01229 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01230 @see CLASS_ATTR_MAX 01231 @see CLASS_ATTR_FILTER_MAX 01232 @see CLASS_ATTR_FILTER_CLIP 01233 */ 01234 #define CLASS_ATTR_MIN(c,attrname,flags,parsestr) \ 01235 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); CLASS_ATTR_ATTR_PARSE(c,attrname,"min",(t_symbol *)object_method(theattr,USESYM(gettype)),flags,parsestr); } 01236 01237 01238 /** 01239 Add a new attribute to the specified attribute to specify an upper range. 01240 The values will not be automatically limited. 01241 01242 @ingroup attr 01243 @param c The class pointer. 01244 @param attrname The name of the attribute as a C-string. 01245 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01246 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01247 @see CLASS_ATTR_MIN 01248 @see CLASS_ATTR_FILTER_MAX 01249 @see CLASS_ATTR_FILTER_CLIP 01250 */ 01251 #define CLASS_ATTR_MAX(c,attrname,flags,parsestr) \ 01252 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); CLASS_ATTR_ATTR_PARSE(c,attrname,"max",(t_symbol *)object_method(theattr,USESYM(gettype)),flags,parsestr); } 01253 01254 01255 // useful attr attr macros for UI objects 01256 01257 /** 01258 Add a new attribute indicating that any changes to the specified attribute will trigger a call 01259 to the object's paint method. 01260 01261 @ingroup attr 01262 @param c The class pointer. 01263 @param attrname The name of the attribute as a C-string. 01264 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01265 */ 01266 #define CLASS_ATTR_PAINT(c,attrname,flags) \ 01267 CLASS_ATTR_ATTR_PARSE(c,attrname,"paint",USESYM(long),flags,"1") 01268 01269 01270 /** 01271 A convenience wrapper for both #CLASS_ATTR_DEFAULT and #CLASS_ATTR_PAINT. 01272 01273 @ingroup attr 01274 @param c The class pointer. 01275 @param attrname The name of the attribute as a C-string. 01276 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01277 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01278 @see CLASS_ATTR_DEFAULT 01279 @see CLASS_ATTR_PAINT 01280 */ 01281 #define CLASS_ATTR_DEFAULT_PAINT(c,attrname,flags,parsestr) \ 01282 { CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr); CLASS_ATTR_PAINT(c,attrname,flags); } 01283 01284 01285 /** 01286 A convenience wrapper for #CLASS_ATTR_DEFAULT, #CLASS_ATTR_SAVE, and #CLASS_ATTR_PAINT. 01287 01288 @ingroup attr 01289 @param c The class pointer. 01290 @param attrname The name of the attribute as a C-string. 01291 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01292 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01293 @see CLASS_ATTR_DEFAULT 01294 @see CLASS_ATTR_PAINT 01295 @see CLASS_ATTR_SAVE 01296 */ 01297 #define CLASS_ATTR_DEFAULT_SAVE_PAINT(c,attrname,flags,parsestr) \ 01298 { CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); CLASS_ATTR_PAINT(c,attrname,flags); } 01299 01300 01301 /** 01302 A convenience wrapper for #CLASS_ATTR_DEFAULTNAME, #CLASS_ATTR_SAVE, and #CLASS_ATTR_PAINT. 01303 01304 @ingroup attr 01305 @param c The class pointer. 01306 @param attrname The name of the attribute as a C-string. 01307 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01308 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01309 @see CLASS_ATTR_DEFAULTNAME 01310 @see CLASS_ATTR_PAINT 01311 @see CLASS_ATTR_SAVE 01312 */ 01313 #define CLASS_ATTR_DEFAULTNAME_PAINT(c,attrname,flags,parsestr) \ 01314 { CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr); CLASS_ATTR_PAINT(c,attrname,flags); } 01315 01316 01317 /** 01318 A convenience wrapper for #CLASS_ATTR_DEFAULTNAME, #CLASS_ATTR_SAVE, and #CLASS_ATTR_PAINT. 01319 01320 @ingroup attr 01321 @param c The class pointer. 01322 @param attrname The name of the attribute as a C-string. 01323 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01324 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01325 @see CLASS_ATTR_DEFAULTNAME 01326 @see CLASS_ATTR_PAINT 01327 @see CLASS_ATTR_SAVE 01328 */ 01329 #define CLASS_ATTR_DEFAULTNAME_SAVE_PAINT(c,attrname,flags,parsestr) \ 01330 { CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); CLASS_ATTR_PAINT(c,attrname,flags); } 01331 01332 01333 // useful attr attr macros for inpector properties 01334 01335 01336 /** 01337 Add a new attribute to the specified attribute to specify an editor style for the Max inspector. 01338 Available styles include 01339 <ul> 01340 <li>"text" : a text editor</li> 01341 <li>"onoff" : a toggle switch</li> 01342 <li>"rgba" : a color chooser</li> 01343 <li>"enum" : a menu of available choices, whose symbol will be passed upon selection</li> 01344 <li>"enumindex" : a menu of available choices, whose index will be passed upon selection</li> 01345 <li>"rect" : a style for displaying and editing #t_rect values</li> 01346 <li>"font" : a font chooser</li> 01347 <li>"file" : a file chooser dialog</li> 01348 </ul> 01349 01350 @ingroup attr 01351 @param c The class pointer. 01352 @param attrname The name of the attribute as a C-string. 01353 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01354 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01355 */ 01356 #define CLASS_ATTR_STYLE(c,attrname,flags,parsestr) \ 01357 CLASS_ATTR_ATTR_PARSE(c,attrname,"style",USESYM(symbol),flags,parsestr) 01358 01359 01360 /** 01361 Add a new attribute to the specified attribute to specify an a human-friendly label for the Max inspector. 01362 01363 @ingroup attr 01364 @param c The class pointer. 01365 @param attrname The name of the attribute as a C-string. 01366 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01367 @param labelstr A C-string, which will be parsed into an array of atoms to set the initial value. 01368 */ 01369 #define CLASS_ATTR_LABEL(c,attrname,flags,labelstr) \ 01370 CLASS_ATTR_ATTR_FORMAT(c,attrname,"label",USESYM(symbol),flags,"s",gensym(labelstr)) 01371 01372 01373 /** 01374 Add a new attribute to the specified attribute to specify a list of choices to display in a menu 01375 for the Max inspector. 01376 01377 @ingroup attr 01378 @param c The class pointer. 01379 @param attrname The name of the attribute as a C-string. 01380 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01381 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01382 01383 @remark This macro automatically calls 01384 @code 01385 CLASS_ATTR_STYLE(c,attrname,flags,"enum"). 01386 @endcode 01387 01388 @see CLASS_ATTR_ENUMINDEX 01389 */ 01390 #define CLASS_ATTR_ENUM(c,attrname,flags,parsestr) \ 01391 { CLASS_ATTR_STYLE(c,attrname,flags,"enum"); CLASS_ATTR_ATTR_PARSE(c,attrname,"enumvals",USESYM(atom),flags,parsestr); } 01392 01393 01394 /** 01395 Add a new attribute to the specified attribute to specify a list of choices to display in a menu 01396 for the Max inspector. 01397 01398 @ingroup attr 01399 @param c The class pointer. 01400 @param attrname The name of the attribute as a C-string. 01401 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01402 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01403 01404 @remark This macro automatically calls 01405 @code 01406 CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"). 01407 @endcode 01408 01409 @see CLASS_ATTR_ENUM 01410 */ 01411 #define CLASS_ATTR_ENUMINDEX(c,attrname,flags,parsestr) \ 01412 { CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); CLASS_ATTR_ATTR_PARSE(c,attrname,"enumvals",USESYM(atom),flags,parsestr); } 01413 01414 01415 /** 01416 Add a new attribute to the specified attribute to specify a category to which the attribute is assigned 01417 in the Max inspector. 01418 Categories are represented in the inspector as tabs. 01419 If the specified category does not exist then it will be created. 01420 01421 @ingroup attr 01422 @param c The class pointer. 01423 @param attrname The name of the attribute as a C-string. 01424 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01425 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01426 */ 01427 #define CLASS_ATTR_CATEGORY(c,attrname,flags,parsestr) \ 01428 CLASS_ATTR_ATTR_PARSE(c,attrname,"category",USESYM(symbol),flags,parsestr) 01429 01430 01431 /** 01432 A convenience wrapper for #CLASS_ATTR_STYLE, and #CLASS_ATTR_LABEL. 01433 01434 @ingroup attr 01435 @param c The class pointer. 01436 @param attrname The name of the attribute as a C-string. 01437 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01438 @param stylestr A C-string that names the style for the attribute. 01439 See #CLASS_ATTR_STYLE for the available styles. 01440 @param labelstr A C-string that names the category to which the attribute is assigned in the inspector. 01441 01442 @see CLASS_ATTR_STYLE 01443 @see CLASS_ATTR_LABEL 01444 */ 01445 #define CLASS_ATTR_STYLE_LABEL(c,attrname,flags,stylestr,labelstr) \ 01446 { CLASS_ATTR_ATTR_PARSE(c,attrname,"style",USESYM(symbol),flags,stylestr); CLASS_ATTR_ATTR_FORMAT(c,attrname,"label",USESYM(symbol),flags,"s",gensym(labelstr)); } 01447 01448 01449 /** 01450 Add a new attribute to the specified attribute to flag an attribute as invisible to the Max inspector. 01451 01452 @ingroup attr 01453 @param c The class pointer. 01454 @param attrname The name of the attribute as a C-string. 01455 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01456 */ 01457 #define CLASS_ATTR_INVISIBLE(c,attrname,flags) \ 01458 CLASS_ATTR_ATTR_PARSE(c,attrname,"invisible",USESYM(long),flags,"1") 01459 01460 01461 /** 01462 Add a new attribute to the specified attribute to specify a default order in which to list attributes. 01463 01464 @ingroup attr 01465 @param c The class pointer. 01466 @param attrname The name of the attribute as a C-string. 01467 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01468 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01469 01470 @remark A value of zero indicates that there is no ordering. Ordering values begin at 1. For example: 01471 @code 01472 CLASS_ATTR_ORDER(c, "firstattr", 0, "1"); 01473 CLASS_ATTR_ORDER(c, "secondattr", 0, "2"); 01474 CLASS_ATTR_ORDER(c, "thirdattr", 0, "3"); 01475 @endcode 01476 */ 01477 #define CLASS_ATTR_ORDER(c,attrname,flags,parsestr) \ 01478 CLASS_ATTR_ATTR_PARSE(c,attrname,"order",USESYM(long),flags,parsestr) 01479 01480 01481 01482 // useful attr attr macro for objects that embed binary data as base64 01483 01484 #define CLASS_ATTR_ATOMARRAY(c,attrname,flags) \ 01485 CLASS_ATTR_ATTR_PARSE(c,attrname,"atomarray",USESYM(long),flags,"1") 01486 01487 01488 /** Define and add attributes to class methods. 01489 @ingroup attr 01490 @param c The class pointer. 01491 @param methodname The name of the existing method as a C-string. 01492 @param attrname The name of the attribute to add as a C-string. 01493 @param type The datatype of the attribute to be added. 01494 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01495 @param parsestring A C-string, which will be parsed into an array of atoms to set the initial value. 01496 01497 @remark An example which makes a method invisible to users: 01498 @code 01499 class_addmethod(c, (method)my_foo, "foo", 0); 01500 CLASS_METHOD_ATTR_PARSE(c, "foo", "undocumented", gensym("long"), 0, "1"); 01501 @endcode 01502 */ 01503 #define CLASS_METHOD_ATTR_PARSE(c,methodname,attrname,type,flags,parsestring) \ 01504 { t_hashtab *methods=NULL; \ 01505 t_object *m=NULL; \ 01506 methods = (t_hashtab *)class_extra_lookup(c,gensym("methods")); \ 01507 if (methods) { \ 01508 hashtab_lookup(methods,gensym((methodname)),&m); \ 01509 if (m) \ 01510 object_addattr_parse(m,attrname,type,flags,parsestring); \ 01511 } \ 01512 } 01513 01514 01515 #define OBJ_ATTR_ATTR_ATOMS object_attr_addattr_atoms 01516 #define OBJ_ATTR_ATTR_PARSE object_attr_addattr_parse 01517 #define OBJ_ATTR_ATTR_FORMAT object_attr_addattr_format 01518 01519 01520 /** 01521 An instance-attribute version of #CLASS_ATTR_DEFAULT. 01522 01523 @ingroup attr 01524 @param x The #t_object instance pointer. 01525 @param attrname The name of the attribute as a C-string. 01526 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01527 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01528 @see CLASS_ATTR_DEFAULT 01529 */ 01530 #define OBJ_ATTR_DEFAULT(x,attrname,flags,parsestr) \ 01531 { t_object *theattr=(t_object *)object_attr_get(x,gensym(attrname)); OBJ_ATTR_ATTR_PARSE(x,attrname,"default",(t_symbol *)object_method(theattr,USESYM(gettype)),flags,parsestr); } 01532 01533 01534 /** 01535 An instance-attribute version of #CLASS_ATTR_SAVE. 01536 01537 @ingroup attr 01538 @param x The #t_object instance pointer. 01539 @param attrname The name of the attribute as a C-string. 01540 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01541 @see CLASS_ATTR_SAVE 01542 */ 01543 #define OBJ_ATTR_SAVE(x,attrname,flags) \ 01544 OBJ_ATTR_ATTR_PARSE(x,attrname,"save",USESYM(long),flags,"1") 01545 01546 01547 /** 01548 An instance-attribute version of #CLASS_ATTR_DEFAULT_SAVE. 01549 01550 @ingroup attr 01551 @param x The #t_object instance pointer. 01552 @param attrname The name of the attribute as a C-string. 01553 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01554 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01555 @see CLASS_ATTR_DEFAULT_SAVE 01556 */ 01557 #define OBJ_ATTR_DEFAULT_SAVE(x,attrname,flags,parsestr) \ 01558 { OBJ_ATTR_DEFAULT(x,attrname,flags,parsestr); OBJ_ATTR_SAVE(x,attrname,flags); } 01559 01560 01561 // sticky macros for attribute attributes, and method attributes. Useful for defining attribute groups 01562 01563 /** 01564 Create an attribute, and add it to all following attribute declarations. 01565 The block is closed by a call to #CLASS_STICKY_ATTR_CLEAR. 01566 01567 @ingroup attr 01568 @param c The class pointer. 01569 @param name The name of the new attribute to create as a C-string. 01570 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01571 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01572 01573 @remark The most common use of CLASS_STICKY_ATTR is for creating multiple attributes with the same category, 01574 as in this example: 01575 @code 01576 CLASS_STICKY_ATTR(c, "category", 0, "Foo"); 01577 01578 CLASS_ATTR_DOUBLE(c, "bar", 0, t_myobject, x_bar); 01579 CLASS_ATTR_LABEL(c, "bar", 0, "A Bar"); 01580 01581 CLASS_ATTR_CHAR(c, "switch", 0, t_myobject, x_switch); 01582 CLASS_ATTR_STYLE_LABEL(c, "switch", 0, "onoff", "Bar Switch"); 01583 01584 CLASS_ATTR_DOUBLE(c, "flow", 0, t_myobject, x_flow); 01585 CLASS_ATTR_LABEL(c, "flow", 0, "Flow Amount"); 01586 01587 CLASS_STICKY_ATTR_CLEAR(c, "category"); 01588 @endcode 01589 01590 @see CLASS_STICKY_ATTR_CLEAR 01591 */ 01592 #define CLASS_STICKY_ATTR(c,name,flags,parsestr) \ 01593 { t_object *attr = attribute_new_parse(name,NULL,flags,parsestr); class_sticky(c,gensym("sticky_attr"),gensym(name),attr); } 01594 01595 01596 /** 01597 Close a #CLASS_STICKY_ATTR block. 01598 01599 @ingroup attr 01600 @param c The class pointer. 01601 @param name The name of the sticky attribute as a C-string. 01602 @see CLASS_STICKY_ATTR 01603 */ 01604 #define CLASS_STICKY_ATTR_CLEAR(c,name) class_sticky_clear(c,gensym("sticky_attr"),name?gensym(name):NULL) 01605 01606 01607 /** 01608 Create an attribute, and add it to all following method declarations. 01609 The block is closed by a call to #CLASS_STICKY_METHOD_CLEAR. 01610 01611 @ingroup attr 01612 @param c The class pointer. 01613 @param name The name of the new attribute to create as a C-string. 01614 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01615 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01616 01617 @remark The most common use of CLASS_STICKY_ATTR is for creating multiple attributes with the same category, 01618 as in this example: 01619 @code 01620 CLASS_STICKY_METHOD(c, "undocumented", 0, "1"); 01621 01622 // add some methods here with class_add_method() 01623 // the undocumented attribute for methods means that the ref-page 01624 // generator will ignore these methods. 01625 01626 CLASS_STICKY_METHOD_CLEAR(c, "undocumented"); 01627 @endcode 01628 01629 @see CLASS_STICKY_METHOD_CLEAR 01630 */ 01631 #define CLASS_STICKY_METHOD(c,name,flags,parsestr) \ 01632 { t_object *attr = attribute_new_parse(name,NULL,flags,parsestr); class_sticky(c,gensym("sticky_method"),gensym(name),attr); } 01633 01634 01635 /** 01636 Close a #CLASS_STICKY_METHOD block. 01637 01638 @ingroup attr 01639 @param c The class pointer. 01640 @param name The name of the sticky attribute as a C-string. 01641 @see CLASS_STICKY_METHOD 01642 */ 01643 #define CLASS_STICKY_METHOD_CLEAR(c,name) class_sticky_clear(c,gensym("sticky_method"),name?gensym(name):clear) 01644 01645 01646 01647 01648 // support for long lists 01649 01650 #define OBEX_UTIL_MAX_ATOM_GETBYTES 4095 01651 #define OBEX_UTIL_MAX_ATOM_STATIC 2048 01652 01653 01654 //static memory case 01655 #define OBEX_UTIL_ATOM_SETUP_VAR_STATIC t_atom atemp[OBEX_UTIL_MAX_ATOM_STATIC]; t_atom *av2=atemp; long ac2=OBEX_UTIL_MAX_ATOM_STATIC; 01656 #define OBEX_UTIL_ATOM_CLEANUP_VAR_STATIC 01657 #define OBEX_UTIL_ATOM_SETUP_ARRAY_STATIC(ac) t_atom atemp[OBEX_UTIL_MAX_ATOM_STATIC]; t_atom *av2=atemp; long ac2; ac2 = MIN(ac,OBEX_UTIL_MAX_ATOM_STATIC); 01658 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_STATIC(ac) 01659 01660 01661 //dynamic memory case 01662 #define OBEX_UTIL_ATOM_SETUP_VAR_DYN t_atom *av2=NULL; long ac2=0; 01663 #define OBEX_UTIL_ATOM_CLEANUP_VAR_DYN if (ac2&&av2) mm_freebytes((char *)av2,sizeof(t_atom)*ac2); 01664 #define OBEX_UTIL_ATOM_SETUP_ARRAY_DYN(ac) t_atom *av2=NULL; long ac2=0; av2 = (t_atom *)mm_getbytes(sizeof(t_atom)*ac); ac2 = ac; 01665 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_DYN(ac) if (ac2&&av2) mm_freebytes(av2,sizeof(t_atom)*ac2); 01666 01667 01668 //combo static/dynamic. faster for smaller atom lists on input, but not limited 01669 #define OBEX_UTIL_ATOM_SETUP_VAR_COMBO OBEX_UTIL_ATOM_SETUP_VAR_DYN // same for VAR 01670 #define OBEX_UTIL_ATOM_CLEANUP_VAR_COMBO OBEX_UTIL_ATOM_CLEANUP_VAR_DYN // same for VAR 01671 #define OBEX_UTIL_ATOM_SETUP_ARRAY_COMBO(ac) \ 01672 t_atom atemp[OBEX_UTIL_MAX_ATOM_STATIC]; \ 01673 t_atom *av2=atemp; \ 01674 long ac2; \ 01675 long usestatic=1; \ 01676 ac2 = MIN(ac,OBEX_UTIL_MAX_ATOM_STATIC); \ 01677 if (ac>OBEX_UTIL_MAX_ATOM_STATIC) { usestatic=0; av2 = (t_atom *)mm_getbytes(sizeof(t_atom)*ac); ac2=ac; } 01678 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_COMBO(ac) if ((!usestatic)&&ac2&&av2) mm_freebytes((char *)av2,sizeof(t_atom)*ac2); 01679 01680 01681 // default to combo 01682 #define OBEX_UTIL_ATOM_SETUP_VAR OBEX_UTIL_ATOM_SETUP_VAR_COMBO 01683 #define OBEX_UTIL_ATOM_CLEANUP_VAR OBEX_UTIL_ATOM_CLEANUP_VAR_COMBO 01684 #define OBEX_UTIL_ATOM_SETUP_ARRAY OBEX_UTIL_ATOM_SETUP_ARRAY_COMBO 01685 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY OBEX_UTIL_ATOM_CLEANUP_ARRAY_COMBO 01686 01687 01688 /** 01689 Flags that determine how functions convert atoms into text (C-strings). 01690 @ingroup atom 01691 */ 01692 typedef enum{ 01693 OBEX_UTIL_ATOM_GETTEXT_DEFAULT = 0x00000000, ///< default translation rules for getting text from atoms 01694 OBEX_UTIL_ATOM_GETTEXT_TRUNCATE_ZEROS = 0x00000001, ///< eliminate redundant zeros for floating point numbers (default used) 01695 OBEX_UTIL_ATOM_GETTEXT_SYM_NO_QUOTE = 0x00000002, ///< don't introduce quotes around symbols with spaces 01696 OBEX_UTIL_ATOM_GETTEXT_SYM_FORCE_QUOTE = 0x00000004, ///< always introduce quotes around symbols (useful for JSON) 01697 OBEX_UTIL_ATOM_GETTEXT_COMMA_DELIM = 0x00000008, ///< separate atoms with commas (useful for JSON) 01698 OBEX_UTIL_ATOM_GETTEXT_FORCE_ZEROS = 0x00000010, ///< always print the zeros 01699 OBEX_UTIL_ATOM_GETTEXT_NUM_HI_RES = 0x00000020 ///< print more decimal places 01700 } e_max_atom_gettext_flags; 01701 01702 01703 // atom utilities (will move to atomutils2.c) 01704 01705 /** 01706 Assign an array of char values to an array of atoms. 01707 01708 @ingroup atom 01709 @param ac The number of atoms to try to fetch from the array of chars. 01710 You should have at least this number of atoms allocated in av. 01711 @param av The address to the first of an array of allocated atoms. 01712 @param count The number of values in the array specified by vals. 01713 @param vals The array from which to copy the values into the array of atoms at av. 01714 @return A Max error code. 01715 */ 01716 t_max_err atom_setchar_array(long ac, t_atom *av, long count, unsigned char *vals); 01717 01718 01719 /** 01720 Assign an array of long integer values to an array of atoms. 01721 01722 @ingroup atom 01723 @param ac The number of atoms to try to fetch from the array of longs. 01724 You should have at least this number of atoms allocated in av. 01725 @param av The address to the first of an array of allocated atoms. 01726 @param count The number of values in the array specified by vals. 01727 @param vals The array from which to copy the values into the array of atoms at av. 01728 @return A Max error code. 01729 */ 01730 t_max_err atom_setlong_array(long ac, t_atom *av, long count, long *vals); 01731 01732 01733 /** 01734 Assign an array of 32bit float values to an array of atoms. 01735 01736 @ingroup atom 01737 @param ac The number of atoms to try to fetch from the array of floats. 01738 You should have at least this number of atoms allocated in av. 01739 @param av The address to the first of an array of allocated atoms. 01740 @param count The number of values in the array specified by vals. 01741 @param vals The array from which to copy the values into the array of atoms at av. 01742 @return A Max error code. 01743 */ 01744 t_max_err atom_setfloat_array(long ac, t_atom *av, long count, float *vals); 01745 01746 01747 /** 01748 Assign an array of 64bit float values to an array of atoms. 01749 01750 @ingroup atom 01751 @param ac The number of atoms to try to fetch from the array of doubles. 01752 You should have at least this number of atoms allocated in av. 01753 @param av The address to the first of an array of allocated atoms. 01754 @param count The number of values in the array specified by vals. 01755 @param vals The array from which to copy the values into the array of atoms at av. 01756 @return A Max error code. 01757 */ 01758 t_max_err atom_setdouble_array(long ac, t_atom *av, long count, double *vals); 01759 01760 01761 /** 01762 Assign an array of #t_symbol* values to an array of atoms. 01763 01764 @ingroup atom 01765 @param ac The number of atoms to try to fetch from the array of symbols. 01766 You should have at least this number of atoms allocated in av. 01767 @param av The address to the first of an array of allocated atoms. 01768 @param count The number of values in the array specified by vals. 01769 @param vals The array from which to copy the values into the array of atoms at av. 01770 @return A Max error code. 01771 */ 01772 t_max_err atom_setsym_array(long ac, t_atom *av, long count, t_symbol **vals); 01773 01774 01775 /** 01776 Assign an array of #t_atom values to an array of atoms. 01777 01778 @ingroup atom 01779 @param ac The number of atoms to try to fetch from the second array of atoms. 01780 You should have at least this number of atoms allocated in av. 01781 @param av The address to the first of an array of allocated atoms. 01782 @param count The number of values in the array specified by vals. 01783 @param vals The array from which to copy the values into the array of atoms at av. 01784 @return A Max error code. 01785 */ 01786 t_max_err atom_setatom_array(long ac, t_atom *av, long count, t_atom *vals); 01787 01788 01789 /** 01790 Assign an array of #t_object* values to an array of atoms. 01791 01792 @ingroup atom 01793 @param ac The number of atoms to try to fetch from the array of objects. 01794 You should have at least this number of atoms allocated in av. 01795 @param av The address to the first of an array of allocated atoms. 01796 @param count The number of values in the array specified by vals. 01797 @param vals The array from which to copy the values into the array of atoms at av. 01798 @return A Max error code. 01799 */ 01800 t_max_err atom_setobj_array(long ac, t_atom *av, long count, t_object **vals); 01801 01802 01803 // these variable size calls can alloc mem if desired 01804 01805 /** 01806 Parse a C-string into an array of atoms. 01807 This function allocates memory for the atoms if the ac and av parameters are NULL. 01808 Otherwise it will attempt to use any memory already allocated to av. 01809 Any allocated memory should be freed with sysmem_freeptr(). 01810 01811 @ingroup atom 01812 @param ac The address of a variable to hold the number of returned atoms. 01813 @param av The address of a #t_atom pointer to which memory may be allocated and atoms copied. 01814 @param parsestr The C-string to parse. 01815 @return A Max error code. 01816 01817 @remark The following example will parse the string "foo bar 1 2 3.0" into an array of 5 atoms. 01818 The atom types will be determined automatically as 2 #A_SYM atoms, 2 #A_LONG atoms, and 1 #A_FLOAT atom. 01819 @code 01820 t_atom *av = NULL; 01821 long ac = 0; 01822 t_max_err err = MAX_ERR_NONE; 01823 01824 err = atom_setparse(&ac, &av, "foo bar 1 2 3.0"); 01825 @endcode 01826 */ 01827 t_max_err atom_setparse(long *ac, t_atom **av, char *parsestr); 01828 01829 01830 t_max_err atom_setbinbuf(long *ac, t_atom **av, void *buf); 01831 01832 01833 t_max_err atom_setattrval(long *ac, t_atom **av, t_symbol *attrname, t_object *obj); 01834 01835 01836 t_max_err atom_setobjval(long *ac, t_atom **av, t_object *obj); 01837 01838 01839 01840 01841 /** 01842 Create an array of atoms populated with values using sprintf-like syntax. 01843 atom_setformat() supports clfdsoaCLFDSOA tokens 01844 (primitive type scalars and arrays respectively for the 01845 char, long, float, double, #t_symbol*, #t_object*, #t_atom*). 01846 It also supports vbp@ tokens (obval, binbuf, parsestr, attribute). 01847 01848 This function allocates memory for the atoms if the ac and av parameters are NULL. 01849 Otherwise it will attempt to use any memory already allocated to av. 01850 Any allocated memory should be freed with sysmem_freeptr(). 01851 01852 @ingroup atom 01853 01854 @param ac The address of a variable to hold the number of returned atoms. 01855 @param av The address of a #t_atom pointer to which memory may be allocated and atoms copied. 01856 @param fmt An sprintf-style format string specifying values for the atoms. 01857 @param ... One or more arguments which are to be substituted into the format string. 01858 01859 @return A Max error code. 01860 @see atom_getformat() 01861 @see atom_setparse() 01862 */ 01863 t_max_err atom_setformat(long *ac, t_atom **av, char *fmt, ...); 01864 01865 01866 /** 01867 Retrieve values from an array of atoms using sscanf-like syntax. 01868 atom_getformat() supports clfdsoaCLFDSOA tokens 01869 (primitive type scalars and arrays respectively for the 01870 char, long, float, double, #t_symbol*, #t_object*, #t_atom*). 01871 It does not support vbp@ the tokens found in atom_setformat(). 01872 01873 @ingroup atom 01874 01875 @param ac The number of atoms to parse in av. 01876 @param av The address of the first #t_atom pointer in an array to parse. 01877 @param fmt An sscanf-style format string specifying types for the atoms. 01878 @param ... One or more arguments which are address of variables to be set according to the fmt string. 01879 01880 @return A Max error code. 01881 @see atom_setformat() 01882 */ 01883 t_max_err atom_getformat(long ac, t_atom *av, char *fmt, ...); 01884 01885 01886 /** 01887 Convert an array of atoms into a C-string. 01888 01889 @ingroup atom 01890 01891 @param ac The number of atoms to fetch in av. 01892 @param av The address of the first #t_atom pointer in an array to retrieve. 01893 @param textsize The size of the string to which the atoms will be formatted and copied. 01894 @param text The address of the string to which the text will be written. 01895 @param flags Determines the rules by which atoms will be translated into text. 01896 Values are bit mask as defined by #e_max_atom_gettext_flags. 01897 01898 @return A Max error code. 01899 @see atom_setparse() 01900 */ 01901 t_max_err atom_gettext(long ac, t_atom *av, long *textsize, char **text, long flags); 01902 01903 01904 /** 01905 Fetch an array of char values from an array of atoms. 01906 01907 @ingroup atom 01908 @param ac The number of atoms allocated in the av parameter. 01909 @param av The address to the first of an array of allocated atoms. 01910 @param count The number of values to fetch from the array specified by vals. 01911 @param vals The address of the array to which is copied the values from av. 01912 @return A Max error code. 01913 */ 01914 t_max_err atom_getchar_array(long ac, t_atom *av, long count, unsigned char *vals); 01915 01916 01917 /** 01918 Fetch an array of long integer values from an array of atoms. 01919 01920 @ingroup atom 01921 @param ac The number of atoms allocated in the av parameter. 01922 @param av The address to the first of an array of allocated atoms. 01923 @param count The number of values to fetch from the array specified by vals. 01924 @param vals The address of the array to which is copied the values from av. 01925 @return A Max error code. 01926 */ 01927 t_max_err atom_getlong_array(long ac, t_atom *av, long count, long *vals); 01928 01929 01930 /** 01931 Fetch an array of 32bit float values from an array of atoms. 01932 01933 @ingroup atom 01934 @param ac The number of atoms allocated in the av parameter. 01935 @param av The address to the first of an array of allocated atoms. 01936 @param count The number of values to fetch from the array specified by vals. 01937 @param vals The address of the array to which is copied the values from av. 01938 @return A Max error code. 01939 */ 01940 t_max_err atom_getfloat_array(long ac, t_atom *av, long count, float *vals); 01941 01942 01943 /** 01944 Fetch an array of 64bit float values from an array of atoms. 01945 01946 @ingroup atom 01947 @param ac The number of atoms allocated in the av parameter. 01948 @param av The address to the first of an array of allocated atoms. 01949 @param count The number of values to fetch from the array specified by vals. 01950 @param vals The address of the array to which is copied the values from av. 01951 @return A Max error code. 01952 */ 01953 t_max_err atom_getdouble_array(long ac, t_atom *av, long count, double *vals); 01954 01955 01956 /** 01957 Fetch an array of #t_symbol* values from an array of atoms. 01958 01959 @ingroup atom 01960 @param ac The number of atoms allocated in the av parameter. 01961 @param av The address to the first of an array of allocated atoms. 01962 @param count The number of values to fetch from the array specified by vals. 01963 @param vals The address of the array to which is copied the values from av. 01964 @return A Max error code. 01965 */ 01966 t_max_err atom_getsym_array(long ac, t_atom *av, long count, t_symbol **vals); 01967 01968 01969 /** 01970 Fetch an array of #t_atom values from an array of atoms. 01971 01972 @ingroup atom 01973 @param ac The number of atoms allocated in the av parameter. 01974 @param av The address to the first of an array of allocated atoms. 01975 @param count The number of values to fetch from the array specified by vals. 01976 @param vals The address of the array to which is copied the values from av. 01977 @return A Max error code. 01978 */ 01979 t_max_err atom_getatom_array(long ac, t_atom *av, long count, t_atom *vals); 01980 01981 01982 /** 01983 Fetch an array of #t_object* values from an array of atoms. 01984 01985 @ingroup atom 01986 @param ac The number of atoms allocated in the av parameter. 01987 @param av The address to the first of an array of allocated atoms. 01988 @param count The number of values to fetch from the array specified by vals. 01989 @param vals The address of the array to which is copied the values from av. 01990 @return A Max error code. 01991 */ 01992 t_max_err atom_getobj_array(long ac, t_atom *av, long count, t_object **vals); 01993 01994 01995 01996 /** 01997 Determines whether or not an atom represents a #t_string object. 01998 01999 @ingroup atom 02000 @param a The address of the atom to test. 02001 @return Returns true if the #t_atom contains a valid #t_string object. 02002 */ 02003 long atomisstring(t_atom *a); 02004 02005 02006 /** 02007 Determines whether or not an atom represents a #t_atomarray object. 02008 02009 @ingroup atom 02010 @param a The address of the atom to test. 02011 @return Returns true if the #t_atom contains a valid #t_atomarray object. 02012 */ 02013 long atomisatomarray(t_atom *a); 02014 02015 02016 /** 02017 Determines whether or not an atom represents a #t_dictionary object. 02018 02019 @ingroup atom 02020 @param a The address of the atom to test. 02021 @return Returns true if the #t_atom contains a valid #t_dictionary object. 02022 */ 02023 long atomisdictionary(t_atom *a); 02024 02025 02026 02027 // quick object programming macros 02028 #define msg(x,p) object_method_parse(x,NULL,p,NULL); 02029 02030 02031 //object_method_typed utilities 02032 02033 /** 02034 Convenience wrapper for object_method_typed() that uses atom_setparse() to define the arguments. 02035 02036 @ingroup obj 02037 @param x The object to which the message will be sent. 02038 @param s The name of the method to call on the object. 02039 @param parsestr A C-string to parse into an array of atoms to pass to the method. 02040 @param rv The address of an atom to hold a return value. 02041 @return A Max error code. 02042 02043 @see object_method_typed() 02044 @see atom_setparse() 02045 */ 02046 t_max_err object_method_parse(t_object *x, t_symbol *s, char *parsestr, t_atom *rv); 02047 t_max_err object_method_binbuf(t_object *x, t_symbol *s, void *buf, t_atom *rv); 02048 t_max_err object_method_attrval(t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj, t_atom *rv); 02049 t_max_err object_method_objval(t_object *x, t_symbol *s, t_object *obj, t_atom *rv); 02050 02051 /** 02052 Convenience wrapper for object_method_typed() that uses atom_setformat() to define the arguments. 02053 02054 @ingroup obj 02055 @param x The object to which the message will be sent. 02056 @param s The name of the method to call on the object. 02057 @param rv The address of an atom to hold a return value. 02058 @param fmt An sprintf-style format string specifying values for the atoms. 02059 @param ... One or more arguments which are to be substituted into the format string. 02060 @return A Max error code. 02061 02062 @see object_method_typed() 02063 @see atom_setformat() 02064 */ 02065 t_max_err object_method_format(t_object *x, t_symbol *s, t_atom *rv, char *fmt, ...); 02066 02067 02068 02069 /** 02070 Convenience wrapper for object_method_typed() that passes a single char as an argument. 02071 02072 @ingroup obj 02073 @param x The object to which the message will be sent. 02074 @param s The name of the method to call on the object. 02075 @param v An argument to pass to the method. 02076 @param rv The address of an atom to hold a return value. 02077 02078 @return A Max error code. 02079 @see object_method_typed() 02080 */ 02081 t_max_err object_method_char(t_object *x, t_symbol *s, unsigned char v, t_atom *rv); 02082 02083 02084 /** 02085 Convenience wrapper for object_method_typed() that passes a single long integer as an argument. 02086 02087 @ingroup obj 02088 @param x The object to which the message will be sent. 02089 @param s The name of the method to call on the object. 02090 @param v An argument to pass to the method. 02091 @param rv The address of an atom to hold a return value. 02092 02093 @return A Max error code. 02094 @see object_method_typed() 02095 */ 02096 t_max_err object_method_long(t_object *x, t_symbol *s, long v, t_atom *rv); 02097 02098 02099 /** 02100 Convenience wrapper for object_method_typed() that passes a single 32bit float as an argument. 02101 02102 @ingroup obj 02103 @param x The object to which the message will be sent. 02104 @param s The name of the method to call on the object. 02105 @param v An argument to pass to the method. 02106 @param rv The address of an atom to hold a return value. 02107 02108 @return A Max error code. 02109 @see object_method_typed() 02110 */ 02111 t_max_err object_method_float(t_object *x, t_symbol *s, float v, t_atom *rv); 02112 02113 02114 /** 02115 Convenience wrapper for object_method_typed() that passes a single 64bit float as an argument. 02116 02117 @ingroup obj 02118 @param x The object to which the message will be sent. 02119 @param s The name of the method to call on the object. 02120 @param v An argument to pass to the method. 02121 @param rv The address of an atom to hold a return value. 02122 02123 @return A Max error code. 02124 @see object_method_typed() 02125 */ 02126 t_max_err object_method_double(t_object *x, t_symbol *s, double v, t_atom *rv); 02127 02128 02129 /** 02130 Convenience wrapper for object_method_typed() that passes a single #t_symbol* as an argument. 02131 02132 @ingroup obj 02133 @param x The object to which the message will be sent. 02134 @param s The name of the method to call on the object. 02135 @param v An argument to pass to the method. 02136 @param rv The address of an atom to hold a return value. 02137 02138 @return A Max error code. 02139 @see object_method_typed() 02140 */ 02141 t_max_err object_method_sym(t_object *x, t_symbol *s, t_symbol *v, t_atom *rv); 02142 02143 02144 /** 02145 Convenience wrapper for object_method_typed() that passes a single #t_object* as an argument. 02146 02147 @ingroup obj 02148 @param x The object to which the message will be sent. 02149 @param s The name of the method to call on the object. 02150 @param v An argument to pass to the method. 02151 @param rv The address of an atom to hold a return value. 02152 02153 @return A Max error code. 02154 @see object_method_typed() 02155 */ 02156 t_max_err object_method_obj(t_object *x, t_symbol *s, t_object *v, t_atom *rv); 02157 02158 02159 02160 /** 02161 Convenience wrapper for object_method_typed() that passes an array of char values as an argument. 02162 02163 @ingroup obj 02164 @param x The object to which the message will be sent. 02165 @param s The name of the method to call on the object. 02166 @param ac The number of arguments to pass to the method. 02167 @param av The address of the first of the array of arguments to pass to the method. 02168 @param rv The address of an atom to hold a return value. 02169 02170 @return A Max error code. 02171 @see object_method_typed() 02172 */ 02173 t_max_err object_method_char_array(t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv); 02174 02175 02176 /** 02177 Convenience wrapper for object_method_typed() that passes an array of long integers values as an argument. 02178 02179 @ingroup obj 02180 @param x The object to which the message will be sent. 02181 @param s The name of the method to call on the object. 02182 @param ac The number of arguments to pass to the method. 02183 @param av The address of the first of the array of arguments to pass to the method. 02184 @param rv The address of an atom to hold a return value. 02185 02186 @return A Max error code. 02187 @see object_method_typed() 02188 */ 02189 t_max_err object_method_long_array(t_object *x, t_symbol *s, long ac, long *av, t_atom *rv); 02190 02191 02192 /** 02193 Convenience wrapper for object_method_typed() that passes an array of 32bit floats values as an argument. 02194 02195 @ingroup obj 02196 @param x The object to which the message will be sent. 02197 @param s The name of the method to call on the object. 02198 @param ac The number of arguments to pass to the method. 02199 @param av The address of the first of the array of arguments to pass to the method. 02200 @param rv The address of an atom to hold a return value. 02201 02202 @return A Max error code. 02203 @see object_method_typed() 02204 */ 02205 t_max_err object_method_float_array(t_object *x, t_symbol *s, long ac, float *av, t_atom *rv); 02206 02207 02208 /** 02209 Convenience wrapper for object_method_typed() that passes an array of 64bit float values as an argument. 02210 02211 @ingroup obj 02212 @param x The object to which the message will be sent. 02213 @param s The name of the method to call on the object. 02214 @param ac The number of arguments to pass to the method. 02215 @param av The address of the first of the array of arguments to pass to the method. 02216 @param rv The address of an atom to hold a return value. 02217 02218 @return A Max error code. 02219 @see object_method_typed() 02220 */ 02221 t_max_err object_method_double_array(t_object *x, t_symbol *s, long ac, double *av, t_atom *rv); 02222 02223 02224 /** 02225 Convenience wrapper for object_method_typed() that passes an array of #t_symbol* values as an argument. 02226 02227 @ingroup obj 02228 @param x The object to which the message will be sent. 02229 @param s The name of the method to call on the object. 02230 @param ac The number of arguments to pass to the method. 02231 @param av The address of the first of the array of arguments to pass to the method. 02232 @param rv The address of an atom to hold a return value. 02233 02234 @return A Max error code. 02235 @see object_method_typed() 02236 */ 02237 t_max_err object_method_sym_array(t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv); 02238 02239 02240 /** 02241 Convenience wrapper for object_method_typed() that passes an array of #t_object* values as an argument. 02242 02243 @ingroup obj 02244 @param x The object to which the message will be sent. 02245 @param s The name of the method to call on the object. 02246 @param ac The number of arguments to pass to the method. 02247 @param av The address of the first of the array of arguments to pass to the method. 02248 @param rv The address of an atom to hold a return value. 02249 02250 @return A Max error code. 02251 @see object_method_typed() 02252 */ 02253 t_max_err object_method_obj_array(t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv); 02254 02255 02256 // call_method_typed utilities -- not currently used in any Cycling '74 code 02257 02258 t_max_err call_method_typed(method m, t_object *x, t_symbol *s, long ac, t_atom *av, t_atom *rv); 02259 t_max_err call_method_parse(method m, t_object *x, t_symbol *s, char *parsestr, t_atom *rv); 02260 t_max_err call_method_binbuf(method m, t_object *x, t_symbol *s, void *buf, t_atom *rv); 02261 t_max_err call_method_attrval(method m, t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj, t_atom *rv); 02262 t_max_err call_method_objval(method m, t_object *x, t_symbol *s, t_object *obj, t_atom *rv); 02263 t_max_err call_method_format(method m, t_object *x, t_symbol *s, t_atom *rv, char *fmt, ...); 02264 02265 t_max_err call_method_char(method m, t_object *x, t_symbol *s, unsigned char v, t_atom *rv); 02266 t_max_err call_method_long(method m, t_object *x, t_symbol *s, long v, t_atom *rv); 02267 t_max_err call_method_float(method m, t_object *x, t_symbol *s,float v, t_atom *rv); 02268 t_max_err call_method_double(method m, t_object *x, t_symbol *s, double v, t_atom *rv); 02269 t_max_err call_method_sym(method m, t_object *x, t_symbol *s, t_symbol *v, t_atom *rv); 02270 t_max_err call_method_obj(method m, t_object *x, t_symbol *s, t_object *v, t_atom *rv); 02271 02272 t_max_err call_method_char_array(method m, t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv); 02273 t_max_err call_method_long_array(method m, t_object *x, t_symbol *s, long ac, long *av, t_atom *rv); 02274 t_max_err call_method_float_array(method m, t_object *x, t_symbol *s, long ac, float *av, t_atom *rv); 02275 t_max_err call_method_double_array(method m, t_object *x, t_symbol *s, long ac, double *av, t_atom *rv); 02276 t_max_err call_method_sym_array(method m, t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv); 02277 t_max_err call_method_obj_array(method m, t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv); 02278 02279 02280 // object attribute methods (will move to attribtue_util.c with the rest of these) 02281 02282 /** 02283 Set an attribute value with one or more atoms parsed from a C-string. 02284 02285 @ingroup attr 02286 @param x The object whose attribute will be set. 02287 @param s The name of the attribute to set. 02288 @param parsestr A C-string to parse into an array of atoms to set the attribute value. 02289 @return A Max error code. 02290 @see atom_setparse() 02291 */ 02292 t_max_err object_attr_setparse(t_object *x, t_symbol *s, char *parsestr); 02293 t_max_err object_attr_setbinbuf(t_object *x, t_symbol *s, void *buf); 02294 t_max_err object_attr_setattrval(t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj); 02295 t_max_err object_attr_setobjval(t_object *x, t_symbol *s, t_object *obj); 02296 t_max_err object_attr_setformat(t_object *x, t_symbol *s, char *fmt, ...); 02297 02298 02299 // t_attribute these probably belong in attribute.c 02300 t_object *attribute_new_atoms(char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 02301 t_object *attribute_new_parse(char *attrname, t_symbol *type, long flags, char *parsestr); 02302 t_object *attribute_new_binbuf(char *attrname, t_symbol *type, long flags, void *buf); 02303 t_object *attribute_new_attrval(char *attrname, t_symbol *type, long flags, t_symbol *objattrname, t_object *obj); 02304 t_object *attribute_new_objval(char *attrname, t_symbol *type, long flags, t_object *obj); 02305 t_object *attribute_new_format(char *attrname, t_symbol *type, long flags, char *fmt, ...); 02306 02307 02308 // general object constructors for objects with typed constructors 02309 02310 /** 02311 Create a new object with one or more atoms parsed from a C-string. 02312 The object's new method must have an #A_GIMME signature. 02313 02314 @ingroup attr 02315 @param name_space The namespace in which to create the instance. Typically this is either #CLASS_BOX or #CLASS_NOBOX. 02316 @param classname The name of the class to instantiate. 02317 @param parsestr A C-string to parse into an array of atoms to set the attribute value. 02318 02319 @return A pointer to the new instance. 02320 @see atom_setparse() 02321 @see object_new_typed() 02322 */ 02323 void *object_new_parse(t_symbol *name_space, t_symbol *classname, char *parsestr); 02324 void *object_new_binbuf(t_symbol *name_space, t_symbol *classname, void *buf); 02325 void *object_new_attrval(t_symbol *name_space, t_symbol *classname, t_symbol *objattrname, t_object *obj); 02326 void *object_new_objval(t_symbol *name_space, t_symbol *classname, t_object *obj); 02327 void *object_new_format(t_symbol *name_space, t_symbol *classname, char *fmt, ...); // not used or tested in any Cycling '74 code 02328 02329 02330 // attr attr functions necessary due to offset attributes as singletons for the class 02331 // need to copy object local to set any attributes. 02332 // undocumented for now in favor of using the macros defined above. 02333 02334 t_max_err object_attr_addattr(t_object *x, t_symbol *attrname, t_object *attr); 02335 t_object *object_attr_attr_get(t_object *x, t_symbol *attrname, t_symbol *attrname2); 02336 t_max_err object_attr_attr_setvalueof(t_object *x, t_symbol *attrname, t_symbol *attrname2, long argc, t_atom *argv); 02337 t_max_err object_attr_attr_getvalueof(t_object *x, t_symbol *attrname, t_symbol *attrname2, long *argc, t_atom **argv); 02338 02339 t_max_err class_attr_addattr(t_class *c, t_symbol *attrname, t_object *attr); 02340 t_object *class_attr_attr_get(t_class *c, t_symbol *attrname, t_symbol *attrname2); 02341 t_max_err class_attr_attr_setvalueof(t_class *c, t_symbol *attrname, t_symbol *attrname2, long argc, t_atom *argv); 02342 t_max_err class_attr_attr_getvalueof(t_class *c, t_symbol *attrname, t_symbol *attrname2, long *argc, t_atom **argv); 02343 02344 t_max_err object_attr_enforcelocal(t_object *x, t_symbol *attrname); 02345 02346 t_max_err class_addattr_atoms(t_class *c, char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 02347 t_max_err class_addattr_parse(t_class *c, char *attrname, t_symbol *type, long flags, char *parsestr); 02348 t_max_err class_addattr_format(t_class *c, char *attrname, t_symbol *type, long flags, char *fmt, ...); 02349 t_max_err class_attr_addattr_atoms(t_class *c, char *attrname, char *attrname2, t_symbol *type, long flags, long ac, t_atom *av); 02350 t_max_err class_attr_addattr_parse(t_class *c, char *attrname, char *attrname2, t_symbol *type, long flags, char *parsestr); 02351 t_max_err class_attr_addattr_format(t_class *c, char *attrname, char *attrname2, t_symbol *type, long flags, char *fmt, ...); 02352 02353 t_max_err object_addattr_atoms(t_object *x, char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 02354 t_max_err object_addattr_parse(t_object *x, char *attrname, t_symbol *type, long flags, char *parsestr); 02355 t_max_err object_addattr_format(t_object *x, char *attrname, t_symbol *type, long flags, char *fmt, ...); 02356 t_max_err object_attr_addattr_atoms(t_object *x, char *attrname, char *attrname2, t_symbol *type, long flags, long ac, t_atom *av); 02357 t_max_err object_attr_addattr_parse(t_object *x, char *attrname, char *attrname2, t_symbol *type, long flags, char *parsestr); 02358 t_max_err object_attr_addattr_format(t_object *x, char *attrname, char *attrname2, t_symbol *type, long flags, char *fmt, ...); 02359 02360 02361 // other general functions from obex.c 02362 t_object *object_clone(t_object *x); 02363 t_object *object_clone_generic(t_object *x); 02364 02365 // this function has been de-activated and now does nothing 02366 void object_zero(t_object *x); 02367 02368 02369 // menu command stuff 02370 02371 t_max_err class_addcommand(t_class *c, method cmd, method enabler, method handler, char *message); 02372 void *object_commandenabled(t_object *o, t_symbol *cmd); 02373 t_max_err object_getenabler(t_object *c, t_symbol *cmd, method *m); 02374 t_max_err object_getcommand(t_object *o, t_symbol *cmd, method *m); 02375 void *object_handlecommand(t_object *o, t_symbol *s, long argc, t_atom *argv, t_atom *rv); 02376 02377 t_max_err object_attr_setdisabled(t_object *o, t_symbol *attrname, long way); 02378 02379 #ifdef __cplusplus 02380 } 02381 #endif // __cplusplus 02382 02383 #endif //__OBEX_UTIL_H__
Copyright © 2008, Cycling '74