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 // attach attrs to class methods 01488 #define CLASS_METHOD_ATTR_PARSE(c,methodname,attrname,type,flags,parsestring) \ 01489 { t_hashtab *methods=NULL; \ 01490 t_object *m=NULL; \ 01491 methods = (t_hashtab *)class_extra_lookup(c,gensym("methods")); \ 01492 if (methods) { \ 01493 hashtab_lookup(methods,gensym((methodname)),&m); \ 01494 if (m) \ 01495 object_addattr_parse(m,attrname,type,flags,parsestring); \ 01496 } \ 01497 } 01498 01499 01500 #define OBJ_ATTR_ATTR_ATOMS object_attr_addattr_atoms 01501 #define OBJ_ATTR_ATTR_PARSE object_attr_addattr_parse 01502 #define OBJ_ATTR_ATTR_FORMAT object_attr_addattr_format 01503 01504 01505 /** 01506 An instance-attribute version of #CLASS_ATTR_DEFAULT. 01507 01508 @ingroup attr 01509 @param x The #t_object instance pointer. 01510 @param attrname The name of the attribute as a C-string. 01511 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01512 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01513 @see CLASS_ATTR_DEFAULT 01514 */ 01515 #define OBJ_ATTR_DEFAULT(x,attrname,flags,parsestr) \ 01516 { 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); } 01517 01518 01519 /** 01520 An instance-attribute version of #CLASS_ATTR_SAVE. 01521 01522 @ingroup attr 01523 @param x The #t_object instance pointer. 01524 @param attrname The name of the attribute as a C-string. 01525 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01526 @see CLASS_ATTR_SAVE 01527 */ 01528 #define OBJ_ATTR_SAVE(x,attrname,flags) \ 01529 OBJ_ATTR_ATTR_PARSE(x,attrname,"save",USESYM(long),flags,"1") 01530 01531 01532 /** 01533 An instance-attribute version of #CLASS_ATTR_DEFAULT_SAVE. 01534 01535 @ingroup attr 01536 @param x The #t_object instance pointer. 01537 @param attrname The name of the attribute as a C-string. 01538 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01539 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01540 @see CLASS_ATTR_DEFAULT_SAVE 01541 */ 01542 #define OBJ_ATTR_DEFAULT_SAVE(x,attrname,flags,parsestr) \ 01543 { OBJ_ATTR_DEFAULT(x,attrname,flags,parsestr); OBJ_ATTR_SAVE(x,attrname,flags); } 01544 01545 01546 // sticky macros for attribute attributes, and method attributes. Useful for defining attribute groups 01547 01548 /** 01549 Create an attribute, and add it to all following attribute declarations. 01550 The block is closed by a call to #CLASS_STICKY_ATTR_CLEAR. 01551 01552 @ingroup attr 01553 @param c The class pointer. 01554 @param name The name of the new attribute to create as a C-string. 01555 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01556 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01557 01558 @remark The most common use of CLASS_STICKY_ATTR is for creating multiple attributes with the same category, 01559 as in this example: 01560 @code 01561 CLASS_STICKY_ATTR(c, "category", 0, "Foo"); 01562 01563 CLASS_ATTR_DOUBLE(c, "bar", 0, t_myobject, x_bar); 01564 CLASS_ATTR_LABEL(c, "bar", 0, "A Bar"); 01565 01566 CLASS_ATTR_CHAR(c, "switch", 0, t_myobject, x_switch); 01567 CLASS_ATTR_STYLE_LABEL(c, "switch", 0, "onoff", "Bar Switch"); 01568 01569 CLASS_ATTR_DOUBLE(c, "flow", 0, t_myobject, x_flow); 01570 CLASS_ATTR_LABEL(c, "flow", 0, "Flow Amount"); 01571 01572 CLASS_STICKY_ATTR_CLEAR(c, "category"); 01573 @endcode 01574 01575 @see CLASS_STICKY_ATTR_CLEAR 01576 */ 01577 #define CLASS_STICKY_ATTR(c,name,flags,parsestr) \ 01578 { t_object *attr = attribute_new_parse(name,NULL,flags,parsestr); class_sticky(c,gensym("sticky_attr"),gensym(name),attr); } 01579 01580 01581 /** 01582 Close a #CLASS_STICKY_ATTR block. 01583 01584 @ingroup attr 01585 @param c The class pointer. 01586 @param name The name of the sticky attribute as a C-string. 01587 @see CLASS_STICKY_ATTR 01588 */ 01589 #define CLASS_STICKY_ATTR_CLEAR(c,name) class_sticky_clear(c,gensym("sticky_attr"),name?gensym(name):NULL) 01590 01591 01592 /** 01593 Create an attribute, and add it to all following method declarations. 01594 The block is closed by a call to #CLASS_STICKY_METHOD_CLEAR. 01595 01596 @ingroup attr 01597 @param c The class pointer. 01598 @param name The name of the new attribute to create as a C-string. 01599 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 01600 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 01601 01602 @remark The most common use of CLASS_STICKY_ATTR is for creating multiple attributes with the same category, 01603 as in this example: 01604 @code 01605 CLASS_STICKY_ATTR(c, "undocumented", 0, "1"); 01606 01607 // add some methods here with class_add_method() 01608 // the undocumented attribute for methods means that the ref-page 01609 // generator will ignore these methods. 01610 01611 CLASS_STICKY_ATTR_CLEAR(c, "undocumented"); 01612 @endcode 01613 01614 @see CLASS_STICKY_METHOD_CLEAR 01615 */ 01616 #define CLASS_STICKY_METHOD(c,name,flags,parsestr) \ 01617 { t_object *attr = attribute_new_parse(name,NULL,flags,parsestr); class_sticky(c,gensym("sticky_method"),gensym(name),attr); } 01618 01619 01620 /** 01621 Close a #CLASS_STICKY_METHOD block. 01622 01623 @ingroup attr 01624 @param c The class pointer. 01625 @param name The name of the sticky attribute as a C-string. 01626 @see CLASS_STICKY_METHOD 01627 */ 01628 #define CLASS_STICKY_METHOD_CLEAR(c,name) class_sticky_clear(c,gensym("sticky_method"),name?gensym(name):clear) 01629 01630 01631 01632 01633 // support for long lists 01634 01635 #define OBEX_UTIL_MAX_ATOM_GETBYTES 4095 01636 #define OBEX_UTIL_MAX_ATOM_STATIC 2048 01637 01638 01639 //static memory case 01640 #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; 01641 #define OBEX_UTIL_ATOM_CLEANUP_VAR_STATIC 01642 #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); 01643 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_STATIC(ac) 01644 01645 01646 //dynamic memory case 01647 #define OBEX_UTIL_ATOM_SETUP_VAR_DYN t_atom *av2=NULL; long ac2=0; 01648 #define OBEX_UTIL_ATOM_CLEANUP_VAR_DYN if (ac2&&av2) mm_freebytes((char *)av2,sizeof(t_atom)*ac2); 01649 #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; 01650 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_DYN(ac) if (ac2&&av2) mm_freebytes(av2,sizeof(t_atom)*ac2); 01651 01652 01653 //combo static/dynamic. faster for smaller atom lists on input, but not limited 01654 #define OBEX_UTIL_ATOM_SETUP_VAR_COMBO OBEX_UTIL_ATOM_SETUP_VAR_DYN // same for VAR 01655 #define OBEX_UTIL_ATOM_CLEANUP_VAR_COMBO OBEX_UTIL_ATOM_CLEANUP_VAR_DYN // same for VAR 01656 #define OBEX_UTIL_ATOM_SETUP_ARRAY_COMBO(ac) \ 01657 t_atom atemp[OBEX_UTIL_MAX_ATOM_STATIC]; \ 01658 t_atom *av2=atemp; \ 01659 long ac2; \ 01660 long usestatic=1; \ 01661 ac2 = MIN(ac,OBEX_UTIL_MAX_ATOM_STATIC); \ 01662 if (ac>OBEX_UTIL_MAX_ATOM_STATIC) { usestatic=0; av2 = (t_atom *)mm_getbytes(sizeof(t_atom)*ac); ac2=ac; } 01663 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_COMBO(ac) if ((!usestatic)&&ac2&&av2) mm_freebytes((char *)av2,sizeof(t_atom)*ac2); 01664 01665 01666 // default to combo 01667 #define OBEX_UTIL_ATOM_SETUP_VAR OBEX_UTIL_ATOM_SETUP_VAR_COMBO 01668 #define OBEX_UTIL_ATOM_CLEANUP_VAR OBEX_UTIL_ATOM_CLEANUP_VAR_COMBO 01669 #define OBEX_UTIL_ATOM_SETUP_ARRAY OBEX_UTIL_ATOM_SETUP_ARRAY_COMBO 01670 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY OBEX_UTIL_ATOM_CLEANUP_ARRAY_COMBO 01671 01672 01673 /** 01674 Flags that determine how functions convert atoms into text (C-strings). 01675 @ingroup atom 01676 */ 01677 typedef enum{ 01678 OBEX_UTIL_ATOM_GETTEXT_DEFAULT = 0x00000000, ///< default translation rules for getting text from atoms 01679 OBEX_UTIL_ATOM_GETTEXT_TRUNCATE_ZEROS = 0x00000001, ///< eliminate redundant zeros for floating point numbers (default used) 01680 OBEX_UTIL_ATOM_GETTEXT_SYM_NO_QUOTE = 0x00000002, ///< don't introduce quotes around symbols with spaces 01681 OBEX_UTIL_ATOM_GETTEXT_SYM_FORCE_QUOTE = 0x00000004, ///< always introduce quotes around symbols (useful for JSON) 01682 OBEX_UTIL_ATOM_GETTEXT_COMMA_DELIM = 0x00000008, ///< separate atoms with commas (useful for JSON) 01683 OBEX_UTIL_ATOM_GETTEXT_FORCE_ZEROS = 0x00000010, ///< always print the zeros 01684 OBEX_UTIL_ATOM_GETTEXT_NUM_HI_RES = 0x00000020 ///< print more decimal places 01685 } e_max_atom_gettext_flags; 01686 01687 01688 // atom utilities (will move to atomutils2.c) 01689 01690 /** 01691 Assign an array of char values to an array of atoms. 01692 01693 @ingroup atom 01694 @param ac The number of atoms to try to fetch from the array of chars. 01695 You should have at least this number of atoms allocated in av. 01696 @param av The address to the first of an array of allocated atoms. 01697 @param count The number of values in the array specified by vals. 01698 @param vals The array from which to copy the values into the array of atoms at av. 01699 @return A Max error code. 01700 */ 01701 t_max_err atom_setchar_array(long ac, t_atom *av, long count, unsigned char *vals); 01702 01703 01704 /** 01705 Assign an array of long integer values to an array of atoms. 01706 01707 @ingroup atom 01708 @param ac The number of atoms to try to fetch from the array of longs. 01709 You should have at least this number of atoms allocated in av. 01710 @param av The address to the first of an array of allocated atoms. 01711 @param count The number of values in the array specified by vals. 01712 @param vals The array from which to copy the values into the array of atoms at av. 01713 @return A Max error code. 01714 */ 01715 t_max_err atom_setlong_array(long ac, t_atom *av, long count, long *vals); 01716 01717 01718 /** 01719 Assign an array of 32bit float values to an array of atoms. 01720 01721 @ingroup atom 01722 @param ac The number of atoms to try to fetch from the array of floats. 01723 You should have at least this number of atoms allocated in av. 01724 @param av The address to the first of an array of allocated atoms. 01725 @param count The number of values in the array specified by vals. 01726 @param vals The array from which to copy the values into the array of atoms at av. 01727 @return A Max error code. 01728 */ 01729 t_max_err atom_setfloat_array(long ac, t_atom *av, long count, float *vals); 01730 01731 01732 /** 01733 Assign an array of 64bit float values to an array of atoms. 01734 01735 @ingroup atom 01736 @param ac The number of atoms to try to fetch from the array of doubles. 01737 You should have at least this number of atoms allocated in av. 01738 @param av The address to the first of an array of allocated atoms. 01739 @param count The number of values in the array specified by vals. 01740 @param vals The array from which to copy the values into the array of atoms at av. 01741 @return A Max error code. 01742 */ 01743 t_max_err atom_setdouble_array(long ac, t_atom *av, long count, double *vals); 01744 01745 01746 /** 01747 Assign an array of #t_symbol* values to an array of atoms. 01748 01749 @ingroup atom 01750 @param ac The number of atoms to try to fetch from the array of symbols. 01751 You should have at least this number of atoms allocated in av. 01752 @param av The address to the first of an array of allocated atoms. 01753 @param count The number of values in the array specified by vals. 01754 @param vals The array from which to copy the values into the array of atoms at av. 01755 @return A Max error code. 01756 */ 01757 t_max_err atom_setsym_array(long ac, t_atom *av, long count, t_symbol **vals); 01758 01759 01760 /** 01761 Assign an array of #t_atom values to an array of atoms. 01762 01763 @ingroup atom 01764 @param ac The number of atoms to try to fetch from the second array of atoms. 01765 You should have at least this number of atoms allocated in av. 01766 @param av The address to the first of an array of allocated atoms. 01767 @param count The number of values in the array specified by vals. 01768 @param vals The array from which to copy the values into the array of atoms at av. 01769 @return A Max error code. 01770 */ 01771 t_max_err atom_setatom_array(long ac, t_atom *av, long count, t_atom *vals); 01772 01773 01774 /** 01775 Assign an array of #t_object* values to an array of atoms. 01776 01777 @ingroup atom 01778 @param ac The number of atoms to try to fetch from the array of objects. 01779 You should have at least this number of atoms allocated in av. 01780 @param av The address to the first of an array of allocated atoms. 01781 @param count The number of values in the array specified by vals. 01782 @param vals The array from which to copy the values into the array of atoms at av. 01783 @return A Max error code. 01784 */ 01785 t_max_err atom_setobj_array(long ac, t_atom *av, long count, t_object **vals); 01786 01787 01788 // these variable size calls can alloc mem if desired 01789 01790 /** 01791 Parse a C-string into an array of atoms. 01792 This function allocates memory for the atoms if the ac and av parameters are NULL. 01793 Otherwise it will attempt to use any memory already allocated to av. 01794 Any allocated memory should be freed with sysmem_freeptr(). 01795 01796 @ingroup atom 01797 @param ac The address of a variable to hold the number of returned atoms. 01798 @param av The address of a #t_atom pointer to which memory may be allocated and atoms copied. 01799 @param parsestr The C-string to parse. 01800 @return A Max error code. 01801 01802 @remark The following example will parse the string "foo bar 1 2 3.0" into an array of 5 atoms. 01803 The atom types will be determined automatically as 2 #A_SYM atoms, 2 #A_LONG atoms, and 1 #A_FLOAT atom. 01804 @code 01805 t_atom *av = NULL; 01806 long ac = 0; 01807 t_max_err err = MAX_ERR_NONE; 01808 01809 err = atom_setparse(&ac, &av, "foo bar 1 2 3.0"); 01810 @endcode 01811 */ 01812 t_max_err atom_setparse(long *ac, t_atom **av, char *parsestr); 01813 01814 01815 t_max_err atom_setbinbuf(long *ac, t_atom **av, void *buf); 01816 01817 01818 t_max_err atom_setattrval(long *ac, t_atom **av, t_symbol *attrname, t_object *obj); 01819 01820 01821 t_max_err atom_setobjval(long *ac, t_atom **av, t_object *obj); 01822 01823 01824 01825 01826 /** 01827 Create an array of atoms populated with values using sprintf-like syntax. 01828 atom_setformat() supports clfdsoaCLFDSOA tokens 01829 (primitive type scalars and arrays respectively for the 01830 char, long, float, double, #t_symbol*, #t_object*, #t_atom*). 01831 It also supports vbp@ tokens (obval, binbuf, parsestr, attribute). 01832 01833 This function allocates memory for the atoms if the ac and av parameters are NULL. 01834 Otherwise it will attempt to use any memory already allocated to av. 01835 Any allocated memory should be freed with sysmem_freeptr(). 01836 01837 @ingroup atom 01838 01839 @param ac The address of a variable to hold the number of returned atoms. 01840 @param av The address of a #t_atom pointer to which memory may be allocated and atoms copied. 01841 @param fmt An sprintf-style format string specifying values for the atoms. 01842 @param ... One or more arguments which are to be substituted into the format string. 01843 01844 @return A Max error code. 01845 @see atom_getformat() 01846 @see atom_setparse() 01847 */ 01848 t_max_err atom_setformat(long *ac, t_atom **av, char *fmt, ...); 01849 01850 01851 /** 01852 Retrieve values from an array of atoms using sscanf-like syntax. 01853 atom_getformat() supports clfdsoaCLFDSOA tokens 01854 (primitive type scalars and arrays respectively for the 01855 char, long, float, double, #t_symbol*, #t_object*, #t_atom*). 01856 It does not support vbp@ the tokens found in atom_setformat(). 01857 01858 @ingroup atom 01859 01860 @param ac The number of atoms to parse in av. 01861 @param av The address of the first #t_atom pointer in an array to parse. 01862 @param fmt An sscanf-style format string specifying types for the atoms. 01863 @param ... One or more arguments which are address of variables to be set according to the fmt string. 01864 01865 @return A Max error code. 01866 @see atom_setformat() 01867 */ 01868 t_max_err atom_getformat(long ac, t_atom *av, char *fmt, ...); 01869 01870 01871 /** 01872 Convert an array of atoms into a C-string. 01873 01874 @ingroup atom 01875 01876 @param ac The number of atoms to fetch in av. 01877 @param av The address of the first #t_atom pointer in an array to retrieve. 01878 @param textsize The size of the string to which the atoms will be formatted and copied. 01879 @param text The address of the string to which the text will be written. 01880 @param flags Determines the rules by which atoms will be translated into text. 01881 Values are bit mask as defined by #e_max_atom_gettext_flags. 01882 01883 @return A Max error code. 01884 @see atom_setparse() 01885 */ 01886 t_max_err atom_gettext(long ac, t_atom *av, long *textsize, char **text, long flags); 01887 01888 01889 /** 01890 Fetch an array of char values from an array of atoms. 01891 01892 @ingroup atom 01893 @param ac The number of atoms allocated in the av parameter. 01894 @param av The address to the first of an array of allocated atoms. 01895 @param count The number of values to fetch from the array specified by vals. 01896 @param vals The address of the array to which is copied the values from av. 01897 @return A Max error code. 01898 */ 01899 t_max_err atom_getchar_array(long ac, t_atom *av, long count, unsigned char *vals); 01900 01901 01902 /** 01903 Fetch an array of long integer values from an array of atoms. 01904 01905 @ingroup atom 01906 @param ac The number of atoms allocated in the av parameter. 01907 @param av The address to the first of an array of allocated atoms. 01908 @param count The number of values to fetch from the array specified by vals. 01909 @param vals The address of the array to which is copied the values from av. 01910 @return A Max error code. 01911 */ 01912 t_max_err atom_getlong_array(long ac, t_atom *av, long count, long *vals); 01913 01914 01915 /** 01916 Fetch an array of 32bit float values from an array of atoms. 01917 01918 @ingroup atom 01919 @param ac The number of atoms allocated in the av parameter. 01920 @param av The address to the first of an array of allocated atoms. 01921 @param count The number of values to fetch from the array specified by vals. 01922 @param vals The address of the array to which is copied the values from av. 01923 @return A Max error code. 01924 */ 01925 t_max_err atom_getfloat_array(long ac, t_atom *av, long count, float *vals); 01926 01927 01928 /** 01929 Fetch an array of 64bit float values from an array of atoms. 01930 01931 @ingroup atom 01932 @param ac The number of atoms allocated in the av parameter. 01933 @param av The address to the first of an array of allocated atoms. 01934 @param count The number of values to fetch from the array specified by vals. 01935 @param vals The address of the array to which is copied the values from av. 01936 @return A Max error code. 01937 */ 01938 t_max_err atom_getdouble_array(long ac, t_atom *av, long count, double *vals); 01939 01940 01941 /** 01942 Fetch an array of #t_symbol* values from an array of atoms. 01943 01944 @ingroup atom 01945 @param ac The number of atoms allocated in the av parameter. 01946 @param av The address to the first of an array of allocated atoms. 01947 @param count The number of values to fetch from the array specified by vals. 01948 @param vals The address of the array to which is copied the values from av. 01949 @return A Max error code. 01950 */ 01951 t_max_err atom_getsym_array(long ac, t_atom *av, long count, t_symbol **vals); 01952 01953 01954 /** 01955 Fetch an array of #t_atom values from an array of atoms. 01956 01957 @ingroup atom 01958 @param ac The number of atoms allocated in the av parameter. 01959 @param av The address to the first of an array of allocated atoms. 01960 @param count The number of values to fetch from the array specified by vals. 01961 @param vals The address of the array to which is copied the values from av. 01962 @return A Max error code. 01963 */ 01964 t_max_err atom_getatom_array(long ac, t_atom *av, long count, t_atom *vals); 01965 01966 01967 /** 01968 Fetch an array of #t_object* values from an array of atoms. 01969 01970 @ingroup atom 01971 @param ac The number of atoms allocated in the av parameter. 01972 @param av The address to the first of an array of allocated atoms. 01973 @param count The number of values to fetch from the array specified by vals. 01974 @param vals The address of the array to which is copied the values from av. 01975 @return A Max error code. 01976 */ 01977 t_max_err atom_getobj_array(long ac, t_atom *av, long count, t_object **vals); 01978 01979 01980 01981 /** 01982 Determines whether or not an atom represents a #t_string object. 01983 01984 @ingroup atom 01985 @param a The address of the atom to test. 01986 @return Returns true if the #t_atom contains a valid #t_string object. 01987 */ 01988 long atomisstring(t_atom *a); 01989 01990 01991 /** 01992 Determines whether or not an atom represents a #t_atomarray object. 01993 01994 @ingroup atom 01995 @param a The address of the atom to test. 01996 @return Returns true if the #t_atom contains a valid #t_atomarray object. 01997 */ 01998 long atomisatomarray(t_atom *a); 01999 02000 02001 /** 02002 Determines whether or not an atom represents a #t_dictionary object. 02003 02004 @ingroup atom 02005 @param a The address of the atom to test. 02006 @return Returns true if the #t_atom contains a valid #t_dictionary object. 02007 */ 02008 long atomisdictionary(t_atom *a); 02009 02010 02011 02012 // quick object programming macros 02013 #define msg(x,p) object_method_parse(x,NULL,p,NULL); 02014 02015 02016 //object_method_typed utilities 02017 02018 /** 02019 Convenience wrapper for object_method_typed() that uses atom_setparse() to define the arguments. 02020 02021 @ingroup obj 02022 @param x The object to which the message will be sent. 02023 @param s The name of the method to call on the object. 02024 @param parsestr A C-string to parse into an array of atoms to pass to the method. 02025 @param rv The address of an atom to hold a return value. 02026 @return A Max error code. 02027 02028 @see object_method_typed() 02029 @see atom_setparse() 02030 */ 02031 t_max_err object_method_parse(t_object *x, t_symbol *s, char *parsestr, t_atom *rv); 02032 t_max_err object_method_binbuf(t_object *x, t_symbol *s, void *buf, t_atom *rv); 02033 t_max_err object_method_attrval(t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj, t_atom *rv); 02034 t_max_err object_method_objval(t_object *x, t_symbol *s, t_object *obj, t_atom *rv); 02035 02036 /** 02037 Convenience wrapper for object_method_typed() that uses atom_setformat() to define the arguments. 02038 02039 @ingroup obj 02040 @param x The object to which the message will be sent. 02041 @param s The name of the method to call on the object. 02042 @param rv The address of an atom to hold a return value. 02043 @param fmt An sprintf-style format string specifying values for the atoms. 02044 @param ... One or more arguments which are to be substituted into the format string. 02045 @return A Max error code. 02046 02047 @see object_method_typed() 02048 @see atom_setformat() 02049 */ 02050 t_max_err object_method_format(t_object *x, t_symbol *s, t_atom *rv, char *fmt, ...); 02051 02052 02053 02054 /** 02055 Convenience wrapper for object_method_typed() that passes a single char as an argument. 02056 02057 @ingroup obj 02058 @param x The object to which the message will be sent. 02059 @param s The name of the method to call on the object. 02060 @param v An argument to pass to the method. 02061 @param rv The address of an atom to hold a return value. 02062 02063 @return A Max error code. 02064 @see object_method_typed() 02065 */ 02066 t_max_err object_method_char(t_object *x, t_symbol *s, unsigned char v, t_atom *rv); 02067 02068 02069 /** 02070 Convenience wrapper for object_method_typed() that passes a single long integer 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_long(t_object *x, t_symbol *s, long v, t_atom *rv); 02082 02083 02084 /** 02085 Convenience wrapper for object_method_typed() that passes a single 32bit float 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_float(t_object *x, t_symbol *s, float v, t_atom *rv); 02097 02098 02099 /** 02100 Convenience wrapper for object_method_typed() that passes a single 64bit 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_double(t_object *x, t_symbol *s, double v, t_atom *rv); 02112 02113 02114 /** 02115 Convenience wrapper for object_method_typed() that passes a single #t_symbol* 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_sym(t_object *x, t_symbol *s, t_symbol *v, t_atom *rv); 02127 02128 02129 /** 02130 Convenience wrapper for object_method_typed() that passes a single #t_object* 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_obj(t_object *x, t_symbol *s, t_object *v, t_atom *rv); 02142 02143 02144 02145 /** 02146 Convenience wrapper for object_method_typed() that passes an array of char values as an argument. 02147 02148 @ingroup obj 02149 @param x The object to which the message will be sent. 02150 @param s The name of the method to call on the object. 02151 @param ac The number of arguments to pass to the method. 02152 @param av The address of the first of the array of arguments to pass to the method. 02153 @param rv The address of an atom to hold a return value. 02154 02155 @return A Max error code. 02156 @see object_method_typed() 02157 */ 02158 t_max_err object_method_char_array(t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv); 02159 02160 02161 /** 02162 Convenience wrapper for object_method_typed() that passes an array of long integers values as an argument. 02163 02164 @ingroup obj 02165 @param x The object to which the message will be sent. 02166 @param s The name of the method to call on the object. 02167 @param ac The number of arguments to pass to the method. 02168 @param av The address of the first of the array of arguments to pass to the method. 02169 @param rv The address of an atom to hold a return value. 02170 02171 @return A Max error code. 02172 @see object_method_typed() 02173 */ 02174 t_max_err object_method_long_array(t_object *x, t_symbol *s, long ac, long *av, t_atom *rv); 02175 02176 02177 /** 02178 Convenience wrapper for object_method_typed() that passes an array of 32bit floats values as an argument. 02179 02180 @ingroup obj 02181 @param x The object to which the message will be sent. 02182 @param s The name of the method to call on the object. 02183 @param ac The number of arguments to pass to the method. 02184 @param av The address of the first of the array of arguments to pass to the method. 02185 @param rv The address of an atom to hold a return value. 02186 02187 @return A Max error code. 02188 @see object_method_typed() 02189 */ 02190 t_max_err object_method_float_array(t_object *x, t_symbol *s, long ac, float *av, t_atom *rv); 02191 02192 02193 /** 02194 Convenience wrapper for object_method_typed() that passes an array of 64bit float values as an argument. 02195 02196 @ingroup obj 02197 @param x The object to which the message will be sent. 02198 @param s The name of the method to call on the object. 02199 @param ac The number of arguments to pass to the method. 02200 @param av The address of the first of the array of arguments to pass to the method. 02201 @param rv The address of an atom to hold a return value. 02202 02203 @return A Max error code. 02204 @see object_method_typed() 02205 */ 02206 t_max_err object_method_double_array(t_object *x, t_symbol *s, long ac, double *av, t_atom *rv); 02207 02208 02209 /** 02210 Convenience wrapper for object_method_typed() that passes an array of #t_symbol* values as an argument. 02211 02212 @ingroup obj 02213 @param x The object to which the message will be sent. 02214 @param s The name of the method to call on the object. 02215 @param ac The number of arguments to pass to the method. 02216 @param av The address of the first of the array of arguments to pass to the method. 02217 @param rv The address of an atom to hold a return value. 02218 02219 @return A Max error code. 02220 @see object_method_typed() 02221 */ 02222 t_max_err object_method_sym_array(t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv); 02223 02224 02225 /** 02226 Convenience wrapper for object_method_typed() that passes an array of #t_object* values as an argument. 02227 02228 @ingroup obj 02229 @param x The object to which the message will be sent. 02230 @param s The name of the method to call on the object. 02231 @param ac The number of arguments to pass to the method. 02232 @param av The address of the first of the array of arguments to pass to the method. 02233 @param rv The address of an atom to hold a return value. 02234 02235 @return A Max error code. 02236 @see object_method_typed() 02237 */ 02238 t_max_err object_method_obj_array(t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv); 02239 02240 02241 // call_method_typed utilities -- not currently used in any Cycling '74 code 02242 02243 t_max_err call_method_typed(method m, t_object *x, t_symbol *s, long ac, t_atom *av, t_atom *rv); 02244 t_max_err call_method_parse(method m, t_object *x, t_symbol *s, char *parsestr, t_atom *rv); 02245 t_max_err call_method_binbuf(method m, t_object *x, t_symbol *s, void *buf, t_atom *rv); 02246 t_max_err call_method_attrval(method m, t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj, t_atom *rv); 02247 t_max_err call_method_objval(method m, t_object *x, t_symbol *s, t_object *obj, t_atom *rv); 02248 t_max_err call_method_format(method m, t_object *x, t_symbol *s, t_atom *rv, char *fmt, ...); 02249 02250 t_max_err call_method_char(method m, t_object *x, t_symbol *s, unsigned char v, t_atom *rv); 02251 t_max_err call_method_long(method m, t_object *x, t_symbol *s, long v, t_atom *rv); 02252 t_max_err call_method_float(method m, t_object *x, t_symbol *s,float v, t_atom *rv); 02253 t_max_err call_method_double(method m, t_object *x, t_symbol *s, double v, t_atom *rv); 02254 t_max_err call_method_sym(method m, t_object *x, t_symbol *s, t_symbol *v, t_atom *rv); 02255 t_max_err call_method_obj(method m, t_object *x, t_symbol *s, t_object *v, t_atom *rv); 02256 02257 t_max_err call_method_char_array(method m, t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv); 02258 t_max_err call_method_long_array(method m, t_object *x, t_symbol *s, long ac, long *av, t_atom *rv); 02259 t_max_err call_method_float_array(method m, t_object *x, t_symbol *s, long ac, float *av, t_atom *rv); 02260 t_max_err call_method_double_array(method m, t_object *x, t_symbol *s, long ac, double *av, t_atom *rv); 02261 t_max_err call_method_sym_array(method m, t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv); 02262 t_max_err call_method_obj_array(method m, t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv); 02263 02264 02265 // object attribute methods (will move to attribtue_util.c with the rest of these) 02266 02267 /** 02268 Set an attribute value with one or more atoms parsed from a C-string. 02269 02270 @ingroup attr 02271 @param x The object whose attribute will be set. 02272 @param s The name of the attribute to set. 02273 @param parsestr A C-string to parse into an array of atoms to set the attribute value. 02274 @return A Max error code. 02275 @see atom_setparse() 02276 */ 02277 t_max_err object_attr_setparse(t_object *x, t_symbol *s, char *parsestr); 02278 t_max_err object_attr_setbinbuf(t_object *x, t_symbol *s, void *buf); 02279 t_max_err object_attr_setattrval(t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj); 02280 t_max_err object_attr_setobjval(t_object *x, t_symbol *s, t_object *obj); 02281 t_max_err object_attr_setformat(t_object *x, t_symbol *s, char *fmt, ...); 02282 02283 02284 // t_attribute these probably belong in attribute.c 02285 t_object *attribute_new_atoms(char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 02286 t_object *attribute_new_parse(char *attrname, t_symbol *type, long flags, char *parsestr); 02287 t_object *attribute_new_binbuf(char *attrname, t_symbol *type, long flags, void *buf); 02288 t_object *attribute_new_attrval(char *attrname, t_symbol *type, long flags, t_symbol *objattrname, t_object *obj); 02289 t_object *attribute_new_objval(char *attrname, t_symbol *type, long flags, t_object *obj); 02290 t_object *attribute_new_format(char *attrname, t_symbol *type, long flags, char *fmt, ...); 02291 02292 02293 // general object constructors for objects with typed constructors 02294 02295 /** 02296 Create a new object with one or more atoms parsed from a C-string. 02297 The object's new method must have an #A_GIMME signature. 02298 02299 @ingroup attr 02300 @param name_space The namespace in which to create the instance. Typically this is either #CLASS_BOX or #CLASS_NOBOX. 02301 @param classname The name of the class to instantiate. 02302 @param parsestr A C-string to parse into an array of atoms to set the attribute value. 02303 02304 @return A pointer to the new instance. 02305 @see atom_setparse() 02306 @see object_new_typed() 02307 */ 02308 void *object_new_parse(t_symbol *name_space, t_symbol *classname, char *parsestr); 02309 void *object_new_binbuf(t_symbol *name_space, t_symbol *classname, void *buf); 02310 void *object_new_attrval(t_symbol *name_space, t_symbol *classname, t_symbol *objattrname, t_object *obj); 02311 void *object_new_objval(t_symbol *name_space, t_symbol *classname, t_object *obj); 02312 void *object_new_format(t_symbol *name_space, t_symbol *classname, char *fmt, ...); // not used or tested in any Cycling '74 code 02313 02314 02315 // attr attr functions necessary due to offset attributes as singletons for the class 02316 // need to copy object local to set any attributes. 02317 // undocumented for now in favor of using the macros defined above. 02318 02319 t_max_err object_attr_addattr(t_object *x, t_symbol *attrname, t_object *attr); 02320 t_object *object_attr_attr_get(t_object *x, t_symbol *attrname, t_symbol *attrname2); 02321 t_max_err object_attr_attr_setvalueof(t_object *x, t_symbol *attrname, t_symbol *attrname2, long argc, t_atom *argv); 02322 t_max_err object_attr_attr_getvalueof(t_object *x, t_symbol *attrname, t_symbol *attrname2, long *argc, t_atom **argv); 02323 02324 t_max_err class_attr_addattr(t_class *c, t_symbol *attrname, t_object *attr); 02325 t_object *class_attr_attr_get(t_class *c, t_symbol *attrname, t_symbol *attrname2); 02326 t_max_err class_attr_attr_setvalueof(t_class *c, t_symbol *attrname, t_symbol *attrname2, long argc, t_atom *argv); 02327 t_max_err class_attr_attr_getvalueof(t_class *c, t_symbol *attrname, t_symbol *attrname2, long *argc, t_atom **argv); 02328 02329 t_max_err object_attr_enforcelocal(t_object *x, t_symbol *attrname); 02330 02331 t_max_err class_addattr_atoms(t_class *c, char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 02332 t_max_err class_addattr_parse(t_class *c, char *attrname, t_symbol *type, long flags, char *parsestr); 02333 t_max_err class_addattr_format(t_class *c, char *attrname, t_symbol *type, long flags, char *fmt, ...); 02334 t_max_err class_attr_addattr_atoms(t_class *c, char *attrname, char *attrname2, t_symbol *type, long flags, long ac, t_atom *av); 02335 t_max_err class_attr_addattr_parse(t_class *c, char *attrname, char *attrname2, t_symbol *type, long flags, char *parsestr); 02336 t_max_err class_attr_addattr_format(t_class *c, char *attrname, char *attrname2, t_symbol *type, long flags, char *fmt, ...); 02337 02338 t_max_err object_addattr_atoms(t_object *x, char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 02339 t_max_err object_addattr_parse(t_object *x, char *attrname, t_symbol *type, long flags, char *parsestr); 02340 t_max_err object_addattr_format(t_object *x, char *attrname, t_symbol *type, long flags, char *fmt, ...); 02341 t_max_err object_attr_addattr_atoms(t_object *x, char *attrname, char *attrname2, t_symbol *type, long flags, long ac, t_atom *av); 02342 t_max_err object_attr_addattr_parse(t_object *x, char *attrname, char *attrname2, t_symbol *type, long flags, char *parsestr); 02343 t_max_err object_attr_addattr_format(t_object *x, char *attrname, char *attrname2, t_symbol *type, long flags, char *fmt, ...); 02344 02345 02346 // other general functions from obex.c 02347 t_object *object_clone(t_object *x); 02348 t_object *object_clone_generic(t_object *x); 02349 void object_zero(t_object *x); 02350 02351 02352 // menu command stuff 02353 02354 t_max_err class_addcommand(t_class *c, method cmd, method enabler, method handler, char *message); 02355 void *object_commandenabled(t_object *o, t_symbol *cmd); 02356 t_max_err object_getenabler(t_object *c, t_symbol *cmd, method *m); 02357 t_max_err object_getcommand(t_object *o, t_symbol *cmd, method *m); 02358 void *object_handlecommand(t_object *o, t_symbol *s, long argc, t_atom *argv, t_atom *rv); 02359 02360 t_max_err object_attr_setdisabled(t_object *o, t_symbol *attrname, long way); 02361 02362 #ifdef __cplusplus 02363 } 02364 #endif // __cplusplus 02365 02366 #endif //__OBEX_UTIL_H__
Copyright © 2008, Cycling '74