github.com/256dpi/max-go@v0.7.0/lib/max/ext_obex.h (about) 1 2 #ifndef _EXT_OBEX_H_ 3 #define _EXT_OBEX_H_ 4 5 #include "ext_prefix.h" 6 #include "ext_mess.h" 7 8 #include "ext_preprocessor.h" 9 #include "ext_hashtab.h" 10 #include "ext_dictionary.h" 11 12 BEGIN_USING_C_LINKAGE 13 14 #ifndef TRUE 15 #define TRUE 1 16 #endif 17 #ifndef FALSE 18 #define FALSE 0 19 #endif 20 21 #ifndef C74_USE_COMMON_SYMBOLS 22 /** The namespace for all Max object classes which can be instantiated in a box, i.e. in a patcher. 23 @ingroup class */ 24 #define CLASS_BOX gensym("box") 25 26 /** A namespace for creating hidden or internal object classes which are not a direct part of the user 27 creating patcher. 28 @ingroup class */ 29 #define CLASS_NOBOX gensym("nobox") 30 31 #else 32 #define CLASS_BOX _sym_box 33 #define CLASS_NOBOX _sym_nobox 34 #endif 35 36 /** Attribute flags 37 @ingroup attr 38 39 @remark To create a readonly attribute, for example, 40 you should pass ATTR_SET_OPAQUE or ATTR_SET_OPAQUE_USER as a flag when you create your attribute. 41 */ 42 typedef enum { 43 ATTR_FLAGS_NONE = 0x0000000, ///< No flags 44 ATTR_GET_OPAQUE = 0x00000001, ///< The attribute cannot be queried by either max message when used inside of a CLASS_BOX object, nor from C code. 45 ATTR_SET_OPAQUE = 0x00000002, ///< The attribute cannot be set by either max message when used inside of a CLASS_BOX object, nor from C code. 46 ATTR_GET_OPAQUE_USER = 0x00000100, ///< The attribute cannot be queried by max message when used inside of a CLASS_BOX object, but <em>can</em> be queried from C code. 47 ATTR_SET_OPAQUE_USER = 0x00000200, ///< The attribute cannot be set by max message when used inside of a CLASS_BOX object, but <em>can</em> be set from C code. 48 ATTR_GET_DEFER = 0x00010000, // Placeholder for potential future functionality: Any attribute queries will be called through a defer(). 49 ATTR_GET_USURP = 0x00020000, // Placeholder for potential future functionality: Any calls to query the attribute will be called through the equivalent of a defer(), repeated calls will be ignored until the getter is actually run. 50 ATTR_GET_DEFER_LOW = 0x00040000, // Placeholder for potential future functionality: Any attribute queries will be called through a defer_low(). 51 ATTR_GET_USURP_LOW = 0x00080000, // Placeholder for potential future functionality: Any calls to query the attribute will be called through the equivalent of a defer_low(), repeated calls will be ignored until the getter is actually run. 52 ATTR_SET_DEFER = 0x01000000, // Placeholder for potential future functionality: The attribute setter will be called through a defer(). 53 ATTR_SET_USURP = 0x02000000, // Placeholder for potential future functionality: Any calls to set the attribute will be called through the equivalent of a defer_low(), repeated calls will be ignored until the setter is actually run. 54 ATTR_SET_DEFER_LOW = 0x04000000, // Placeholder for potential future functionality: The attribute setter will be called through a defer_low() 55 ATTR_SET_USURP_LOW = 0x08000000, // Placeholder for potential future functionality: Any calls to set the attribute will be called through the equivalent of a defer_low(), repeated calls will be ignored until the setter is actually run. 56 ATTR_IS_JBOXATTR = 0x10000000, // a common jbox attr 57 ATTR_DIRTY = 0x20000000 // attr has been changed from its default value 58 } e_max_attrflags; 59 60 /** Flags used in linklist and hashtab objects 61 @ingroup datastore */ 62 typedef enum { 63 OBJ_FLAG_OBJ = 0x00000000, ///< free using object_free() 64 OBJ_FLAG_REF = 0x00000001, ///< don't free 65 OBJ_FLAG_DATA = 0x00000002, ///< don't free data or call method 66 OBJ_FLAG_MEMORY = 0x00000004, ///< don't call method, and when freeing use sysmem_freeptr() instead of freeobject 67 OBJ_FLAG_SILENT = 0x00000100, ///< don't notify when modified 68 OBJ_FLAG_INHERITABLE = 0x00000200, ///< obexprototype entry will be inherited by subpatchers and abstractions 69 OBJ_FLAG_ITERATING = 0x00001000, ///< used by linklist to signal when is inside iteration 70 OBJ_FLAG_CLONE = 0x00002000, ///< object should be cloned when added to data structure (i.e. dictionary) 71 OBJ_FLAG_DANGER = 0x20000000, ///< context-dependent flag, used internally for hashtable code 72 OBJ_FLAG_DEBUG = 0x40000000 ///< context-dependent flag, used internally for linklist debug code 73 } e_max_datastore_flags; 74 75 #if C74_PRAGMA_STRUCT_PACKPUSH 76 #pragma pack(push, 2) 77 #elif C74_PRAGMA_STRUCT_PACK 78 #pragma pack(2) 79 #endif 80 81 #define C74_SPLAT_PREPARE(splat_prev_arg) va_list splat_va_args; \ 82 void *sp_arg1, *sp_arg2, *sp_arg3, *sp_arg4, *sp_arg5, *sp_arg6, *sp_arg7, *sp_arg8; \ 83 va_start(splat_va_args, splat_prev_arg); \ 84 sp_arg1 = va_arg(splat_va_args, void*); \ 85 sp_arg2 = va_arg(splat_va_args, void*); \ 86 sp_arg3 = va_arg(splat_va_args, void*); \ 87 sp_arg4 = va_arg(splat_va_args, void*); \ 88 sp_arg5 = va_arg(splat_va_args, void*); \ 89 sp_arg6 = va_arg(splat_va_args, void*); \ 90 sp_arg7 = va_arg(splat_va_args, void*); \ 91 sp_arg8 = va_arg(splat_va_args, void*); 92 #define C74_SPLAT_PASS sp_arg1, sp_arg2, sp_arg3, sp_arg4, sp_arg5, sp_arg6, sp_arg7, sp_arg8 93 94 #define C74_SPLAT_CLEANUP va_end(splat_va_args); 95 96 /** Common attr struct. This struct is provided for debugging convenience, 97 but should be considered opaque and is subject to change without notice. 98 99 @ingroup attr 100 */ 101 typedef struct _attr 102 { 103 t_object ob; 104 t_symbol *name; 105 t_symbol *type; 106 long flags; //public/private get/set methods 107 method get; //override default get method 108 method set; //override default set method 109 void *filterget; //filterobject for get method 110 void *filterset; //filterobject for set method 111 void *reserved; //for future use 112 } t_attr; 113 114 /** macros for settings and getting attribute dirty flag */ 115 116 #define ATTR_SET_DIRTY(x) (((t_attr *)(x))->flags |= ATTR_DIRTY) 117 #define ATTR_UNSET_DIRTY(x) (((t_attr *)(x))->flags &= ~ATTR_DIRTY) 118 #define ATTR_GET_DIRTY(x) (((t_attr *)(x))->flags & ATTR_DIRTY) 119 120 /** 121 A method that always returns true. 122 @ingroup misc 123 */ 124 t_atom_long method_true(void *x); 125 126 127 /** 128 A method that always returns false. 129 @ingroup misc 130 */ 131 t_atom_long method_false(void *x); 132 133 134 #ifndef class_new 135 /** 136 Initializes a class by informing Max of its name, instance creation and free functions, size and argument types. 137 Developers wishing to use obex class features (attributes, etc.) <em>must</em> use class_new() 138 instead of the traditional setup() function. 139 140 @ingroup class 141 142 @param name The class's name, as a C-string 143 @param mnew The instance creation function 144 @param mfree The instance free function 145 @param size The size of the object's data structure in bytes. 146 Usually you use the C sizeof operator here. 147 @param mmenu Obsolete - pass NULL. 148 In Max 4 this was a function pointer for UI objects called when the user created a new object of the 149 class from the Patch window's palette. 150 @param type A standard Max <em>type list</em> as explained in Chapter 3 151 of the Writing Externals in Max document (in the Max SDK). 152 The final argument of the type list should be a 0. 153 <em>Generally, obex objects have a single type argument</em>, 154 #A_GIMME, followed by a 0. 155 156 @return This function returns the class pointer for the new object class. 157 <em>This pointer is used by numerous other functions and should be 158 stored in a global or static variable.</em> 159 */ 160 t_class *class_new(C74_CONST char *name, C74_CONST method mnew, C74_CONST method mfree, long size, C74_CONST method mmenu, short type, ...); 161 #endif 162 163 164 /** 165 Frees a previously defined object class. <em>This function is not typically used by external developers.</em> 166 167 @ingroup class 168 @param c The class pointer 169 @return This function returns the error code #MAX_ERR_NONE if successful, 170 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 171 */ 172 t_max_err class_free(t_class *c); 173 174 175 #ifndef class_register 176 /** 177 Registers a previously defined object class. This function is required, and should be called at the end of <tt>main()</tt>. 178 179 @ingroup class 180 181 @param name_space The desired class's name space. Typically, either the 182 constant #CLASS_BOX, for obex classes which can 183 instantiate inside of a Max patcher (e.g. boxes, UI objects, 184 etc.), or the constant #CLASS_NOBOX, for classes 185 which will only be used internally. Developers can define 186 their own name spaces as well, but this functionality is 187 currently undocumented. 188 @param c The class pointer 189 190 @return This function returns the error code #MAX_ERR_NONE if successful, 191 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 192 */ 193 t_max_err class_register(t_symbol *name_space, t_class *c); 194 #endif 195 196 197 /** 198 Registers an alias for a previously defined object class. 199 200 @ingroup class 201 @param c The class pointer 202 @param aliasname A symbol who's name will become an alias for the given class 203 204 @return This function returns the error code #MAX_ERR_NONE if successful, 205 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 206 */ 207 t_max_err class_alias(t_class *c, t_symbol *aliasname); 208 209 // function: class_copy 210 /** 211 * Duplicates a previously registered object class, and registers a copy of this class. 212 * 213 * @ingroup classmod 214 * 215 * @param src_name_space The source class's name space. 216 * @param src_classname The source class's class name. 217 * @param dst_name_space The copied class's name space. 218 * @param dst_classname The copied class's class name. 219 * 220 * @return This function returns the error code <tt>MAX_ERR_NONE</tt> if successful, 221 * or one of the other error codes defined in "ext_obex.h" if unsuccessful. 222 * 223 */ 224 t_max_err class_copy(t_symbol *src_name_space, t_symbol *src_classname, t_symbol *dst_name_space, t_symbol *dst_classname); 225 226 227 #ifndef class_addmethod 228 /** 229 Adds a method to a previously defined object class. 230 231 @ingroup class 232 233 @param c The class pointer 234 @param m Function to be called when the method is invoked 235 @param name C-string defining the message (message selector) 236 @param ... One or more integers specifying the arguments to the message, 237 in the standard Max type list format (see Chapter 3 of the 238 Writing Externals in Max document for more information). 239 240 @return This function returns the error code #MAX_ERR_NONE if successful, 241 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 242 243 @remark The class_addmethod() function works essentially like the 244 traditional addmess() function, adding the function pointed to 245 by <tt>m</tt>, to respond to the message string <tt>name</tt> in the 246 leftmost inlet of the object. 247 */ 248 t_max_err class_addmethod(t_class *c, C74_CONST method m, C74_CONST char *name, ...); 249 #endif 250 251 252 /** 253 Adds an attribute to a previously defined object class. 254 255 @ingroup class 256 257 @param c The class pointer 258 @param attr The attribute to add. The attribute will be a pointer returned 259 by attribute_new(), attr_offset_new() or 260 attr_offset_array_new(). 261 262 @return This function returns the error code #MAX_ERR_NONE if successful, 263 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 264 */ 265 t_max_err class_addattr(t_class *c,t_object *attr); 266 267 268 // private 269 t_max_err class_addadornment(t_class *c,t_object *o); 270 271 272 // private 273 void *class_adornment_get(t_class *c,t_symbol *classname); 274 275 276 /** 277 Retrieves the name of a class, given the class's pointer. 278 279 @ingroup class 280 @param c The class pointer 281 @return If successful, this function returns the name of the class as a t_symbol *. 282 */ 283 t_symbol *class_nameget(t_class *c); 284 285 286 /** 287 Finds the class pointer for a class, given the class's namespace and name. 288 289 @ingroup class 290 291 @param name_space The desired class's name space. Typically, either the 292 constant #CLASS_BOX, for obex classes which can 293 instantiate inside of a Max patcher (e.g. boxes, UI objects, 294 etc.), or the constant #CLASS_NOBOX, for classes 295 which will only be used internally. Developers can define 296 their own name spaces as well, but this functionality is 297 currently undocumented. 298 @param classname The name of the class to be looked up 299 300 @return If successful, this function returns the class's data pointer. Otherwise, it returns NULL. 301 */ 302 t_class *class_findbyname(t_symbol *name_space, t_symbol *classname); 303 304 305 /** 306 Finds the class pointer for a class, given the class's namespace and name. 307 308 @ingroup class 309 310 @param name_space The desired class's name space. Typically, either the 311 constant #CLASS_BOX, for obex classes which can 312 instantiate inside of a Max patcher (e.g. boxes, UI objects, 313 etc.), or the constant #CLASS_NOBOX, for classes 314 which will only be used internally. Developers can define 315 their own name spaces as well, but this functionality is 316 currently undocumented. 317 @param classname The name of the class to be looked up (case free) 318 319 @return If successful, this function returns the class's data pointer. Otherwise, it returns NULL. 320 */ 321 t_class *class_findbyname_casefree(t_symbol *name_space, t_symbol *classname); 322 323 324 /** 325 Wraps user gettable attributes with a method that gets the values and sends out dumpout outlet. 326 327 @ingroup class 328 @param c The class pointer 329 @return This function returns the error code #MAX_ERR_NONE if successful, 330 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 331 */ 332 t_max_err class_dumpout_wrap(t_class *c); 333 334 t_class *class_getifloaded(t_symbol *name_space, t_symbol *classname); 335 t_class *class_getifloaded_casefree(t_symbol *name_space, t_symbol *classname); 336 337 338 /** 339 Determines if a particular object is an instance of a given class. 340 341 @ingroup obj 342 343 @param x The object to test 344 @param name The name of the class to test this object against 345 @return This function returns 1 if the object is an instance of the named class. Otherwise, 0 is returned. 346 @remark For instance, to determine whether an unknown object pointer is a pointer to a print object, one would call: 347 348 @code 349 long isprint = object_classname_compare(x, gensym("print")); 350 @endcode 351 */ 352 long object_classname_compare(void *x, t_symbol *name); 353 354 t_hashtab *reg_object_namespace_lookup(t_symbol *name_space); 355 method class_method(t_class *x, t_symbol *methodname); 356 t_messlist *class_mess(t_class *x, t_symbol *methodname); 357 t_messlist *object_mess(t_object *x, t_symbol *methodname); 358 method class_attr_method(t_class *x, t_symbol *methodname, void **attr, long *get); 359 void *class_attr_get(t_class *x, t_symbol *attrname); 360 t_max_err class_extra_store(t_class *x,t_symbol *s,t_object *o); 361 t_max_err class_extra_storeflags(t_class *x,t_symbol *s,t_object *o,long flags); 362 void *class_extra_lookup(t_class *x,t_symbol *s); 363 t_max_err class_addtypedwrapper(t_class *x, method m, char *name, ...); 364 t_messlist *class_typedwrapper_get(t_class *x, t_symbol *s); 365 t_max_err object_addtypedwrapper(t_object *x, method m, char *name, ...); 366 t_messlist *object_typedwrapper_get(t_object *x, t_symbol *s); 367 t_hashtab *class_namespace_fromsym(t_symbol *name_space); 368 t_max_err class_namespace_getclassnames(t_symbol *name_space, long *kc, t_symbol ***kv); 369 t_max_err class_setpath(t_class *x, short vol); 370 short class_getpath(t_class *x); 371 372 373 #ifndef object_alloc 374 /** 375 Allocates the memory for an instance of an object class and initialize its object header. 376 It is used like the traditional function newobject, inside of an object's <tt>new</tt> method, but its use is required with obex-class objects. 377 378 @ingroup obj 379 @param c The class pointer, returned by class_new() 380 @return This function returns a new instance of an object class if successful, or NULL if unsuccessful. 381 */ 382 void *object_alloc(t_class *c); 383 #endif 384 385 386 /** 387 Allocates the memory for an instance of an object class and initialize its object header <em>internal to Max</em>. 388 It is used similarly to the traditional function newinstance(), but its use is required with obex-class objects. 389 390 @ingroup obj 391 392 @param name_space The desired object's name space. Typically, either the 393 constant #CLASS_BOX, for obex classes which can 394 instantiate inside of a Max patcher (e.g. boxes, UI objects, 395 etc.), or the constant #CLASS_NOBOX, for classes 396 which will only be used internally. Developers can define 397 their own name spaces as well, but this functionality is 398 currently undocumented. 399 @param classname The name of the class of the object to be created 400 @param ... Any arguments expected by the object class being instantiated 401 402 @return This function returns a new instance of the object class if successful, or NULL if unsuccessful. 403 */ 404 void *object_new(t_symbol *name_space, t_symbol *classname, ...); 405 406 #ifdef C74_X64 407 #define object_new(...) C74_VARFUN(object_new_imp, __VA_ARGS__) 408 #endif 409 410 void *object_new_imp(void *p1, void *p2, void *p3, void *p4, void *p5, void *p6, void *p7, void *p8, void *p9, void *p10); 411 412 413 /** 414 Allocates the memory for an instance of an object class and initialize its object header <em>internal to Max</em>. 415 It is used similarly to the traditional function newinstance(), but its use is required with obex-class objects. 416 The object_new_typed() function differs from object_new() by its use of an atom list for object arguments—in this way, 417 it more resembles the effect of typing something into an object box from the Max interface. 418 419 @ingroup obj 420 421 @param name_space The desired object's name space. Typically, either the 422 constant #CLASS_BOX, for obex classes which can 423 instantiate inside of a Max patcher (e.g. boxes, UI objects, 424 etc.), or the constant #CLASS_NOBOX, for classes 425 which will only be used internally. Developers can define 426 their own name spaces as well, but this functionality is 427 currently undocumented. 428 @param classname The name of the class of the object to be created 429 @param ac Count of arguments in <tt>av</tt> 430 @param av Array of t_atoms; arguments to the class's instance creation function. 431 432 @return This function returns a new instance of the object class if successful, or NULL if unsuccessful. 433 */ 434 void *object_new_typed(t_symbol *name_space, t_symbol *classname, long ac, t_atom *av); 435 436 void *object_new_menufun(t_symbol *name_space, t_symbol *classname, void *p, long h, long v, long f); 437 438 439 #ifndef object_free 440 /** 441 Call the free function and release the memory for an instance of an internal object class previously instantiated using object_new(), 442 object_new_typed() or other new-style object constructor functions (e.g. hashtab_new()). 443 It is, at the time of this writing, a wrapper for the traditional function freeobject(), but its use is suggested with obex-class objects. 444 445 @ingroup obj 446 @param x The pointer to the object to be freed. 447 @return This function returns the error code #MAX_ERR_NONE if successful, 448 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 449 */ 450 t_max_err object_free(void *x); 451 #endif 452 453 454 /** 455 Sends an untyped message to an object. 456 There are some caveats to its use, however, particularly for 64-bit architectures. 457 object_method_direct() should be used in cases where floating-point or other non-integer types are being passed on the stack or in return values. 458 459 @ingroup obj 460 461 @param x The object that will receive the message 462 @param s The message selector 463 @param ... Any arguments to the message 464 465 @return If the receiver object can respond to the message, object_method() returns the result. Otherwise, the function will return 0. 466 467 @remark Example: To send the message <tt>bang</tt> to the object <tt>bang_me</tt>: 468 @code 469 void *bang_result; 470 bang_result = object_method(bang_me, gensym("bang")); 471 @endcode 472 */ 473 474 void *object_method(void *x, t_symbol *s, ...); 475 476 #ifdef C74_X64 477 #define object_method(...) C74_VARFUN(object_method_imp, __VA_ARGS__) 478 #endif 479 480 void *object_method_imp(void *x, void *sym, void *p1, void *p2, void *p3, void *p4, void *p5, void *p6, void *p7, void *p8); 481 482 /** 483 do a strongly typed direct call to a method of an object 484 485 @ingroup obj 486 487 488 @param rt The type of the return value (double, void*, void...) 489 @param sig the actual signature of the function in brackets ! 490 something like (t_object *, double, long) 491 @param x The object where the method we want to call will be looked for, 492 it will also always be the first argument to the function call 493 @param s The message selector 494 @param ... Any arguments to the call, the first one will always be the object (x) 495 496 @return will return anything that the called function returns, typed by (rt) 497 498 @remark Example: To call the function identified by <tt>getcolorat</tt> on the object <tt>pwindow</tt> 499 which is declared like: 500 t_jrgba pwindow_getcolorat(t_object *window, double x, double y) 501 @code 502 double x = 44.73; 503 double y = 79.21; 504 t_object *pwindow; 505 t_jrgba result = object_method_direct(t_jrgba, (t_object *, double, double), pwindow, gensym("getcolorat"), x, y); 506 @endcode 507 */ 508 509 #define object_method_direct(rt, sig, x, s, ...) ((rt (*)sig)object_method_direct_getmethod((t_object *)x, s))((t_object *)object_method_direct_getobject((t_object *)x, s), __VA_ARGS__) 510 511 method object_method_direct_getmethod(t_object *x, t_symbol *sym); 512 void *object_method_direct_getobject(t_object *x, t_symbol *sym); 513 514 /** 515 Sends a type-checked message to an object. 516 517 @ingroup obj 518 519 @param x The object that will receive the message 520 @param s The message selector 521 @param ac Count of message arguments in <tt>av</tt> 522 @param av Array of t_atoms; the message arguments 523 @param rv Return value of function, if available 524 525 @return This function returns the error code #MAX_ERR_NONE if successful, 526 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 527 528 @remark If the receiver object can respond to the message, object_method_typed() returns the result in <tt>rv</tt>. Otherwise, <tt>rv</tt> will contain an #A_NOTHING atom. 529 */ 530 t_max_err object_method_typed(void *x, t_symbol *s, long ac, t_atom *av, t_atom *rv); 531 532 533 /** 534 Currently undocumented. 535 536 @ingroup obj 537 538 @param x The object that will receive the message 539 @param mp Undocumented 540 @param s The message selector 541 @param ac Count of message arguments in <tt>av</tt> 542 @param av Array of t_atoms; the message arguments 543 @param rv Return value of function, if available 544 545 @return This function returns the error code #MAX_ERR_NONE if successful, 546 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 547 548 @remark If the receiver object can respond to the message, object_method_typedfun() returns the result in <tt>rv</tt>. Otherwise, <tt>rv</tt> will contain an #A_NOTHING atom. 549 */ 550 t_max_err object_method_typedfun(void *x, t_messlist *mp, t_symbol *s, long ac, t_atom *av, t_atom *rv); 551 552 553 /** 554 Retrieves an object's #method for a particular message selector. 555 556 @ingroup obj 557 @param x The object whose method is being queried 558 @param s The message selector 559 @return This function returns the #method if successful, or method_false() if unsuccessful. 560 */ 561 method object_getmethod(void *x, t_symbol *s); 562 563 564 /** 565 Retrieves an object instance's class name 566 567 @ingroup obj 568 @param x The object instance whose class name is being queried 569 @return The classname, or NULL if unsuccessful. 570 */ 571 t_symbol *object_classname(void *x); 572 573 574 t_symbol *object_namespace(t_object *x); // return the namespace this object's class is part of 575 576 577 t_symbol *class_namespace(t_class *c); // return the namespace the class is part of 578 579 580 /** 581 Registers an object in a namespace. 582 583 @ingroup obj 584 585 @param name_space The namespace in which to register the object. The namespace can be any symbol. 586 If the namespace does not already exist, it is created automatically. 587 @param s The name of the object in the namespace. This name will be 588 used by other objects to attach and detach from the registered object. 589 @param x The object to register 590 591 @return The function returns a pointer to the registered object. Under some 592 circumstances, object_register will <em>duplicate</em> the object, 593 and return a pointer to the duplicate—the developer should not assume 594 that the pointer passed in is the same pointer that has been registered. 595 To be safe, the returned pointer should be stored and used with the 596 bject_unregister() function. 597 598 @remark You should not register an object if the object is a UI object. 599 UI objects automatically register and attach to themselves in jbox_new(). 600 */ 601 void *object_register(t_symbol *name_space, t_symbol *s, void *x); 602 603 604 t_symbol *object_register_unique(t_symbol *name_space, t_symbol *s, void *x); 605 606 607 /** 608 Determines a registered object's pointer, given its namespace and name. 609 610 @ingroup obj 611 612 @param name_space The namespace of the registered object 613 @param s The name of the registered object in the namespace 614 615 @return This function returns the pointer of the registered object, 616 if successful, or NULL, if unsuccessful. 617 */ 618 void *object_findregistered(t_symbol *name_space, t_symbol *s); 619 620 621 /** 622 Determines the namespace and/or name of a registered object, given the object's pointer. 623 624 @ingroup obj 625 626 @param name_space Pointer to a t_symbol *, to receive the namespace of the registered object 627 @param s Pointer to a t_symbol *, to receive the name of the registered object within the namespace 628 @param x Pointer to the registered object 629 630 @return This function returns the error code #MAX_ERR_NONE if successful, 631 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 632 */ 633 t_max_err object_findregisteredbyptr(t_symbol **name_space, t_symbol **s, void *x); 634 635 /** 636 Returns all registered names in a namespace 637 638 @ingroup obj 639 640 @param name_space Pointer to a t_symbol, the namespace to lookup names in 641 @param namecount Pointer to a long, to receive the count of the registered names within the namespace 642 @param names Pointer to a t_symbol **, to receive the allocated names. This pointer should be freed after use 643 644 @return This function returns the error code <tt>MAX_ERR_NONE</tt> if successful, 645 or one of the other error codes defined in "ext_obex.h" if unsuccessful. 646 */ 647 t_max_err object_register_getnames(t_symbol *name_space, long *namecount, t_symbol ***names); 648 649 /** 650 Attaches a client to a registered object. 651 Once attached, the object will receive notifications sent from the registered object (via the object_notify() function), 652 if it has a <tt>notify</tt> method defined and implemented. 653 654 @ingroup obj 655 656 @param name_space The namespace of the registered object. 657 This should be the same value used in object_register() to register the object. 658 If you don't know the registered object's namespace, the object_findregisteredbyptr() function can be used to determine it. 659 @param s The name of the registered object in the namespace. 660 If you don't know the name of the registered object, the object_findregisteredbyptr() function can be used to determine it. 661 @param x The client object to attach. Generally, this is the pointer to your Max object. 662 663 @return This function returns a pointer to the registered object (to the object 664 referred to by the combination of <tt>name_space</tt> and <tt>s</tt> 665 arguments) if successful, or NULL if unsuccessful. 666 667 @remark You should not attach an object to itself if the object is a UI object. 668 UI objects automatically register and attach to themselves in jbox_new(). 669 670 @see object_notify() 671 @see object_detach() 672 @see object_attach_byptr() 673 @see object_register() 674 */ 675 void *object_attach(t_symbol *name_space, t_symbol *s, void *x); 676 677 678 /** 679 Detach a client from a registered object. 680 681 @ingroup obj 682 683 @param name_space The namespace of the registered object. 684 This should be the same value used in object_register() to register the object. 685 If you don't know the registered object's namespace, the object_findregisteredbyptr() function can be used to determine it. 686 @param s The name of the registered object in the namespace. 687 If you don't know the name of the registered object, the object_findregisteredbyptr() function can be used to determine it. 688 @param x The client object to attach. Generally, this is the pointer to your Max object. 689 690 @return This function returns the error code #MAX_ERR_NONE if successful, 691 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 692 */ 693 t_max_err object_detach(t_symbol *name_space, t_symbol *s, void *x); 694 695 696 /** 697 Attaches a client to a registered object. 698 Unlike object_attach(), the client is specified by providing a pointer to that object 699 rather than the registered name of that object. 700 701 Once attached, the object will receive notifications sent from the registered object (via the object_notify() function), 702 if it has a <tt>notify</tt> method defined and implemented. 703 704 @ingroup obj 705 @param x The attaching client object. Generally, this is the pointer to your Max object. 706 @param registeredobject A pointer to the registered object to which you wish to attach. 707 @return A Max error code. 708 709 @remark You should not attach an object to itself if the object is a UI object. 710 UI objects automatically register and attach to themselves in jbox_new(). 711 712 @see object_notify() 713 @see object_detach() 714 @see object_attach() 715 @see object_register() 716 @see object_attach_byptr_register() 717 */ 718 t_max_err object_attach_byptr(void *x, void *registeredobject); 719 720 721 /** 722 A convenience function wrapping object_register() and object_attach_byptr(). 723 724 @ingroup obj 725 726 @param x The attaching client object. Generally, this is the pointer to your Max object. 727 @param object_to_attach A pointer to the object to which you wish to registered and then to which to attach. 728 @param reg_name_space The namespace in which to register the object_to_attach. 729 @return A Max error code. 730 731 @see object_register() 732 @see object_attach_byptr() 733 */ 734 t_max_err object_attach_byptr_register(void *x, void *object_to_attach, t_symbol *reg_name_space); 735 736 737 /** 738 Detach a client from a registered object. 739 740 @ingroup obj 741 @param x The attaching client object. Generally, this is the pointer to your Max object. 742 @param registeredobject The object from which to detach. 743 @return A Max error code. 744 745 @see object_detach() 746 @see object_attach_byptr() 747 */ 748 t_max_err object_detach_byptr(void *x, void *registeredobject); 749 750 // function: object_subscribe 751 /** 752 * Subscribes a client to wait for an object to register. Upon registration, the object will attach. Once attached, the object will receive notifications sent from the registered object (via the <tt>object_notify</tt> function), if it has a <tt>notify</tt> method defined and implemented. See below for more information, in the reference for <tt>object_notify</tt>. 753 * 754 * @ingroup obj 755 * 756 * @param name_space The namespace of the registered object. This should be the 757 * same value used in <tt>object_register</tt> to register the 758 * object. If you don't know the registered object's namespace, 759 * the <tt>object_findregisteredbyptr</tt> function can be 760 * used to determine it. 761 * @param s The name of the registered object in the namespace. If you 762 * don't know the name of the registered object, the 763 * <tt>object_findregisteredbyptr</tt> function can be used to 764 * determine it. 765 * @param classname The classname of the registered object in the namespace to 766 * use as a filter. If NULL, then it will attach to any class 767 * of object. 768 * @param x The client object to attach. Generally, this is the pointer to your Max object. 769 * 770 * @return This function returns a pointer to the object if registered (to the object 771 * referred to by the combination of <tt>name_space</tt> and <tt>s</tt> 772 * arguments) if successful, or NULL if the object is not yet registered. 773 * 774 */ 775 void *object_subscribe(t_symbol *name_space, t_symbol *s, t_symbol *classname, void *x); 776 777 // function: object_unsubscribe 778 /** 779 * Unsubscribe a client from a registered object, detaching if the object is registered. 780 * 781 * @ingroup obj 782 * 783 * @param name_space The namespace of the registered object. This should be the 784 * same value used in <tt>object_register</tt> to register the 785 * object. If you don't know the registered object's namespace, 786 * the <tt>object_findregisteredbyptr</tt> function can be 787 * used to determine it. 788 * @param s The name of the registered object in the namespace. If you 789 * don't know the name of the registered object, the 790 * <tt>object_findregisteredbyptr</tt> function can be used to 791 * determine it. 792 * @param classname The classname of the registered object in the namespace to 793 * use as a filter. Currently unused for unsubscribe. 794 * @param x The client object to detach. Generally, this is the pointer to your Max object. 795 * 796 * @return This function returns the error code <tt>MAX_ERR_NONE</tt> if successful, 797 * or one of the other error codes defined in "ext_obex.h" if unsuccessful. 798 * 799 */ 800 t_max_err object_unsubscribe(t_symbol *name_space, t_symbol *s, t_symbol *classname, void *x); 801 802 803 /** 804 Removes a registered object from a namespace. 805 806 @ingroup obj 807 @param x The object to unregister. This should be the pointer returned from the object_register() function. 808 @return This function returns the error code #MAX_ERR_NONE if successful, 809 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 810 */ 811 t_max_err object_unregister(void *x); 812 813 /** 814 Returns all registered names in a namespace 815 816 @ingroup obj 817 818 @param name_space Pointer to a t_symbol, the namespace to lookup names in 819 @param namecount Pointer to a long, to receive the count of the registered names within the namespace 820 @param names Pointer to a t_symbol **, to receive the allocated names. This pointer should be freed after use 821 822 @return This function returns the error code <tt>MAX_ERR_NONE</tt> if successful, 823 or one of the other error codes defined in "ext_obex.h" if unsuccessful. 824 */ 825 t_max_err object_register_getnames(t_symbol *name_space, long *namecount, t_symbol ***names); 826 827 828 /** 829 Broadcast a message (with an optional argument) from a registered object to any attached client objects. 830 831 @ingroup obj 832 833 @param x Pointer to the registered object 834 @param s The message to send 835 @param data An optional argument which will be passed with the message. 836 Sets this argument to NULL if it will be unused. 837 838 @return This function returns the error code #MAX_ERR_NONE if successful, 839 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 840 841 @remark In order for client objects to receive notifications, they must define and implement a special method, <tt>notify</tt>, like so: 842 @code 843 class_addmethod(c, (method)myobject_notify, "notify", A_CANT, 0); 844 @endcode 845 846 @remark The <tt>notify</tt> method should be prototyped as: 847 @code 848 void myobject_notify(t_myobject *x, t_symbol *s, t_symbol *msg, void *sender, void *data); 849 @endcode 850 where 851 <tt>x</tt> is the pointer to the receiving object, 852 <tt>s</tt> is the name of the sending (registered) object in its namespace, 853 <tt>msg</tt> is the sent message, 854 <tt>sender</tt> is the pointer to the sending object, and 855 <tt>data</tt> is an optional argument sent with the message. 856 This value corresponds to the data argument in the object_notify() method. 857 */ 858 t_max_err object_notify(void *x, t_symbol *s, void *data); 859 860 // currently for internal use only 861 t_symbol *reg_object_singlesym(t_symbol *name_space, t_symbol *s); 862 t_symbol *reg_object_singlesymbyptr(t_object *x); 863 t_max_err reg_object_singlesym_split(t_symbol *singlesym, t_symbol **name_space, t_symbol **objname); 864 865 866 /** 867 Determines the class of a given object. 868 869 @ingroup obj 870 @param x The object to test 871 @return This function returns the t_class * of the object's class, if successful, or NULL, if unsuccessful. 872 */ 873 t_class *object_class(void *x); 874 875 876 /** 877 Retrieves the value of an object which supports the <tt>getvalueof/setvalueof</tt> interface. See part 2 of the pattr SDK for more information on this interface. 878 879 @ingroup obj 880 881 @param x The object whose value is of interest 882 @param ac Pointer to a long variable to receive the count of arguments in <tt>av</tt>. The long variable itself should be set to 0 previous to calling this function. 883 @param av Pointer to a t_atom *, to receive object data. The t_atom * itself should be set to NULL previous to calling this function. 884 885 @return This function returns the error code #MAX_ERR_NONE if successful, 886 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 887 888 @remark Calling the object_getvalueof() function allocates memory for any data it returns. 889 It is the developer's responsibility to free it, using the freebytes() function. 890 891 @remark Developers wishing to design objects which will support this function being called on them must define and implement a special method, <tt>getvalueof</tt>, like so: 892 @code 893 class_addmethod(c, (method)myobject_getvalueof, "getvalueof", A_CANT, 0); 894 @endcode 895 896 @remark The <tt>getvalueof</tt> method should be prototyped as: 897 @code 898 t_max_err myobject_getvalueof(t_myobject *x, long *ac, t_atom **av); 899 @endcode 900 901 @remark And implemented, generally, as: 902 @code 903 t_max_err myobj_getvalueof(t_myobj *x, long *ac, t_atom **av) 904 { 905 if (ac && av) { 906 if (*ac && *av) { 907 // memory has been passed in; use it. 908 } else { 909 // allocate enough memory for your data 910 *av = (t_atom *)getbytes(sizeof(t_atom)); 911 } 912 *ac = 1; // our data is a single floating point value 913 atom_setfloat(*av, x->objvalue); 914 } 915 return MAX_ERR_NONE; 916 } 917 918 @remark By convention, and to permit the interoperability of objects using the obex API, 919 developers should allocate memory in their <tt>getvalueof</tt> methods using the getbytes() function. 920 @endcode 921 */ 922 t_max_err object_getvalueof(void *x, long *ac, t_atom **av); 923 924 925 /** 926 Sets the value of an object which supports the <tt>getvalueof/setvalueof</tt> interface. 927 928 @ingroup obj 929 930 @param x The object whose value is of interest 931 @param ac The count of arguments in <tt>av</tt> 932 @param av Array of t_atoms; the new desired data for the object 933 934 @return This function returns the error code #MAX_ERR_NONE if successful, 935 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 936 937 @remark Developers wishing to design objects which will support this function being called on them must define and implement a special method, <tt>setvalueof</tt>, like so: 938 @code 939 class_addmethod(c, (method)myobject_setvalueof, "setvalueof", A_CANT, 0); 940 @endcode 941 942 @remark The <tt>setvalueof</tt> method should be prototyped as: 943 @code 944 t_max_err myobject_setvalueof(t_myobject *x, long *ac, t_atom **av); 945 @endcode 946 947 @remark And implemented, generally, as: 948 @code 949 t_max_err myobject_setvalueof(t_myobject *x, long ac, t_atom *av) 950 { 951 if (ac && av) { 952 // simulate receipt of a float value 953 myobject_float(x, atom_getfloat(av)); 954 } 955 return MAX_ERR_NONE; 956 } 957 @endcode 958 */ 959 t_max_err object_setvalueof(void *x, long ac, t_atom *av); 960 961 /** 962 Returns the pointer to an attribute, given its name. 963 964 @ingroup attr 965 966 @param x Pointer to the object whose attribute is of interest 967 @param attrname The attribute's name 968 969 @return This function returns a pointer to the attribute, if successful, or NULL, if unsuccessful. 970 */ 971 void *object_attr_get(void *x, t_symbol *attrname); 972 973 974 /** 975 Returns the method of an attribute's <tt>get</tt> or <tt>set</tt> function, as well as a pointer to the attribute itself, from a message name. 976 977 @ingroup attr 978 979 @param x Pointer to the object whose attribute is of interest 980 @param methodname The Max message used to call the attribute's <tt>get</tt> or <tt>set</tt> function. For example, <tt>gensym("mode")</tt> or <tt>gensym("getthresh")</tt>. 981 @param attr A pointer to a void *, which will be set to the attribute pointer upon successful completion of the function 982 @param get A pointer to a long variable, which will be set to 1 upon successful completion of the function, 983 if the queried method corresponds to the <tt>get</tt> function of the attribute. 984 985 @return This function returns the requested method, if successful, or NULL, if unsuccessful. 986 */ 987 method object_attr_method(void *x, t_symbol *methodname, void **attr, long *get); 988 989 990 /** 991 Determines if an object's attribute can be set from the Max interface (i.e. if its #ATTR_SET_OPAQUE_USER flag is set). 992 993 @ingroup attr 994 995 @param x Pointer to the object whose attribute is of interest 996 @param s The attribute's name 997 998 @return This function returns 1 if the attribute can be set from the Max interface. Otherwise, it returns 0. 999 */ 1000 long object_attr_usercanset(void *x,t_symbol *s); 1001 1002 1003 /** 1004 Determines if the value of an object's attribute can be queried from the Max interface (i.e. if its #ATTR_GET_OPAQUE_USER flag is set). 1005 1006 @ingroup attr 1007 1008 @param x Pointer to the object whose attribute is of interest 1009 @param s The attribute's name 1010 1011 @return This function returns 1 if the value of the attribute can be queried from the Max interface. Otherwise, it returns 0. 1012 */ 1013 long object_attr_usercanget(void *x,t_symbol *s); 1014 1015 1016 /** 1017 Forces a specified object's attribute to send its value from the object's dumpout outlet in the Max interface. 1018 1019 @ingroup attr 1020 1021 @param x Pointer to the object whose attribute is of interest 1022 @param s The attribute's name 1023 @param argc Unused 1024 @param argv Unused 1025 */ 1026 void object_attr_getdump(void *x, t_symbol *s, long argc, t_atom *argv); 1027 1028 1029 t_max_err object_attr_getvalueof(void *x, t_symbol *s, long *argc, t_atom **argv); 1030 1031 1032 /** 1033 Sets the value of an object's attribute. 1034 1035 @ingroup attr 1036 1037 @param x Pointer to the object whose attribute is of interest 1038 @param s The attribute's name 1039 @param argc The count of arguments in <tt>argv</tt> 1040 @param argv Array of t_atoms; the new desired data for the attribute 1041 1042 @return This function returns the error code #MAX_ERR_NONE if successful, 1043 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1044 */ 1045 t_max_err object_attr_setvalueof(void *x, t_symbol *s, long argc, t_atom *argv); 1046 1047 1048 // for internal use only 1049 t_max_err object_attr_lock(t_object *x, t_symbol *s); 1050 t_max_err object_attr_unlock(t_object *x, t_symbol *s); 1051 1052 //object specific attributes(dynamically add/delete) 1053 1054 /** 1055 Attaches an attribute directly to an object. 1056 1057 @ingroup attr 1058 1059 @param x An object to which the attribute should be attached 1060 @param attr The attribute's pointer—this should be a pointer returned from attribute_new(), attr_offset_new() or attr_offset_array_new(). 1061 1062 @return This function returns the error code #MAX_ERR_NONE if successful, 1063 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1064 */ 1065 t_max_err object_addattr(void *x, t_object *attr); 1066 1067 1068 /** 1069 Detach an attribute from an object that was previously attached with object_addattr(). 1070 The function will also free all memory associated with the attribute. 1071 If you only wish to detach the attribute, without freeing it, see the object_chuckattr() function. 1072 1073 @ingroup attr 1074 1075 @param x The object to which the attribute is attached 1076 @param attrsym The attribute's name 1077 1078 @return This function returns the error code #MAX_ERR_NONE if successful, 1079 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1080 */ 1081 t_max_err object_deleteattr(void *x, t_symbol *attrsym); 1082 1083 1084 /** 1085 Detach an attribute from an object that was previously attached with object_addattr(). 1086 This function will <em>not</em> free the attribute (use object_free() to do this manually). 1087 1088 @ingroup attr 1089 1090 @param x The object to which the attribute is attached 1091 @param attrsym The attribute's name 1092 1093 @return This function returns the error code #MAX_ERR_NONE if successful, 1094 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1095 */ 1096 t_max_err object_chuckattr(void *x, t_symbol *attrsym); 1097 1098 1099 // obex 1100 1101 /** 1102 Registers the byte-offset of the obex member of the class's data structure with the previously defined object class. 1103 Use of this function is required for obex-class objects. It must be called from <tt>main()</tt>. 1104 1105 @ingroup class 1106 1107 @param c The class pointer 1108 @param offset The byte-offset to the obex member of the object's data structure. 1109 Conventionally, the macro #calcoffset is used to calculate the offset. 1110 */ 1111 void class_obexoffset_set(t_class *c, long offset); 1112 1113 1114 /** 1115 Retrieves the byte-offset of the obex member of the class's data structure. 1116 1117 @ingroup class 1118 @param c The class pointer 1119 @return This function returns the byte-offset of the obex member of the class's data structure. 1120 */ 1121 long class_obexoffset_get(t_class *c); 1122 1123 1124 /** 1125 Retrieves the value of a data stored in the obex. 1126 1127 @ingroup obj 1128 1129 @param x The object pointer. This function should only be called on instantiated objects (i.e. in the <tt>new</tt> method or later), not directly on classes (i.e. in <tt>main()</tt>). 1130 @param key The symbolic name for the data to be retrieved 1131 @param val A pointer to a #t_object *, to be filled with the data retrieved from the obex. 1132 1133 @return This function returns the error code #MAX_ERR_NONE if successful, 1134 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1135 1136 @remark By default, pointers to the object's containing patcher and box objects are stored in the obex, under the keys '#P' and '#B', respectively. 1137 To retrieve them, the developer could do something like the following: 1138 @code 1139 void post_containers(t_obexobj *x) 1140 { 1141 t_patcher *p; 1142 t_box *b; 1143 t_max_err err; 1144 1145 err = object_obex_lookup(x, gensym("#P"), (t_object **)&p); 1146 err = object_obex_lookup(x, gensym("#B"), (t_object **)&b); 1147 1148 post("my patcher is located at 0x%X", p); 1149 post("my box is located at 0x%X", b); 1150 } 1151 @endcode 1152 */ 1153 t_max_err object_obex_lookup(void *x, t_symbol *key, t_object **val); 1154 t_max_err object_obex_lookuplong(void *x, t_symbol *key, t_atom_long *val); 1155 t_max_err object_obex_lookupsym(void *x, t_symbol *key, t_symbol **val); 1156 1157 /** 1158 Stores data in the object's obex. 1159 1160 @ingroup obj 1161 1162 @param x The object pointer. This function should only be called on instantiated objects (i.e. in the <tt>new</tt> method or later), not directly on classes (i.e. in <tt>main()</tt>). 1163 @param key A symbolic name for the data to be stored 1164 @param val A #t_object *, to be stored in the obex, referenced under the <tt>key</tt>. 1165 1166 @return This function returns the error code #MAX_ERR_NONE if successful, 1167 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1168 1169 @remark Most developers will need to use this function for the specific purpose of storing the dumpout outlet in the obex 1170 (the dumpout outlet is used by attributes to report data in response to 'get' queries). 1171 For this, the developer should use something like the following in the object's <tt>new</tt> method: 1172 @code 1173 object_obex_store(x, _sym_dumpout, outlet_new(x, NULL)); 1174 @endcode 1175 */ 1176 t_max_err object_obex_store(void *x,t_symbol *key, t_object *val); 1177 t_max_err object_obex_storeflags(void *x,t_symbol *key, t_object *val, long flags); 1178 1179 t_max_err object_obex_storelong(void *x, t_symbol *key, t_atom_long val); 1180 t_max_err object_obex_storesym(void *x, t_symbol *key, t_symbol *val); 1181 1182 1183 // private 1184 t_max_err object_obex_set(void *x, t_hashtab *obex); 1185 1186 1187 // private 1188 t_hashtab *object_obex_get(void *x); 1189 1190 1191 // private 1192 t_hashtab *object_obex_enforce(void *x); 1193 1194 1195 /** 1196 Sends data from the object's dumpout outlet. 1197 The dumpout outlet is stored in the obex using the object_obex_store() function (see above). 1198 It is used approximately like outlet_anything(). 1199 1200 @ingroup obj 1201 1202 @param x The object pointer. 1203 This function should only be called on instantiated objects (i.e. in the <tt>new</tt> method or later), not directly on classes (i.e. in <tt>main()</tt>). 1204 @param s The message selector #t_symbol * 1205 @param argc Number of elements in the argument list in argv 1206 @param argv t_atoms constituting the message arguments 1207 1208 @return This function returns the error code #MAX_ERR_NONE if successful, 1209 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1210 */ 1211 void object_obex_dumpout(void *x, t_symbol *s, long argc, t_atom *argv); 1212 1213 1214 // DO NOT CALL THIS -- It is called automatically now from object_free() or freeobject() -- calling this will cause problems. 1215 C74_DEPRECATED( void object_obex_free(void *x) ); 1216 1217 1218 //atom functions 1219 1220 #ifndef atom_setlong 1221 /** 1222 Inserts an integer into a #t_atom and change the t_atom's type to #A_LONG. 1223 1224 @ingroup atom 1225 1226 @param a Pointer to a #t_atom whose value and type will be modified 1227 @param b Integer value to copy into the #t_atom 1228 1229 @return This function returns the error code #MAX_ERR_NONE if successful, 1230 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1231 */ 1232 t_max_err atom_setlong(t_atom *a, t_atom_long b); 1233 #endif 1234 1235 1236 #ifndef atom_setfloat 1237 /** 1238 Inserts a floating point number into a #t_atom and change the t_atom's type to #A_FLOAT. 1239 1240 @ingroup atom 1241 1242 @param a Pointer to a #t_atom whose value and type will be modified 1243 @param b Floating point value to copy into the #t_atom 1244 1245 @return This function returns the error code #MAX_ERR_NONE if successful, 1246 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1247 */ 1248 t_max_err atom_setfloat(t_atom *a, double b); 1249 #endif 1250 1251 1252 #ifndef atom_setsym 1253 /** 1254 Inserts a #t_symbol * into a #t_atom and change the t_atom's type to #A_SYM. 1255 1256 @ingroup atom 1257 1258 @param a Pointer to a #t_atom whose value and type will be modified 1259 @param b Pointer to a #t_symbol to copy into the #t_atom 1260 1261 @return This function returns the error code #MAX_ERR_NONE if successful, 1262 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1263 */ 1264 t_max_err atom_setsym(t_atom *a, t_symbol *b); 1265 #endif 1266 1267 1268 /** 1269 Inserts a generic pointer value into a #t_atom and change the t_atom's type to #A_OBJ. 1270 1271 @ingroup atom 1272 1273 @param a Pointer to a #t_atom whose value and type will be modified 1274 @param b Pointer value to copy into the #t_atom 1275 1276 @return This function returns the error code #MAX_ERR_NONE if successful, 1277 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1278 */ 1279 t_max_err atom_setobj(t_atom *a, void *b); 1280 1281 1282 #ifndef atom_getlong 1283 /** 1284 Retrieves a long integer value from a #t_atom. 1285 1286 @ingroup atom 1287 1288 @param a Pointer to a #t_atom whose value is of interest 1289 @return This function returns the value of the specified #t_atom as an integer, if possible. Otherwise, it returns 0. 1290 @remark If the #t_atom is not of the type specified by the function, the function will attempt to coerce a valid value from the t_atom. 1291 For instance, if the t_atom <tt>at</tt> is set to type #A_FLOAT with a value of <tt>3.7</tt>, 1292 the atom_getlong() function will return the truncated integer value of <tt>at</tt>, or <tt>3</tt>. 1293 An attempt is also made to coerce #t_symbol data. 1294 */ 1295 t_atom_long atom_getlong(const t_atom *a); 1296 #endif 1297 1298 1299 #ifndef atom_getfloat 1300 /** 1301 Retrieves a floating point value from a #t_atom. 1302 1303 @ingroup atom 1304 @param a Pointer to a #t_atom whose value is of interest 1305 @return This function returns the value of the specified #t_atom as a floating point number, if possible. Otherwise, it returns 0. 1306 1307 @remark If the #t_atom is not of the type specified by the function, the function will attempt to coerce a valid value from the t_atom. 1308 For instance, if the t_atom <tt>at</tt> is set to type #A_LONG with a value of <tt>5</tt>, 1309 the atom_getfloat() function will return the value of <tt>at</tt> as a float, or <tt>5.0</tt>. 1310 An attempt is also made to coerce #t_symbol data. 1311 */ 1312 t_atom_float atom_getfloat(const t_atom *a); 1313 #endif 1314 1315 1316 #ifndef atom_getsym 1317 /** 1318 Retrieves a t_symbol * value from a t_atom. 1319 1320 @ingroup atom 1321 @param a Pointer to a t_atom whose value is of interest 1322 @return This function returns the value of the specified #A_SYM-typed #t_atom, if possible. 1323 Otherwise, it returns an empty, but valid, #t_symbol *, equivalent to <tt>gensym("")</tt>, or <tt>_sym_nothing</tt>. 1324 1325 @remark No attempt is made to coerce non-matching data types. 1326 */ 1327 t_symbol *atom_getsym(const t_atom *a); 1328 #endif 1329 1330 1331 /** 1332 Retrieves a generic pointer value from a #t_atom. 1333 1334 @ingroup atom 1335 @param a Pointer to a #t_atom whose value is of interest 1336 @return This function returns the value of the specified #A_OBJ-typed t_atom, if possible. Otherwise, it returns NULL. 1337 */ 1338 void *atom_getobj(const t_atom *a); 1339 1340 1341 /** 1342 Retrieves an unsigned integer value between 0 and 255 from a t_atom. 1343 1344 @ingroup atom 1345 @param a Pointer to a #t_atom whose value is of interest 1346 @return This function returns the value of the specified #t_atom as an integer between 0 and 255, if possible. Otherwise, it returns 0. 1347 1348 @remark If the #t_atom is typed #A_LONG, but the data falls outside of the range 0-255, the data is truncated to that range before output. 1349 1350 @remark If the t_atom is typed #A_FLOAT, the floating point value is multiplied by 255. and truncated to the range 0-255 before output. 1351 For example, the floating point value <tt>0.5</tt> would be output from atom_getcharfix as <tt>127</tt> (0.5 * 255. = 127.5). 1352 1353 @remark No attempt is also made to coerce #t_symbol data. 1354 */ 1355 long atom_getcharfix(const t_atom *a); 1356 1357 1358 #ifndef atom_gettype 1359 /** 1360 Retrieves type from a #t_atom. 1361 1362 @ingroup atom 1363 @param a Pointer to a #t_atom whose type is of interest 1364 @return This function returns the type of the specified t_atom as defined in #e_max_atomtypes 1365 */ 1366 long atom_gettype(const t_atom *a); 1367 #endif 1368 1369 1370 //the following are useful for setting the values _only_ if there is an arg 1371 //rather than setting it to 0 or _sym_nothing 1372 1373 /** 1374 Retrieves the integer value of a particular t_atom from an atom list, if the atom exists. 1375 1376 @ingroup atom 1377 1378 @param c Pointer to a long variable to receive the atom's data if the function is successful. 1379 @param idx Offset into the atom list of the atom of interest, starting from 0. 1380 For instance, if you want data from the 3rd atom in the atom list, <tt>idx</tt> should be set to 2. 1381 @param ac Count of av. 1382 @param av Pointer to the first t_atom of an atom list. 1383 1384 @return This function returns the error code #MAX_ERR_NONE if successful, 1385 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1386 1387 @remark The atom_arg_getlong() function only changes the value of <tt>c</tt> if the function is successful. 1388 For instance, the following code snippet illustrates a simple, but typical use: 1389 @code 1390 void myobject_mymessage(t_myobject *x, t_symbol *s, long ac, t_atom *av) 1391 { 1392 t_atom_long var = -1; 1393 1394 // here, we are expecting a value of 0 or greater 1395 atom_arg_getlong(&var, 0, ac, av); 1396 if (val == -1) // i.e. unchanged 1397 post("it is likely that the user did not provide a valid argument"); 1398 else { 1399 ... 1400 } 1401 } 1402 @endcode 1403 */ 1404 t_max_err atom_arg_getlong(t_atom_long *c, long idx, long ac, const t_atom *av); 1405 1406 1407 /** 1408 Retrieves the floating point value of a particular t_atom from an atom list, if the atom exists. 1409 1410 @ingroup atom 1411 1412 @param c Pointer to a float variable to receive the atom's data if the function is successful. Otherwise, the value is left unchanged. 1413 @param idx Offset into the atom list of the atom of interest, starting from 0. 1414 For instance, if you want data from the 3rd atom in the atom list, <tt>idx</tt> should be set to 2. 1415 @param ac Count of av. 1416 @param av Pointer to the first t_atom of an atom list. 1417 1418 @return This function returns the error code #MAX_ERR_NONE if successful, 1419 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1420 */ 1421 long atom_arg_getfloat(float *c, long idx, long ac, const t_atom *av); 1422 1423 1424 /** 1425 Retrieves the floating point value, as a double, of a particular t_atom from an atom list, if the atom exists. 1426 1427 @ingroup atom 1428 1429 @param c Pointer to a double variable to receive the atom's data if the function is successful. Otherwise the value is left unchanged. 1430 @param idx Offset into the atom list of the atom of interest, starting from 0. 1431 For instance, if you want data from the 3rd atom in the atom list, <tt>idx</tt> should be set to 2. 1432 @param ac Count of av. 1433 @param av Pointer to the first t_atom of an atom list. 1434 1435 @return This function returns the error code #MAX_ERR_NONE if successful, 1436 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1437 */ 1438 long atom_arg_getdouble(double *c, long idx, long ac, const t_atom *av); 1439 1440 1441 /** 1442 Retrieves the t_symbol * value of a particular t_atom from an atom list, if the atom exists. 1443 1444 @ingroup atom 1445 1446 @param c Pointer to a t_symbol * variable to receive the atom's data if the function is successful. Otherwise, the value is left unchanged. 1447 @param idx Offset into the atom list of the atom of interest, starting from 0. 1448 For instance, if you want data from the 3rd atom in the atom list, <tt>idx</tt> should be set to 2. 1449 @param ac Count of av. 1450 @param av Pointer to the first t_atom of an atom list. 1451 1452 @return This function returns the error code #MAX_ERR_NONE if successful, 1453 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1454 1455 @remark The atom_arg_getsym() function only changes the value of <tt>c</tt> if the function is successful. 1456 For instance, the following code snippet illustrates a simple, but typical use: 1457 @code 1458 void myobject_open(t_myobject *x, t_symbol *s, long ac, t_atom *av) 1459 { 1460 t_symbol *filename = _sym_nothing; 1461 1462 // here, we are expecting a file name. 1463 // if we don't get it, open a dialog box 1464 atom_arg_getsym(&filename, 0, ac, av); 1465 if (filename == _sym_nothing) { // i.e. unchanged 1466 // open the file dialog box, 1467 // get a value for filename 1468 } 1469 // do something with the filename 1470 } 1471 @endcode 1472 */ 1473 long atom_arg_getsym(t_symbol **c, long idx, long ac, const t_atom *av); 1474 1475 1476 //attr functions 1477 1478 /** 1479 Determines the point in an atom list where attribute arguments begin. 1480 Developers can use this function to assist in the manual processing of attribute arguments, when attr_args_process() 1481 doesn't provide the correct functionality for a particular purpose. 1482 1483 @ingroup attr 1484 1485 @param ac The count of t_atoms in <tt>av</tt> 1486 @param av An atom list 1487 1488 @return This function returns an offset into the atom list, where the first attribute argument occurs. 1489 For instance, the atom list <tt>foo bar 3.0 \@mode 6</tt> would cause <tt>attr_args_offset</tt> to return 3 1490 (the attribute <tt>mode</tt> appears at position 3 in the atom list). 1491 */ 1492 long attr_args_offset(short ac, t_atom *av); 1493 1494 1495 /** 1496 Takes an atom list and properly set any attributes described within. This function is typically used in an object's <tt>new</tt> method to conveniently process attribute arguments. 1497 1498 @ingroup attr 1499 1500 @param x The object whose attributes will be processed 1501 @param ac The count of t_atoms in <tt>av</tt> 1502 @param av An atom list 1503 1504 @remark Here is a typical example of usage: 1505 @code 1506 void *myobject_new(t_symbol *s, long ac, t_atom *av) 1507 { 1508 t_myobject *x = NULL; 1509 1510 if (x=(t_myobject *)object_alloc(myobject_class)) 1511 { 1512 // initialize any data before processing 1513 // attributes to avoid overwriting 1514 // attribute argument-set values 1515 x->data = 0; 1516 1517 // process attr args, if any 1518 attr_args_process(x, ac, av); 1519 } 1520 return x; 1521 } 1522 @endcode 1523 */ 1524 void attr_args_process(void *x, short ac, t_atom *av); 1525 1526 1527 //constructors 1528 1529 1530 /** 1531 Create a new attribute. The attribute will allocate memory and store its own data. Attributes created using attribute_new() can be assigned either to classes (using the class_addattr() function) or to objects (using the object_addattr() function). 1532 1533 @ingroup attr 1534 1535 @param name A name for the attribute, as a C-string 1536 @param type A t_symbol * representing a valid attribute type. 1537 At the time of this writing, the valid type-symbols are: 1538 <tt>_sym_char</tt> (char), 1539 <tt>_sym_long</tt> (long), 1540 <tt>_sym_float32</tt> (32-bit float), 1541 <tt>_sym_float64</tt> (64-bit float), 1542 <tt>_sym_atom</tt> (Max #t_atom pointer), 1543 <tt>_sym_symbol</tt> (Max #t_symbol pointer), 1544 <tt>_sym_pointer</tt> (generic pointer) and 1545 <tt>_sym_object</tt> (Max #t_object pointer). 1546 @param flags Any attribute flags, expressed as a bitfield. 1547 Attribute flags are used to determine if an attribute is accessible for setting or querying. 1548 The available accessor flags are defined in #e_max_attrflags. 1549 @param mget The method to use for the attribute's <tt>get</tt> functionality. If <tt>mget</tt> is NULL, the default method is used. 1550 @param mset The method to use for the attribute's <tt>set</tt> functionality. If <tt>mset</tt> is NULL, the default method is used. 1551 1552 @return This function returns the new attribute's object pointer if successful, or NULL if unsuccessful. 1553 1554 @remark Developers wishing to define custom methods for <tt>get</tt> or <tt>set</tt> functionality need to prototype them as: 1555 @code 1556 t_max_err myobject_myattr_get(t_myobject *x, void *attr, long *ac, t_atom **av); 1557 @endcode 1558 @code 1559 t_max_err myobject_myattr_set(t_myobject *x, void *attr, long ac, t_atom *av); 1560 @endcode 1561 1562 @remark Implementation will vary, of course, but need to follow the following basic models. 1563 Note that, as with custom <tt>getvalueof</tt> and <tt>setvalueof</tt> methods for the object, 1564 assumptions are made throughout Max that getbytes() has been used for memory allocation. 1565 Developers are strongly urged to do the same: 1566 @code 1567 t_max_err myobject_myattr_get(t_myobject *x, void *attr, long *ac, t_atom **av) 1568 { 1569 if (*ac && *av) 1570 // memory passed in; use it 1571 else { 1572 *ac = 1; // size of attr data 1573 *av = (t_atom *)getbytes(sizeof(t_atom) * (*ac)); 1574 if (!(*av)) { 1575 *ac = 0; 1576 return MAX_ERR_OUT_OF_MEM; 1577 } 1578 } 1579 atom_setlong(*av, x->some_value); 1580 return MAX_ERR_NONE; 1581 } 1582 1583 t_max_err myobject_myattr_set(t_myobject *x, void *attr, long ac, t_atom *av) 1584 { 1585 if (ac && av) { 1586 x->some_value = atom_getlong(av); 1587 } 1588 return MAX_ERR_NONE; 1589 } 1590 @endcode 1591 */ 1592 t_object *attribute_new(C74_CONST char *name, t_symbol *type, long flags, method mget, method mset); 1593 1594 1595 /** 1596 Create a new attribute. The attribute references memory stored outside of itself, in the object's data structure. Attributes created using attr_offset_new() can be assigned either to classes (using the class_addattr() function) or to objects (using the object_addattr() function). 1597 1598 @ingroup attr 1599 1600 @param name A name for the attribute, as a C-string 1601 @param type A t_symbol * representing a valid attribute type. 1602 At the time of this writing, the valid type-symbols are: 1603 <tt>_sym_char</tt> (char), 1604 <tt>_sym_long</tt> (long), 1605 <tt>_sym_float32</tt> (32-bit float), 1606 <tt>_sym_float64</tt> (64-bit float), 1607 <tt>_sym_atom</tt> (Max #t_atom pointer), 1608 <tt>_sym_symbol</tt> (Max #t_symbol pointer), 1609 <tt>_sym_pointer</tt> (generic pointer) and 1610 <tt>_sym_object</tt> (Max #t_object pointer). 1611 @param flags Any attribute flags, expressed as a bitfield. 1612 Attribute flags are used to determine if an attribute is accessible for setting or querying. 1613 The available accessor flags are defined in #e_max_attrflags. 1614 @param mget The method to use for the attribute's <tt>get</tt> functionality. 1615 If <tt>mget</tt> is NULL, the default method is used. See the discussion under attribute_new(), for more information. 1616 @param mset The method to use for the attribute's <tt>set</tt> functionality. 1617 If <tt>mset</tt> is NULL, the default method is used. See the discussion under attribute_new(), for more information. 1618 @param offset Byte offset into the class data structure of the object which will "own" the attribute. 1619 The offset should point to the data to be referenced by the attribute. 1620 Typically, the #calcoffset macro (described above) is used to calculate this offset. 1621 1622 @return This function returns the new attribute's object pointer if successful, or NULL if unsuccessful. 1623 1624 @remark For instance, to create a new attribute which references the value of a double variable (<tt>val</tt>) in an object class's data structure: 1625 @code 1626 t_object *attr = attr_offset_new("myattr", _sym_float64 / * matches data size * /, 0 / * no flags * /, (method)0L, (method)0L, calcoffset(t_myobject, val)); 1627 @endcode 1628 */ 1629 t_object *attr_offset_new(C74_CONST char *name, C74_CONST t_symbol *type, long flags, C74_CONST method mget, C74_CONST method mset, long offset); 1630 1631 1632 /** 1633 Create a new attribute. The attribute references an array of memory stored outside of itself, in the object's data structure. Attributes created using attr_offset_array_new() can be assigned either to classes (using the class_addattr() function) or to objects (using the object_addattr() function). 1634 1635 @ingroup attr 1636 1637 @param name A name for the attribute, as a C-string 1638 @param type A t_symbol * representing a valid attribute type. 1639 At the time of this writing, the valid type-symbols are: 1640 <tt>_sym_char</tt> (char), 1641 <tt>_sym_long</tt> (long), 1642 <tt>_sym_float32</tt> (32-bit float), 1643 <tt>_sym_float64</tt> (64-bit float), 1644 <tt>_sym_atom</tt> (Max #t_atom pointer), 1645 <tt>_sym_symbol</tt> (Max #t_symbol pointer), 1646 <tt>_sym_pointer</tt> (generic pointer) and 1647 <tt>_sym_object</tt> (Max #t_object pointer). 1648 @param size Maximum number of items that may be in the array. 1649 @param flags Any attribute flags, expressed as a bitfield. 1650 Attribute flags are used to determine if an attribute is accessible for setting or querying. 1651 The available accessor flags are defined in #e_max_attrflags. 1652 @param mget The method to use for the attribute's <tt>get</tt> functionality. 1653 If <tt>mget</tt> is NULL, the default method is used. See the discussion under attribute_new(), for more information. 1654 @param mset The method to use for the attribute's <tt>set</tt> functionality. 1655 If <tt>mset</tt> is NULL, the default method is used. See the discussion under attribute_new(), for more information. 1656 @param offsetcount Byte offset into the object class's data structure of a long variable describing how many array elements 1657 (up to <tt>size</tt>) comprise the data to be referenced by the attribute. 1658 Typically, the #calcoffset macro is used to calculate this offset. 1659 @param offset Byte offset into the class data structure of the object which will "own" the attribute. 1660 The offset should point to the data to be referenced by the attribute. 1661 Typically, the #calcoffset macro is used to calculate this offset. 1662 1663 @return This function returns the new attribute's object pointer if successful, or NULL if unsuccessful. 1664 1665 @remark For instance, to create a new attribute which references an array of 10 t_atoms (<tt>atm</tt>; 1666 the current number of "active" elements in the array is held in the variable <tt>atmcount</tt>) in an object class's data structure: 1667 @code 1668 t_object *attr = attr_offset_array_new("myattrarray", _sym_atom / * matches data size * /, 10 / * max * /, 0 / * no flags * /, (method)0L, (method)0L, calcoffset(t_myobject, atmcount) / * count * /, calcoffset(t_myobject, atm) / * data * /); 1669 @endcode 1670 */ 1671 t_object *attr_offset_array_new(C74_CONST char *name, t_symbol *type, long size, long flags, method mget, method mset, long offsetcount, long offset); 1672 1673 1674 t_object *attr_filter_clip_new(void); 1675 1676 1677 t_object *attr_filter_proc_new(method proc); 1678 1679 1680 //for easy access of simple attributes 1681 1682 /** 1683 Retrieves the value of an attribute, given its parent object and name. 1684 1685 @ingroup attr 1686 1687 @param x The attribute's parent object 1688 @param s The attribute's name 1689 1690 @return This function returns the value of the specified attribute, if successful, or 0, if unsuccessful. 1691 1692 @remark If the attribute is not of the type specified by the function, the 1693 function will attempt to coerce a valid value from the attribute. 1694 */ 1695 t_atom_long object_attr_getlong(void *x, t_symbol *s); 1696 1697 1698 /** 1699 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1700 1701 @ingroup attr 1702 1703 @param x The attribute's parent object 1704 @param s The attribute's name 1705 @param c An integer value; the new value for the attribute 1706 1707 @return This function returns the error code #MAX_ERR_NONE if successful, 1708 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1709 */ 1710 t_max_err object_attr_setlong(void *x, t_symbol *s, t_atom_long c); 1711 1712 1713 /** 1714 Retrieves the value of an attribute, given its parent object and name. 1715 1716 @ingroup attr 1717 1718 @param x The attribute's parent object 1719 @param s The attribute's name 1720 1721 @return This function returns the value of the specified attribute, if successful, or 0, if unsuccessful. 1722 1723 @remark If the attribute is not of the type specified by the function, the 1724 function will attempt to coerce a valid value from the attribute. 1725 */ 1726 t_atom_float object_attr_getfloat(void *x, t_symbol *s); 1727 1728 1729 /** 1730 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1731 1732 @ingroup attr 1733 1734 @param x The attribute's parent object 1735 @param s The attribute's name 1736 @param c An floating point value; the new value for the attribute 1737 1738 @return This function returns the error code #MAX_ERR_NONE if successful, 1739 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1740 */ 1741 t_max_err object_attr_setfloat(void *x, t_symbol *s, t_atom_float c); 1742 1743 1744 /** 1745 Retrieves the value of an attribute, given its parent object and name. 1746 1747 @ingroup attr 1748 1749 @param x The attribute's parent object 1750 @param s The attribute's name 1751 1752 @return This function returns the value of the specified attribute, if successful, or the empty symbol (equivalent to <tt>gensym("")</tt> or <tt>_sym_nothing</tt>), if unsuccessful. 1753 */ 1754 t_symbol *object_attr_getsym(void *x, t_symbol *s); 1755 1756 1757 /** 1758 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1759 1760 @ingroup attr 1761 1762 @param x The attribute's parent object 1763 @param s The attribute's name 1764 @param c A t_symbol *; the new value for the attribute 1765 1766 @return This function returns the error code #MAX_ERR_NONE if successful, 1767 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1768 */ 1769 t_max_err object_attr_setsym(void *x, t_symbol *s, t_symbol *c); 1770 1771 1772 char object_attr_getchar(void *x, t_symbol *s); 1773 t_max_err object_attr_setchar(void *x, t_symbol *s, char c); 1774 t_object* object_attr_getobj(void *x, t_symbol *s); 1775 t_max_err object_attr_setobj(void *x, t_symbol *s, t_object *o); 1776 1777 1778 /** 1779 Retrieves the value of an attribute, given its parent object and name. 1780 This function uses a developer-allocated array to copy data to. 1781 Developers wishing to retrieve the value of an attribute without pre-allocating memory should refer to the object_attr_getvalueof() function. 1782 1783 @ingroup attr 1784 1785 @param x The attribute's parent object 1786 @param s The attribute's name 1787 @param max The number of array elements in <tt>vals</tt>. The function will take care not to overwrite the bounds of the array. 1788 @param vals Pointer to the first element of a pre-allocated array of long data. 1789 1790 @return This function returns the number of elements copied into <tt>vals</tt>. 1791 1792 @remark If the attribute is not of the type specified by the function, the 1793 function will attempt to coerce a valid value from the attribute. 1794 */ 1795 long object_attr_getlong_array(void *x, t_symbol *s, long max, t_atom_long *vals); 1796 1797 1798 /** 1799 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1800 1801 @ingroup attr 1802 1803 @param x The attribute's parent object 1804 @param s The attribute's name 1805 @param count The number of array elements in vals 1806 @param vals Pointer to the first element of an array of long data 1807 1808 @return This function returns the error code #MAX_ERR_NONE if successful, 1809 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1810 */ 1811 t_max_err object_attr_setlong_array(void *x, t_symbol *s, long count, t_atom_long *vals); 1812 1813 1814 /** 1815 Retrieves the value of an attribute, given its parent object and name. 1816 This function uses a developer-allocated array to copy data to. 1817 Developers wishing to retrieve the value of an attribute without pre-allocating memory should refer to the object_attr_getvalueof() function. 1818 1819 @ingroup attr 1820 1821 @param x The attribute's parent object 1822 @param s The attribute's name 1823 @param max The number of array elements in <tt>vals</tt>. The function will take care not to overwrite the bounds of the array. 1824 @param vals Pointer to the first element of a pre-allocated array of unsigned char data. 1825 1826 @return This function returns the number of elements copied into <tt>vals</tt>. 1827 1828 @remark If the attribute is not of the type specified by the function, the 1829 function will attempt to coerce a valid value from the attribute. 1830 */ 1831 long object_attr_getchar_array(void *x, t_symbol *s, long max, t_uint8 *vals); 1832 1833 1834 /** 1835 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1836 1837 @ingroup attr 1838 1839 @param x The attribute's parent object 1840 @param s The attribute's name 1841 @param count The number of array elements in vals 1842 @param vals Pointer to the first element of an array of unsigned char data 1843 1844 @return This function returns the error code #MAX_ERR_NONE if successful, 1845 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1846 */ 1847 t_max_err object_attr_setchar_array(void *x, t_symbol *s, long count, C74_CONST t_uint8 *vals); 1848 1849 1850 /** 1851 Retrieves the value of an attribute, given its parent object and name. 1852 This function uses a developer-allocated array to copy data to. 1853 Developers wishing to retrieve the value of an attribute without pre-allocating memory should refer to the object_attr_getvalueof() function. 1854 1855 @ingroup attr 1856 1857 @param x The attribute's parent object 1858 @param s The attribute's name 1859 @param max The number of array elements in <tt>vals</tt>. The function will take care not to overwrite the bounds of the array. 1860 @param vals Pointer to the first element of a pre-allocated array of float data. 1861 1862 @return This function returns the number of elements copied into <tt>vals</tt>. 1863 1864 @remark If the attribute is not of the type specified by the function, the 1865 function will attempt to coerce a valid value from the attribute. 1866 */ 1867 long object_attr_getfloat_array(void *x, t_symbol *s, long max, float *vals); 1868 1869 1870 /** 1871 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1872 1873 @ingroup attr 1874 1875 @param x The attribute's parent object 1876 @param s The attribute's name 1877 @param count The number of array elements in vals 1878 @param vals Pointer to the first element of an array of float data 1879 1880 @return This function returns the error code #MAX_ERR_NONE if successful, 1881 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1882 */ 1883 t_max_err object_attr_setfloat_array(void *x, t_symbol *s, long count, float *vals); 1884 1885 1886 /** 1887 Retrieves the value of an attribute, given its parent object and name. 1888 This function uses a developer-allocated array to copy data to. 1889 Developers wishing to retrieve the value of an attribute without pre-allocating memory should refer to the object_attr_getvalueof() function. 1890 1891 @ingroup attr 1892 1893 @param x The attribute's parent object 1894 @param s The attribute's name 1895 @param max The number of array elements in <tt>vals</tt>. The function will take care not to overwrite the bounds of the array. 1896 @param vals Pointer to the first element of a pre-allocated array of double data. 1897 1898 @return This function returns the number of elements copied into <tt>vals</tt>. 1899 1900 @remark If the attribute is not of the type specified by the function, the 1901 function will attempt to coerce a valid value from the attribute. 1902 */ 1903 long object_attr_getdouble_array(void *x, t_symbol *s, long max, double *vals); 1904 1905 1906 /** 1907 Sets the value of an attribute, given its parent object and name. The function will call the attribute's <tt>set</tt> method, using the data provided. 1908 1909 @ingroup attr 1910 1911 @param x The attribute's parent object 1912 @param s The attribute's name 1913 @param count The number of array elements in vals 1914 @param vals Pointer to the first element of an array of double data 1915 1916 @return This function returns the error code #MAX_ERR_NONE if successful, 1917 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1918 */ 1919 t_max_err object_attr_setdouble_array(void *x, t_symbol *s, long count, double *vals); 1920 1921 1922 /** 1923 Retrieves the value of an attribute, given its parent object and name. 1924 This function uses a developer-allocated array to copy data to. 1925 Developers wishing to retrieve the value of an attribute without pre-allocating memory should refer to the object_attr_getvalueof() function. 1926 1927 @ingroup attr 1928 1929 @param x The attribute's parent object 1930 @param s The attribute's name 1931 @param max The number of array elements in <tt>vals</tt>. The function will take care not to overwrite the bounds of the array. 1932 @param vals Pointer to the first element of a pre-allocated array of #t_symbol *s. 1933 1934 @return This function returns the number of elements copied into <tt>vals</tt>. 1935 */ 1936 long object_attr_getsym_array(void *x, t_symbol *s, long max, t_symbol **vals); 1937 1938 1939 /** 1940 Sets the value of an attribute, given its parent object and name. 1941 The function will call the attribute's <tt>set</tt> method, using the data provided. 1942 1943 @ingroup attr 1944 1945 @param x The attribute's parent object 1946 @param s The attribute's name 1947 @param count The number of array elements in vals 1948 @param vals Pointer to the first element of an array of #t_symbol *s 1949 1950 @return This function returns the error code #MAX_ERR_NONE if successful, 1951 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1952 */ 1953 t_max_err object_attr_setsym_array(void *x, t_symbol *s, long count, t_symbol **vals); 1954 1955 1956 //attr filters util 1957 1958 /** 1959 Attaches a clip filter to an attribute. 1960 The filter will <em>only</em> clip values sent to the attribute using the attribute's <tt>set</tt> function. 1961 1962 @ingroup attr 1963 1964 @param x Pointer to the attribute to receive the filter 1965 @param min Minimum value for the clip filter 1966 @param max Maximum value for the clip filter 1967 @param usemin Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 1968 @param usemax Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 1969 1970 @return This function returns the error code #MAX_ERR_NONE if successful, 1971 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1972 */ 1973 t_max_err attr_addfilterset_clip(void *x, double min, double max, long usemin, long usemax); 1974 1975 1976 /** 1977 Attaches a clip/scale filter to an attribute. 1978 The filter will <em>only</em> clip and scale values sent to the attribute using the attribute's <tt>set</tt> function. 1979 1980 @ingroup attr 1981 1982 @param x Pointer to the attribute to receive the filter 1983 @param scale Scale value. Data sent to the attribute will be scaled by this amount. <em>Scaling occurs previous to clipping</em>. 1984 @param min Minimum value for the clip filter 1985 @param max Maximum value for the clip filter 1986 @param usemin Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 1987 @param usemax Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 1988 1989 @return This function returns the error code #MAX_ERR_NONE if successful, 1990 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 1991 */ 1992 t_max_err attr_addfilterset_clip_scale(void *x, double scale, double min, double max, long usemin, long usemax); 1993 1994 1995 /** 1996 Attaches a clip filter to an attribute. 1997 The filter will <em>only</em> clip values retrieved from the attribute using the attribute's <tt>get</tt> function. 1998 1999 @ingroup attr 2000 2001 @param x Pointer to the attribute to receive the filter 2002 @param min Minimum value for the clip filter 2003 @param max Maximum value for the clip filter 2004 @param usemin Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2005 @param usemax Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2006 2007 @return This function returns the error code #MAX_ERR_NONE if successful, 2008 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2009 */ 2010 t_max_err attr_addfilterget_clip(void *x, double min, double max, long usemin, long usemax); 2011 2012 2013 /** 2014 Attaches a clip/scale filter to an attribute. 2015 The filter will <em>only</em> clip and scale values retrieved from the attribute using the attribute's <tt>get</tt> function. 2016 2017 @ingroup attr 2018 2019 @param x Pointer to the attribute to receive the filter 2020 @param scale Scale value. Data retrieved from the attribute will be scaled by this amount. <em>Scaling occurs previous to clipping</em>. 2021 @param min Minimum value for the clip filter 2022 @param max Maximum value for the clip filter 2023 @param usemin Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2024 @param usemax Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2025 2026 @return This function returns the error code #MAX_ERR_NONE if successful, 2027 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2028 */ 2029 t_max_err attr_addfilterget_clip_scale(void *x, double scale, double min, double max, long usemin, long usemax); 2030 2031 2032 /** 2033 Attaches a clip filter to an attribute. 2034 The filter will clip any values sent to or retrieved from the attribute using the attribute's <tt>get</tt> and <tt>set</tt> functions. 2035 2036 @ingroup attr 2037 2038 @param x Pointer to the attribute to receive the filter 2039 @param min Minimum value for the clip filter 2040 @param max Maximum value for the clip filter 2041 @param usemin Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2042 @param usemax Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2043 2044 @return This function returns the error code #MAX_ERR_NONE if successful, 2045 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2046 */ 2047 t_max_err attr_addfilter_clip(void *x, double min, double max, long usemin, long usemax); 2048 2049 2050 /** 2051 Attaches a clip/scale filter to an attribute. 2052 The filter will clip and scale any values sent to or retrieved from the attribute using the attribute's <tt>get</tt> and <tt>set</tt> functions. 2053 2054 @ingroup attr 2055 2056 @param x Pointer to the attribute to receive the filter 2057 @param scale Scale value. Data sent to the attribute will be scaled by this amount. Data retrieved from the attribute will be scaled by its reciprocal. 2058 <em>Scaling occurs previous to clipping</em>. 2059 @param min Minimum value for the clip filter 2060 @param max Maximum value for the clip filter 2061 @param usemin Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2062 @param usemax Sets this value to 0 if the minimum clip value should <em>not</em> be used. Otherwise, set the value to non-zero. 2063 2064 @return This function returns the error code #MAX_ERR_NONE if successful, 2065 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2066 */ 2067 t_max_err attr_addfilter_clip_scale(void *x, double scale, double min, double max, long usemin, long usemax); 2068 2069 2070 /** 2071 Attaches a custom filter method to an attribute. 2072 The filter will <em>only</em> be called for values retrieved from the attribute using the attribute's <tt>set</tt> function. 2073 2074 @ingroup attr 2075 2076 @param x Pointer to the attribute to receive the filter 2077 @param proc A filter method 2078 2079 @return This function returns the error code #MAX_ERR_NONE if successful, 2080 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2081 2082 @remark The filter method should be prototyped and implemented as follows: 2083 @code 2084 t_max_err myfiltermethod(void *parent, void *attr, long ac, t_atom *av); 2085 2086 t_max_err myfiltermethod(void *parent, void *attr, long ac, t_atom *av) 2087 { 2088 long i; 2089 float temp, 2090 2091 // this filter rounds off all values 2092 // assumes that the data is float 2093 for (i = 0; i < ac; i++) { 2094 temp = atom_getfloat(av + i); 2095 temp = (float)((long)(temp + 0.5)); 2096 atom_setfloat(av + i, temp); 2097 } 2098 return MAX_ERR_NONE; 2099 } 2100 @endcode 2101 */ 2102 t_max_err attr_addfilterset_proc(void *x, method proc); 2103 2104 2105 /** 2106 Attaches a custom filter method to an attribute. The filter will <em>only</em> be called for values retrieved from the attribute using the attribute's <tt>get</tt> function. 2107 2108 @ingroup attr 2109 2110 @param x Pointer to the attribute to receive the filter 2111 @param proc A filter method 2112 2113 @return This function returns the error code #MAX_ERR_NONE if successful, 2114 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2115 2116 @remark The filter method should be prototyped and implemented as described above for the attr_addfilterset_proc() function. 2117 */ 2118 t_max_err attr_addfilterget_proc(void *x, method proc); 2119 2120 2121 //more util functions 2122 2123 /** 2124 Generates a unique #t_symbol *. The symbol will be formatted somewhat like "u123456789". 2125 2126 @ingroup misc 2127 @return This function returns a unique #t_symbol *. 2128 */ 2129 t_symbol *symbol_unique(void); 2130 2131 2132 /** 2133 Strip quotes from the beginning and end of a symbol if they are present. 2134 @ingroup misc 2135 @param s The symbol to be stipped. 2136 @return Symbol with any leading/trailing quote pairs removed. 2137 */ 2138 t_symbol *symbol_stripquotes(t_symbol *s); 2139 2140 2141 void error_code(void *x,t_max_err v); //interrupt safe 2142 2143 2144 /** 2145 Posts an error message to the Max window. This function is interrupt safe. 2146 2147 @ingroup misc 2148 2149 @param x The object's pointer 2150 @param s Symbol to be posted as an error in the Max window 2151 */ 2152 void error_sym(void *x,t_symbol *s); //interrupt safe 2153 2154 2155 /** 2156 Posts a message to the Max window. This function is interrupt safe. 2157 2158 @ingroup misc 2159 @param x The object's pointer 2160 @param s Symbol to be posted in the Max window 2161 */ 2162 void post_sym(void *x,t_symbol *s); //interrupt safe 2163 2164 2165 /** 2166 Performs an ASCII sort on an array of #t_symbol *s. 2167 2168 @ingroup misc 2169 2170 @param ac The count of #t_symbol *s in <tt>av</tt> 2171 @param av An array of #t_symbol *s to be sorted 2172 2173 @return This function returns the error code #MAX_ERR_NONE if successful, 2174 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 2175 */ 2176 t_max_err symbolarray_sort(long ac, t_symbol **av); 2177 2178 2179 /** 2180 Developers do not need to directly use the object_obex_quickref() function. 2181 It was used in Max 4 to add support for attributes to the quickref, but this is automatic in Max 5. 2182 2183 @ingroup misc 2184 */ 2185 void object_obex_quickref(void *x, long *numitems, t_symbol **items); 2186 2187 2188 method class_menufun_get(t_class *c); 2189 2190 long class_clonable(t_class *x); 2191 long object_clonable(t_object *x); 2192 t_max_err class_buildprototype(t_class *x); 2193 t_dictionary *class_cloneprototype(t_class *x); 2194 2195 2196 /** 2197 Create a dictionary of attribute-name, attribute-value pairs 2198 from an array of atoms containing an attribute definition list. 2199 2200 @ingroup attr 2201 @param x A dictionary instance pointer. 2202 @param ac The number of atoms to parse in av. 2203 @param av A pointer to the first of the array of atoms containing the attribute values. 2204 2205 @remark The code example below shows the creation of a list of atoms using atom_setparse(), 2206 and then uses that list of atoms to fill the dictionary with attr_args_dictionary(). 2207 @code 2208 long ac = 0; 2209 t_atom *av = NULL; 2210 char parsebuf[4096]; 2211 t_dictionary *d = dictionary_new(); 2212 t_atom a; 2213 2214 sprintf(parsebuf,"@defrect %.6f %.6f %.6f %.6f @title Untitled @presentation 0 ", r->x, r->y, r->width, r->height); 2215 atom_setparse(&ac, &av, parsebuf); 2216 attr_args_dictionary(d, ac, av); 2217 atom_setobj(&a, d); 2218 @endcode 2219 */ 2220 void attr_args_dictionary(t_dictionary *x, short ac, t_atom *av); 2221 2222 2223 /** 2224 Set attributes for an object that are defined in a dictionary. 2225 Objects with dictionary constructors, such as UI objects, 2226 should call this method to set their attributes when an object is created. 2227 2228 @ingroup attr 2229 @param x The object instance pointer. 2230 @param d The dictionary containing the attributes. 2231 @see attr_args_process() 2232 */ 2233 void attr_dictionary_process(void *x, t_dictionary *d); 2234 2235 /** 2236 Check that a dictionary only contains values for existing attributes 2237 of an object. If a key in the dictionary doesn't correspond an one of 2238 the object's attributes, an error will be posted to the Max window. 2239 2240 @ingroup attr 2241 @param x The object instance pointer. 2242 @param d The dictionary containing the attributes. 2243 @see attr_dictionary_process() 2244 */ 2245 void attr_dictionary_check(void *x, t_dictionary *d); 2246 2247 2248 /** 2249 Retrieve a pointer to a dictionary passed in as an atom argument. 2250 Use this function when working with classes that have dictionary constructors 2251 to fetch the dictionary. 2252 2253 @ingroup obj 2254 @param ac The number of atoms. 2255 @param av A pointer to the first atom in the array. 2256 @return The dictionary retrieved from the atoms. 2257 @see attr_dictionary_process() 2258 */ 2259 t_dictionary *object_dictionaryarg(long ac, t_atom *av); 2260 2261 2262 // use the macros for these in ext_obex_util.h 2263 t_max_err class_sticky(t_class *x, t_symbol *stickyname, t_symbol *s, t_object *o); 2264 t_max_err class_sticky_clear(t_class *x, t_symbol *stickyname, t_symbol *s); 2265 2266 2267 // private -- internal use only (and perhaps not exported?) 2268 t_max_err object_retain(t_object *x); 2269 t_max_err object_release(t_object *x); 2270 2271 typedef struct _method_object 2272 { 2273 t_object ob; 2274 t_messlist messlist_entry; 2275 } t_method_object; 2276 2277 t_method_object *method_object_new(method m, C74_CONST char *name, ...); 2278 t_method_object *method_object_new_messlist(t_messlist *m); 2279 void method_object_free(t_method_object *x); 2280 t_symbol *method_object_getname(t_method_object *x); 2281 void method_object_setname(t_method_object *x, t_symbol *s); 2282 method method_object_getmethod(t_method_object *x); 2283 void method_object_setmethod(t_method_object *x, method m); 2284 t_messlist *method_object_getmesslist(t_method_object *x); 2285 void method_object_setmesslist(t_method_object *x, t_messlist *m); 2286 2287 t_method_object *class_getmethod_object(t_class *x, t_symbol *methodname); 2288 2289 // these methods are private -- instance methods are not actually fully implemented at this time 2290 t_method_object *object_getmethod_object(t_object *x, t_symbol *methodname); 2291 2292 t_max_err object_attrhash_apply(t_object *x, t_hashtab *attrhash); 2293 t_max_err object_sticky(t_object *x, t_symbol *stickyname, t_symbol *s, t_object *o); 2294 t_max_err object_sticky_clear(t_object *x, t_symbol *stickyname, t_symbol *s); 2295 2296 // these methods are private -- instance methods are not actually fully implemented at this time 2297 t_max_err object_addmethod(t_object *x, method m, C74_CONST char *name, ...); 2298 t_max_err object_addmethod_object(t_object *x, t_object *mo); 2299 t_max_err object_deletemethod(t_object *x, t_symbol *methodsym); 2300 t_max_err object_chuckmethod(t_object *x, t_symbol *methodsym); 2301 2302 t_max_err attr_typedfun_set(void *parent, t_object *x, long ac, t_atom *av); 2303 2304 t_max_err object_attr_getnames(void *x, long *argc, t_symbol ***argv); 2305 2306 /** 2307 Allocate a single atom. 2308 If ac and av are both zero then memory is allocated. 2309 Otherwise it is presumed that memory is already allocated and nothing will happen. 2310 2311 @ingroup atom 2312 @param ac The address of a variable that will contain the number of atoms allocated (1). 2313 @param av The address of a pointer that will be set with the new allocated memory for the atom. 2314 @param alloc Address of a variable that will be set true is memory is allocated, otherwise false. 2315 @return A Max error code. 2316 */ 2317 t_max_err atom_alloc(long *ac, t_atom **av, char *alloc); 2318 2319 2320 /** 2321 Allocate an array of atoms. 2322 If ac and av are both zero then memory is allocated. 2323 Otherwise it is presumed that memory is already allocated and nothing will happen. 2324 2325 @ingroup atom 2326 @param minsize The minimum number of atoms that this array will need to contain. 2327 This determines the amount of memory allocated. 2328 @param ac The address of a variable that will contain the number of atoms allocated. 2329 @param av The address of a pointer that will be set with the new allocated memory for the atoms. 2330 @param alloc Address of a variable that will be set true is memory is allocated, otherwise false. 2331 @return A Max error code. 2332 */ 2333 t_max_err atom_alloc_array(long minsize, long *ac, t_atom **av, char *alloc); 2334 2335 2336 2337 // private? 2338 long class_is_box(t_class *c); 2339 t_dictionary *object_dictionary_fromnewargs(t_object *patcher, t_class *c, long argc, t_atom *argv, long flags, char *freedict); 2340 2341 2342 /** 2343 Determine if a class is a user interface object. 2344 2345 @ingroup class 2346 @param c The class pointer. 2347 @return True is the class defines a user interface object, otherwise false. 2348 */ 2349 long class_is_ui(t_class *c); 2350 2351 2352 // new subclassing implementation 2353 /** 2354 Define a subclass of an existing class. 2355 First call class_new on the subclass, then pass in to class_subclass. 2356 If constructor or destructor are NULL will use the superclass constructor. 2357 2358 @ingroup class 2359 @param superclass The superclass pointer. 2360 @param subclass The subclass pointer. 2361 @return A Max error code 2362 */ 2363 t_max_err class_subclass(t_class *superclass, t_class *subclass); 2364 2365 2366 /** 2367 Call super class constructor. 2368 Use this instead of object_alloc if you want to call the super class constructor, 2369 but allocating enough memory for subclass. 2370 2371 @ingroup class 2372 @param c The (sub)class pointer. 2373 @param ... Args to super class constructor. 2374 @return initialized object instance 2375 */ 2376 t_object *class_super_construct(t_class *c, ...); 2377 2378 #ifdef C74_X64 2379 #define class_super_construct(...) C74_VARFUN(class_super_construct_imp, __VA_ARGS__) 2380 #endif 2381 2382 t_object *class_super_construct_imp(void *c, void *p1, void *p2, void *p3, void *p4, void *p5, void *p6, void *p7, void *p8, void *p9); 2383 2384 /** 2385 Sends an untyped message to an object using superclass methods. 2386 Uses a thread specific stack to ensure traversal up the class hierarchy. 2387 2388 @ingroup obj 2389 2390 @param x The object that will receive the message 2391 @param s The message selector 2392 @param ... Any arguments to the message 2393 2394 @return If the receiver object can respond to the message, object_method() returns the result. Otherwise, the function will return 0. 2395 */ 2396 void *object_super_method(t_object *x, t_symbol *s, ...); 2397 2398 #ifdef C74_X64 2399 #define object_super_method(...) C74_VARFUN(object_super_method_imp, __VA_ARGS__) 2400 #endif 2401 2402 void *object_super_method_imp(void *x, void *s, void *p1, void *p2, void *p3, void *p4, void *p5, void *p6, void *p7, void *p8); 2403 2404 /** 2405 Sends an untyped message to an object, respects a thread specific class stack from object_super_method() calls 2406 2407 @ingroup obj 2408 2409 @param x The object that will receive the message 2410 @param s The message selector 2411 @param ... Any arguments to the message 2412 2413 @return If the receiver object can respond to the message, object_method() returns the result. Otherwise, the function will return 0. 2414 */ 2415 void *object_this_method(t_object *x, t_symbol *s, ...); 2416 2417 #ifdef C74_X64 2418 #define object_this_method(...) C74_VARFUN(object_this_method_imp, __VA_ARGS__) 2419 #endif 2420 2421 void *object_this_method_imp(void *x, void *s, void *p1, void *p2, void *p3, void *p4, void *p5, void *p6, void *p7, void *p8); 2422 2423 /** 2424 Mark an attribute as being touched by some code not from the attribute setter. 2425 This will notify clients that the attribute has changed. 2426 2427 @ingroup obj 2428 2429 @param x The object whose attribute has been changed 2430 @param attrname The attribute name 2431 2432 @return A Max error code 2433 */ 2434 t_max_err object_attr_touch(t_object *x, t_symbol *attrname); 2435 2436 /** 2437 Mark one or more attributes as being touched by some code not from the attribute setter. 2438 This will notify clients that the attributes have changed. Utility to call object_attr_touch() 2439 for several attributes 2440 2441 @ingroup obj 2442 2443 @param x The object whose attribute has been changed 2444 @param attrnames The attribute names as a space separated string 2445 2446 @return A Max error code 2447 */ 2448 t_max_err object_attr_touch_parse(t_object *x, char *attrnames); 2449 2450 2451 t_max_err object_attr_getvalueof_ext(void *x, t_symbol *s, long *argc, t_atom **argv); 2452 t_max_err object_attr_setvalueof_ext(void *x, t_symbol *s, long argc, t_atom *argv); 2453 long object_attr_getdirty(t_object *x, t_symbol *attrname); 2454 2455 #if C74_PRAGMA_STRUCT_PACKPUSH 2456 #pragma pack(pop) 2457 #elif C74_PRAGMA_STRUCT_PACK 2458 #pragma pack() 2459 #endif 2460 2461 END_USING_C_LINKAGE 2462 2463 #endif // _EXT_OBEX_H_