github.com/256dpi/max-go@v0.7.0/lib/max/ext_obex_util.h (about) 1 /* 2 * obex_util.h 3 * 4 * Copyright 2006 Cycling '74. All rights reserved. 5 * 6 */ 7 8 #ifndef _EXT_OBEX_UTIL_H_ 9 #define _EXT_OBEX_UTIL_H_ 10 11 #include "ext_prefix.h" 12 #include "ext_mess.h" 13 14 BEGIN_USING_C_LINKAGE 15 16 #include <stdarg.h> 17 18 // symbol macros which may be swapped to use common symbol pointers for performance 19 #define USESYM(x) gensym(#x) 20 //#define USESYM(x) _sym_##x 21 22 // macros for attributes 23 // class attributes are almost universally attr_offset, except for class static attributes 24 25 26 /** 27 Create an attribute that does not store its data in the object struct. 28 NB: if you use this you must have a custom getter/setter or not ever get/set. 29 Perhaps we should rewrite this using a generic attribute_new rather than attr_offset_new? 30 31 @ingroup attr 32 @param c The class pointer. 33 @param attrname The name of this attribute as a C-string. 34 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 35 @param typesym The type the getter and setter would expect: _sym_char, _sym_long, _sym_atom_long, _sym_float32, _sym_float64, _sym_symbol, _sym_atom, etc 36 */ 37 #define CLASS_ATTR_OFFSET_DUMMY(c,attrname,flags,typesym) \ 38 class_addattr((c),attr_offset_new(attrname,typesym,(flags),(method)0L,(method)0L,0)); 39 40 /** 41 Create a char attribute and add it to a Max class. 42 43 @ingroup attr 44 @param c The class pointer. 45 @param attrname The name of this attribute as a C-string. 46 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 47 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 48 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 49 */ 50 #define CLASS_ATTR_CHAR(c,attrname,flags,structname,structmember) \ 51 { \ 52 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(char), "structmember must be char type"); \ 53 class_addattr((c),attr_offset_new(attrname,USESYM(char),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 54 } 55 56 57 /** 58 Create a long integer attribute and add it to a Max class. 59 60 @ingroup attr 61 @param c The class pointer. 62 @param attrname The name of this attribute as a C-string. 63 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 64 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 65 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 66 */ 67 68 #define CLASS_ATTR_LONG(c,attrname,flags,structname,structmember) \ 69 { \ 70 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(long), "structmember must be long type"); \ 71 class_addattr((c),attr_offset_new(attrname,USESYM(long),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 72 } 73 74 /** 75 Create a t_atom_long integer attribute and add it to a Max class. 76 77 @ingroup attr 78 @param c The class pointer. 79 @param attrname The name of this attribute as a C-string. 80 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 81 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 82 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 83 */ 84 85 #define CLASS_ATTR_ATOM_LONG(c,attrname,flags,structname,structmember) \ 86 { \ 87 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(t_atom_long), "structmember must be t_atom_long type"); \ 88 class_addattr((c),attr_offset_new(attrname,USESYM(atom_long),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 89 } 90 91 /** 92 Create a t_int32 integer attribute and add it to a Max class. 93 94 @ingroup attr 95 @param c The class pointer. 96 @param attrname The name of this attribute as a C-string. 97 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 98 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 99 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 100 */ 101 102 #define CLASS_ATTR_INT32(c,attrname,flags,structname,structmember) \ 103 { \ 104 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(t_int32), "structmember must be t_int32 type"); \ 105 class_addattr((c),attr_offset_new(attrname,USESYM(int32),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 106 } 107 108 #define CLASS_ATTR_FILEPATH(c,attrname,flags,structname,structmember) \ 109 { \ 110 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(t_filepath), "structmember must be t_filepath type"); \ 111 class_addattr((c),attr_offset_new(attrname,USESYM(filepath),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 112 } 113 114 /** 115 Create a 32-bit float attribute and add it to a Max class. 116 117 @ingroup attr 118 @param c The class pointer. 119 @param attrname The name of this attribute as a C-string. 120 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 121 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 122 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 123 */ 124 #define CLASS_ATTR_FLOAT(c,attrname,flags,structname,structmember) \ 125 { \ 126 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(float), "structmember must be float type"); \ 127 class_addattr((c),attr_offset_new(attrname,USESYM(float32),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 128 } 129 130 131 /** 132 Create a 64-bit float attribute and add it to a Max class. 133 134 @ingroup attr 135 @param c The class pointer. 136 @param attrname The name of this attribute as a C-string. 137 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 138 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 139 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 140 */ 141 #define CLASS_ATTR_DOUBLE(c,attrname,flags,structname,structmember) \ 142 { \ 143 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(double), "structmember must be double type"); \ 144 class_addattr((c),attr_offset_new(attrname,USESYM(float64),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 145 } 146 147 148 /** 149 Create a #t_symbol* attribute and add it to a Max class. 150 151 @ingroup attr 152 @param c The class pointer. 153 @param attrname The name of this attribute as a C-string. 154 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 155 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 156 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 157 */ 158 #define CLASS_ATTR_SYM(c,attrname,flags,structname,structmember) \ 159 { \ 160 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(t_symbol*), "structmember must be t_symbol* type"); \ 161 class_addattr((c),attr_offset_new(attrname,USESYM(symbol),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 162 } 163 164 165 /** 166 Create a #t_atom attribute and add it to a Max class. 167 168 @ingroup attr 169 @param c The class pointer. 170 @param attrname The name of this attribute as a C-string. 171 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 172 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 173 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 174 */ 175 #define CLASS_ATTR_ATOM(c,attrname,flags,structname,structmember) \ 176 { \ 177 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(t_atom), "structmember must be t_atom type"); \ 178 class_addattr((c),attr_offset_new(attrname,USESYM(atom),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 179 } 180 181 182 /** 183 Create a #t_object* attribute and add it to a Max class. 184 185 @ingroup attr 186 @param c The class pointer. 187 @param attrname The name of this attribute as a C-string. 188 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 189 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 190 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 191 */ 192 #define CLASS_ATTR_OBJ(c,attrname,flags,structname,structmember) \ 193 { \ 194 C74_STATIC_ASSERT(structmembersize(structname,structmember)==sizeof(t_object*), "structmember must be t_object* type"); \ 195 class_addattr((c),attr_offset_new(attrname,USESYM(object),(flags),(method)0L,(method)0L,calcoffset(structname,structmember))); \ 196 } 197 198 /** 199 Create an array-of-chars attribute of fixed length, and add it to a Max class. 200 201 @ingroup attr 202 @param c The class pointer. 203 @param attrname The name of this attribute as a C-string. 204 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 205 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 206 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 207 @param size The number of chars in the array. 208 */ 209 #define CLASS_ATTR_CHAR_ARRAY(c,attrname,flags,structname,structmember,size) \ 210 class_addattr((c),attr_offset_array_new(attrname,USESYM(char),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 211 212 213 /** 214 Create an array-of-long-integers attribute of fixed length, and add it to a Max class. 215 216 @ingroup attr 217 @param c The class pointer. 218 @param attrname The name of this attribute as a C-string. 219 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 220 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 221 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 222 @param size The number of longs in the array. 223 */ 224 #define CLASS_ATTR_LONG_ARRAY(c,attrname,flags,structname,structmember,size) \ 225 { \ 226 C74_STATIC_ASSERT(structmembersize(structname,structmember[0])==sizeof(long), "structmember must be long type"); \ 227 class_addattr((c),attr_offset_array_new(attrname,USESYM(long),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))); \ 228 } 229 230 /** 231 Create an array-of-t_atom_long-integers attribute of fixed length, and add it to a Max class. 232 233 @ingroup attr 234 @param c The class pointer. 235 @param attrname The name of this attribute as a C-string. 236 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 237 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 238 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 239 @param size The number of longs in the array. 240 */ 241 #define CLASS_ATTR_ATOM_LONG_ARRAY(c,attrname,flags,structname,structmember,size) \ 242 { \ 243 C74_STATIC_ASSERT(structmembersize(structname,structmember[0])==sizeof(t_atom_long), "structmember must be t_atom_long type"); \ 244 class_addattr((c),attr_offset_array_new(attrname,USESYM(atom_long),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))); \ 245 } 246 247 248 /** 249 Create an array-of-32bit-floats attribute of fixed length, and add it to a Max class. 250 251 @ingroup attr 252 @param c The class pointer. 253 @param attrname The name of this attribute as a C-string. 254 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 255 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 256 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 257 @param size The number of floats in the array. 258 */ 259 #define CLASS_ATTR_FLOAT_ARRAY(c,attrname,flags,structname,structmember,size) \ 260 { \ 261 C74_STATIC_ASSERT(structmembersize(structname, structmember[0])==sizeof(float), "structmember must be float type"); \ 262 class_addattr((c), attr_offset_array_new(attrname, USESYM(float32), (size), (flags), (method)0L, (method)0L, 0/*fix*/, calcoffset(structname, structmember))); \ 263 } 264 265 266 /** 267 Create an array-of-64bit-floats attribute of fixed length, and add it to a Max class. 268 269 @ingroup attr 270 @param c The class pointer. 271 @param attrname The name of this attribute as a C-string. 272 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 273 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 274 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 275 @param size The number of doubles in the array. 276 */ 277 #define CLASS_ATTR_DOUBLE_ARRAY(c,attrname,flags,structname,structmember,size) \ 278 class_addattr((c),attr_offset_array_new(attrname,USESYM(float64),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 279 280 281 /** 282 Create an array-of-symbols attribute of fixed length, and add it to a Max class. 283 284 @ingroup attr 285 @param c The class pointer. 286 @param attrname The name of this attribute as a C-string. 287 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 288 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 289 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 290 @param size The number of items in the #t_symbol* array. 291 */ 292 #define CLASS_ATTR_SYM_ARRAY(c,attrname,flags,structname,structmember,size) \ 293 class_addattr((c),attr_offset_array_new(attrname,USESYM(symbol),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 294 295 296 /** 297 Create an array-of-atoms attribute of fixed length, and add it to a Max class. 298 299 @ingroup attr 300 @param c The class pointer. 301 @param attrname The name of this attribute as a C-string. 302 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 303 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 304 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 305 @param size The number of items in the #t_atom array. 306 */ 307 #define CLASS_ATTR_ATOM_ARRAY(c,attrname,flags,structname,structmember,size) \ 308 class_addattr((c),attr_offset_array_new(attrname,USESYM(atom),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 309 310 311 /** 312 Create an array-of-objects attribute of fixed length, and add it to a Max class. 313 314 @ingroup attr 315 @param c The class pointer. 316 @param attrname The name of this attribute as a C-string. 317 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 318 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 319 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 320 @param size The number of items in the #t_object* array. 321 */ 322 #define CLASS_ATTR_OBJ_ARRAY(c,attrname,flags,structname,structmember,size) \ 323 class_addattr((c),attr_offset_array_new(attrname,USESYM(object),(size),(flags),(method)0L,(method)0L,0/*fix*/,calcoffset(structname,structmember))) 324 325 326 327 328 /** 329 Create an array-of-chars attribute of variable length, and add it to a Max class. 330 331 @ingroup attr 332 @param c The class pointer. 333 @param attrname The name of this attribute as a C-string. 334 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 335 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 336 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 337 @param sizemember The actual number of items in the char array at any given moment. 338 @param maxsize The maximum number of items in the char array, i.e. the number of members allocated for the array in the struct. 339 */ 340 #define CLASS_ATTR_CHAR_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 341 class_addattr((c),attr_offset_array_new(attrname,USESYM(char),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 342 343 344 /** 345 Create an array-of-long-integers attribute of variable length, and add it to a Max class. 346 347 @ingroup attr 348 @param c The class pointer. 349 @param attrname The name of this attribute as a C-string. 350 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 351 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 352 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 353 @param sizemember The actual number of items in the long array at any given moment. 354 @param maxsize The maximum number of items in the long array, i.e. the number of members allocated for the array in the struct. 355 */ 356 #define CLASS_ATTR_LONG_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 357 { \ 358 C74_STATIC_ASSERT(structmembersize(structname,structmember[0])==sizeof(long), "structmember must be t_atom_long type"); \ 359 class_addattr((c),attr_offset_array_new(attrname,USESYM(long),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))); \ 360 } 361 362 /** 363 Create an array-of-32bit-floats attribute of variable length, and add it to a Max class. 364 365 @ingroup attr 366 @param c The class pointer. 367 @param attrname The name of this attribute as a C-string. 368 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 369 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 370 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 371 @param sizemember The actual number of items in the float array at any given moment. 372 @param maxsize The maximum number of items in the float array, i.e. the number of members allocated for the array in the struct. 373 */ 374 #define CLASS_ATTR_FLOAT_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 375 class_addattr((c),attr_offset_array_new(attrname,USESYM(float32),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 376 377 378 /** 379 Create an array-of-64bit-floats attribute of variable length, and add it to a Max class. 380 381 @ingroup attr 382 @param c The class pointer. 383 @param attrname The name of this attribute as a C-string. 384 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 385 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 386 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 387 @param sizemember The actual number of items in the double array at any given moment. 388 @param maxsize The maximum number of items in the double array, i.e. the number of members allocated for the array in the struct. 389 */ 390 #define CLASS_ATTR_DOUBLE_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 391 class_addattr((c),attr_offset_array_new(attrname,USESYM(float64),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 392 393 394 /** 395 Create an array-of-symbols attribute of variable length, and add it to a Max class. 396 397 @ingroup attr 398 @param c The class pointer. 399 @param attrname The name of this attribute as a C-string. 400 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 401 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 402 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 403 @param sizemember The actual number of items in the #t_symbol* array at any given moment. 404 @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. 405 */ 406 #define CLASS_ATTR_SYM_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 407 class_addattr((c),attr_offset_array_new(attrname,USESYM(symbol),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 408 409 410 /** 411 Create an array-of-atoms attribute of variable length, and add it to a Max class. 412 413 @ingroup attr 414 @param c The class pointer. 415 @param attrname The name of this attribute as a C-string. 416 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 417 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 418 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 419 @param sizemember The actual number of items in the #t_atom array at any given moment. 420 @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. 421 */ 422 #define CLASS_ATTR_ATOM_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 423 class_addattr((c),attr_offset_array_new(attrname,USESYM(atom),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 424 425 426 /** 427 Create an array-of-objects attribute of variable length, and add it to a Max class. 428 429 @ingroup attr 430 @param c The class pointer. 431 @param attrname The name of this attribute as a C-string. 432 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 433 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 434 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 435 @param sizemember The actual number of items in the #t_object* array at any given moment. 436 @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. 437 */ 438 #define CLASS_ATTR_OBJ_VARSIZE(c,attrname,flags,structname,structmember,sizemember,maxsize) \ 439 class_addattr((c),attr_offset_array_new(attrname,USESYM(object),(maxsize),(flags),(method)0L,(method)0L,calcoffset(structname,sizemember),calcoffset(structname,structmember))) 440 441 442 443 444 // "struct" attributes are just like class attributes, but the struct member name is the same as the attribute name 445 // we use CMacro "stringification" in this case 446 447 // scalar variants 448 449 /** 450 Create a char attribute and add it to a Max class. 451 The name of the attribute is automatically determined by the name of the struct member. 452 453 @ingroup attr 454 @param c The class pointer. 455 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 456 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 457 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 458 */ 459 #define STRUCT_ATTR_CHAR(c,flags,structname,structmember) CLASS_ATTR_CHAR(c,#structmember,flags,structname,structmember) 460 461 462 /** 463 Create a long integer attribute and add it to a Max class. 464 The name of the attribute is automatically determined by the name of the struct member. 465 466 @ingroup attr 467 @param c The class pointer. 468 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 469 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 470 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 471 */ 472 #define STRUCT_ATTR_LONG(c,flags,structname,structmember) CLASS_ATTR_LONG(c,#structmember,flags,structname,structmember) 473 474 /** 475 Create a t_atom_long integer attribute and add it to a Max class. 476 The name of the attribute is automatically determined by the name of the struct member. 477 478 @ingroup attr 479 @param c The class pointer. 480 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 481 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 482 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 483 */ 484 #define STRUCT_ATTR_ATOM_LONG(c,flags,structname,structmember) CLASS_ATTR_ATOM_LONG(c,#structmember,flags,structname,structmember) 485 486 /** 487 Create a 32bit float attribute and add it to a Max class. 488 The name of the attribute is automatically determined by the name of the struct member. 489 490 @ingroup attr 491 @param c The class pointer. 492 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 493 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 494 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 495 */ 496 #define STRUCT_ATTR_FLOAT(c,flags,structname,structmember) CLASS_ATTR_FLOAT(c,#structmember,flags,structname,structmember) 497 498 499 /** 500 Create a 64bit float attribute and add it to a Max class. 501 The name of the attribute is automatically determined by the name of the struct member. 502 503 @ingroup attr 504 @param c The class pointer. 505 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 506 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 507 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 508 */ 509 #define STRUCT_ATTR_DOUBLE(c,flags,structname,structmember) CLASS_ATTR_DOUBLE(c,#structmember,flags,structname,structmember) 510 511 512 /** 513 Create a #t_symbol* attribute and add it to a Max class. 514 The name of the attribute is automatically determined by the name of the struct member. 515 516 @ingroup attr 517 @param c The class pointer. 518 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 519 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 520 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 521 */ 522 #define STRUCT_ATTR_SYM(c,flags,structname,structmember) CLASS_ATTR_SYM(c,#structmember,flags,structname,structmember) 523 524 525 /** 526 Create a #t_atom attribute and add it to a Max class. 527 The name of the attribute is automatically determined by the name of the struct member. 528 529 @ingroup attr 530 @param c The class pointer. 531 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 532 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 533 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 534 */ 535 #define STRUCT_ATTR_ATOM(c,flags,structname,structmember) CLASS_ATTR_ATOM(c,#structmember,flags,structname,structmember) 536 537 538 /** 539 Create a #t_object* attribute and add it to a Max class. 540 The name of the attribute is automatically determined by the name of the struct member. 541 542 @ingroup attr 543 @param c The class pointer. 544 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 545 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 546 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 547 */ 548 #define STRUCT_ATTR_OBJ(c,flags,structname,structmember) CLASS_ATTR_OBJ(c,#structmember,flags,structname,structmember) 549 550 551 552 // fixed size array variants 553 554 /** 555 Create an array-of-chars attribute of fixed length, and add it to a Max class. 556 The name of the attribute is automatically determined by the name of the struct member. 557 558 @ingroup attr 559 @param c The class pointer. 560 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 561 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 562 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 563 @param size The number of items in the char array. 564 */ 565 #define STRUCT_ATTR_CHAR_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_CHAR_ARRAY(c,#structmember,flags,structname,structmember,size) 566 567 568 /** 569 Create an array-of-long-integers attribute of fixed length, and add it to a Max class. 570 The name of the attribute is automatically determined by the name of the struct member. 571 572 @ingroup attr 573 @param c The class pointer. 574 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 575 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 576 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 577 @param size The number of items in the long array. 578 */ 579 #define STRUCT_ATTR_LONG_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_LONG_ARRAY(c,#structmember,flags,structname,structmember,size) 580 581 582 /** 583 Create an array-of-32bit-floats attribute of fixed length, and add it to a Max class. 584 The name of the attribute is automatically determined by the name of the struct member. 585 586 @ingroup attr 587 @param c The class pointer. 588 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 589 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 590 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 591 @param size The number of items in the floats array. 592 */ 593 #define STRUCT_ATTR_FLOAT_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_FLOAT_ARRAY(c,#structmember,flags,structname,structmember,size) 594 595 596 /** 597 Create an array-of-64bit-floats attribute of fixed length, and add it to a Max class. 598 The name of the attribute is automatically determined by the name of the struct member. 599 600 @ingroup attr 601 @param c The class pointer. 602 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 603 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 604 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 605 @param size The number of items in the double array. 606 */ 607 #define STRUCT_ATTR_DOUBLE_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_DOUBLE_ARRAY(c,#structmember,flags,structname,structmember,size) 608 609 610 /** 611 Create an array-of-symbols attribute of fixed length, and add it to a Max class. 612 The name of the attribute is automatically determined by the name of the struct member. 613 614 @ingroup attr 615 @param c The class pointer. 616 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 617 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 618 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 619 @param size The number of items in the #t_symbol* array. 620 */ 621 #define STRUCT_ATTR_SYM_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_SYM_ARRAY(c,#structmember,flags,structname,structmember,size) 622 623 624 /** 625 Create an array-of-atoms attribute of fixed length, and add it to a Max class. 626 The name of the attribute is automatically determined by the name of the struct member. 627 628 @ingroup attr 629 @param c The class pointer. 630 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 631 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 632 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 633 @param size The number of items in the #t_atom array. 634 */ 635 #define STRUCT_ATTR_ATOM_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_ATOM_ARRAY(c,#structmember,flags,structname,structmember,size) 636 637 638 /** 639 Create an array-of-objects attribute of fixed length, and add it to a Max class. 640 The name of the attribute is automatically determined by the name of the struct member. 641 642 @ingroup attr 643 @param c The class pointer. 644 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 645 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 646 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 647 @param size The number of items in the #t_object* array. 648 */ 649 #define STRUCT_ATTR_OBJ_ARRAY(c,flags,structname,structmember,size) CLASS_ATTR_OBJ_ARRAY(c,#structmember,flags,structname,structmember,size) 650 651 652 653 654 // variable size array variants 655 656 /** 657 Create an array-of-chars attribute of variable length, and add it to a Max class. 658 The name of the attribute is automatically determined by the name of the struct member. 659 660 @ingroup attr 661 @param c The class pointer. 662 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 663 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 664 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 665 @param sizemember The actual number of items in the char array at any given moment. 666 @param maxsize The maximum number of items in the char array, i.e. the number of members allocated for the array in the struct. 667 */ 668 #define STRUCT_ATTR_CHAR_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_CHAR_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 669 670 671 /** 672 Create an array-of-long-integers attribute of variable length, and add it to a Max class. 673 The name of the attribute is automatically determined by the name of the struct member. 674 675 @ingroup attr 676 @param c The class pointer. 677 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 678 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 679 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 680 @param sizemember The actual number of items in the long array at any given moment. 681 @param maxsize The maximum number of items in the long array, i.e. the number of members allocated for the array in the struct. 682 */ 683 #define STRUCT_ATTR_LONG_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_LONG_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 684 685 686 /** 687 Create an array-of-32bit-floats attribute of variable length, and add it to a Max class. 688 The name of the attribute is automatically determined by the name of the struct member. 689 690 @ingroup attr 691 @param c The class pointer. 692 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 693 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 694 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 695 @param sizemember The actual number of items in the float array at any given moment. 696 @param maxsize The maximum number of items in the float array, i.e. the number of members allocated for the array in the struct. 697 */ 698 #define STRUCT_ATTR_FLOAT_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_FLOAT_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 699 700 701 /** 702 Create an array-of-64bit-floats attribute of variable length, and add it to a Max class. 703 The name of the attribute is automatically determined by the name of the struct member. 704 705 @ingroup attr 706 @param c The class pointer. 707 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 708 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 709 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 710 @param sizemember The actual number of items in the double array at any given moment. 711 @param maxsize The maximum number of items in the double array, i.e. the number of members allocated for the array in the struct. 712 */ 713 #define STRUCT_ATTR_DOUBLE_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_DOUBLE_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 714 715 716 /** 717 Create an array-of-symbols attribute of variable length, and add it to a Max class. 718 The name of the attribute is automatically determined by the name of the struct member. 719 720 @ingroup attr 721 @param c The class pointer. 722 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 723 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 724 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 725 @param sizemember The actual number of items in the #t_symbol* array at any given moment. 726 @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. 727 */ 728 #define STRUCT_ATTR_SYM_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_SYM_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 729 730 731 /** 732 Create an array-of-atoms attribute of variable length, and add it to a Max class. 733 The name of the attribute is automatically determined by the name of the struct member. 734 735 @ingroup attr 736 @param c The class pointer. 737 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 738 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 739 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 740 @param sizemember The actual number of items in the #t_atom array at any given moment. 741 @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. 742 */ 743 #define STRUCT_ATTR_ATOM_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_ATOM_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 744 745 746 /** 747 Create an array-of-objects attribute of variable length, and add it to a Max class. 748 The name of the attribute is automatically determined by the name of the struct member. 749 750 @ingroup attr 751 @param c The class pointer. 752 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 753 @param structname The C identifier for the struct (containing a valid #t_object header) representing an instance of this class. 754 @param structmember The C identifier of the member in the struct that holds the value of this attribute. 755 @param sizemember The actual number of items in the #t_object* array at any given moment. 756 @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. 757 */ 758 #define STRUCT_ATTR_OBJ_VARSIZE(c,flags,structname,structmember,sizemember,maxsize) CLASS_ATTR_OBJ_VARSIZE(c,#structmember,flags,structname,structmember,sizemember,maxsize) 759 760 761 762 763 // class static variants 764 // these are unused in any c74 code 765 #define STATIC_ATTR_ATOMS class_addattr_atoms 766 #define STATIC_ATTR_PARSE class_addattr_parse 767 #define STATIC_ATTR_FORMAT class_addattr_format 768 #define STATIC_ATTR_CHAR(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(char),flags,"c",val) 769 #define STATIC_ATTR_LONG(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(long),flags,"l",val) 770 #define STATIC_ATTR_FLOAT(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(float32),flags,"f",val) 771 #define STATIC_ATTR_DOUBLE(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(float64),flags,"d",val) 772 #define STATIC_ATTR_SYM(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(symbol),flags,"s",val) 773 #define STATIC_ATTR_ATOM(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(atom),flags,"a",val) 774 #define STATIC_ATTR_OBJ(c,attrname,flags,val) STATIC_ATTR_FORMAT(c,attrname,USESYM(object),flags,"o",val) 775 #define STATIC_ATTR_CHAR_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(char),flags,"C",count,vals) 776 #define STATIC_ATTR_LONG_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(long),flags,"L",count,vals) 777 #define STATIC_ATTR_FLOAT_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(float32),flags,"F",count,vals) 778 #define STATIC_ATTR_DOUBLE_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(float64),flags,"D",count,vals) 779 #define STATIC_ATTR_SYM_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(symbol),flags,"S",count,vals) 780 #define STATIC_ATTR_ATOM_ARRAY STATIC_ATTR_ATOMS // these are really the same, included for consistency 781 #define STATIC_ATTR_OBJ_ARRAY(c,attrname,flags,count,vals) STATIC_ATTR_FORMAT(c,attrname,USESYM(object),flags,"O",count,vals) 782 783 784 785 786 // object versions, creates new object local attribute 787 #define OBJ_ATTR_ATOMS object_addattr_atoms 788 #define OBJ_ATTR_PARSE object_addattr_parse 789 #define OBJ_ATTR_FORMAT object_addattr_format 790 791 792 /** 793 Create an instance-local char attribute and add it to a Max class. 794 795 @ingroup attr 796 @param x The object pointer. 797 @param attrname The name of this attribute as a C-string. 798 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 799 @param val Pointer to the value. 800 */ 801 #define OBJ_ATTR_CHAR(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(char),flags,"c",val) 802 803 804 /** 805 Create an instance-local long integer attribute and add it to a Max class. 806 807 @ingroup attr 808 @param x The object pointer. 809 @param attrname The name of this attribute as a C-string. 810 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 811 @param val Pointer to the value. 812 */ 813 #define OBJ_ATTR_LONG(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(long),flags,"l",val) 814 815 816 /** 817 Create an instance-local 32bit float attribute and add it to a Max class. 818 819 @ingroup attr 820 @param x The object pointer. 821 @param attrname The name of this attribute as a C-string. 822 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 823 @param val Pointer to the value. 824 */ 825 #define OBJ_ATTR_FLOAT(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(float32),flags,"f",val) 826 827 828 /** 829 Create an instance-local 64bit float attribute and add it to a Max class. 830 831 @ingroup attr 832 @param x The object pointer. 833 @param attrname The name of this attribute as a C-string. 834 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 835 @param val Pointer to the value. 836 */ 837 #define OBJ_ATTR_DOUBLE(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(float64),flags,"d",val) 838 839 840 /** 841 Create an instance-local #t_symbol* attribute and add it to a Max class. 842 843 @ingroup attr 844 @param x The object pointer. 845 @param attrname The name of this attribute as a C-string. 846 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 847 @param val Pointer to the value. 848 */ 849 #define OBJ_ATTR_SYM(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(symbol),flags,"s",val) 850 851 852 /** 853 Create an instance-local #t_atom attribute and add it to a Max class. 854 855 @ingroup attr 856 @param x The object pointer. 857 @param attrname The name of this attribute as a C-string. 858 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 859 @param val Pointer to the value. 860 */ 861 #define OBJ_ATTR_ATOM(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(atom),flags,"a",val) 862 863 864 /** 865 Create an instance-local #t_object* attribute and add it to a Max class. 866 867 @ingroup attr 868 @param x The object pointer. 869 @param attrname The name of this attribute as a C-string. 870 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 871 @param val Pointer to the value. 872 */ 873 #define OBJ_ATTR_OBJ(x,attrname,flags,val) OBJ_ATTR_FORMAT(x,attrname,USESYM(object),flags,"o",val) 874 875 876 877 878 /** 879 Create an instance-local array-of-chars attribute of fixed length, and add it to the object. 880 881 @ingroup attr 882 @param x The object pointer. 883 @param attrname The name of this attribute as a C-string. 884 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 885 @param count The number of items in the char array. 886 @param vals Pointer to the values. 887 */ 888 #define OBJ_ATTR_CHAR_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(char),flags,"C",count,vals) 889 890 891 /** 892 Create an instance-local array-of-long-integers attribute of fixed length, and add it to the object. 893 894 @ingroup attr 895 @param x The object pointer. 896 @param attrname The name of this attribute as a C-string. 897 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 898 @param count The number of items in the long array. 899 @param vals Pointer to the values. 900 */ 901 #define OBJ_ATTR_LONG_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(long),flags,"L",count,vals) 902 903 904 /** 905 Create an instance-local array-of-32bit-floats attribute of fixed length, and add it to the object. 906 907 @ingroup attr 908 @param x The object pointer. 909 @param attrname The name of this attribute as a C-string. 910 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 911 @param count The number of items in the float array. 912 @param vals Pointer to the values. 913 */ 914 #define OBJ_ATTR_FLOAT_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(float32),flags,"F",count,vals) 915 916 917 /** 918 Create an instance-local array-of-64bit-floats attribute of fixed length, and add it to the object. 919 920 @ingroup attr 921 @param x The object pointer. 922 @param attrname The name of this attribute as a C-string. 923 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 924 @param count The number of items in the double array. 925 @param vals Pointer to the values. 926 */ 927 #define OBJ_ATTR_DOUBLE_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(float64),flags,"D",count,vals) 928 929 930 /** 931 Create an instance-local array-of-symbols attribute of fixed length, and add it to the object. 932 933 @ingroup attr 934 @param x The object pointer. 935 @param attrname The name of this attribute as a C-string. 936 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 937 @param count The number of items in the #t_symbol* array. 938 @param vals Pointer to the values. 939 */ 940 #define OBJ_ATTR_SYM_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(symbol),flags,"S",count,vals) 941 942 943 /** 944 Create an instance-local array-of-atoms attribute of fixed length, and add it to the object. 945 946 @ingroup attr 947 @param x The object pointer. 948 @param attrname The name of this attribute as a C-string. 949 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 950 @param count The number of items in the #t_atom array. 951 @param vals Pointer to the values. 952 */ 953 #define OBJ_ATTR_ATOM_ARRAY OBJ_ATTR_ATOMS // these are really the same, included for consistency 954 955 956 /** 957 Create an instance-local array-of-objects attribute of fixed length, and add it to the object. 958 959 @ingroup attr 960 @param x The object pointer. 961 @param attrname The name of this attribute as a C-string. 962 @param flags Any flags you wish to declare for this attribute, as defined in #e_max_attrflags. 963 @param count The number of items in the #t_object* array. 964 @param vals Pointer to the values. 965 */ 966 #define OBJ_ATTR_OBJ_ARRAY(x,attrname,flags,count,vals) OBJ_ATTR_FORMAT(x,attrname,USESYM(object),flags,"O",count,vals) 967 968 969 970 971 972 /** 973 Specify custom accessor methods for an attribute. 974 If you specify a non-NULL value for the setter or getter, 975 then the function you specify will be called to set or get the attribute's value 976 rather than using the built-in accessor. 977 978 @ingroup attr 979 @param c The class pointer. 980 @param attrname The name of the attribute as a C-string. 981 @param getter An appropriate getter method as discussed in @ref attribute_accessors, 982 or NULL to use the default getter. 983 @param setter An appropriate setter method as discussed in @ref attribute_accessors, 984 or NULL to use the default setter. 985 */ 986 #define CLASS_ATTR_ACCESSORS(c,attrname,getter,setter) \ 987 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 988 object_method(theattr,gensym("setmethod"),USESYM(get),getter); \ 989 object_method(theattr,gensym("setmethod"),USESYM(set),setter); } 990 991 992 /** 993 Add flags to an attribute. 994 995 @ingroup attr 996 @param c The class pointer. 997 @param attrname The name of the attribute as a C-string. 998 @param flags Any flags you wish to add to this attribute, as defined in #e_max_attrflags. 999 */ 1000 #define CLASS_ATTR_ADD_FLAGS(c,attrname,flags) \ 1001 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 1002 long oldflags = object_method(theattr,gensym("getflags")); \ 1003 object_method(theattr,gensym("setflags"),oldflags|(flags)); } 1004 1005 1006 /** 1007 Remove flags from an attribute. 1008 1009 @ingroup attr 1010 @param c The class pointer. 1011 @param attrname The name of the attribute as a C-string. 1012 @param flags Any flags you wish to remove from this attribute, as defined in #e_max_attrflags. 1013 */ 1014 #define CLASS_ATTR_REMOVE_FLAGS(c,attrname,flags) \ 1015 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 1016 long oldflags = object_method(theattr,gensym("getflags")); \ 1017 object_method(theattr,gensym("setflags"),oldflags&(~(flags))); } 1018 1019 1020 /** 1021 Add a filter to the attribute to limit the lower bound of a value. 1022 The limiting will be performed by the default attribute accessor. 1023 1024 @ingroup attr 1025 @param c The class pointer. 1026 @param attrname The name of the attribute as a C-string. 1027 @param minval The minimum acceptable value to which the attribute will be limited. 1028 @see CLASS_ATTR_FILTER_MAX 1029 @see CLASS_ATTR_FILTER_CLIP 1030 @see CLASS_ATTR_MIN 1031 */ 1032 #define CLASS_ATTR_FILTER_MIN(c,attrname,minval) \ 1033 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 1034 attr_addfilter_clip(theattr,minval,0,1,0); } 1035 1036 1037 /** 1038 Add a filter to the attribute to limit the upper bound of a value. 1039 The limiting will be performed by the default attribute accessor. 1040 1041 @ingroup attr 1042 @param c The class pointer. 1043 @param attrname The name of the attribute as a C-string. 1044 @param maxval The maximum acceptable value to which the attribute will be limited. 1045 @see CLASS_ATTR_FILTER_MIN 1046 @see CLASS_ATTR_FILTER_CLIP 1047 @see CLASS_ATTR_MAX 1048 */ 1049 #define CLASS_ATTR_FILTER_MAX(c,attrname,maxval) \ 1050 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 1051 attr_addfilter_clip(theattr,0,maxval,0,1); } 1052 1053 1054 /** 1055 Add a filter to the attribute to limit both the lower and upper bounds of a value. 1056 The limiting will be performed by the default attribute accessor. 1057 1058 @ingroup attr 1059 @param c The class pointer. 1060 @param attrname The name of the attribute as a C-string. 1061 @param minval The maximum acceptable value to which the attribute will be limited. 1062 @param maxval The maximum acceptable value to which the attribute will be limited. 1063 @see 1064 */ 1065 #define CLASS_ATTR_FILTER_CLIP(c,attrname,minval,maxval) \ 1066 { t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 1067 attr_addfilter_clip(theattr,minval,maxval,1,1); } 1068 1069 1070 /** 1071 Create a new attribute that is an alias of an existing attribute. 1072 1073 @ingroup attr 1074 @param c The class pointer. 1075 @param attrname The name of the actual attribute as a C-string. 1076 @param aliasname The name of the new alias attribute. 1077 */ 1078 #define CLASS_ATTR_ALIAS(c,attrname,aliasname) \ 1079 { t_object *thealias; \ 1080 t_object *theattr=(t_object *)class_attr_get(c,gensym(attrname)); \ 1081 thealias = object_clone(theattr); \ 1082 object_method(thealias,USESYM(setname),gensym(aliasname)); \ 1083 class_addattr(c,thealias); \ 1084 CLASS_ATTR_ATTR_PARSE(c,aliasname,"alias",USESYM(symbol),0,attrname); } 1085 1086 1087 1088 1089 // macros for attribute of attributes 1090 #define CLASS_ATTR_ATTR_ATOMS class_attr_addattr_atoms 1091 #define CLASS_ATTR_ATTR_PARSE class_attr_addattr_parse 1092 #define CLASS_ATTR_ATTR_FORMAT class_attr_addattr_format 1093 1094 1095 /** 1096 Add a new attribute to the specified attribute to specify a default value. 1097 The default value will be automatically set when the object is created only if your object uses a dictionary constructor 1098 with the #CLASS_FLAG_NEWDICTIONARY flag. 1099 1100 @ingroup attr 1101 @param c The class pointer. 1102 @param attrname The name of the attribute as a C-string. 1103 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1104 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1105 */ 1106 #define CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr) \ 1107 { 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); } 1108 1109 1110 /** 1111 Add a new attribute to the specified attribute to indicate that the specified attribute should be saved with the patcher. 1112 1113 @ingroup attr 1114 @param c The class pointer. 1115 @param attrname The name of the attribute as a C-string. 1116 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1117 */ 1118 #define CLASS_ATTR_SAVE(c,attrname,flags) \ 1119 CLASS_ATTR_ATTR_PARSE(c,attrname,"save",USESYM(long),flags,"1") 1120 1121 /** 1122 Add a new attribute to the specified attribute to indicate that it is saved by the object 1123 (so it does not appear in italics in the inspector). 1124 1125 @ingroup attr 1126 @param c The class pointer. 1127 @param attrname The name of the attribute as a C-string. 1128 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1129 */ 1130 #define CLASS_ATTR_SELFSAVE(c,attrname,flags) \ 1131 CLASS_ATTR_ATTR_PARSE(c,attrname,"selfsave",USESYM(long),flags,"1") 1132 1133 /** 1134 A convenience wrapper for both #CLASS_ATTR_DEFAULT and #CLASS_ATTR_SAVE. 1135 1136 @ingroup attr 1137 @param c The class pointer. 1138 @param attrname The name of the attribute as a C-string. 1139 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1140 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1141 @see CLASS_ATTR_DEFAULT 1142 @see CLASS_ATTR_SAVE 1143 */ 1144 #define CLASS_ATTR_DEFAULT_SAVE(c,attrname,flags,parsestr) \ 1145 { CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); } 1146 1147 1148 /** 1149 Add a new attribute to the specified attribute to specify a default value, based on Max's Object Defaults. 1150 If a value is present in Max's Object Defaults, then that value will be used as the default value. 1151 Otherwise, use the default value specified here. 1152 The default value will be automatically set when the object is created only if your object uses a dictionary constructor 1153 with the #CLASS_FLAG_NEWDICTIONARY flag. 1154 1155 @ingroup attr 1156 @param c The class pointer. 1157 @param attrname The name of the attribute as a C-string. 1158 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1159 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1160 */ 1161 #define CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr) \ 1162 { 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); } 1163 1164 1165 /** 1166 A convenience wrapper for both #CLASS_ATTR_DEFAULTNAME and #CLASS_ATTR_SAVE. 1167 1168 @ingroup attr 1169 @param c The class pointer. 1170 @param attrname The name of the attribute as a C-string. 1171 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1172 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1173 @see CLASS_ATTR_DEFAULTNAME 1174 @see CLASS_ATTR_SAVE 1175 */ 1176 #define CLASS_ATTR_DEFAULTNAME_SAVE(c,attrname,flags,parsestr) \ 1177 { CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); } 1178 1179 1180 /** 1181 Add a new attribute to the specified attribute to specify a lower range. 1182 The values will not be automatically limited. 1183 1184 @ingroup attr 1185 @param c The class pointer. 1186 @param attrname The name of the attribute as a C-string. 1187 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1188 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1189 @see CLASS_ATTR_MAX 1190 @see CLASS_ATTR_FILTER_MAX 1191 @see CLASS_ATTR_FILTER_CLIP 1192 */ 1193 #define CLASS_ATTR_MIN(c,attrname,flags,parsestr) \ 1194 { 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); } 1195 1196 1197 /** 1198 Add a new attribute to the specified attribute to specify an upper range. 1199 The values will not be automatically limited. 1200 1201 @ingroup attr 1202 @param c The class pointer. 1203 @param attrname The name of the attribute as a C-string. 1204 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1205 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1206 @see CLASS_ATTR_MIN 1207 @see CLASS_ATTR_FILTER_MAX 1208 @see CLASS_ATTR_FILTER_CLIP 1209 */ 1210 #define CLASS_ATTR_MAX(c,attrname,flags,parsestr) \ 1211 { 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); } 1212 1213 1214 // useful attr attr macros for UI objects 1215 1216 /** 1217 Add a new attribute indicating that any changes to the specified attribute will trigger a call 1218 to the object's paint method. 1219 1220 @ingroup attr 1221 @param c The class pointer. 1222 @param attrname The name of the attribute as a C-string. 1223 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1224 */ 1225 #define CLASS_ATTR_PAINT(c,attrname,flags) \ 1226 CLASS_ATTR_ATTR_PARSE(c,attrname,"paint",USESYM(long),flags,"1") 1227 1228 1229 /** 1230 A convenience wrapper for both #CLASS_ATTR_DEFAULT and #CLASS_ATTR_PAINT. 1231 1232 @ingroup attr 1233 @param c The class pointer. 1234 @param attrname The name of the attribute as a C-string. 1235 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1236 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1237 @see CLASS_ATTR_DEFAULT 1238 @see CLASS_ATTR_PAINT 1239 */ 1240 #define CLASS_ATTR_DEFAULT_PAINT(c,attrname,flags,parsestr) \ 1241 { CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr); CLASS_ATTR_PAINT(c,attrname,flags); } 1242 1243 1244 /** 1245 A convenience wrapper for #CLASS_ATTR_DEFAULT, #CLASS_ATTR_SAVE, and #CLASS_ATTR_PAINT. 1246 1247 @ingroup attr 1248 @param c The class pointer. 1249 @param attrname The name of the attribute as a C-string. 1250 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1251 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1252 @see CLASS_ATTR_DEFAULT 1253 @see CLASS_ATTR_PAINT 1254 @see CLASS_ATTR_SAVE 1255 */ 1256 #define CLASS_ATTR_DEFAULT_SAVE_PAINT(c,attrname,flags,parsestr) \ 1257 { CLASS_ATTR_DEFAULT(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); CLASS_ATTR_PAINT(c,attrname,flags); } 1258 1259 1260 /** 1261 A convenience wrapper for #CLASS_ATTR_DEFAULTNAME, #CLASS_ATTR_SAVE, and #CLASS_ATTR_PAINT. 1262 1263 @ingroup attr 1264 @param c The class pointer. 1265 @param attrname The name of the attribute as a C-string. 1266 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1267 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1268 @see CLASS_ATTR_DEFAULTNAME 1269 @see CLASS_ATTR_PAINT 1270 @see CLASS_ATTR_SAVE 1271 */ 1272 #define CLASS_ATTR_DEFAULTNAME_PAINT(c,attrname,flags,parsestr) \ 1273 { CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr); CLASS_ATTR_PAINT(c,attrname,flags); } 1274 1275 1276 /** 1277 A convenience wrapper for #CLASS_ATTR_DEFAULTNAME, #CLASS_ATTR_SAVE, and #CLASS_ATTR_PAINT. 1278 1279 @ingroup attr 1280 @param c The class pointer. 1281 @param attrname The name of the attribute as a C-string. 1282 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1283 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1284 @see CLASS_ATTR_DEFAULTNAME 1285 @see CLASS_ATTR_PAINT 1286 @see CLASS_ATTR_SAVE 1287 */ 1288 #define CLASS_ATTR_DEFAULTNAME_SAVE_PAINT(c,attrname,flags,parsestr) \ 1289 { CLASS_ATTR_DEFAULTNAME(c,attrname,flags,parsestr); CLASS_ATTR_SAVE(c,attrname,flags); CLASS_ATTR_PAINT(c,attrname,flags); } 1290 1291 1292 // useful attr attr macros for inpector properties 1293 1294 1295 /** 1296 Add a new attribute to the specified attribute to specify an editor style for the Max inspector. 1297 Available styles include 1298 <ul> 1299 <li>"text" : a text editor</li> 1300 <li>"onoff" : a toggle switch</li> 1301 <li>"rgba" : a color chooser</li> 1302 <li>"enum" : a menu of available choices, whose symbol will be passed upon selection</li> 1303 <li>"enumindex" : a menu of available choices, whose index will be passed upon selection</li> 1304 <li>"rect" : a style for displaying and editing #t_rect values</li> 1305 <li>"font" : a font chooser</li> 1306 <li>"file" : a file chooser dialog</li> 1307 </ul> 1308 1309 @ingroup attr 1310 @param c The class pointer. 1311 @param attrname The name of the attribute as a C-string. 1312 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1313 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1314 */ 1315 #define CLASS_ATTR_STYLE(c,attrname,flags,parsestr) \ 1316 CLASS_ATTR_ATTR_PARSE(c,attrname,"style",USESYM(symbol),flags,parsestr) 1317 1318 1319 /** 1320 Add a new attribute to the specified attribute to specify an a human-friendly label for the Max inspector. 1321 1322 @ingroup attr 1323 @param c The class pointer. 1324 @param attrname The name of the attribute as a C-string. 1325 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1326 @param labelstr A C-string, which will be parsed into an array of atoms to set the initial value. 1327 */ 1328 #define CLASS_ATTR_LABEL(c,attrname,flags,labelstr) \ 1329 CLASS_ATTR_ATTR_FORMAT(c,attrname,"label",USESYM(symbol),flags,"s",gensym_tr(labelstr)) 1330 1331 1332 /** 1333 Add a new attribute to the specified attribute to specify a list of choices to display in a menu 1334 for the Max inspector. 1335 1336 @ingroup attr 1337 @param c The class pointer. 1338 @param attrname The name of the attribute as a C-string. 1339 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1340 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1341 1342 @remark This macro automatically calls 1343 @code 1344 CLASS_ATTR_STYLE(c,attrname,flags,"enum"). 1345 @endcode 1346 1347 @see CLASS_ATTR_ENUMINDEX 1348 */ 1349 #define CLASS_ATTR_ENUM(c,attrname,flags,parsestr) \ 1350 { CLASS_ATTR_STYLE(c,attrname,flags,"enum"); CLASS_ATTR_ATTR_PARSE(c,attrname,"enumvals",USESYM(atom),flags,parsestr); } 1351 1352 1353 /** 1354 Add a new attribute to the specified attribute to specify a list of choices to display in a menu 1355 for the Max inspector. 1356 1357 @ingroup attr 1358 @param c The class pointer. 1359 @param attrname The name of the attribute as a C-string. 1360 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1361 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1362 1363 @remark This macro automatically calls 1364 @code 1365 CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"). 1366 @endcode 1367 1368 @see CLASS_ATTR_ENUM 1369 */ 1370 #define CLASS_ATTR_ENUMINDEX(c,attrname,flags,parsestr) \ 1371 { CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); CLASS_ATTR_ATTR_PARSE(c,attrname,"enumvals",USESYM(atom),flags,parsestr); } 1372 1373 // localizable versions 1374 #define CLASS_ATTR_ENUMINDEX2(c,attrname,flags,enum1,enum2) \ 1375 { t_atom aaa[2]; CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); atom_setsym(aaa,gensym_tr(enum1)); atom_setsym(aaa+1,gensym_tr(enum2)); \ 1376 CLASS_ATTR_ATTR_ATOMS(c,attrname,"enumvals",USESYM(atom),flags,2,aaa); } 1377 1378 #define CLASS_ATTR_ENUMINDEX3(c,attrname,flags,enum1,enum2,enum3) \ 1379 { t_atom aaa[3]; CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); atom_setsym(aaa,gensym_tr(enum1)); atom_setsym(aaa+1,gensym_tr(enum2)); atom_setsym(aaa+2,gensym_tr(enum3));\ 1380 CLASS_ATTR_ATTR_ATOMS(c,attrname,"enumvals",USESYM(atom),flags,3,aaa); } 1381 1382 #define CLASS_ATTR_ENUMINDEX4(c,attrname,flags,enum1,enum2,enum3,enum4) \ 1383 { t_atom aaa[4]; CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); atom_setsym(aaa,gensym_tr(enum1)); atom_setsym(aaa+1,gensym_tr(enum2)); atom_setsym(aaa+2,gensym_tr(enum3)); atom_setsym(aaa+3,gensym_tr(enum4));\ 1384 CLASS_ATTR_ATTR_ATOMS(c,attrname,"enumvals",USESYM(atom),flags,4,aaa); } 1385 1386 #define CLASS_ATTR_ENUMINDEX5(c,attrname,flags,enum1,enum2,enum3,enum4,enum5) \ 1387 { t_atom aaa[5]; CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); atom_setsym(aaa,gensym_tr(enum1)); atom_setsym(aaa+1,gensym_tr(enum2)); atom_setsym(aaa+2,gensym_tr(enum3));\ 1388 atom_setsym(aaa+3,gensym_tr(enum4)); atom_setsym(aaa+4,gensym_tr(enum5));\ 1389 CLASS_ATTR_ATTR_ATOMS(c,attrname,"enumvals",USESYM(atom),flags,5,aaa); } 1390 1391 #define CLASS_ATTR_ENUMINDEX6(c,attrname,flags,enum1,enum2,enum3,enum4,enum5,enum6) \ 1392 { t_atom aaa[6]; CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); atom_setsym(aaa,gensym_tr(enum1)); atom_setsym(aaa+1,gensym_tr(enum2)); atom_setsym(aaa+2,gensym_tr(enum3));\ 1393 atom_setsym(aaa+3,gensym_tr(enum4)); atom_setsym(aaa+4,gensym_tr(enum5)); atom_setsym(aaa+5,gensym_tr(enum6));\ 1394 CLASS_ATTR_ATTR_ATOMS(c,attrname,"enumvals",USESYM(atom),flags,6,aaa); } 1395 1396 #define CLASS_ATTR_ENUMINDEX7(c,attrname,flags,enum1,enum2,enum3,enum4,enum5,enum6,enum7) \ 1397 { t_atom aaa[7]; CLASS_ATTR_STYLE(c,attrname,flags,"enumindex"); atom_setsym(aaa,gensym_tr(enum1)); atom_setsym(aaa+1,gensym_tr(enum2)); atom_setsym(aaa+2,gensym_tr(enum3));\ 1398 atom_setsym(aaa+3,gensym_tr(enum4)); atom_setsym(aaa+4,gensym_tr(enum5)); atom_setsym(aaa+5,gensym_tr(enum6)); atom_setsym(aaa+6,gensym_tr(enum7));\ 1399 CLASS_ATTR_ATTR_ATOMS(c,attrname,"enumvals",USESYM(atom),flags,7,aaa); } 1400 1401 /** 1402 Add a new attribute to the specified attribute to specify a category to which the attribute is assigned 1403 in the Max inspector. 1404 Categories are represented in the inspector as tabs. 1405 If the specified category does not exist then it will be created. 1406 1407 @ingroup attr 1408 @param c The class pointer. 1409 @param attrname The name of the attribute as a C-string. 1410 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1411 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1412 */ 1413 #define CLASS_ATTR_CATEGORY(c,attrname,flags,parsestr) \ 1414 CLASS_ATTR_ATTR_PARSE(c,attrname,"category",USESYM(symbol),flags,str_tr(parsestr)) 1415 1416 1417 /** 1418 A convenience wrapper for #CLASS_ATTR_STYLE, and #CLASS_ATTR_LABEL. 1419 1420 @ingroup attr 1421 @param c The class pointer. 1422 @param attrname The name of the attribute as a C-string. 1423 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1424 @param stylestr A C-string that names the style for the attribute. 1425 See #CLASS_ATTR_STYLE for the available styles. 1426 @param labelstr A C-string that names the category to which the attribute is assigned in the inspector. 1427 1428 @see CLASS_ATTR_STYLE 1429 @see CLASS_ATTR_LABEL 1430 */ 1431 #define CLASS_ATTR_STYLE_LABEL(c,attrname,flags,stylestr,labelstr) \ 1432 { CLASS_ATTR_ATTR_PARSE(c,attrname,"style",USESYM(symbol),flags,stylestr); CLASS_ATTR_ATTR_FORMAT(c,attrname,"label",USESYM(symbol),flags,"s",gensym_tr(labelstr)); } 1433 1434 1435 /** 1436 Add a new attribute to the specified attribute to flag an attribute as invisible to the Max inspector. 1437 1438 @ingroup attr 1439 @param c The class pointer. 1440 @param attrname The name of the attribute as a C-string. 1441 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1442 */ 1443 #define CLASS_ATTR_INVISIBLE(c,attrname,flags) \ 1444 CLASS_ATTR_ATTR_PARSE(c,attrname,"invisible",USESYM(long),flags,"1") 1445 1446 1447 /** 1448 Add a new attribute to the specified attribute to specify a default order in which to list attributes. 1449 1450 @ingroup attr 1451 @param c The class pointer. 1452 @param attrname The name of the attribute as a C-string. 1453 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1454 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1455 1456 @remark A value of zero indicates that there is no ordering. Ordering values begin at 1. For example: 1457 @code 1458 CLASS_ATTR_ORDER(c, "firstattr", 0, "1"); 1459 CLASS_ATTR_ORDER(c, "secondattr", 0, "2"); 1460 CLASS_ATTR_ORDER(c, "thirdattr", 0, "3"); 1461 @endcode 1462 */ 1463 #define CLASS_ATTR_ORDER(c,attrname,flags,parsestr) \ 1464 CLASS_ATTR_ATTR_PARSE(c,attrname,"order",USESYM(long),flags,parsestr) 1465 1466 /** 1467 Add a new attribute to the specified attribute to specify that it should appear in the inspector's Basic tab. 1468 1469 @ingroup attr 1470 @param c The class pointer. 1471 @param attrname The name of the attribute as a C-string. 1472 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1473 1474 */ 1475 #define CLASS_ATTR_BASIC(c,attrname,flags) \ 1476 CLASS_ATTR_ATTR_PARSE(c,attrname,"basic",USESYM(long),flags,"1") 1477 1478 1479 1480 1481 // useful attr attr macro for objects that embed binary data as base64 1482 1483 #define CLASS_ATTR_ATOMARRAY(c,attrname,flags) \ 1484 CLASS_ATTR_ATTR_PARSE(c,attrname,"atomarray",USESYM(long),flags,"1") 1485 1486 1487 /** Define and add attributes to class methods. 1488 @ingroup attr 1489 @param c The class pointer. 1490 @param methodname The name of the existing method as a C-string. 1491 @param attrname The name of the attribute to add as a C-string. 1492 @param type The datatype of the attribute to be added. 1493 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1494 @param parsestring A C-string, which will be parsed into an array of atoms to set the initial value. 1495 1496 @remark An example which makes a method invisible to users: 1497 @code 1498 class_addmethod(c, (method)my_foo, "foo", 0); 1499 CLASS_METHOD_ATTR_PARSE(c, "foo", "undocumented", gensym("long"), 0, "1"); 1500 @endcode 1501 */ 1502 #define CLASS_METHOD_ATTR_PARSE(c,methodname,attrname,type,flags,parsestring) \ 1503 { t_hashtab *methods=NULL; \ 1504 t_object *m=NULL; \ 1505 methods = (t_hashtab *)class_extra_lookup(c,gensym("methods")); \ 1506 if (methods) { \ 1507 hashtab_lookup(methods,gensym((methodname)),&m); \ 1508 if (m) \ 1509 object_addattr_parse(m,attrname,type,flags,parsestring); \ 1510 } \ 1511 } 1512 1513 1514 /** 1515 Add a new attribute to the specified attribute to specify a legacy default value. 1516 The default value will be automatically set when the object is created only if your object uses a dictionary constructor 1517 with the #CLASS_FLAG_NEWDICTIONARY flag. 1518 1519 @ingroup attr 1520 @param c The class pointer. 1521 @param legacyattrname The name of the attribute. 1522 @param newattrname The name of the attribute. 1523 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1524 @param parsestr A C-string, which will be parsed into an array of atoms to set the legacy value, used by jbox_processlegacydefaults() 1525 */ 1526 #define CLASS_ATTR_LEGACYDEFAULT(c,legacyattrname,newattrname,flags,parsestr) \ 1527 { \ 1528 t_object *theattr = (t_object *)class_attr_get(c,gensym(legacyattrname)); \ 1529 t_hashtab *legs = NULL; \ 1530 CLASS_ATTR_ATTR_PARSE(c,legacyattrname,"legacydefault",(t_symbol *)object_method(theattr,USESYM(gettype)),flags,parsestr); \ 1531 legs = (t_hashtab *)class_extra_lookup(c, gensym("legacydefaults")); \ 1532 if (legs == NULL) { \ 1533 legs = (t_hashtab *)hashtab_new(0); hashtab_flags(legs, OBJ_FLAG_DATA); \ 1534 class_extra_store(c, gensym("legacydefaults"), (t_object *)legs); \ 1535 } \ 1536 hashtab_store(legs, gensym(legacyattrname), (t_object *)gensym(newattrname)); \ 1537 } 1538 1539 1540 /** 1541 Add a new attribute to the specified attribute to flag it as obsolete. 1542 1543 @ingroup attr 1544 @param c The class pointer. 1545 @param attrname The name of the attribute as a C-string. 1546 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1547 */ 1548 #define CLASS_ATTR_OBSOLETE(c,attrname,flags) \ 1549 { \ 1550 t_object *attr; \ 1551 attr = (t_object *)class_attr_get(c,gensym(attrname)); \ 1552 if (!attr) { \ 1553 attr = attribute_new(attrname, USESYM(atom), 0, (method)object_attr_obsolete_getter, (method)object_attr_obsolete_setter); \ 1554 class_addattr(c, attr); \ 1555 } \ 1556 CLASS_ATTR_ATTR_PARSE(c,attrname,"obsolete",USESYM(long),flags,"1"); \ 1557 CLASS_ATTR_ATTR_PARSE(c,attrname,"invisible",USESYM(long),flags,"1"); \ 1558 } 1559 1560 1561 /** 1562 Add a new attribute to the specified attribute to flag it as renamed. 1563 1564 @ingroup attr 1565 @param c The class pointer. 1566 @param oldname The name of the old attribute as a C-string. 1567 @param newname The name of the new attribute as a C-string. 1568 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1569 */ 1570 #define CLASS_ATTR_RENAMED(c,oldname,newname,flags) \ 1571 { \ 1572 CLASS_ATTR_OBSOLETE(c,oldname,flags); \ 1573 CLASS_ATTR_ATTR_PARSE(c,oldname,"renamed",USESYM(symbol),flags,newname); \ 1574 } 1575 1576 1577 /** 1578 Add a new attribute to the specified attribute to indicate in which version the attribute was introduced. 1579 1580 @ingroup attr 1581 @param c The class pointer. 1582 @param attrname The name of the attribute as a C-string. 1583 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1584 @param versionstr A C-string, which will be parsed set the version number (e.g. "7.0.0"). 1585 */ 1586 #define CLASS_ATTR_INTRODUCED(c,attrname,flags,versionstr) \ 1587 CLASS_ATTR_ATTR_PARSE(c,attrname,"introduced",USESYM(symbol),flags,str_tr(versionstr)) 1588 1589 1590 /** 1591 Add a new attribute to the specified method to flag it as obsolete. 1592 1593 @ingroup attr 1594 @param c The class pointer. 1595 @param methodname The name of the method as a C-string. 1596 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1597 */ 1598 #define CLASS_METHOD_OBSOLETE(c,methodname,flags) \ 1599 { t_hashtab *methods=NULL; \ 1600 t_object *m=NULL; \ 1601 methods = (t_hashtab *)class_extra_lookup(c,gensym("methods")); \ 1602 if (methods) { \ 1603 hashtab_lookup(methods,gensym((methodname)),&m); \ 1604 if (!m) \ 1605 { \ 1606 class_addmethod(c,(method)object_method_obsolete,methodname,A_GIMME,0L); \ 1607 hashtab_lookup(methods,gensym((methodname)),&m); \ 1608 } \ 1609 if (m) \ 1610 { \ 1611 object_addattr_parse(m,"invisible",USESYM(long),flags,"1"); \ 1612 object_addattr_parse(m,"obsolete",USESYM(long),flags,"1"); \ 1613 } \ 1614 } \ 1615 } 1616 1617 /** 1618 Add a new attribute to the specified method to flag a method as renamed. 1619 1620 @ingroup attr 1621 @param c The class pointer. 1622 @param oldname The name of the old method as a C-string. 1623 @param newname The name of the new method as a C-string. 1624 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1625 */ 1626 #define CLASS_METHOD_RENAMED(c,oldname,newname,flags) \ 1627 { \ 1628 CLASS_METHOD_OBSOLETE(c,oldname,flags); \ 1629 CLASS_METHOD_ATTR_PARSE(c,oldname,"renamed",USESYM(symbol),flags,newname); \ 1630 } 1631 1632 /** 1633 Add a new attribute to the specified method to indicate in which version the method was introduced. 1634 1635 @ingroup attr 1636 @param c The class pointer. 1637 @param methodname The name of the method as a C-string. 1638 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1639 @param versionstr A C-string, which will be parsed set the version number (e.g. "7.0.0"). 1640 */ 1641 #define CLASS_METHOD_INTRODUCED(c,methodname,flags,versionstr) \ 1642 CLASS_METHOD_ATTR_PARSE(c,methodname,"introduced",USESYM(symbol),flags,str_tr(versionstr)) 1643 1644 1645 #define OBJ_ATTR_ATTR_ATOMS object_attr_addattr_atoms 1646 #define OBJ_ATTR_ATTR_PARSE object_attr_addattr_parse 1647 #define OBJ_ATTR_ATTR_FORMAT object_attr_addattr_format 1648 1649 1650 /** 1651 An instance-attribute version of #CLASS_ATTR_DEFAULT. 1652 1653 @ingroup attr 1654 @param x The #t_object instance pointer. 1655 @param attrname The name of the attribute as a C-string. 1656 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1657 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1658 @see CLASS_ATTR_DEFAULT 1659 */ 1660 #define OBJ_ATTR_DEFAULT(x,attrname,flags,parsestr) \ 1661 { 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); } 1662 1663 1664 /** 1665 An instance-attribute version of #CLASS_ATTR_SAVE. 1666 1667 @ingroup attr 1668 @param x The #t_object instance pointer. 1669 @param attrname The name of the attribute as a C-string. 1670 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1671 @see CLASS_ATTR_SAVE 1672 */ 1673 #define OBJ_ATTR_SAVE(x,attrname,flags) \ 1674 OBJ_ATTR_ATTR_PARSE(x,attrname,"save",USESYM(long),flags,"1") 1675 1676 1677 /** 1678 An instance-attribute version of #CLASS_ATTR_DEFAULT_SAVE. 1679 1680 @ingroup attr 1681 @param x The #t_object instance pointer. 1682 @param attrname The name of the attribute as a C-string. 1683 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1684 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1685 @see CLASS_ATTR_DEFAULT_SAVE 1686 */ 1687 #define OBJ_ATTR_DEFAULT_SAVE(x,attrname,flags,parsestr) \ 1688 { OBJ_ATTR_DEFAULT(x,attrname,flags,parsestr); OBJ_ATTR_SAVE(x,attrname,flags); } 1689 1690 // used to transition former CLASS_ATTR_SAVE attrs mistakenly declared 1691 1692 #define CLASS_ATTR_DONTSAVE(c,attrname,flags) \ 1693 CLASS_ATTR_ATTR_PARSE(c,attrname,"dontsave",USESYM(long),flags,"1") 1694 1695 1696 1697 // sticky macros for attribute attributes, and method attributes. Useful for defining attribute groups 1698 1699 /** 1700 Create an attribute, and add it to all following attribute declarations. 1701 The block is closed by a call to #CLASS_STICKY_ATTR_CLEAR. 1702 1703 @ingroup attr 1704 @param c The class pointer. 1705 @param name The name of the new attribute to create as a C-string. 1706 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1707 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1708 1709 @remark The most common use of CLASS_STICKY_ATTR is for creating multiple attributes with the same category, 1710 as in this example: 1711 @code 1712 CLASS_STICKY_ATTR(c, "category", 0, "Foo"); 1713 1714 CLASS_ATTR_DOUBLE(c, "bar", 0, t_myobject, x_bar); 1715 CLASS_ATTR_LABEL(c, "bar", 0, "A Bar"); 1716 1717 CLASS_ATTR_CHAR(c, "switch", 0, t_myobject, x_switch); 1718 CLASS_ATTR_STYLE_LABEL(c, "switch", 0, "onoff", "Bar Switch"); 1719 1720 CLASS_ATTR_DOUBLE(c, "flow", 0, t_myobject, x_flow); 1721 CLASS_ATTR_LABEL(c, "flow", 0, "Flow Amount"); 1722 1723 CLASS_STICKY_ATTR_CLEAR(c, "category"); 1724 @endcode 1725 1726 @see CLASS_STICKY_ATTR_CLEAR 1727 */ 1728 #define CLASS_STICKY_ATTR(c,name,flags,parsestr) \ 1729 { t_object *attr = attribute_new_parse(name,NULL,flags,parsestr); class_sticky(c,gensym("sticky_attr"),gensym(name),attr); } 1730 1731 1732 /** 1733 Close a #CLASS_STICKY_ATTR block. 1734 1735 @ingroup attr 1736 @param c The class pointer. 1737 @param name The name of the sticky attribute as a C-string. 1738 @see CLASS_STICKY_ATTR 1739 */ 1740 #define CLASS_STICKY_ATTR_CLEAR(c,name) class_sticky_clear(c,gensym("sticky_attr"),name?gensym(name):NULL) 1741 1742 #define CLASS_STICKY_CATEGORY(c,flags,name) \ 1743 { t_object *attr = attribute_new_format("category",NULL,flags,"s",gensym_tr(name)); class_sticky(c,gensym("sticky_attr"),gensym("category"),attr); } 1744 1745 #define CLASS_STICKY_CATEGORY_CLEAR(c) class_sticky_clear(c,gensym("sticky_attr"),gensym("category")) 1746 1747 /** 1748 Create an attribute, and add it to all following method declarations. 1749 The block is closed by a call to #CLASS_STICKY_METHOD_CLEAR. 1750 1751 @ingroup attr 1752 @param c The class pointer. 1753 @param name The name of the new attribute to create as a C-string. 1754 @param flags Any flags you wish to declare for this new attribute, as defined in #e_max_attrflags. 1755 @param parsestr A C-string, which will be parsed into an array of atoms to set the initial value. 1756 1757 @remark The most common use of CLASS_STICKY_ATTR is for creating multiple attributes with the same category, 1758 as in this example: 1759 @code 1760 CLASS_STICKY_METHOD(c, "undocumented", 0, "1"); 1761 1762 // add some methods here with class_addmethod() 1763 // the undocumented attribute for methods means that the ref-page 1764 // generator will ignore these methods. 1765 1766 CLASS_STICKY_METHOD_CLEAR(c, "undocumented"); 1767 @endcode 1768 1769 @see CLASS_STICKY_METHOD_CLEAR 1770 */ 1771 #define CLASS_STICKY_METHOD(c,name,flags,parsestr) \ 1772 { t_object *attr = attribute_new_parse(name,NULL,flags,parsestr); class_sticky(c,gensym("sticky_method"),gensym(name),attr); } 1773 1774 1775 /** 1776 Close a #CLASS_STICKY_METHOD block. 1777 1778 @ingroup attr 1779 @param c The class pointer. 1780 @param name The name of the sticky attribute as a C-string. 1781 @see CLASS_STICKY_METHOD 1782 */ 1783 #define CLASS_STICKY_METHOD_CLEAR(c,name) class_sticky_clear(c,gensym("sticky_method"),name?gensym(name):NULL) 1784 1785 1786 1787 1788 // support for long lists 1789 1790 #define OBEX_UTIL_MAX_ATOM_GETBYTES 1048576 1791 #define OBEX_UTIL_MAX_ATOM_STATIC 2048 1792 1793 1794 //static memory case 1795 #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; 1796 #define OBEX_UTIL_ATOM_CLEANUP_VAR_STATIC 1797 #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); 1798 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_STATIC(ac) 1799 1800 //dynamic memory case 1801 #define OBEX_UTIL_ATOM_SETUP_VAR_DYN t_atom *av2=NULL; long ac2=0; 1802 #define OBEX_UTIL_ATOM_CLEANUP_VAR_DYN if (ac2&&av2) mm_freebytes((char *)av2,sizeof(t_atom)*ac2); 1803 #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; 1804 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_DYN(ac) if (ac2&&av2) mm_freebytes(av2,sizeof(t_atom)*ac2); 1805 1806 1807 //combo static/dynamic. faster for smaller atom lists on input, but not limited 1808 #define OBEX_UTIL_ATOM_SETUP_VAR_COMBO OBEX_UTIL_ATOM_SETUP_VAR_DYN // same for VAR 1809 #define OBEX_UTIL_ATOM_CLEANUP_VAR_COMBO OBEX_UTIL_ATOM_CLEANUP_VAR_DYN // same for VAR 1810 #define OBEX_UTIL_ATOM_SETUP_ARRAY_COMBO(ac) \ 1811 t_atom atemp[OBEX_UTIL_MAX_ATOM_STATIC]; \ 1812 t_atom *av2=atemp; \ 1813 long ac2; \ 1814 long usestatic=1; \ 1815 ac2 = MIN(ac,OBEX_UTIL_MAX_ATOM_STATIC); \ 1816 if (ac>OBEX_UTIL_MAX_ATOM_STATIC) { usestatic=0; av2 = (t_atom *)mm_getbytes(sizeof(t_atom)*ac); ac2=ac; } 1817 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY_COMBO(ac) if ((!usestatic)&&ac2&&av2) mm_freebytes((char *)av2,sizeof(t_atom)*ac2); 1818 1819 1820 // default to combo 1821 #define OBEX_UTIL_ATOM_SETUP_VAR OBEX_UTIL_ATOM_SETUP_VAR_COMBO 1822 #define OBEX_UTIL_ATOM_CLEANUP_VAR OBEX_UTIL_ATOM_CLEANUP_VAR_COMBO 1823 #define OBEX_UTIL_ATOM_SETUP_ARRAY OBEX_UTIL_ATOM_SETUP_ARRAY_COMBO 1824 #define OBEX_UTIL_ATOM_CLEANUP_ARRAY OBEX_UTIL_ATOM_CLEANUP_ARRAY_COMBO 1825 1826 1827 /** 1828 Flags that determine how functions convert atoms into text (C-strings). 1829 @ingroup atom 1830 */ 1831 typedef enum{ 1832 OBEX_UTIL_ATOM_GETTEXT_DEFAULT = 0x00000000, ///< default translation rules for getting text from atoms 1833 OBEX_UTIL_ATOM_GETTEXT_TRUNCATE_ZEROS = 0x00000001, ///< eliminate redundant zeros for floating point numbers (default used) 1834 OBEX_UTIL_ATOM_GETTEXT_SYM_NO_QUOTE = 0x00000002, ///< don't introduce quotes around symbols with spaces 1835 OBEX_UTIL_ATOM_GETTEXT_SYM_FORCE_QUOTE = 0x00000004, ///< always introduce quotes around symbols (useful for JSON) 1836 OBEX_UTIL_ATOM_GETTEXT_COMMA_DELIM = 0x00000008, ///< separate atoms with commas (useful for JSON) 1837 OBEX_UTIL_ATOM_GETTEXT_FORCE_ZEROS = 0x00000010, ///< always print the zeros 1838 OBEX_UTIL_ATOM_GETTEXT_NUM_HI_RES = 0x00000020, ///< print more decimal places 1839 OBEX_UTIL_ATOM_GETTEXT_NUM_LO_RES = 0x00000040, ///< print fewer decimal places (HI_RES will win though) 1840 OBEX_UTIL_ATOM_GETTEXT_NOESCAPE = 0x00000080, ///< don't add extra escape characters 1841 OBEX_UTIL_ATOM_GETTEXT_LINEBREAK_NODELIM = 0x00000100, ///< don't insert spaces before/after linebreak characters 1842 } e_max_atom_gettext_flags; 1843 1844 1845 // atom utilities (will move to atomutils2.c) 1846 1847 /** 1848 Assign an array of char values to an array of atoms. 1849 1850 @ingroup atom 1851 @param ac The number of atoms to try to fetch from the array of chars. 1852 You should have at least this number of atoms allocated in av. 1853 @param av The address to the first of an array of allocated atoms. 1854 @param count The number of values in the array specified by vals. 1855 @param vals The array from which to copy the values into the array of atoms at av. 1856 @return A Max error code. 1857 */ 1858 t_max_err atom_setchar_array(long ac, t_atom *av, long count, unsigned char *vals); 1859 1860 1861 /** 1862 Assign an array of long integer values to an array of atoms. 1863 1864 @ingroup atom 1865 @param ac The number of atoms to try to fetch from the array of longs. 1866 You should have at least this number of atoms allocated in av. 1867 @param av The address to the first of an array of allocated atoms. 1868 @param count The number of values in the array specified by vals. 1869 @param vals The array from which to copy the values into the array of atoms at av. 1870 @return A Max error code. 1871 */ 1872 t_max_err atom_setlong_array(long ac, t_atom *av, long count, t_atom_long *vals); 1873 1874 1875 /** 1876 Assign an array of 32bit float values to an array of atoms. 1877 1878 @ingroup atom 1879 @param ac The number of atoms to try to fetch from the array of floats. 1880 You should have at least this number of atoms allocated in av. 1881 @param av The address to the first of an array of allocated atoms. 1882 @param count The number of values in the array specified by vals. 1883 @param vals The array from which to copy the values into the array of atoms at av. 1884 @return A Max error code. 1885 */ 1886 t_max_err atom_setfloat_array(long ac, t_atom *av, long count, float *vals); 1887 1888 1889 /** 1890 Assign an array of 64bit float values to an array of atoms. 1891 1892 @ingroup atom 1893 @param ac The number of atoms to try to fetch from the array of doubles. 1894 You should have at least this number of atoms allocated in av. 1895 @param av The address to the first of an array of allocated atoms. 1896 @param count The number of values in the array specified by vals. 1897 @param vals The array from which to copy the values into the array of atoms at av. 1898 @return A Max error code. 1899 */ 1900 t_max_err atom_setdouble_array(long ac, t_atom *av, long count, double *vals); 1901 1902 1903 /** 1904 Assign an array of #t_symbol* values to an array of atoms. 1905 1906 @ingroup atom 1907 @param ac The number of atoms to try to fetch from the array of symbols. 1908 You should have at least this number of atoms allocated in av. 1909 @param av The address to the first of an array of allocated atoms. 1910 @param count The number of values in the array specified by vals. 1911 @param vals The array from which to copy the values into the array of atoms at av. 1912 @return A Max error code. 1913 */ 1914 t_max_err atom_setsym_array(long ac, t_atom *av, long count, t_symbol **vals); 1915 1916 1917 /** 1918 Assign an array of #t_atom values to an array of atoms. 1919 1920 @ingroup atom 1921 @param ac The number of atoms to try to fetch from the second array of atoms. 1922 You should have at least this number of atoms allocated in av. 1923 @param av The address to the first of an array of allocated atoms. 1924 @param count The number of values in the array specified by vals. 1925 @param vals The array from which to copy the values into the array of atoms at av. 1926 @return A Max error code. 1927 */ 1928 t_max_err atom_setatom_array(long ac, t_atom *av, long count, t_atom *vals); 1929 1930 1931 /** 1932 Assign an array of #t_object* values to an array of atoms. 1933 1934 @ingroup atom 1935 @param ac The number of atoms to try to fetch from the array of objects. 1936 You should have at least this number of atoms allocated in av. 1937 @param av The address to the first of an array of allocated atoms. 1938 @param count The number of values in the array specified by vals. 1939 @param vals The array from which to copy the values into the array of atoms at av. 1940 @return A Max error code. 1941 */ 1942 t_max_err atom_setobj_array(long ac, t_atom *av, long count, t_object **vals); 1943 1944 1945 // these variable size calls can alloc mem if desired 1946 1947 /** 1948 Parse a C-string into an array of atoms. 1949 This function allocates memory for the atoms if the ac and av parameters are NULL. 1950 Otherwise it will attempt to use any memory already allocated to av. 1951 Any allocated memory should be freed with sysmem_freeptr(). 1952 1953 @ingroup atom 1954 @param ac The address of a variable to hold the number of returned atoms. 1955 @param av The address of a #t_atom pointer to which memory may be allocated and atoms copied. 1956 @param parsestr The C-string to parse. 1957 @return A Max error code. 1958 1959 @remark The following example will parse the string "foo bar 1 2 3.0" into an array of 5 atoms. 1960 The atom types will be determined automatically as 2 #A_SYM atoms, 2 #A_LONG atoms, and 1 #A_FLOAT atom. 1961 @code 1962 t_atom *av = NULL; 1963 long ac = 0; 1964 t_max_err err = MAX_ERR_NONE; 1965 1966 err = atom_setparse(&ac, &av, "foo bar 1 2 3.0"); 1967 @endcode 1968 */ 1969 t_max_err atom_setparse(long *ac, t_atom **av, C74_CONST char *parsestr); 1970 1971 1972 t_max_err atom_setbinbuf(long *ac, t_atom **av, void *buf); 1973 1974 1975 t_max_err atom_setattrval(long *ac, t_atom **av, t_symbol *attrname, t_object *obj); 1976 1977 1978 t_max_err atom_setobjval(long *ac, t_atom **av, t_object *obj); 1979 1980 1981 1982 1983 /** 1984 Create an array of atoms populated with values using sprintf-like syntax. 1985 atom_setformat() supports clfdsoaCLFDSOA tokens 1986 (primitive type scalars and arrays respectively for the 1987 char, long, float, double, #t_symbol*, #t_object*, #t_atom*). 1988 It also supports vbp@ tokens (obval, binbuf, parsestr, attribute). 1989 1990 This function allocates memory for the atoms if the ac and av parameters are NULL. 1991 Otherwise it will attempt to use any memory already allocated to av. 1992 Any allocated memory should be freed with sysmem_freeptr(). 1993 1994 @ingroup atom 1995 1996 @param ac The address of a variable to hold the number of returned atoms. 1997 @param av The address of a #t_atom pointer to which memory may be allocated and atoms copied. 1998 @param fmt An sprintf-style format string specifying values for the atoms. 1999 @param ... One or more arguments which are to be substituted into the format string. 2000 2001 @return A Max error code. 2002 @see atom_getformat() 2003 @see atom_setparse() 2004 */ 2005 t_max_err atom_setformat(long *ac, t_atom **av, C74_CONST char *fmt, ...); 2006 2007 // same as atom_setformat using va_list 2008 t_max_err atom_setformat_va(long *ac, t_atom **av, C74_CONST char *fmt, va_list args); 2009 2010 2011 /** 2012 Retrieve values from an array of atoms using sscanf-like syntax. 2013 atom_getformat() supports clfdsoaCLFDSOA tokens 2014 (primitive type scalars and arrays respectively for the 2015 char, long, float, double, #t_symbol*, #t_object*, #t_atom*). 2016 It does not support vbp@ the tokens found in atom_setformat(). 2017 2018 @ingroup atom 2019 2020 @param ac The number of atoms to parse in av. 2021 @param av The address of the first #t_atom pointer in an array to parse. 2022 @param fmt An sscanf-style format string specifying types for the atoms. 2023 @param ... One or more arguments which are address of variables to be set according to the fmt string. 2024 2025 @return A Max error code. 2026 @see atom_setformat() 2027 */ 2028 t_max_err atom_getformat(long ac, t_atom *av, C74_CONST char *fmt, ...); 2029 2030 // same as atom_getformat using va_list 2031 t_max_err atom_getformat_va(long ac, t_atom *av, C74_CONST char *fmt, va_list args); 2032 2033 2034 /** 2035 Convert an array of atoms into a C-string. 2036 2037 @ingroup atom 2038 2039 @param ac The number of atoms to fetch in av. 2040 @param av The address of the first #t_atom pointer in an array to retrieve. 2041 @param textsize The size of the string to which the atoms will be formatted and copied. 2042 @param text The address of the string to which the text will be written. 2043 @param flags Determines the rules by which atoms will be translated into text. 2044 Values are bit mask as defined by #e_max_atom_gettext_flags. 2045 2046 @return A Max error code. 2047 @see atom_setparse() 2048 */ 2049 t_max_err atom_gettext(long ac, t_atom *av, long *textsize, char **text, long flags); 2050 2051 2052 /** 2053 Convert an array of atoms into a C-string, specifying floating-point precision. 2054 2055 @ingroup atom 2056 2057 @param ac The number of atoms to fetch in av. 2058 @param av The address of the first #t_atom pointer in an array to retrieve. 2059 @param textsize The size of the string to which the atoms will be formatted and copied. 2060 @param text The address of the string to which the text will be written. 2061 @param flags Determines the rules by which atoms will be translated into text. 2062 Values are bit mask as defined by #e_max_atom_gettext_flags. 2063 @param precision Determines the number of digits after the decimal point when floats are translated into text. 2064 This overrides the OBEX_UTIL_ATOM_GETTEXT_NUM_HI_RES and 2065 OBEX_UTIL_ATOM_GETTEXT_NUM_LO_RES #e_max_atom_gettext_flags. 2066 Pass -1 to ignore this value and behave as atom_gettext(). 2067 2068 @return A Max error code. 2069 @see atom_setparse() 2070 */ 2071 t_max_err atom_gettext_precision(long ac, t_atom *av, long *textsize, char **text, long flags, long precision); 2072 2073 2074 /** 2075 Fetch an array of char values from an array of atoms. 2076 2077 @ingroup atom 2078 @param ac The number of atoms allocated in the av parameter. 2079 @param av The address to the first of an array of allocated atoms. 2080 @param count The number of values to fetch from the array specified by vals. 2081 @param vals The address of the array to which is copied the values from av. 2082 @return A Max error code. 2083 */ 2084 t_max_err atom_getchar_array(long ac, t_atom *av, long count, unsigned char *vals); 2085 2086 2087 /** 2088 Fetch an array of long integer values from an array of atoms. 2089 2090 @ingroup atom 2091 @param ac The number of atoms allocated in the av parameter. 2092 @param av The address to the first of an array of allocated atoms. 2093 @param count The number of values to fetch from the array specified by vals. 2094 @param vals The address of the array to which is copied the values from av. 2095 @return A Max error code. 2096 */ 2097 t_max_err atom_getlong_array(long ac, t_atom *av, long count, t_atom_long *vals); 2098 2099 2100 /** 2101 Fetch an array of 32bit float values from an array of atoms. 2102 2103 @ingroup atom 2104 @param ac The number of atoms allocated in the av parameter. 2105 @param av The address to the first of an array of allocated atoms. 2106 @param count The number of values to fetch from the array specified by vals. 2107 @param vals The address of the array to which is copied the values from av. 2108 @return A Max error code. 2109 */ 2110 t_max_err atom_getfloat_array(long ac, t_atom *av, long count, float *vals); 2111 2112 2113 /** 2114 Fetch an array of 64bit float values from an array of atoms. 2115 2116 @ingroup atom 2117 @param ac The number of atoms allocated in the av parameter. 2118 @param av The address to the first of an array of allocated atoms. 2119 @param count The number of values to fetch from the array specified by vals. 2120 @param vals The address of the array to which is copied the values from av. 2121 @return A Max error code. 2122 */ 2123 t_max_err atom_getdouble_array(long ac, t_atom *av, long count, double *vals); 2124 2125 2126 /** 2127 Fetch an array of #t_symbol* values from an array of atoms. 2128 2129 @ingroup atom 2130 @param ac The number of atoms allocated in the av parameter. 2131 @param av The address to the first of an array of allocated atoms. 2132 @param count The number of values to fetch from the array specified by vals. 2133 @param vals The address of the array to which is copied the values from av. 2134 @return A Max error code. 2135 */ 2136 t_max_err atom_getsym_array(long ac, t_atom *av, long count, t_symbol **vals); 2137 2138 2139 /** 2140 Fetch an array of #t_atom values from an array of atoms. 2141 2142 @ingroup atom 2143 @param ac The number of atoms allocated in the av parameter. 2144 @param av The address to the first of an array of allocated atoms. 2145 @param count The number of values to fetch from the array specified by vals. 2146 @param vals The address of the array to which is copied the values from av. 2147 @return A Max error code. 2148 */ 2149 t_max_err atom_getatom_array(long ac, t_atom *av, long count, t_atom *vals); 2150 2151 2152 /** 2153 Fetch an array of #t_object* values from an array of atoms. 2154 2155 @ingroup atom 2156 @param ac The number of atoms allocated in the av parameter. 2157 @param av The address to the first of an array of allocated atoms. 2158 @param count The number of values to fetch from the array specified by vals. 2159 @param vals The address of the array to which is copied the values from av. 2160 @return A Max error code. 2161 */ 2162 t_max_err atom_getobj_array(long ac, t_atom *av, long count, t_object **vals); 2163 2164 2165 2166 /** 2167 Determines whether or not an atom represents a #t_string object. 2168 2169 @ingroup atom 2170 @param a The address of the atom to test. 2171 @return Returns true if the #t_atom contains a valid #t_string object. 2172 */ 2173 long atomisstring(const t_atom *a); 2174 2175 2176 /** 2177 Determines whether or not an atom represents a #t_atomarray object. 2178 2179 @ingroup atom 2180 @param a The address of the atom to test. 2181 @return Returns true if the #t_atom contains a valid #t_atomarray object. 2182 */ 2183 long atomisatomarray(t_atom *a); 2184 2185 2186 /** 2187 Determines whether or not an atom represents a #t_dictionary object. 2188 2189 @ingroup atom 2190 @param a The address of the atom to test. 2191 @return Returns true if the #t_atom contains a valid #t_dictionary object. 2192 */ 2193 long atomisdictionary(t_atom *a); 2194 2195 2196 // quick object programming macros 2197 #define OB_MSG(x,p) object_method_parse(x,NULL,p,NULL); 2198 2199 //object_method_typed utilities 2200 2201 /** 2202 Convenience wrapper for object_method_typed() that uses atom_setparse() to define the arguments. 2203 2204 @ingroup obj 2205 @param x The object to which the message will be sent. 2206 @param s The name of the method to call on the object. 2207 @param parsestr A C-string to parse into an array of atoms to pass to the method. 2208 @param rv The address of an atom to hold a return value. 2209 @return A Max error code. 2210 2211 @see object_method_typed() 2212 @see atom_setparse() 2213 */ 2214 t_max_err object_method_parse(t_object *x, t_symbol *s, C74_CONST char *parsestr, t_atom *rv); 2215 t_max_err object_method_binbuf(t_object *x, t_symbol *s, void *buf, t_atom *rv); 2216 t_max_err object_method_attrval(t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj, t_atom *rv); 2217 t_max_err object_method_objval(t_object *x, t_symbol *s, t_object *obj, t_atom *rv); 2218 2219 /** 2220 Convenience wrapper for object_method_typed() that uses atom_setformat() to define the arguments. 2221 2222 @ingroup obj 2223 @param x The object to which the message will be sent. 2224 @param s The name of the method to call on the object. 2225 @param rv The address of an atom to hold a return value. 2226 @param fmt An sprintf-style format string specifying values for the atoms. 2227 @param ... One or more arguments which are to be substituted into the format string. 2228 @return A Max error code. 2229 2230 @see object_method_typed() 2231 @see atom_setformat() 2232 */ 2233 t_max_err object_method_format(t_object *x, t_symbol *s, t_atom *rv, C74_CONST char *fmt, ...); 2234 2235 2236 2237 /** 2238 Convenience wrapper for object_method_typed() that passes a single char as an argument. 2239 2240 @ingroup obj 2241 @param x The object to which the message will be sent. 2242 @param s The name of the method to call on the object. 2243 @param v An argument to pass to the method. 2244 @param rv The address of an atom to hold a return value. 2245 2246 @return A Max error code. 2247 @see object_method_typed() 2248 */ 2249 t_max_err object_method_char(t_object *x, t_symbol *s, unsigned char v, t_atom *rv); 2250 2251 2252 /** 2253 Convenience wrapper for object_method_typed() that passes a single long integer as an argument. 2254 2255 @ingroup obj 2256 @param x The object to which the message will be sent. 2257 @param s The name of the method to call on the object. 2258 @param v An argument to pass to the method. 2259 @param rv The address of an atom to hold a return value. 2260 2261 @return A Max error code. 2262 @see object_method_typed() 2263 */ 2264 t_max_err object_method_long(t_object *x, t_symbol *s, long v, t_atom *rv); 2265 2266 2267 /** 2268 Convenience wrapper for object_method_typed() that passes a single 32bit float as an argument. 2269 2270 @ingroup obj 2271 @param x The object to which the message will be sent. 2272 @param s The name of the method to call on the object. 2273 @param v An argument to pass to the method. 2274 @param rv The address of an atom to hold a return value. 2275 2276 @return A Max error code. 2277 @see object_method_typed() 2278 */ 2279 t_max_err object_method_float(t_object *x, t_symbol *s, float v, t_atom *rv); 2280 2281 2282 /** 2283 Convenience wrapper for object_method_typed() that passes a single 64bit float as an argument. 2284 2285 @ingroup obj 2286 @param x The object to which the message will be sent. 2287 @param s The name of the method to call on the object. 2288 @param v An argument to pass to the method. 2289 @param rv The address of an atom to hold a return value. 2290 2291 @return A Max error code. 2292 @see object_method_typed() 2293 */ 2294 t_max_err object_method_double(t_object *x, t_symbol *s, double v, t_atom *rv); 2295 2296 2297 /** 2298 Convenience wrapper for object_method_typed() that passes a single #t_symbol* as an argument. 2299 2300 @ingroup obj 2301 @param x The object to which the message will be sent. 2302 @param s The name of the method to call on the object. 2303 @param v An argument to pass to the method. 2304 @param rv The address of an atom to hold a return value. 2305 2306 @return A Max error code. 2307 @see object_method_typed() 2308 */ 2309 t_max_err object_method_sym(t_object *x, t_symbol *s, t_symbol *v, t_atom *rv); 2310 2311 2312 /** 2313 Convenience wrapper for object_method_typed() that passes a single #t_object* as an argument. 2314 2315 @ingroup obj 2316 @param x The object to which the message will be sent. 2317 @param s The name of the method to call on the object. 2318 @param v An argument to pass to the method. 2319 @param rv The address of an atom to hold a return value. 2320 2321 @return A Max error code. 2322 @see object_method_typed() 2323 */ 2324 t_max_err object_method_obj(t_object *x, t_symbol *s, t_object *v, t_atom *rv); 2325 2326 2327 2328 /** 2329 Convenience wrapper for object_method_typed() that passes an array of char values as an argument. 2330 2331 @ingroup obj 2332 @param x The object to which the message will be sent. 2333 @param s The name of the method to call on the object. 2334 @param ac The number of arguments to pass to the method. 2335 @param av The address of the first of the array of arguments to pass to the method. 2336 @param rv The address of an atom to hold a return value. 2337 2338 @return A Max error code. 2339 @see object_method_typed() 2340 */ 2341 t_max_err object_method_char_array(t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv); 2342 2343 2344 /** 2345 Convenience wrapper for object_method_typed() that passes an array of long integers values as an argument. 2346 2347 @ingroup obj 2348 @param x The object to which the message will be sent. 2349 @param s The name of the method to call on the object. 2350 @param ac The number of arguments to pass to the method. 2351 @param av The address of the first of the array of arguments to pass to the method. 2352 @param rv The address of an atom to hold a return value. 2353 2354 @return A Max error code. 2355 @see object_method_typed() 2356 */ 2357 t_max_err object_method_long_array(t_object *x, t_symbol *s, long ac, t_atom_long *av, t_atom *rv); 2358 2359 2360 /** 2361 Convenience wrapper for object_method_typed() that passes an array of 32bit floats values as an argument. 2362 2363 @ingroup obj 2364 @param x The object to which the message will be sent. 2365 @param s The name of the method to call on the object. 2366 @param ac The number of arguments to pass to the method. 2367 @param av The address of the first of the array of arguments to pass to the method. 2368 @param rv The address of an atom to hold a return value. 2369 2370 @return A Max error code. 2371 @see object_method_typed() 2372 */ 2373 t_max_err object_method_float_array(t_object *x, t_symbol *s, long ac, float *av, t_atom *rv); 2374 2375 2376 /** 2377 Convenience wrapper for object_method_typed() that passes an array of 64bit float values as an argument. 2378 2379 @ingroup obj 2380 @param x The object to which the message will be sent. 2381 @param s The name of the method to call on the object. 2382 @param ac The number of arguments to pass to the method. 2383 @param av The address of the first of the array of arguments to pass to the method. 2384 @param rv The address of an atom to hold a return value. 2385 2386 @return A Max error code. 2387 @see object_method_typed() 2388 */ 2389 t_max_err object_method_double_array(t_object *x, t_symbol *s, long ac, double *av, t_atom *rv); 2390 2391 2392 /** 2393 Convenience wrapper for object_method_typed() that passes an array of #t_symbol* values as an argument. 2394 2395 @ingroup obj 2396 @param x The object to which the message will be sent. 2397 @param s The name of the method to call on the object. 2398 @param ac The number of arguments to pass to the method. 2399 @param av The address of the first of the array of arguments to pass to the method. 2400 @param rv The address of an atom to hold a return value. 2401 2402 @return A Max error code. 2403 @see object_method_typed() 2404 */ 2405 t_max_err object_method_sym_array(t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv); 2406 2407 2408 /** 2409 Convenience wrapper for object_method_typed() that passes an array of #t_object* values as an argument. 2410 2411 @ingroup obj 2412 @param x The object to which the message will be sent. 2413 @param s The name of the method to call on the object. 2414 @param ac The number of arguments to pass to the method. 2415 @param av The address of the first of the array of arguments to pass to the method. 2416 @param rv The address of an atom to hold a return value. 2417 2418 @return A Max error code. 2419 @see object_method_typed() 2420 */ 2421 t_max_err object_method_obj_array(t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv); 2422 2423 2424 // call_method_typed utilities -- not currently used in any Cycling '74 code 2425 2426 t_max_err call_method_typed(method m, t_object *x, t_symbol *s, long ac, t_atom *av, t_atom *rv); 2427 t_max_err call_method_parse(method m, t_object *x, t_symbol *s, char *parsestr, t_atom *rv); 2428 t_max_err call_method_binbuf(method m, t_object *x, t_symbol *s, void *buf, t_atom *rv); 2429 t_max_err call_method_attrval(method m, t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj, t_atom *rv); 2430 t_max_err call_method_objval(method m, t_object *x, t_symbol *s, t_object *obj, t_atom *rv); 2431 t_max_err call_method_format(method m, t_object *x, t_symbol *s, t_atom *rv, char *fmt, ...); 2432 2433 t_max_err call_method_char(method m, t_object *x, t_symbol *s, unsigned char v, t_atom *rv); 2434 t_max_err call_method_long(method m, t_object *x, t_symbol *s, long v, t_atom *rv); 2435 t_max_err call_method_float(method m, t_object *x, t_symbol *s,float v, t_atom *rv); 2436 t_max_err call_method_double(method m, t_object *x, t_symbol *s, double v, t_atom *rv); 2437 t_max_err call_method_sym(method m, t_object *x, t_symbol *s, t_symbol *v, t_atom *rv); 2438 t_max_err call_method_obj(method m, t_object *x, t_symbol *s, t_object *v, t_atom *rv); 2439 2440 t_max_err call_method_char_array(method m, t_object *x, t_symbol *s, long ac, unsigned char *av, t_atom *rv); 2441 t_max_err call_method_long_array(method m, t_object *x, t_symbol *s, long ac, t_atom_long *av, t_atom *rv); 2442 t_max_err call_method_float_array(method m, t_object *x, t_symbol *s, long ac, float *av, t_atom *rv); 2443 t_max_err call_method_double_array(method m, t_object *x, t_symbol *s, long ac, double *av, t_atom *rv); 2444 t_max_err call_method_sym_array(method m, t_object *x, t_symbol *s, long ac, t_symbol **av, t_atom *rv); 2445 t_max_err call_method_obj_array(method m, t_object *x, t_symbol *s, long ac, t_object **av, t_atom *rv); 2446 2447 2448 // object attribute methods (will move to attribtue_util.c with the rest of these) 2449 2450 /** 2451 Set an attribute value with one or more atoms parsed from a C-string. 2452 2453 @ingroup attr 2454 @param x The object whose attribute will be set. 2455 @param s The name of the attribute to set. 2456 @param parsestr A C-string to parse into an array of atoms to set the attribute value. 2457 @return A Max error code. 2458 @see atom_setparse() 2459 */ 2460 t_max_err object_attr_setparse(t_object *x, t_symbol *s, C74_CONST char *parsestr); 2461 t_max_err object_attr_setbinbuf(t_object *x, t_symbol *s, void *buf); 2462 t_max_err object_attr_setattrval(t_object *x, t_symbol *s, t_symbol *attrname, t_object *obj); 2463 t_max_err object_attr_setobjval(t_object *x, t_symbol *s, t_object *obj); 2464 t_max_err object_attr_setformat(t_object *x, t_symbol *s, C74_CONST char *fmt, ...); 2465 2466 2467 // t_attribute these probably belong in attribute.c 2468 t_object *attribute_new_atoms(C74_CONST char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 2469 t_object *attribute_new_parse(C74_CONST char *attrname, t_symbol *type, long flags, C74_CONST char *parsestr); 2470 t_object *attribute_new_binbuf(C74_CONST char *attrname, t_symbol *type, long flags, void *buf); 2471 t_object *attribute_new_attrval(C74_CONST char *attrname, t_symbol *type, long flags, t_symbol *objattrname, t_object *obj); 2472 t_object *attribute_new_objval(C74_CONST char *attrname, t_symbol *type, long flags, t_object *obj); 2473 t_object *attribute_new_format(C74_CONST char *attrname, t_symbol *type, long flags, C74_CONST char *fmt, ...); 2474 2475 2476 // general object constructors for objects with typed constructors 2477 2478 /** 2479 Create a new object with one or more atoms parsed from a C-string. 2480 The object's new method must have an #A_GIMME signature. 2481 2482 @ingroup attr 2483 @param name_space The namespace in which to create the instance. Typically this is either #CLASS_BOX or #CLASS_NOBOX. 2484 @param classname The name of the class to instantiate. 2485 @param parsestr A C-string to parse into an array of atoms to set the attribute value. 2486 2487 @return A pointer to the new instance. 2488 @see atom_setparse() 2489 @see object_new_typed() 2490 */ 2491 void *object_new_parse(t_symbol *name_space, t_symbol *classname, C74_CONST char *parsestr); 2492 void *object_new_binbuf(t_symbol *name_space, t_symbol *classname, void *buf); 2493 void *object_new_attrval(t_symbol *name_space, t_symbol *classname, t_symbol *objattrname, t_object *obj); 2494 void *object_new_objval(t_symbol *name_space, t_symbol *classname, t_object *obj); 2495 void *object_new_format(t_symbol *name_space, t_symbol *classname, C74_CONST char *fmt, ...); // not used or tested in any Cycling '74 code 2496 2497 2498 // attr attr functions necessary due to offset attributes as singletons for the class 2499 // need to copy object local to set any attributes. 2500 // undocumented for now in favor of using the macros defined above. 2501 2502 t_max_err object_attr_addattr(t_object *x, t_symbol *attrname, t_object *attr); 2503 t_object *object_attr_attr_get(t_object *x, t_symbol *attrname, t_symbol *attrname2); 2504 t_max_err object_attr_attr_setvalueof(t_object *x, t_symbol *attrname, t_symbol *attrname2, long argc, t_atom *argv); 2505 t_max_err object_attr_attr_getvalueof(t_object *x, t_symbol *attrname, t_symbol *attrname2, long *argc, t_atom **argv); 2506 2507 t_max_err class_attr_addattr(t_class *c, t_symbol *attrname, t_object *attr); 2508 t_object *class_attr_attr_get(t_class *c, t_symbol *attrname, t_symbol *attrname2); 2509 t_max_err class_attr_attr_setvalueof(t_class *c, t_symbol *attrname, t_symbol *attrname2, long argc, t_atom *argv); 2510 t_max_err class_attr_attr_getvalueof(t_class *c, t_symbol *attrname, t_symbol *attrname2, long *argc, t_atom **argv); 2511 2512 t_max_err object_attr_enforcelocal(t_object *x, t_symbol *attrname); 2513 2514 t_max_err class_addattr_atoms(t_class *c, C74_CONST char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 2515 t_max_err class_addattr_parse(t_class *c, C74_CONST char *attrname, t_symbol *type, long flags, C74_CONST char *parsestr); 2516 t_max_err class_addattr_format(t_class *c, C74_CONST char *attrname, t_symbol *type, long flags, C74_CONST char *fmt, ...); 2517 t_max_err class_attr_addattr_atoms(t_class *c, C74_CONST char *attrname, C74_CONST char *attrname2, t_symbol *type, long flags, long ac, t_atom *av); 2518 t_max_err class_attr_addattr_parse(t_class *c, C74_CONST char *attrname, C74_CONST char *attrname2, t_symbol *type, long flags, C74_CONST char *parsestr); 2519 t_max_err class_attr_addattr_format(t_class *c, C74_CONST char *attrname, C74_CONST char *attrname2, C74_CONST t_symbol *type, long flags, C74_CONST char *fmt, ...); 2520 2521 t_max_err object_addattr_atoms(t_object *x, C74_CONST char *attrname, t_symbol *type, long flags, long ac, t_atom *av); 2522 t_max_err object_addattr_parse(t_object *x, C74_CONST char *attrname, t_symbol *type, long flags, C74_CONST char *parsestr); 2523 t_max_err object_addattr_format(t_object *x, C74_CONST char *attrname, t_symbol *type, long flags, C74_CONST char *fmt, ...); 2524 t_max_err object_attr_addattr_atoms(t_object *x, C74_CONST char *attrname, C74_CONST char *attrname2, t_symbol *type, long flags, long ac, t_atom *av); 2525 t_max_err object_attr_addattr_parse(t_object *x, C74_CONST char *attrname, C74_CONST char *attrname2, t_symbol *type, long flags, C74_CONST char *parsestr); 2526 t_max_err object_attr_addattr_format(t_object *x, C74_CONST char *attrname, C74_CONST char *attrname2, t_symbol *type, long flags, C74_CONST char *fmt, ...); 2527 2528 2529 // other general functions from obex.c 2530 t_object *object_clone(t_object *x); 2531 t_object *object_clone_generic(t_object *x); 2532 2533 // this function has been de-activated and now does nothing 2534 void object_zero(t_object *x); 2535 2536 2537 // menu command stuff 2538 2539 t_max_err class_addcommand(t_class *c, method cmd, method enabler, method handler, C74_CONST char *message); 2540 void *object_commandenabled(t_object *o, t_symbol *cmd); 2541 t_max_err object_getenabler(t_object *c, t_symbol *cmd, method *m); 2542 t_max_err object_getcommand(t_object *o, t_symbol *cmd, method *m); 2543 void *object_handlecommand(t_object *o, t_symbol *s, long argc, t_atom *argv, t_atom *rv); 2544 2545 t_ptr_int object_attr_getdisabled(t_object *o, t_symbol *attrname); 2546 t_max_err object_attr_setdisabled(t_object *o, t_symbol *attrname, long way); 2547 2548 // arg replacing (for objects that save their own way in dictionaries and want values treated as "attributes" would be) 2549 t_max_err object_replaceargs(t_object *x, long argc, t_atom *argv, char match, char poundfill); 2550 2551 // stubs for obsolete attrs/methods 2552 t_max_err object_attr_obsolete_getter(t_object *x, t_object *attr, long *ac, t_atom **av); 2553 t_max_err object_attr_obsolete_setter(t_object *x, t_object *attr, long ac, t_atom *av); 2554 void object_method_obsolete(t_object *x, t_symbol *s, long ac, t_atom *av); 2555 2556 2557 END_USING_C_LINKAGE 2558 2559 #endif //_EXT_OBEX_UTIL_H_