github.com/256dpi/max-go@v0.7.0/lib/max/ext_symobject.h (about) 1 #ifndef __EXT_SYMOBJECT_H__ 2 #define __EXT_SYMOBJECT_H__ 3 4 #include "ext_prefix.h" 5 #include "ext_mess.h" 6 7 #if C74_PRAGMA_STRUCT_PACKPUSH 8 #pragma pack(push, 2) 9 #elif C74_PRAGMA_STRUCT_PACK 10 #pragma pack(2) 11 #endif 12 13 14 /** The symobject data structure. 15 @ingroup symobject 16 */ 17 typedef struct _symobject{ 18 t_object obj; ///< Max object header. 19 t_symbol *sym; ///< The symbol contained by the object. 20 long flags; ///< Any user-flags you wish to set or get. 21 void *thing; ///< A generic pointer for attaching additional data to the symobject. 22 } t_symobject; 23 24 25 #if C74_PRAGMA_STRUCT_PACKPUSH 26 #pragma pack(pop) 27 #elif C74_PRAGMA_STRUCT_PACK 28 #pragma pack() 29 #endif 30 31 BEGIN_USING_C_LINKAGE 32 33 /** The symobject data structure. 34 35 @ingroup symobject 36 @param sym A symbol with which to initialize the new symobject. 37 @return Pointer to the new symobject instance. 38 */ 39 void *symobject_new(t_symbol *sym); 40 41 42 /** Utility for searching a linklist containing symobjects. 43 44 @ingroup symobject 45 @param a (opaque) 46 @param b (opaque) 47 @return Returns true if a match is found, otherwise returns false. 48 49 @remark The following example shows one common use of the this method. 50 @code 51 t_symobject *item = NULL; 52 long index; 53 t_symbol *textsym; 54 55 textsym = gensym("something to look for"); 56 57 // search for a symobject with the symbol 'something to look for' 58 index = linklist_findfirst(s_ll_history, (void **)&item, symobject_linklist_match, textsym); 59 if(index == -1){ 60 // symobject not found. 61 } 62 else{ 63 do something with the symobject, or with the index of the symbobject in the linklist 64 } 65 @endcode 66 67 */ 68 long symobject_linklist_match(void *a, void *b); 69 70 71 END_USING_C_LINKAGE 72 73 #endif // #ifndef __EXT_SYMOBJECT_H__