Max 5 API Reference
00001 /* ext_proto.h -- prototypes for MAX external methods */ 00002 /* copyright 1996 Opcode/IRCAM */ 00003 #ifndef _EXT_PROTO_H_ 00004 #define _EXT_PROTO_H_ 00005 00006 #include "ext_types.h" 00007 #include "ext_maxtypes.h" // contains box, patcher, wind, atombuf 00008 #include "ext_sysmem.h" 00009 #include "ext_sysfile.h" 00010 #include "ext_systime.h" 00011 #include "ext_expr.h" 00012 #include "ext_path.h" 00013 #include "ext_qtimage.h" 00014 #include "ext_wind.h" 00015 #ifdef WIN_VERSION 00016 #include "ext_proto_win.h" 00017 #endif 00018 00019 #ifdef __cplusplus 00020 extern "C" { 00021 #endif 00022 00023 00024 // object/class functions 00025 00026 /** Use the setup() function to initialize your class by informing Max of its size, 00027 the name of your functions that create and destroy instances, 00028 and the types of arguments passed to the instance creation function. 00029 00030 @ingroup class_old 00031 00032 @param ident A global variable in your code that points to the initialized class. 00033 @param makefun Your instance creation function. 00034 @param freefun Your instance free function (see Chapter 7). 00035 @param size The size of your objects data structure in bytes. 00036 Usually you use the C sizeof operator here. 00037 @param menufun No longer used. You should pass NULL for this parameter. 00038 @param type The first of a list of arguments passed to makefun when an object is created. 00039 @param ... Any additional arguments passed to makefun when an object is created. 00040 Together with the type parameter, this creates a standard Max type list 00041 as enumerated in #e_max_atomtypes. 00042 The final argument of the type list should be a 0. 00043 @see @ref chapter_anatomy 00044 */ 00045 void setup(t_messlist **ident, method makefun, method freefun, short size, method menufun, short type, ...); 00046 00047 00048 /** Use addmess() to bind a function to a message other than the standard ones 00049 covered by addbang(), addint(), etc. 00050 00051 @ingroup class_old 00052 @param f Function you want to be the method. 00053 @param s C string defining the message. 00054 @param type The first of one or more integers from #e_max_atomtypes specifying the arguments to the message. 00055 @param ... Any additional types from #e_max_atomtypes for additonal arguments. 00056 @see @ref chapter_anatomy 00057 */ 00058 void addmess(method f, char *s, short type, ...); 00059 00060 00061 /** 00062 Used to bind a function to the common triggering message bang. 00063 00064 @ingroup class_old 00065 @param f Function to be the bang method. 00066 */ 00067 void addbang(method f); 00068 00069 00070 /** 00071 Use addint() to bind a function to the int message received in the leftmost inlet. 00072 @ingroup class_old 00073 @param f Function to be the int method. 00074 */ 00075 void addint(method f); 00076 00077 00078 /** 00079 Use addfloat() to bind a function to the float message received in the leftmost inlet. 00080 @ingroup class_old 00081 @param f Function to be the int method. 00082 */ 00083 void addfloat(method f); 00084 00085 00086 /** 00087 Use addinx() to bind a function to a int message that will be received in 00088 an inlet other than the leftmost one. 00089 00090 @ingroup class_old 00091 @param f Function to be the int method. 00092 @param n Number of the inlet connected to this method. 00093 1 is the first inlet to the right of the left inlet. 00094 00095 @remark This correspondence between inlet locations and messages is not 00096 automatic, but it is strongly suggested that you follow existing practice. 00097 You must set the correspondence up when creating an object of your 00098 class with proper use of intin and floatin in your instance creation 00099 function @ref chapter_anatomy_object_new. 00100 */ 00101 void addinx(method f, short n); 00102 00103 00104 /** 00105 Use addftx() to bind a function to a float message that will be received in 00106 an inlet other than the leftmost one. 00107 00108 @ingroup class_old 00109 @param f Function to be the float method. 00110 @param n Number of the inlet connected to this method. 00111 1 is the first inlet to the right of the left inlet. 00112 00113 @remark This correspondence between inlet locations and messages is not 00114 automatic, but it is strongly suggested that you follow existing practice. 00115 You must set the correspondence up when creating an object of your 00116 class with proper use of intin and floatin in your instance creation 00117 function @ref chapter_anatomy_object_new. 00118 */ 00119 void addftx(method f, short n); 00120 00121 00122 /** 00123 Use newobject to allocate the space for an instance of your class and 00124 initialize its object header. 00125 00126 @ingroup class_old 00127 @param maxclass The global class variable initialized in your main routine by the setup function. 00128 @return A pointer to the new instance. 00129 00130 @remark You call newobject() when creating an instance of your class in your 00131 creation function. newobject allocates the proper amount of memory 00132 for an object of your class and installs a pointer to your class in the 00133 object, so that it can respond with your class’s methods if it receives a 00134 message. 00135 */ 00136 void *newobject(void *maxclass); 00137 00138 00139 /** 00140 Release the memory used by a Max object. 00141 freeobject() calls an object’s free function, if any, then disposes the 00142 memory used by the object itself. freeobject() should be used on any 00143 instance of a standard Max object data structure, with the exception of 00144 Qelems and Atombufs. Clocks, Binbufs, Proxies, Exprs, etc. should be freed with freeobject(). 00145 00146 @ingroup class_old 00147 @param op The object instance pointer to free. 00148 00149 @remark This function can be replaced by the use of object_free(). 00150 Unlike freeobject(), object_free() checkes to make sure the pointer is 00151 not NULL before trying to free it. 00152 00153 @see newobject() 00154 @see object_free() 00155 */ 00156 void freeobject(t_object *op); 00157 00158 00159 /** Make a new instance of an existing Max class. 00160 @ingroup class_old 00161 00162 @param s className Symbol specifying the name of the class of the instance to be created. 00163 @param argc Count of arguments in argv. 00164 @param argv Array of t_atoms; arguments to the class’s instance creation function. 00165 00166 @return A pointer to the created object, or 0 if the class 00167 didn’t exist or there was another type of error in creating the instance. 00168 00169 @remark This function creates a new instance of the specified class. Using 00170 newinstance is equivalent to typing something in a New Object box 00171 when using Max. The difference is that no object box is created in any 00172 Patcher window, and you can send messages to the object directly 00173 without connecting any patch cords. The messages can either be type- 00174 checked (using typedmess) or non-type-checked (using the members 00175 of the getfn family). 00176 00177 This function is useful for taking advantage of other already-defined 00178 objects that you would like to use “privately” in your object, such as 00179 tables. See the source code for the coll object for an example of using a 00180 privately defined class. 00181 */ 00182 void *newinstance(t_symbol *s, short argc, t_atom *argv); 00183 00184 00185 /** 00186 @ingroup class_old 00187 */ 00188 void finder_addclass(char *category, char *classString); 00189 00190 00191 /** 00192 Use the alias function to allow users to refer to your object by a 00193 name other than that of your shared library. 00194 00195 @ingroup class_old 00196 @param name An alternative name for the user to use to make an object of your class. 00197 */ 00198 void alias(char *name); 00199 00200 00201 /** 00202 @ingroup class_old 00203 */ 00204 void class_noinlet(t_messlist *m); 00205 00206 00207 /** 00208 Use class_setname() to associate you object’s name with it’s filename 00209 on disk. 00210 00211 @ingroup class_old 00212 @param obname A character string with the name of your object class as it appears in Max. 00213 @param filename A character string with the name of your external’s file as it appears on disk. 00214 */ 00215 void class_setname(char *obname, char *filename); 00216 00217 00218 short force_install(char *classname); 00219 void loader_setpath(long type, short path); 00220 00221 00222 00223 // memory functions 00224 00225 /** 00226 Allocate small amounts of non-relocatable memory. 00227 As of Max 5 it is unified with sysmem_newptr(), which is the preferred method for allocating memory. 00228 @ingroup memory 00229 @param size The size to allocate in bytes (up to 32767 bytes). 00230 @return A pointer to the allocated memory. 00231 */ 00232 char *getbytes(short size); 00233 00234 00235 /** 00236 Free memory allocated with getbytes(). 00237 As of Max 5 it is unified with sysmem_newptr(), which is the preferred method for allocating memory. 00238 @ingroup memory 00239 @param b A pointer to the block of memory previously allocated that you want to free. 00240 @param size The size the block specified (as parameter b) in bytes. 00241 */ 00242 void freebytes(void *b, short size); 00243 00244 00245 /** 00246 Use getbytes16() to allocate small amounts of non-relocatable 00247 memory that is aligned on a 16-byte boundary for use with vector optimization. 00248 @ingroup memory 00249 @param size The size to allocate in bytes (up to 32767 bytes). 00250 @return A pointer to the allocated memory. 00251 00252 @remark getbytes16() is identical to getbytes except that it returns memory 00253 that is aligned to a 16-byte boundary. This allows you to allocate 00254 storage for vector-optimized memory at interrupt level. Note that any 00255 memory allocated with getbytes16() must be freed with 00256 freebytes16(), not freebytes(). 00257 */ 00258 char *getbytes16(short size); 00259 00260 00261 /** 00262 Free memory allocated with getbytes16(). 00263 As of Max 5 it is unified with sysmem_newptr(), which is the preferred method for allocating memory. 00264 @ingroup memory 00265 @param mem A pointer to the block of memory previously allocated that you want to free. 00266 @param size The size the block specified (as parameter b) in bytes. 00267 00268 @remark Note that freebytes16() will cause memory corruption if you pass it 00269 memory that was allocated with getbytes(). Use it only with memory 00270 allocated with getbytes16(). 00271 */ 00272 void freebytes16(char *mem, short size); 00273 00274 00275 /** 00276 Allocate relocatable memory. 00277 00278 @ingroup memory 00279 @param size The size to allocate in bytes. 00280 @return The allocated handle. 00281 @see sysmem_newhandle() 00282 */ 00283 char **newhandle(long size); 00284 00285 00286 /** 00287 Change the size of a handle. 00288 00289 @ingroup memory 00290 @param h The handle to resize. 00291 @param size The new size to allocate in bytes. 00292 @return Ignored. 00293 @see sysmem_resizehandle() 00294 */ 00295 short growhandle(void *h, long size); 00296 00297 00298 /** 00299 Free the memory used by a handle you no longer need. 00300 00301 @ingroup memory 00302 @param h The handle to dispose. 00303 @see sysmem_freehandle() 00304 */ 00305 void disposhandle(char **h); 00306 00307 00308 00309 #ifdef MM_UNIFIED // sysmem and getbytes are unified 00310 #define getbytes(size) ((char *)sysmem_newptr((long)(size))) 00311 #define freebytes(p,size) sysmem_freeptr((char *)(p)) 00312 #endif 00313 00314 // symbol/string/text/error functions 00315 00316 /** 00317 Given a C-string, fetch the matching #t_symbol pointer from the symbol table, 00318 generating the symbol if neccessary. 00319 00320 @ingroup symbol 00321 @param s A C-string to be looked up in Max’s symbol table. 00322 @return A pointer to the #t_symbol in the symbol table. 00323 */ 00324 t_symbol *gensym(char *s); 00325 00326 00327 /** 00328 Print text to the Max window. 00329 Max 5 introduced object_post(), which provides several enhancements to post() 00330 where a valid #t_object pointer is available. 00331 00332 post() is a printf() for the Max window. It even works from non-main threads, 00333 queuing up multiple lines of text to be printed when the main thread processing resumes. 00334 post() can be quite useful in debugging your external object. 00335 00336 @ingroup console 00337 @param fmt A C-string containing text and printf-like codes 00338 specifying the sizes and formatting of the additional arguments. 00339 @param ... Arguments of any type that correspond to the format codes in fmtString. 00340 00341 @remark Note that post only passes 16 bytes of arguments to sprintf, so if 00342 you want additional formatted items on a single line, use postatom(). 00343 00344 Example: 00345 @code 00346 short whatIsIt; 00347 00348 whatIsIt = 999; 00349 post ("the variable is %ld",(long)whatIsIt); 00350 @endcode 00351 00352 @remark The Max Window output when this code is executed. 00353 @code 00354 the variable is 999 00355 @endcode 00356 00357 @see object_post() 00358 @see error() 00359 @see cpost() 00360 */ 00361 void post(char *fmt, ...); 00362 00363 00364 /** 00365 Print text to the system console. 00366 On the Mac this post will be visible by launching Console.app in the /Applications/Utilities folder. 00367 On Windows this post will be visible by launching the dbgView.exe program, which is a free download 00368 as a part of Microsoft's SysInternals. 00369 00370 @ingroup console 00371 @param fmt A C-string containing text and printf-like codes 00372 specifying the sizes and formatting of the additional arguments. 00373 @param ... Arguments of any type that correspond to the format codes in fmtString. 00374 00375 @remark Particularly on MacOS 10.5, posting to Console.app can be a computationally expensive operation. 00376 Use with care. 00377 00378 @see post() 00379 @see object_post() 00380 */ 00381 void cpost(char *fmt, ...); 00382 00383 00384 /** 00385 Print an error to the Max window. 00386 Max 5 introduced object_error(), which provides several enhancements to error() 00387 where a valid #t_object pointer is available. 00388 00389 error() is very similar to post(), thought it offers two additional features: 00390 - the post to the Max window is highlighted (with a red background). 00391 - the post can be trapped with the error object in a patcher. 00392 00393 @ingroup console 00394 @param fmt A C-string containing text and printf-like codes 00395 specifying the sizes and formatting of the additional arguments. 00396 @param ... Arguments of any type that correspond to the format codes in fmtString. 00397 00398 @see object_post() 00399 @see post() 00400 @see cpost() 00401 */ 00402 void error(char *fmt, ...); 00403 00404 /** 00405 Put up an error or advisory alert box on the screen. 00406 00407 Don't use this function. Instead use error(), object_error(), or object_error_obtrusive(). 00408 00409 This function performs an sprintf() on fmtstring and items, then 00410 puts up an alert box. ouchstring() will queue the message to a lower 00411 priority level if it’s called in an interrupt and there is no alert box 00412 request already pending. 00413 00414 @ingroup console 00415 @param s A C-string containing text and printf-like codes 00416 specifying the sizes and formatting of the additional arguments. 00417 @param ... Arguments of any type that correspond to the format codes in fmtString. 00418 00419 @see error() 00420 @see object_error() 00421 @see object_error_obtrusive() 00422 */ 00423 void ouchstring(char *s, ...); 00424 short advise(char *s, ...); 00425 short advise_explain(char *note, char *explanation, char *b1, char *b2, char *b3); 00426 void t_cpytext(void); 00427 void drawstr(char *s); 00428 00429 /** 00430 Print multiple items in the same line of text in the Max window. 00431 This function prints a single #t_atom on a line in the Max window 00432 without a carriage return afterwards, as post() does. Each #t_atom printed 00433 is followed by a space character. 00434 00435 @ingroup console 00436 @param ap The address of a #t_atom to print. 00437 00438 @see object_post() 00439 @see post() 00440 @see cpost() 00441 00442 */ 00443 void postatom(t_atom *ap); 00444 00445 // tap -- this one doesn't do anything any more, right? at least on windows it doesn't.... 00446 //void assist_string(short id,long msg,long arg, short firstin, short firstout,char *dst,...); 00447 00448 void stdinletinfo(t_object *s, void *b, long a, char *t); 00449 00450 void debug_printf(char *,...); 00451 00452 00453 /** Receive messages from the error handler. 00454 @ingroup misc 00455 @param x The object to be subscribed to the error handler. 00456 00457 @remark error_subscribe() enables your object to receive a message (error), 00458 followed by the list of atoms in the error message posted to the Max 00459 window. 00460 00461 Prior to calling error_subscribe(), you should bind the error 00462 message to an internal error handling routine: 00463 @code 00464 addmess((method)myobject_error, "error", A_GIMME, 0); 00465 @endcode 00466 Your error handling routine should be declared as follows: 00467 @code 00468 void myobject_error(t_myobject *x, t_symbol *s, short argc, t_atom *argv); 00469 @endcode 00470 */ 00471 void error_subscribe(t_object *x); 00472 00473 00474 /** Remove an object as an error message recipient. 00475 @ingroup misc 00476 @param x The object to unsubscribe. 00477 */ 00478 void error_unsubscribe(t_object *x); 00479 00480 00481 void xsetpost(); 00482 void post_getpos(short *row, short *col); 00483 void poststring(char *s); 00484 // not sure where to put these... 00485 00486 enum { 00487 POSTROW_POST = 0, 00488 POSTROW_ERROR = 1, 00489 POSTROW_WARNING = 2, 00490 POSTROW_BUG = 3 00491 }; 00492 00493 enum { 00494 JMAXWINDOW_ADVANCE = 1, 00495 JMAXWINDOW_APPEND = 2, 00496 JMAXWINDOW_WRITE = 4, 00497 JMAXWINDOW_UNIQUE = 8 00498 }; 00499 00500 00501 /** 00502 Print text to the Max window, linked to an instance of your object. 00503 00504 Max window rows which are generated using object_post() or object_error() can be 00505 double-clicked by the user to have Max assist with locating the object in a patcher. 00506 Rows created with object_post() and object_error() will also automatically provide 00507 the name of the object's class in the correct column in the Max window. 00508 00509 @ingroup console 00510 @param x A pointer to your object. 00511 @param s A C-string containing text and printf-like codes 00512 specifying the sizes and formatting of the additional arguments. 00513 @param ... Arguments of any type that correspond to the format codes in fmtString. 00514 00515 @remark Example: 00516 @code 00517 void myMethod(myObject *x, long someArgument) 00518 { 00519 object_post((t_object*)x, "This is my argument: %ld", someArgument); 00520 } 00521 @endcode 00522 00523 @see object_error() 00524 */ 00525 void object_post(t_object *x, char *s, ...); 00526 00527 00528 /** 00529 Print text to the Max window, linked to an instance of your object, 00530 and flagged as an error (highlighted with a red background). 00531 00532 Max window rows which are generated using object_post() or object_error() can be 00533 double-clicked by the user to have Max assist with locating the object in a patcher. 00534 Rows created with object_post() and object_error() will also automatically provide 00535 the name of the object's class in the correct column in the Max window. 00536 00537 @ingroup console 00538 @param x A pointer to your object. 00539 @param s A C-string containing text and printf-like codes 00540 specifying the sizes and formatting of the additional arguments. 00541 @param ... Arguments of any type that correspond to the format codes in fmtString. 00542 00543 @see object_post() 00544 @see object_warn() 00545 */ 00546 void object_error(t_object *x, char *s, ...); 00547 00548 00549 /** 00550 Print text to the Max window, linked to an instance of your object, 00551 and flagged as a warning (highlighted with a yellow background). 00552 00553 Max window rows which are generated using object_post(), object_error(), or object_warn can be 00554 double-clicked by the user to have Max assist with locating the object in a patcher. 00555 Rows created with object_post(), object_error(), or object_warn() will also automatically provide 00556 the name of the object's class in the correct column in the Max window. 00557 00558 @ingroup console 00559 @param x A pointer to your object. 00560 @param s A C-string containing text and printf-like codes 00561 specifying the sizes and formatting of the additional arguments. 00562 @param ... Arguments of any type that correspond to the format codes in fmtString. 00563 00564 @see object_post() 00565 @see object_error() 00566 */ 00567 void object_warn(t_object *x, char *s, ...); 00568 00569 // ? 00570 void object_bug(t_object *x, char *s, ...); 00571 00572 // private? 00573 void object_poststring(t_object *ob, long kind, long flags, char *text); 00574 00575 00576 /** 00577 Print text to the Max window, linked to an instance of your object, 00578 and flagged as an error (highlighted with a red background), 00579 and grab the user's attention by displaying a banner in the patcher window. 00580 00581 This function should be used exceedingly sparingly, with preference given to 00582 object_error() when a problem occurs. 00583 00584 @ingroup console 00585 @param x A pointer to your object. 00586 @param s A C-string containing text and printf-like codes 00587 specifying the sizes and formatting of the additional arguments. 00588 @param ... Arguments of any type that correspond to the format codes in fmtString. 00589 00590 @see object_post() 00591 @see object_error() 00592 */ 00593 void object_error_obtrusive(t_object *x, char *s, ...); 00594 00595 00596 long jdialog_showtext(char *prompt, char *deftext, long flags, char **text); 00597 00598 00599 #ifndef WIN_VERSION 00600 int sprintf(char *, const char *, ...); 00601 int sscanf(const char *, const char *, ...); 00602 #endif //WIN_VERSION 00603 00604 00605 // inlet/outlet functions 00606 00607 /** 00608 Use inlet_new() to create an inlet that can receive a specific message or any message. 00609 00610 @ingroup inout 00611 @param x Your object. 00612 @param s Character string of the message, or NULL to receive any message. 00613 @return A pointer to the new inlet. 00614 00615 @remark inlet_new() ceates a general purpose inlet. 00616 You can use it in circumstances where you would like special messages to be received in 00617 inlets other than the leftmost one. 00618 To create an inlet that receives a particular message, pass the message’s 00619 character string. For example, to create an inlet that receives only bang 00620 messages, do the following 00621 @code 00622 inlet_new (myObject,"bang"); 00623 @endcode 00624 00625 @remark To create an inlet that can receive any message, pass NULL for msg 00626 @code 00627 inlet_new (myObject, NULL); 00628 @endcode 00629 00630 @remark Proxies are an alternative method for general-purpose inlets that have 00631 a number of advantages. If you create multiple inlets as shown above, 00632 there would be no way to figure out which inlet received a message. See 00633 the discussion in @ref chapter_inout_proxies. 00634 */ 00635 void *inlet_new(void *x, char *s); 00636 00637 /** 00638 Use intin() to create an inlet typed to receive only integers. 00639 00640 @ingroup inout 00641 @param x Your object. 00642 @param n Location of the inlet from 1 to 9. 1 is immediately to the right of the leftmost inlet. 00643 @return A pointer to the new inlet. 00644 00645 @remark intin creates integer inlets. 00646 It takes a pointer to your newly created object and an integer n, from 1 to 9. 00647 The number specifies the message 00648 type you’ll get, so you can distinguish one inlet from another. For 00649 example, an integer sent in inlet 1 will be of message type in1 and a 00650 floating point number sent in inlet 4 will be of type ft4. You use 00651 addinx() and addftx() to add methods to respond to these messages. 00652 00653 The order you create additional inlets is important. If you want the 00654 rightmost inlet to be the have the highest number in- or ft- message 00655 (which is usually the case), you should create the highest number 00656 message inlet first. 00657 */ 00658 void *intin(void *x, short n); 00659 00660 00661 /** 00662 Use floatin() to create an inlet typed to receive only floats. 00663 00664 @ingroup inout 00665 @param x Your object. 00666 @param n Location of the inlet from 1 to 9. 1 is immediately to the right of the leftmost inlet. 00667 @return A pointer to the new inlet. 00668 */ 00669 void *floatin(void *x, short n); 00670 00671 00672 /** 00673 Use outlet_new() to create an outlet that can send a specific non-standard message, or any message. 00674 00675 @ingroup inout 00676 @param x Your object. 00677 @param s A C-string specifying the message that will be sent out this outlet, 00678 or NULL to indicate the outlet will be used to send various messages. 00679 The advantage of this kind of outlet’s flexibility is balanced by the fact that 00680 Max must perform a message-lookup in real-time for every message sent through it, 00681 rather than when a patch is being constructed, as is true for other types of outlets. 00682 Patchers execute faster when outlets are typed, since the message 00683 lookup can be done before the program executes. 00684 @return A pointer to the new outlet. 00685 */ 00686 void *outlet_new(void *x, char *s); 00687 00688 00689 /** 00690 Use bangout() to create an outlet that will always send the bang message. 00691 00692 @ingroup inout 00693 @param x Your object. 00694 @return A pointer to the new outlet. 00695 00696 @remark You can send a bang message out a general purpose outlet, but creating 00697 an outlet using bangout() allows Max to type-check the connection a 00698 user might make and refuse to connect the outlet to any object that 00699 cannot receive a bang message. bangout() returns the created outlet. 00700 */ 00701 void *bangout(void *x); 00702 00703 00704 /** 00705 Use intout() to create an outlet that will always send the int message. 00706 00707 @ingroup inout 00708 @param x Your object. 00709 @return A pointer to the new outlet. 00710 00711 @remark You can send a bang message out a general purpose outlet, but creating 00712 an outlet using bangout() allows Max to type-check the connection a 00713 user might make and refuse to connect the outlet to any object that 00714 cannot receive a bang message. bangout() returns the created outlet. 00715 */ 00716 void *intout(void *x); 00717 00718 00719 /** 00720 Use floatout() to create an outlet that will always send the float message. 00721 00722 @ingroup inout 00723 @param x Your object. 00724 @return A pointer to the new outlet. 00725 */ 00726 void *floatout(void *x); 00727 00728 00729 /** 00730 Use listout() to create an outlet that will always send the list message. 00731 @ingroup inout 00732 @param x Your object. 00733 @return A pointer to the new outlet. 00734 */ 00735 void *listout(void *x); 00736 00737 00738 /** 00739 Use outlet_bang() to send a bang message out an outlet. 00740 00741 @ingroup inout 00742 @param o Outlet that will send the message. 00743 @return Returns 0 if a stack overflow occurred, otherwise returns 1. 00744 */ 00745 void *outlet_bang(void *o); 00746 00747 00748 /** 00749 Use outlet_int() to send a float message out an outlet. 00750 00751 @ingroup inout 00752 @param o Outlet that will send the message. 00753 @param n Integer value to send. 00754 @return Returns 0 if a stack overflow occurred, otherwise returns 1. 00755 */ 00756 void *outlet_int(void *o, long n); 00757 00758 00759 /** 00760 Use outlet_float() to send an int message out an outlet. 00761 00762 @ingroup inout 00763 @param o Outlet that will send the message. 00764 @param f Float value to send. 00765 @return Returns 0 if a stack overflow occurred, otherwise returns 1. 00766 */ 00767 void *outlet_float(void *o, double f); 00768 00769 00770 /** 00771 Use outlet_list() to send a list message out an outlet. 00772 00773 @ingroup inout 00774 @param o Outlet that will send the message. 00775 @param s Should be NULL, but can be the _sym_list. 00776 @param ac Number of elements in the list in argv. 00777 @param av Atoms constituting the list. 00778 @return Returns 0 if a stack overflow occurred, otherwise returns 1. 00779 00780 @remark outlet_list() sends the list specified by argv and argc out the 00781 specified outlet. The outlet must have been created with listout or 00782 outlet_new in your object creation function (see above). You create 00783 the list as an array of Atoms, but the first item in the list must be an 00784 integer or float. 00785 00786 Here’s an example of sending a list of three numbers. 00787 @code 00788 t_atom myList[3]; 00789 long theNumbers[3]; 00790 short i; 00791 00792 theNumbers[0] = 23; 00793 theNumbers[1] = 12; 00794 theNumbers[2] = 5; 00795 for (i=0; i < 3; i++) { 00796 atom_setlong(myList+i,theNumbers[i]); 00797 } 00798 outlet_list(myOutlet,0L,3,&myList); 00799 @endcode 00800 00801 @remark It’s not a good idea to pass large lists to outlet_list that are 00802 comprised of local (automatic) variables. If the list is small, as in the 00803 above example, there’s no problem. If your object will regularly send 00804 lists, it might make sense to keep an array of t_atoms inside your 00805 object’s data structure. 00806 */ 00807 void *outlet_list(void *o, t_symbol *s, short ac, t_atom *av); 00808 00809 00810 /** 00811 Use outlet_anything() to send any message out an outlet. 00812 00813 @ingroup inout 00814 @param o Outlet that will send the message. 00815 @param s The message selector #t_symbol*. 00816 @param ac Number of elements in the list in argv. 00817 @param av Atoms constituting the list. 00818 @return Returns 0 if a stack overflow occurred, otherwise returns 1. 00819 00820 @remark This function lets you send an arbitrary message out an outlet. 00821 Here are a couple of examples of its use. 00822 00823 First, here’s a hard way to send the bang message (see outlet_bang() for an easier way): 00824 @code 00825 outlet_anything(myOutlet, gensym("bang"), 0, NIL); 00826 @endcode 00827 00828 @remark And here’s an even harder way to send a single integer (instead of using outlet_int()). 00829 @code 00830 t_atom myNumber; 00831 00832 atom_setlong(&myNumber, 432); 00833 outlet_anything(myOutlet, gensym("int"), 1, &myNumber); 00834 @endcode 00835 00836 @remark Notice that outlet_anything() expects the message argument as a 00837 #t_symbol*, so you must use gensym() on a character string. 00838 00839 If you’ll be sending the same message a lot, you might call gensym() on the message string at 00840 initialization time and store the result in a global variable to save the 00841 (significant) overhead of calling gensym() every time you want to send a 00842 message. 00843 00844 Also, do not send lists using outlet_anything() with list as 00845 the selector argument. Use the outlet_list() function instead. 00846 */ 00847 void *outlet_anything(void *o, t_symbol *s, short ac, t_atom *av); 00848 00849 00850 void *inlet4(void *x, void *w, char *s, char *s1); 00851 00852 00853 void inlet_to(void *x, void *w); 00854 00855 00856 short outlet_add(void *x, void *ip); 00857 00858 00859 void outlet_rm(void *x, void *ip); 00860 00861 00862 void outlet_atoms(void *out, short argc, t_atom *argv); 00863 00864 00865 00866 00867 // clock functions 00868 00869 /** 00870 Create a new Clock object. 00871 Normally, clock_new() is called in your instance creation 00872 function—and it cannot be called from a thread other than the main thread. 00873 To get rid of a clock object you created, use freeobject(). 00874 00875 @ingroup clocks 00876 @param obj Argument that will be passed to clock function fn when it is called. 00877 This will almost always be a pointer to your object. 00878 @param fn Function to be called when the clock goes off, 00879 declared to take a single argument as shown in @ref clocks_using_clocks. 00880 @return A pointer to a newly created Clock object. 00881 */ 00882 void *clock_new(void *obj, method fn); 00883 00884 00885 void clock_set(void *obj,long when); 00886 00887 00888 /** 00889 Schedule the execution of a Clock. 00890 clock_delay() sets a clock to go off at a certain number of 00891 milliseconds from the current logical time. 00892 00893 @ingroup clocks 00894 @param x Clock to schedule. 00895 @param n Delay, in milliseconds, before the Clock will execute. 00896 @see clock_fdelay() 00897 */ 00898 void clock_delay(void *x, long n); 00899 00900 00901 /** 00902 Cancel the scheduled execution of a Clock. 00903 clock_unset() will do nothing (and not complain) if the Clock passed 00904 to it has not been set. 00905 00906 @ingroup clocks 00907 @param x Clock to cancel. 00908 */ 00909 void clock_unset(void *x); 00910 void clock_xdelay(void *x, long n); 00911 void clock_xset(void *x, long n); 00912 void clock_xunset(void *x); 00913 short clock_getextfmt(void); 00914 00915 00916 /** 00917 Schedule the execution of a Clock using a floating-point argument. 00918 clock_delay() sets a clock to go off at a certain number of 00919 milliseconds from the current logical time. 00920 00921 @ingroup clocks 00922 @param c Clock to schedule. 00923 @param time Delay, in milliseconds, before the Clock will execute. 00924 @see clock_delay() 00925 */ 00926 void clock_fdelay(void *c, double time); 00927 void clock_fset(void *x, double when); 00928 void clock_fset2(void *x, double when, double offset); 00929 void clock_fdelay(void *x, double f); 00930 void clock_fdelay2(void *x, double delay, double offset); 00931 00932 00933 /** 00934 Find out the current logical time of the scheduler in milliseconds 00935 as a floating-point number. 00936 00937 @ingroup clocks 00938 @param time Returns the current time. 00939 @see gettime() 00940 @see setclock_getftime() 00941 @see setclock_gettime() 00942 */ 00943 void clock_getftime(double *time); 00944 00945 00946 /** Schedule a Clock on a scheduler. 00947 Schedules the Clock c to execute at time units after the current 00948 time. If scheduler x is 0 or does not point to a setclock object, the 00949 internal millisecond scheduler is used. Otherwise c is scheduled on 00950 the setclock object’s list of Clocks. The Clock should be created with 00951 clock_new(), the same as for a Clock passed to clock_delay(). 00952 00953 @ingroup clocks 00954 @param x A setclock object to be used for scheduling this clock. 00955 @param c Clock object containing the function to be executed. 00956 @param time Time delay (in the units of the Setclock) from the 00957 current time when the Clock will be executed. 00958 @see @ref setclock 00959 @see setclock_fdelay() 00960 */ 00961 void setclock_delay(t_object *x, void *c, long time); 00962 00963 00964 /** Remove a Clock from a scheduler. 00965 This function unschedules the Clock c in the list of Clocks in the 00966 setclock object x, or the internal millisecond scheduler if scheduler is 0. 00967 00968 @ingroup clocks 00969 @param x The setclock object that was used to schedule this clock. 00970 If 0, the clock is unscheduled from the internal millisecond scheduler. 00971 @param c Clock object to be removed from the scheduler. 00972 @see @ref setclock 00973 */ 00974 void setclock_unset(t_object *x, void *c); 00975 00976 00977 /** Find out the current time value of a setclock object. 00978 @ingroup clocks 00979 @param x A setclock object. 00980 @return Returns the current time value of the setclock object scheduler. 00981 If scheduler is 0, setclock_gettime is equivalent to the function 00982 gettime that returns the current value of the internal millisecond clock. 00983 @see @ref setclock 00984 @see setclock_getftime() 00985 */ 00986 long setclock_gettime(t_object *x); 00987 00988 00989 /** Schedule a Clock on a scheduler, using a floating-point time argument. 00990 @ingroup clocks 00991 @param s A setclock object to be used for scheduling this clock. 00992 @param c Clock object containing the function to be executed. 00993 @param time Time delay (in the units of the Setclock) from the 00994 current time when the Clock will be executed. 00995 @see @ref setclock 00996 @see setclock_delay() 00997 */ 00998 void setclock_fdelay(t_object *s, void *c, double time); 00999 01000 01001 /** Find out the current time value of a setclock object in floating-point milliseconds. 01002 @ingroup clocks 01003 @param s A setclock object. 01004 @param time The current time in milliseconds. 01005 @see @ref setclock 01006 @see setclock_gettime() 01007 */ 01008 void setclock_getftime(t_object *s, double *time); 01009 01010 01011 01012 // real-time 01013 01014 /** 01015 While most Max/MSP timing references "logical" time derived from Max's millisecond scheduler, 01016 time values produced by the systimer_gettime() are referenced from the CPU clock and can be used 01017 to time real world events with microsecond precision. 01018 01019 The standard 'cpuclock' external in Max is a simple wrapper around this function. 01020 01021 @ingroup clocks 01022 @return Returns the current real-world time. 01023 */ 01024 double systimer_gettime(void); 01025 01026 01027 // scheduler functions 01028 01029 /** 01030 Find out the current logical time of the scheduler in milliseconds. 01031 01032 @ingroup clocks 01033 @return Returns the current time. 01034 @see clock_getftime() 01035 */ 01036 long gettime(void); 01037 long getschedtime(void); 01038 long getexttime(void); 01039 void sched_suspend(void); 01040 void sched_resume(void); 01041 01042 01043 /** 01044 Cause a function to be executed at the timer level at some time in the future. 01045 01046 @ingroup threading 01047 @param ob First argument passed to the function fun when it executes. 01048 @param fun Function to be called, see below for how it should be declared. 01049 @param when The logical time that the function fun will be executed. 01050 @param sym Second argument passed to the function fun when it executes. 01051 @param argc Count of arguments in argv. argc is also the third argument passed to the function fun when it executes. 01052 @param argv Array containing a variable number of #t_atom function arguments. 01053 If this argument is non-zero, defer allocates memory to make a copy of the arguments 01054 (according to the size passed in argc) 01055 and passes the copied array to the function fun when it executes as the fourth argument. 01056 01057 @remark schedule() calls a function at some time in the future. Unlike defer(), 01058 the function is called in the scheduling loop when logical time is equal 01059 to the specified value when. This means that the function could be 01060 called at interrupt level, so it should follow the usual restrictions on 01061 interrupt-level conduct. The function fun passed to schedule should 01062 be declared as follows: 01063 01064 @code 01065 void myobject_do (myObject *client, t_symbol *s, short argc, t_atom *argv); 01066 @endcode 01067 01068 @remark One use of schedule() is as an alternative to using the lockout flag. 01069 01070 @see defer() 01071 */ 01072 void schedule(void *ob, method fun, long when, t_symbol *sym, short argc, Atom *argv); 01073 void schedulef(void *ob, method fun, double when, t_symbol *sym, short argc, Atom *argv); 01074 01075 01076 01077 01078 /** Create a new local scheduler. 01079 @ingroup clocks 01080 @return A pointer to the newly created scheduler. 01081 @see @ref creating_schedulers 01082 */ 01083 void *scheduler_new(void); 01084 01085 01086 /** Make a scheduler current, so that future related calls (such as 01087 clock_delay()) will affect the appropriate scheduler. 01088 01089 @ingroup clocks 01090 @param x The scheduler to make current. 01091 @return This routine returns a pointer to the previously current scheduler, 01092 wsaved and restored when local scheduling is complete. 01093 @see @ref creating_schedulers 01094 */ 01095 void *scheduler_set(void *x); 01096 01097 /** Get the currently set scheduler. 01098 01099 @ingroup clocks 01100 @return This routine returns a pointer to the current scheduler, 01101 @see @ref creating_schedulers 01102 */ 01103 void *scheduler_get(); 01104 01105 /** Get the scheduler associated with a given object, if any. 01106 01107 @ingroup clocks 01108 @param o The object who's scheduler is to be returned. 01109 @return This routine returns a pointer to the scheduler or the passed in object, 01110 @see @ref creating_schedulers 01111 */ 01112 void *scheduler_fromobject(t_object *o); 01113 01114 /** Run scheduler events to a selected time. 01115 @ingroup clocks 01116 @param x The scheduler to advance. 01117 @param until The ending time for this run (in milliseconds). 01118 @see @ref creating_schedulers 01119 */ 01120 void scheduler_run(void *x, double until); 01121 01122 01123 /** Set the current time of the scheduler. 01124 @ingroup clocks 01125 @param x The scheduler to set. 01126 @param time The new current time for the selected scheduler (in milliseconds). 01127 @see @ref creating_schedulers 01128 */ 01129 void scheduler_settime(void *x, double time); 01130 01131 01132 /** Retrieve the current time of the selected scheduler. 01133 @ingroup clocks 01134 @param x The scheduler to query. 01135 @param time The current time of the selected scheduler. 01136 @see @ref creating_schedulers 01137 */ 01138 void scheduler_gettime(void *x, double *time); 01139 01140 01141 01142 01143 /** 01144 Cause a function to be executed at the timer level at some time in the future specified by a delay offset. 01145 01146 @ingroup threading 01147 @param ob First argument passed to the function fun when it executes. 01148 @param fun Function to be called, see below for how it should be declared. 01149 @param delay The delay from the current time before the function will be executed. 01150 @param sym Second argument passed to the function fun when it executes. 01151 @param argc Count of arguments in argv. argc is also the third argument passed to the function fun when it executes. 01152 @param argv Array containing a variable number of #t_atom function arguments. 01153 If this argument is non-zero, defer allocates memory to make a copy of the arguments 01154 (according to the size passed in argc) 01155 and passes the copied array to the function fun when it executes as the fourth argument. 01156 01157 @remark schedule_delay() is similar to schedule but allows you to specify the 01158 time as a delay rather than a specific logical time. 01159 01160 One use of schedule() or schedule_delay() is as an alternative to 01161 using the lockout flag. Here is an example click method that calls 01162 schedule() instead of outlet_int() surrounded by lockout_set() calls. 01163 01164 @code 01165 void myobject_click (t_myobject *x, Point pt, short modifiers) 01166 { 01167 t_atom a[1]; 01168 a[0].a_type = A_LONG; 01169 a[0].a_w.w_long = Random(); 01170 schedule_delay(x, myobject_sched, 0 ,0, 1, a); 01171 } 01172 01173 void myobject_sched (t_myobject *x, t_symbol *s, short ac, t_atom *av) 01174 { 01175 outlet_int(x->m_out,av->a_w.w_long); 01176 } 01177 @endcode 01178 01179 @see schedule() 01180 */ 01181 void schedule_delay(void *ob, method fun, long delay, t_symbol *sym, short argc, t_atom *argv); 01182 void schedule_fdelay(void *ob, method fun, double delay, t_symbol *sym, short argc, t_atom *argv); 01183 void schedule_defer(void *ob, method fun, long delay, t_symbol *sym, short argc, t_atom *arv); 01184 void schedule_fdefer(void *ob, method fun, double delay, t_symbol *sym, short argc, t_atom *arv); 01185 short lockout_set(short); 01186 01187 /** 01188 Determine whether your code is executing in the Max scheduler thread. 01189 01190 @ingroup threading 01191 @return This function returns non-zero if you are within Max's scheduler thread, zero otherwise. 01192 Note that if your code sets up other types of interrupt-level callbacks, 01193 such as for other types of device drivers used in asynchronous mode, isr will return false. 01194 */ 01195 long isr(void); 01196 short isr_set(short way); 01197 01198 01199 01200 // queue functions 01201 01202 /** 01203 Create a new Qelem. 01204 The created Qelem will need to be freed using qelem_free(), do not use freeobject(). 01205 01206 @ingroup qelems 01207 @param obj Argument to be passed to function fun when the Qelem executes. 01208 Normally a pointer to your object. 01209 @param fn Function to execute. 01210 @return A pointer to a Qelem instance. 01211 You need to store this value to pass to qelem_set(). 01212 01213 @remark Any kind of drawing or calling of Macintosh Toolbox routines that 01214 allocate or purge memory should be done in a Qelem function. 01215 */ 01216 void *qelem_new(void *obj, method fn); 01217 01218 01219 /** 01220 Cause a Qelem to execute. 01221 01222 @ingroup qelems 01223 @param q The Qelem whose function will be executed in the main thread. 01224 01225 @remark The key behavior of qelem_set() is this: if the Qelem object has already 01226 been set, it will not be set again. (If this is not what you want, see 01227 defer().) This is useful if you want to redraw the state of some 01228 data when it changes, but not in response to changes that occur faster 01229 than can be drawn. A Qelem object is unset after its queue function has 01230 been called. 01231 */ 01232 void qelem_set(void *q); 01233 01234 01235 /** 01236 Cancel a Qelem’s execution. 01237 If the Qelem’s function is set to be called, qelem_unset() will stop it 01238 from being called. Otherwise, qelem_unset() does nothing. 01239 01240 @ingroup qelems 01241 @param q The Qelem whose execution you wish to cancel. 01242 */ 01243 void qelem_unset(void *q); 01244 01245 01246 /** 01247 Free a Qelem object created with qelem_new(). 01248 Typically this will be in your object’s free funtion. 01249 01250 @ingroup qelems 01251 @param x The Qelem to destroy. 01252 */ 01253 void qelem_free(void *x); 01254 01255 01256 /** 01257 Cause a Qelem to execute with a higher priority. 01258 This function is identical to qelem_set(), except that the Qelem’s 01259 function is placed at the front of the list of routines to execute in the 01260 main thread instead of the back. Be polite and only use 01261 qelem_front() only for special time-critical applications. 01262 01263 @ingroup qelems 01264 @param x The Qelem whose function will be executed in the main thread. 01265 */ 01266 void qelem_front(void *x); 01267 01268 01269 /** 01270 Defer execution of a function to the main thread if (and only if) 01271 your function is executing in the scheduler thread. 01272 01273 @ingroup threading 01274 @param ob First argument passed to the function fun when it executes. 01275 @param fn Function to be called, see below for how it should be declared. 01276 @param sym Second argument passed to the function fun when it executes. 01277 @param argc Count of arguments in argv. argc is also the third argument passed to the function fun when it executes. 01278 @param argv Array containing a variable number of #t_atom function arguments. 01279 If this argument is non-zero, defer allocates memory to make a copy of the arguments 01280 (according to the size passed in argc) 01281 and passes the copied array to the function fun when it executes as the fourth argument. 01282 @return Return values is for internal Cycling '74 use only. 01283 01284 @remark This function uses the isr() routine to determine whether you’re at the 01285 Max timer interrupt level (in the scheduler thread). 01286 If so, defer() creates a Qelem (see @ref qelems), calls 01287 qelem_front(), and its queue function calls the function fn you 01288 passed with the specified arguments. 01289 If you’re not in the scheduler thread, the function is executed immediately with the 01290 arguments. Note that this implies that defer() is not appropriate for 01291 using in situations such as Device or File manager I/0 completion routines. 01292 The defer_low() function is appropriate however, because it always defers. 01293 01294 The deferred function should be declared as follows: 01295 @code 01296 void myobject_do (myObject *client, t_symbol *s, short argc, t_atom *argv); 01297 @endcode 01298 01299 @see defer_low() 01300 */ 01301 void *defer(void *ob,method fn,t_symbol *sym,short argc,t_atom *argv); 01302 01303 01304 /** 01305 Defer execution of a function to the back of the queue on the main thread. 01306 01307 @ingroup threading 01308 @param ob First argument passed to the function fun when it executes. 01309 @param fn Function to be called, see below for how it should be declared. 01310 @param sym Second argument passed to the function fun when it executes. 01311 @param argc Count of arguments in argv. argc is also the third argument passed to the function fun when it executes. 01312 @param argv Array containing a variable number of #t_atom function arguments. 01313 If this argument is non-zero, defer allocates memory to make a copy of the arguments 01314 (according to the size passed in argc) 01315 and passes the copied array to the function fun when it executes as the fourth argument. 01316 @return Return values is for internal Cycling '74 use only. 01317 01318 @remark defer_low() always defers a call to the function fun whether you are already 01319 in the main thread or not, and uses qelem_set(), not qelem_front(). This 01320 function is recommended for responding to messages that will cause 01321 your object to open a dialog box, such as read and write. 01322 01323 The deferred function should be declared as follows: 01324 @code 01325 void myobject_do (myObject *client, t_symbol *s, short argc, t_atom *argv); 01326 @endcode 01327 01328 @see defer() 01329 */ 01330 void *defer_low(void *ob,method fn,t_symbol *sym,short argc,t_atom *argv); 01331 01332 void *defer_medium(void *ob, method fn, t_symbol *sym, short argc, t_atom *argv); 01333 01334 void *defer_front(void *ob, method fn, t_symbol *sym, short argc, t_atom *argv); 01335 01336 // private 01337 void *defer_sys_low(void *ob,method fn,t_symbol *sym,short argc,t_atom *argv); 01338 01339 01340 01341 // binbuf functions 01342 01343 /** 01344 Use binbuf_new() to create and initialize a Binbuf. 01345 @ingroup binbuf 01346 @return Returns a new binbuf if successful, otherwise NULL. 01347 */ 01348 void *binbuf_new(void); 01349 01350 01351 /** 01352 Use binbuf_vinsert() to append a Max message to a Binbuf adding a semicolon. 01353 @ingroup binbuf 01354 01355 @param x Binbuf containing the desired Atom. 01356 @param fmt A C-string containing one or more letters corresponding to the types of each element of the message. 01357 s for #t_symbol*, l for long, or f for float. 01358 @param ... Elements of the message, passed directly to the function as Symbols, longs, or floats. 01359 01360 @remark binbuf_vinsert() works somewhat like a printf() for Binbufs. It 01361 allows you to pass a number of arguments of different types and insert 01362 them into a Binbuf. The entire message will then be terminated with a 01363 semicolon. Only 16 items can be passed to binbuf_vinsert(). 01364 01365 The example below shows the implementation of a normal object’s 01366 save method. The save method requires that you build a message that 01367 begins with #N (the new object) , followed by the name of your object 01368 (in this case, represented by the #t_symbol myobject), followed by any 01369 arguments your instance creation function requires. In this example, 01370 we save the values of two fields m_val1 and m_val2 defined as longs. 01371 01372 @code 01373 void myobject_save (myObject *x, Binbuf *dstBuf) 01374 { 01375 binbuf_vinsert(dstBuf, "ssll", gensym("#N"), 01376 gensym("myobject"), 01377 x->m_val1, x->m_val2); 01378 } 01379 @endcode 01380 01381 Suppose that such an object had written this data into a file. If you 01382 opened the file as text, you would see the following: 01383 01384 @code 01385 #N myobject 10 20; 01386 #P newobj 218 82 30 myobject; 01387 @endcode 01388 01389 The first line will result in a new myobject object to be created; the 01390 creation function receives the arguments 10 and 20. The second line 01391 contains the text of the object box. The newobj message to a patcher 01392 creates the object box user interface object and attaches it to the 01393 previously created myobject object. Normally, the newex message is 01394 used. This causes the object to be created using the arguments that 01395 were typed into the object box. 01396 */ 01397 void binbuf_vinsert(void *x, char *fmt, ...); 01398 01399 01400 /** 01401 Use binbuf_insert() to append a Max message to a Binbuf adding a semicolon. 01402 @ingroup binbuf 01403 01404 @param x Binbuf to receive the items. 01405 @param s Ignored. Pass NULL. 01406 @param argc Count of items in the argv array. 01407 @param argv Array of t_atoms to add to the Binbuf. 01408 01409 @remark You’ll use binbuf_insert() instead of binbuf_append() if you were 01410 saving your object into a Binbuf and wanted a semicolon at the end. If 01411 the message is part of a file that will later be evaluated, such as a 01412 Patcher file, the first argument argv[0] will be the receiver of the 01413 message and must be a Symbol. binbuf_vinsert() is 01414 easier to use than binbuf_insert(), since you don’t have to format 01415 your data into an array of Atoms first. 01416 01417 binbuf_insert() will also convert the t_symbols #1 through #9 into 01418 $1 through $9. This is used for saving patcher files that take 01419 arguments; you will probably never save these symbols as part of 01420 anything you are doing. 01421 */ 01422 void binbuf_insert(void *x, t_symbol *s, short argc, t_atom *argv); 01423 01424 01425 /** 01426 Use binbuf_eval to evaluate a Max message in a Binbuf, passing it arguments. 01427 binbuf_eval() is an advanced function that evaluates the message in a 01428 Binbuf with arguments in argv, and sends it to receiver. 01429 01430 @ingroup binbuf 01431 @param x Binbuf containing the message. 01432 @param ac Count of items in the argv array. 01433 @param av Array of t_atoms as the arguments to the message. 01434 @param to Receiver of the message. 01435 01436 @return The result of sending the message. 01437 */ 01438 void *binbuf_eval(void *x, short ac, t_atom *av, void *to); 01439 01440 01441 /** 01442 Use binbuf_getatom to retrieve a single Atom from a Binbuf. 01443 01444 @ingroup binbuf 01445 @param x Binbuf containing the desired #t_atom. 01446 @param p1 Offset into the Binbuf’s array of types. Modified to point to the next #t_atom. 01447 @param p2 Offset into the Binbuf’s array of data. Modified to point to the next #t_atom. 01448 @param ap Location of a #t_atom where the retrieved data will be placed. 01449 01450 @return 1 if there were no t_atoms at the specified offsets, 01451 0 if there’s a legitimate t_atom returned in result. 01452 01453 @remark To get the first t_atom, set both typeOffset and stuffOffset to 0. 01454 Here’s an example of getting all the items in a Binbuf: 01455 @code 01456 t_atom holder; 01457 long to, so; 01458 01459 to = 0; 01460 so = 0; 01461 while (!binbuf_getatom(x, &to, &so, &holder)){ 01462 // do something with the t_atom 01463 } 01464 @endcode 01465 */ 01466 short binbuf_getatom(void *x, long *p1, long *p2, t_atom *ap); 01467 01468 01469 /** 01470 Use binbuf_text() to convert a text handle to a Binbuf. 01471 binbuf_text() parses the text in the handle srcText and converts it 01472 into binary format. Use it to evaluate a text file or text line entry into a 01473 Binbuf. 01474 01475 @ingroup binbuf 01476 @param x Binbuf to contain the converted text. 01477 It must have already been created with binbuf_new. 01478 Its previous contents are destroyed. 01479 @param srcText Handle to the text to be converted. It need not be terminated with a 0. 01480 @param n Number of characters in the text. 01481 @return If binbuf_text encounters an error during its operation, 01482 a non-zero result is returned, otherwise it returns 0. 01483 01484 @remark Note: Commas, symbols containing a dollar sign followed by a number 01485 1-9, and semicolons are identified by special pseudo-type constants for 01486 you when your text is binbuf-ized. 01487 01488 The following constants in the a_type field of Atoms returned by 01489 binbuf_getAtom identify the special symbols #A_SEMI, 01490 #A_COMMA, and #A_DOLLAR. 01491 01492 For a #t_atom of the pseudo-type #A_DOLLAR, the a_w.w_long field of 01493 the #t_atom contains the number after the dollar sign in the original 01494 text or symbol. 01495 01496 Using these pseudo-types may be helpful in separating “sentences” and 01497 “phrases” in the input language you design. For example, the old pop-up 01498 umenu object allowed users to have spaces in between words by requiring 01499 the menu items be separated by commas. It’s reasonably easy, using 01500 binbuf_getatom(), to find the commas in a Binbuf in order to 01501 determine the beginning of a new item when reading the atomized text 01502 to be displayed in the menu. 01503 01504 If you want to use a literal comma or semicolon in a symbol, precede it 01505 with a backslash (\\) character. The backslash character can be included 01506 by using two backslashes in a row. 01507 */ 01508 short binbuf_text(void *x, char **srcText, long n); 01509 01510 01511 /** 01512 Use binbuf_totext() to convert a Binbuf into a text handle. 01513 binbuf_totext() converts a Binbuf into text and places it in a handle. 01514 Backslashes are added to protect literal commas and semicolons 01515 contained in symbols. The pseudo-types are converted into commas, 01516 semicolons, or dollar-sign and number, without backslashes preceding 01517 them. binbuf_text can read the output of binbuf_totext and 01518 make the same Binbuf. 01519 01520 @ingroup binbuf 01521 @param x Binbuf with data to convert to text. 01522 @param dstText Pre-existing handle where the text will be placed. 01523 dstText will be resized to accomodate the text. 01524 @param sizep Where binbuf_totext() returns the number of characters in the converted text handle. 01525 @return If binbuf_totext runs out of memory during its operation, it returns a non-zero result, 01526 otherwise it returns 0. 01527 */ 01528 short binbuf_totext(void *x, char **dstText, long *sizep); 01529 01530 01531 /** 01532 Use binbuf_set() to change the entire contents of a Binbuf. 01533 The previous contents of the Binbuf are destroyed. 01534 01535 @ingroup binbuf 01536 @param x Binbuf to receive the items. 01537 @param s Ignored. Pass NULL. 01538 @param argc Count of items in the argv array. 01539 @param argv Array of t_atoms to put in the Binbuf. 01540 */ 01541 void binbuf_set(void *x, t_symbol *s, short argc, t_atom *argv); 01542 01543 01544 /** 01545 Use binbuf_append to append t_atoms to a Binbuf without modifying them. 01546 @ingroup binbuf 01547 @param x Binbuf to receive the items. 01548 @param s Ignored. Pass NULL. 01549 @param argc Count of items in the argv array. 01550 @param argv Array of atoms to add to the Binbuf. 01551 */ 01552 void binbuf_append(void *x, t_symbol *s, short argc, t_atom *argv); 01553 01554 // still supported? 01555 short binbuf_read(void *x, char *name, short volume, short binary); 01556 01557 // still supported? 01558 short binbuf_write(void *x, char *fn, short vol, short binary); 01559 01560 void binbuf_savebox(void *x, void *w, t_symbol *what, short d1, short d2, short d3, long d4, short hidden, short user); 01561 void binbuf_delete(void *x, long fromType, long toType, long fromData, long toData); 01562 void binbuf_addtext(void *x, char **text, long size); 01563 01564 01565 /** 01566 Use readatom() to read a single Atom from a text buffer. 01567 @ingroup binbuf 01568 @param outstr C-string of 256 characters that will receive the next text item read from the buffer. 01569 @param text Handle to the text buffer to be read. 01570 @param n Starts at 0, and is modified by readatom to point to the next item in the text buffer. 01571 @param e Number of characters in text. 01572 @param ap Where the resulting Atom read from the text buffer is placed. 01573 @return readatom() returns non-zero if there is more text to read, 01574 and zero if it has reached the end of the text. 01575 Note that this return value has the opposite logic from that of binbuf_getatom(). 01576 01577 @remark This function provides access to the low-level Max text evaluator used 01578 by binbuf_text(). It is designed to operate on a handle of characters 01579 (text) and called in a loop, as in the example shown below. 01580 @code 01581 long index = 0; 01582 t_atom dst; 01583 char outstr[256]; 01584 01585 while (readatom(outstr,textHandle,&index,textLength,&dst)) 01586 { 01587 // do something with the resulting Atom 01588 } 01589 @endcode 01590 01591 @remark An alternative to using readatom is to turn your text into a Binbuf 01592 using binbuf_text(), then call binbuf_getatom() in a loop. 01593 */ 01594 short readatom(char *outstr, char **text, long *n, long e, t_atom *ap); 01595 char *atom_string(t_atom *a); 01596 01597 01598 // atombuf functions 01599 01600 /** 01601 Use atombuf_new() to create a new Atombuf from an array of t_atoms. 01602 01603 @ingroup atombuf 01604 @param argc Number of t_atoms in the argv array. May be 0. 01605 @param argv Array of t_atoms. If creating an empty Atombuf, you may pass 0. 01606 @return atombuf_new() create a new #t_atombuf and returns a pointer to it. 01607 If 0 is returned, insufficient memory was available. 01608 */ 01609 void *atombuf_new(long argc, t_atom *argv); 01610 01611 01612 /** 01613 Use atombuf_free() to dispose of the memory used by a #t_atombuf. 01614 01615 @ingroup atombuf 01616 @param x The #t_atombuf to free. 01617 */ 01618 void atombuf_free(t_atombuf *x); 01619 01620 01621 /** 01622 Use atombuf_text() to convert text to a #t_atom array in a #t_atombuf. 01623 To use this routine to create a new Atombuf from the text buffer, first 01624 create a new empty t_atombuf with a call to atombuf_new(0,NULL). 01625 01626 @ingroup atombuf 01627 @param x Pointer to existing atombuf variable. 01628 The variable will be replaced by a new Atombuf containing the converted text. 01629 @param text Handle to the text to be converted. It need not be zero-terminated. 01630 @param size Number of characters in the text. 01631 */ 01632 void atombuf_text(t_atombuf **x, char **text, long size); 01633 01634 void atombuf_totext(t_atombuf *x, char **text, long *size); 01635 short atombuf_count(t_atombuf *x); 01636 void atombuf_set(t_atombuf *x, short start, short num); 01637 long atombuf_replacepoundargs(t_atombuf *x, long argc, t_atom *argv); 01638 01639 01640 // message functions 01641 01642 /** Send a typed message directly to a Max object. 01643 @ingroup class_old 01644 01645 @param op Max object that will receive the message. 01646 @param msg The message selector. 01647 @param argc Count of message arguments in argv. 01648 @param argp Array of t_atoms; the message arguments. 01649 @return If the receiver object can respond to the message, 01650 typedmess() returns the result. Otherwise, an error message will be 01651 seen in the Max window and 0 will be returned. 01652 01653 @remark typedmess sends a message to a Max object (receiver) a message 01654 with arguments. Note that the message 01655 must be a #t_symbol, not a character string, so you must call gensym 01656 on a string before passing it to typedmess. Also, note that untyped 01657 messages defined for classes with the argument list #A_CANT cannot be 01658 sent using typedmess. You must use getfn() etc. instead. 01659 01660 Example: 01661 @code 01662 //If you want to send a bang message to the object bang_me… 01663 void *bangResult; 01664 bangResult = typedmess(bang_me,gensym("bang"),0,0L); 01665 @endcode 01666 */ 01667 void *typedmess(t_object *op, t_symbol *msg, short argc, t_atom *argp); 01668 01669 01670 /** Use getfn() to send an untyped message to a Max object with error checking. 01671 @ingroup class_old 01672 01673 @param op Receiver of the message. 01674 @param msg Message selector. 01675 @return getfn returns a pointer to the method bound to the message selector 01676 msg in the receiver’s message list. It returns 0 and prints an error 01677 message in Max Window if the method can’t be found. 01678 */ 01679 method getfn(t_object *op, t_symbol *msg); 01680 01681 01682 /** Use egetfn() to send an untyped message to a Max object that always works. 01683 @ingroup class_old 01684 01685 @param op Receiver of the message. 01686 @param msg Message selector. 01687 @return egetfn returns a pointer to the method bound to the message selector 01688 msg in the receiver’s message list. If the method can’t be found, a 01689 pointer to a do-nothing function is returned. 01690 */ 01691 method egetfn(t_object *op, t_symbol *msg); 01692 01693 01694 /** Use zgetfn() to send an untyped message to a Max object without error checking. 01695 @ingroup class_old 01696 01697 @param op Receiver of the message. 01698 @param msg Message selector. 01699 @return zgetfn returns a pointer to the method bound to the message selector 01700 msg in the receiver’s message list. It returns 0 but doesn’t print an 01701 error message in Max Window if the method can’t be found. 01702 */ 01703 method zgetfn(t_object *op, t_symbol *msg); 01704 01705 01706 01707 // commenting out -- some of these are probably still good, we need to investigate -- TAP 01708 void patcher_eachdo(eachdomethod fun, void *arg); // this one is still legit 01709 void loadbang_suspend(void); // used by poly~ on windows 01710 void loadbang_resume(void); // used by poly~ on windows 01711 /* 01712 // patcher functions 01713 GrafPtr patcher_setport(t_patcher *p); 01714 #ifdef WIN_VERSION 01715 void patcher_restoreport(GrafPtr gp); 01716 #endif 01717 #ifdef MAC_VERSION 01718 #define patcher_restoreport SetPort 01719 #endif 01720 void *patchbox(void *p, method fn, short ac, t_atom *av, short defwidth); 01721 void patcher_dirty(t_patcher *p); 01722 void patcher_selectbox(t_patcher *p, t_box *b); 01723 void patcher_deselectbox(t_patcher *p, t_box *b); 01724 void patcher_okclose(t_patcher *p, void *x); 01725 void patcher_eachdo(eachdomethod fun, void *arg); 01726 void patcher_avoidrect(t_patcher *p, Rect *r2, short id); 01727 short patcher_boxname(t_patcher *p, t_box *b, t_symbol **s); 01728 void patcher_setboxname(t_patcher *p, t_box *b, t_symbol *s); 01729 void patcher_nohilite(t_patcher *p); 01730 void hilite_settarget(t_patcher *p, t_box *b); 01731 void *patcher_parentpatcher(t_patcher *p); 01732 01733 // box functions 01734 void box_new(t_box *b, t_patcher *patcher, short flags, short x1, short y1, short x2, short y2); 01735 void box_free(t_box *b); 01736 void box_ready(t_box *b); 01737 short box_ownerlocked(t_box *b); 01738 void box_size(void *b, short x, short y); 01739 void *textbox(void *p, method fn, short ac, t_atom *av); 01740 short box_nodraw(t_box *b); 01741 void box_erase(t_box *b); 01742 short box_invalnow(t_box *b); 01743 void *box_clip(t_box *b); 01744 void box_enddraw(t_box *b); 01745 short box_visible(t_box *b); 01746 void box_hilite(t_box *b, short way); 01747 void box_color(t_box *b); 01748 void box_getcolor(t_box *b,short index, RGBColor *rgb); 01749 long usecolor(t_box *b); 01750 void palette_getcolor(t_box *b, short index, RGBColor *rgb); 01751 long boxcolor_rgb2index(RGBColor *n); 01752 */ 01753 01754 01755 01756 // table functions 01757 01758 /** Get a handle to the data in a named table object. 01759 @ingroup tables 01760 01761 @param s Symbol containing the name of the table object to find. 01762 @param hp Address of a handle where the table’s data will be returned if the named table object is found. 01763 @param sp Number of elements in the table (its size in longs). 01764 @return If no table object is associated with the symbol tableName, table_get() returns a non-zero result. 01765 01766 @remark table_get searches for a table associated with the t_symbol 01767 tableName. If one is found, a Handle to its elements (stored as an 01768 array of long integers) is returned and the function returns 0. 01769 Never count on a table to exist across calls to 01770 one of your methods. Call table_get and check the result each time 01771 you wish to use a table. 01772 01773 Here is an example of retrieving the 40th element of a table: 01774 @code 01775 long **storage,size,value; 01776 if (!table_get(gensym("somename"),&storage,&size)) { 01777 if (size > 40) 01778 value = *((*storage)+40); 01779 } 01780 @endcode 01781 */ 01782 short table_get(t_symbol *s, long ***hp, long *sp); 01783 01784 01785 /** Mark a table object as having changed data. 01786 @ingroup tables 01787 @param s Symbol containing the name of a table object. 01788 @return If no table is associated with tableName, table_dirty returns a non-zero result. 01789 */ 01790 short table_dirty(t_symbol *s); 01791 01792 // commenting out, where are the replacements? -- tap 01793 /* 01794 // ed functions 01795 void *ed_new(t_object *assoc); 01796 void ed_vis(t_ed *x); 01797 void ed_settext(t_ed *x, t_handle text, long len); 01798 */ 01799 01800 01801 // file functions 01802 01803 /** Load a data file into a handle. 01804 This is a low-level routine used for reading text and data files. You 01805 specify the file’s name and Path ID, as well as a pointer to a Handle. 01806 01807 @ingroup loading_max_files 01808 @param name Name of the patcher file to load. 01809 @param volume Path ID specifying the location of the file. 01810 @param h Pointer to a handle variable that will receive the handle 01811 that contains the data in the file. 01812 @param sizep Size of the handle returned in h. 01813 @return If the file is found, readtohandle creates a Handle, reads all the data in 01814 the file into it, assigns the handle to the variable hp, and returns the 01815 size of the data in size. readtohandle returns 0 if the file was 01816 opened and read successfully, and non-zero if there was an error. 01817 */ 01818 short readtohandle(char *name, short volume, char ***h, long *sizep); 01819 01820 01821 /** Load a patcher file by name and volume reference number. 01822 @ingroup loading_max_files 01823 @param name Filename of the patcher file to load (C string). 01824 @param vol Path ID specifying the location of the file. 01825 @return If the file is found, fileload tries to open 01826 the file, evaluate it, open a window, and bring it to the front. A pointer 01827 to the newly created Patcher is returned if loading is successful, 01828 otherwise, if the file is not found or there is insufficient memory, zero 01829 is returned. 01830 */ 01831 void *fileload(char *name, short vol); 01832 01833 01834 /** Pass arguments to Max files when you open them. 01835 This function loads the specified file and returns a pointer to the 01836 created object. Historically, intload() is was used to open patcher files, 01837 whether they are in text or Max binary format. 01838 It could also open table files whose contents begin with the word “table.” 01839 01840 @ingroup loading_max_files 01841 @param name Name of the file to open. 01842 @param volume Path ID specifying the location of the file. 01843 @param s A symbol. 01844 @param ac Count of t_atoms in av. To properly open a patcher file, ac should be 9. 01845 @param av Array of t_atoms that will replace the changeable 01846 arguments 1-9. The default behavior could be to set 01847 all these to t_atoms of type #A_LONG with a value of 0. 01848 @param couldedit If non-zero and the file is not a patcher file, the file is opened as a text file. 01849 @return If couldedit is non-zero and the file is not a patcher file, it is made into 01850 a text editor, and lowload returns 0. If couldedit is non-zero, lowload 01851 will just alert the user to an error and return 0. If there is no error, the 01852 value returned will be a pointer to a patcher or table object. 01853 */ 01854 void *intload(char *name, short volume, t_symbol *s, short ac, t_atom *av, short couldedit); 01855 01856 01857 /** Load a patcher file located in the Max search path by name. 01858 This function searches for a patcher file, opens it, 01859 evaluates it as a patcher file, opens a window for the patcher and brings 01860 it to the front. You need only specify a filename and Max will look 01861 through its search path for the file. The search path begins with the 01862 current “default volume” that is often the volume of the last opened 01863 patcher file, then the folders specified in the File Preferences dialog, 01864 searched depth first, then finally the folder that contains the Max 01865 application. 01866 01867 @ingroup loading_max_files 01868 @param name Filename of the patcher file to load (C string). 01869 @return If stringload() returns a non-zero result, you can later 01870 use freeobject() to close the patcher, or just let users do it themselves. 01871 If stringload() returns zero, no file with the specified name was 01872 found or there was insufficient memory to open it. 01873 */ 01874 void *stringload(char *name); 01875 01876 void *resource_install(char *name, long rsrc); 01877 void *toolfile_new(char *name, short vol, long type); 01878 long toolfile_fread(void *t, char *buf, long n); 01879 long toolfile_fwrite(void *t, char *buf, long n); 01880 short toolfile_getc(void *t); 01881 short collective_load(char *name, short vol, short argc, t_atom *argv); 01882 void *onecopy_fileload(char *s, short path); 01883 01884 // resource functions 01885 short rescopy(long type,short id); 01886 short resnamecopy(long type, char *name); 01887 01888 01889 01890 // preset functions 01891 01892 /** Give the preset object a general message to restore the current state of your object. 01893 This is a general preset function for use when your object’s state 01894 cannot be restored with a simple int or set message. The example 01895 below shows the expected format for specifying what your current 01896 state is to a preset object. The first thing you supply is your object itself, 01897 followed by the symbol that is the name of your object’s class (which 01898 you can retrieve from your object using the macro ob_sym, declared in 01899 ext_mess.h). Next, supply the symbol that specifies the message you 01900 want receive (a method for which had better be defined in your class), 01901 followed by the arguments to this message—the current values of your 01902 object’s fields. 01903 01904 @ingroup presets 01905 @param fmt C string containing one or more letters corresponding 01906 to the types of each element of the message. s for 01907 Symbol, l for long, or f for float. 01908 @param ... Elements of the message used to restore the state of 01909 your object, passed directly to the function as Symbols, 01910 longs, or floats. See below for an example that 01911 conforms to what the preset object expects. 01912 */ 01913 void preset_store(char *fmt, ... /*struct b100 arg1 */); 01914 01915 01916 /** Restore the state of your object with a set message. 01917 This function causes a set message with the argument value to be sent 01918 to your object from the preset object when the user executes a preset. 01919 01920 @ingroup presets 01921 @param obj Your object. 01922 @param val Current value of your object. 01923 01924 */ 01925 void preset_set(t_object *obj, long val); 01926 01927 01928 /** Restore the state of your object with an int message. 01929 This function causes an int message with the argument value to be 01930 sent to your object from the preset object when the user executes a 01931 preset. All of the existing user interface objects use the int message for 01932 restoring their state when a preset is executed. 01933 01934 @ingroup presets 01935 @param x Your object. 01936 @param n Current value of your object. 01937 */ 01938 void preset_int(void *x,long n); 01939 01940 01941 01942 // num functions 01943 01944 /** Increment the event serial number. 01945 @ingroup evnum 01946 */ 01947 void evnum_incr(void); 01948 01949 01950 /** Get the current value of the event serial number. 01951 @ingroup evnum 01952 @return The current value of the event serial number. 01953 */ 01954 long evnum_get(void); 01955 01956 01957 // commenting out -- tap 01958 //t_numerical *num_new(short top, short left, short bottom, short right, method draw, 01959 // longmethod inc, long flags, long min, long max, long val, short font, short fsize); 01960 //void num_draw(t_numerical *x); 01961 //void num_hilite(t_numerical *x, short way); 01962 //long num_test(t_numerical *x, Point pt); 01963 //void num_track(t_numerical *x, Point pt, method track, void *arg); 01964 //void num_setvalue(t_numerical *x, long newval, short redraw); 01965 01966 01967 01968 // proxy functions 01969 01970 /** 01971 Use proxy_new to create a new Proxy object. 01972 01973 @ingroup inout 01974 @param x Your object. 01975 @param id A non-zero number to be written into your object when a message is received in this particular Proxy. 01976 Normally, id will be the inlet “number” analogous to in1, in2 etc. 01977 @param stuffloc A pointer to a location where the id value will be written. 01978 @return A pointer to the new proxy inlet. 01979 01980 @remark This routine creates a new Proxy object (that includes an inlet). It 01981 allows you to identify messages based on an id value stored in the 01982 location specified by stuffLoc. You should store the pointer 01983 returned by proxy_new() because you’ll need to free all Proxies in your 01984 object’s free function using object_free(). 01985 01986 After your method has finished, Proxy sets the stuffLoc location 01987 back to 0, since it never sees messages coming in an object’s leftmost 01988 inlet. You’ll know you received a message in the leftmost inlet if the 01989 contents of stuffLoc is 0. As of Max 4.3, stuffLoc is not always 01990 guaranteed to be a correct indicator of the inlet in which a message was 01991 received. Use proxy_getinlet() to determine the inlet number. 01992 */ 01993 void *proxy_new(void *x,long id,long *stuffloc); 01994 01995 01996 /** 01997 Use proxy_getinlet to get the inlet number in which a message was received. 01998 Note that the “owner” argument should point to your external object’s instance, not a proxy object. 01999 02000 @ingroup inout 02001 @param master Your object. 02002 @return The index number of the inlet that received the message. 02003 */ 02004 long proxy_getinlet(t_object *master); 02005 02006 02007 //void *gwind_new(t_object *assoc, t_symbol *s, short style, short left, short top, short bottom, short right); 02008 02009 02010 // connection functions 02011 void *connection_client(t_object *cli, t_symbol *name, t_symbol *classname, method traverse); 02012 void connection_server(t_object *obj, t_symbol *name); 02013 void connection_send(t_object *server, t_symbol *name, t_symbol *mess, void *arg); 02014 void connection_delete(t_object *ob, t_symbol *name); 02015 02016 02017 // quittask functions 02018 02019 /** 02020 Register a function that will be called when Max exits. 02021 02022 @ingroup misc 02023 @param m A function that will be called on Max exit. 02024 @param a Argument to be used with method m. 02025 02026 @remark quittask_install() provides a mechanism for your external to 02027 register a routine to be called prior to Max shutdown. This is useful for 02028 objects that need to provide disk-based persistance outside the 02029 standard Max storage mechanisms, or need to shut down hardware or 02030 their connection to system software and cannot do so in the 02031 termination routine of a code fragment. 02032 */ 02033 void quittask_install(method m, void *a); 02034 02035 02036 /** 02037 Unregister a function previously registered with quittask_install(). 02038 02039 @ingroup misc 02040 @param m Function to be removed as a shutdown method. 02041 */ 02042 void quittask_remove(method m); 02043 void quittask_remove2(method m, void *a); 02044 02045 02046 // notify functions 02047 void *notify_new(t_object *owner); 02048 void notify_enlist(t_object *dependent, t_object *owner); 02049 void notify_update(void *xx); 02050 void notify_free(t_object *owner); 02051 02052 // commenting out -- tap 02053 /* 02054 // syswind functions 02055 Boolean syswindow_inlist(t_syswind w); 02056 Boolean syswindow_isvisible(t_syswind w); 02057 Boolean syswindow_isfloating(t_syswind w); 02058 void syswindow_show(t_syswind w); 02059 void syswindow_hide(t_syswind w); 02060 void syswindow_move(t_syswind w, long x, long y, Boolean front); 02061 void syswindow_size(t_syswind w, long width, long height, Boolean update); 02062 t_wind *syswindow_wind(t_syswind w); 02063 */ 02064 02065 02066 02067 // miscellaneous functions 02068 02069 /** 02070 Determine version information about the current Max environment. 02071 02072 This function returns the version number of Max. In Max versions 02073 2.1.4 and later, this number is the version number of the Max kernel 02074 application in binary-coded decimal. Thus, 2.1.4 would return 214 hex 02075 or 532 decimal. Version 3.0 returns 300 hex. 02076 02077 Use this to check for the existence of particular function macros that are only present in more 02078 recent Max versions. Versions before 2.1.4 returned 1, except for 02079 versions 2.1.1 - 2.1.3 which returned 2. 02080 02081 Bit 14 (counting from left) will 02082 be set if Max is running as a standalone application, so you should 02083 mask the lower 12 bits to get the version number. 02084 02085 @ingroup misc 02086 @return The Max environment's version number. 02087 */ 02088 short maxversion(void); 02089 02090 02091 /** Get a unique number for each Patcher file saved. 02092 This function returns a serial number that is incremented each time a 02093 Patcher file is saved. This routine is useful for objects like table and coll 02094 that have multiple objects that refer to the same data, and can “embed” 02095 the data inside a Patcher file. If the serial number hasn’t changed since 02096 your object was last saved, you can detect this and avoid saving 02097 multiple copies of the object’s data. 02098 02099 @ingroup evnum 02100 @return The serial number. 02101 */ 02102 long serialno(void); 02103 02104 02105 char **palette(void); 02106 short ispatcher(t_object *x); 02107 short isnewex(t_object *x); 02108 // commenting out -- tap 02109 //short newex_knows(t_box *x, t_symbol *selector); 02110 void colorinfo(void *r); 02111 void *callback_new(void *assoc, ProcPtr proc, long refCon, short offset, ProcPtr *callfun); 02112 02113 02114 /** 02115 Use open_promptset() to add a prompt message to the open file dialog displayed by open_dialog(). 02116 02117 Calling this function before open_dialog() permits a string to 02118 displayed in the dialog box instructing the user as to the purpose of the 02119 file being opened. It will only apply to the call of open_dialog() that 02120 immediately follows open_promptset(). 02121 02122 @ingroup files 02123 @param s A C-string containing the prompt you wish to display in the dialog box. 02124 @return Ignore. 02125 02126 @see open_dialog() 02127 */ 02128 void open_promptset(char *s); 02129 02130 02131 /** 02132 Use saveas_promptset() to add a prompt message to the open file dialog displayed by saveas_dialog() 02133 or saveasdialog_extended(). 02134 02135 Calling this function before saveasdialog_extended() permits a string to 02136 displayed in the dialog box instructing the user as to the purpose of the 02137 file being opened. It will only apply to the call of saveasdialog_extended() that 02138 immediately follows saveas_promptset(). 02139 02140 @ingroup files 02141 @param s A C-string containing the prompt you wish to display in the dialog box. 02142 @return Ignore. 02143 02144 @see open_dialog() 02145 */ 02146 void saveas_promptset(char *s); 02147 02148 02149 void dialog_setkey(long type); 02150 void saveasdialog_pathset(short path, short force); 02151 void dialog_poll(short dosched, short doevent, unsigned short evtMask); 02152 void forecolor(short index, short way); 02153 void backcolor(short index, short way); 02154 void *tabfromhandle(long **handle, long size); 02155 void stdlist(t_object *x, t_symbol *s, short ac, t_atom *av); 02156 void assist_queue(t_object *x, method fun); 02157 void inspector_open(t_object *x, void *p, void *b); 02158 void *object_subpatcher(t_object *x, long *index, void *arg); 02159 02160 02161 02162 // filewatch functions 02163 02164 /** Create a new filewatcher. 02165 The file will not be actively watched until filewatcher_start() is called. 02166 The filewatcher can be freed using object_free(). 02167 02168 @ingroup files 02169 @param owner Your object. 02170 This object will receive the message "filechanged" when the watcher sees a change in the file or folder. 02171 @param path The path in which the file being watched resides, or the path of the folder being watched. 02172 @param filename The name of the file being watched, or an empty string if you are simply watching the folder specified by path. 02173 @return A pointer to the new filewatcher. 02174 @remark The "filechanged" method should have the prototype: 02175 @code 02176 void myObject_filechanged(t_myObject *x, char *filename, short path); 02177 @endcode 02178 */ 02179 void *filewatcher_new(t_object *owner, short path, char *filename); 02180 02181 /** Start watching a file using a filewatcher created with filewatcher_new(). 02182 @param x A filewatcher pointer, as returned by filewatcher_new(). */ 02183 void filewatcher_start(void *x); 02184 02185 /** Stop watching a file using a filewatcher created with filewatcher_new(). 02186 @param x A filewatcher pointer, as returned by filewatcher_new(). */ 02187 void filewatcher_stop(void *x); 02188 02189 02190 02191 // fileusage functions 02192 02193 /** Add a file to a collective. 02194 @ingroup files 02195 @param w Handle for the collective builder. 02196 @param flags If flags == 1, copy this file to support folder of an app instead of to the collective in an app. 02197 @param name The name of the file. 02198 @param path The path of the file to add. 02199 */ 02200 void fileusage_addfile(void *w, long flags, char *name, short path); 02201 02202 void fileusage_addfilename(void *w, long flags, char *name); 02203 void fileusage_addpathname(void *w, long flags, char *name); 02204 void fileusage_copyfolder(void *w, char *name, long recursive); 02205 void fileusage_makefolder(void *w, char *name); 02206 02207 02208 // fileformat functions 02209 void fileformat_stripsuffix(char *name, long *types, short numtypes); 02210 02211 02212 #ifdef WIN_VERSION 02213 // systext functions 02214 void systext_mactoansi(char *sz); 02215 void systext_ansitomac(char *sz); 02216 #endif 02217 02218 02219 #ifdef MAC_VERSION 02220 long fontinfo_getencoding(long id); 02221 long fontinfo_convert(t_object *x, char *src, long srclen, long encoding, char **out); 02222 long fontinfo_reconvert(t_object *x, char *src, long srclen, long encoding, char **out); 02223 void fontinfo_reconverthandle(t_object *x, char **h, long encoding); 02224 #endif 02225 02226 02227 long fontinfo_prefcheckencoding(void); 02228 02229 t_atom *atom_dynamic_start(const t_atom *static_array, long static_count, long request_count); 02230 void atom_dynamic_end(const t_atom *static_array, t_atom *request_array); 02231 02232 #ifdef __cplusplus 02233 } 02234 #endif 02235 02236 #endif // _EXT_PROTO_H_ 02237
Copyright © 2008, Cycling '74