When a user types the name of your object into an object box, Max looks for an external of this name in the searchpath and, upon finding it, loads the bundle or dll and calls the ext_main() function. More...
Modules | |
Old-Style Classes | |
Inlets and Outlets | |
Routines for creating and communicating with inlets and outlets. | |
Data Structures | |
struct | t_class |
The data structure for a Max class. More... | |
Macros | |
#define | CLASS_BOX |
The namespace for all Max object classes which can be instantiated in a box, i.e. More... | |
#define | CLASS_NOBOX |
A namespace for creating hidden or internal object classes which are not a direct part of the user creating patcher. | |
Functions | |
BEGIN_USING_C_LINKAGE void C74_EXPORT | ext_main (void *r) |
ext_main() is the entry point for an extern to be loaded, which all externs must implement this shared/common prototype ensures that it will be exported correctly on all platforms. More... | |
t_class * | class_new (C74_CONST char *name, C74_CONST method mnew, C74_CONST method mfree, long size, C74_CONST method mmenu, short type,...) |
Initializes a class by informing Max of its name, instance creation and free functions, size and argument types. More... | |
t_max_err | class_free (t_class *c) |
Frees a previously defined object class. More... | |
t_max_err | class_register (t_symbol *name_space, t_class *c) |
Registers a previously defined object class. More... | |
t_max_err | class_alias (t_class *c, t_symbol *aliasname) |
Registers an alias for a previously defined object class. More... | |
t_max_err | class_addmethod (t_class *c, C74_CONST method m, C74_CONST char *name,...) |
Adds a method to a previously defined object class. More... | |
t_max_err | class_addattr (t_class *c, t_object *attr) |
Adds an attribute to a previously defined object class. More... | |
t_symbol * | class_nameget (t_class *c) |
Retrieves the name of a class, given the class's pointer. More... | |
t_class * | class_findbyname (t_symbol *name_space, t_symbol *classname) |
Finds the class pointer for a class, given the class's namespace and name. More... | |
t_class * | class_findbyname_casefree (t_symbol *name_space, t_symbol *classname) |
Finds the class pointer for a class, given the class's namespace and name. More... | |
t_max_err | class_dumpout_wrap (t_class *c) |
Wraps user gettable attributes with a method that gets the values and sends out dumpout outlet. More... | |
void | class_obexoffset_set (t_class *c, long offset) |
Registers the byte-offset of the obex member of the class's data structure with the previously defined object class. More... | |
long | class_obexoffset_get (t_class *c) |
Retrieves the byte-offset of the obex member of the class's data structure. More... | |
long | class_is_ui (t_class *c) |
Determine if a class is a user interface object. More... | |
t_max_err | class_subclass (t_class *superclass, t_class *subclass) |
Define a subclass of an existing class. More... | |
t_object * | class_super_construct (t_class *c,...) |
Call super class constructor. More... | |
When a user types the name of your object into an object box, Max looks for an external of this name in the searchpath and, upon finding it, loads the bundle or dll and calls the ext_main() function.
Thus, Max classes are typically defined in the ext_main() function of an external.
Historically, Max classes have been defined using an API that includes functions like setup() and addmess(). This interface is still supported, and the relevant documentation can be found in Old-Style Classes.
A more recent and more flexible interface for creating objects was introduced with Jitter 1.0 and later included directly in Max 4.5. This newer API includes functions such as class_new() and class_addmethod(). Supporting attributes, user interface objects, and additional new features of Max requires the use of the newer interface for definiting classes documented on this page.
You may not mix these two styles of creating classes within an object.
#define CLASS_BOX |
The namespace for all Max object classes which can be instantiated in a box, i.e.
in a patcher.
Referenced by ext_main().
enum e_max_class_flags |
Class flags.
If not box or polyglot, class is only accessible in C via known interface
Adds an attribute to a previously defined object class.
c | The class pointer |
attr | The attribute to add. The attribute will be a pointer returned by attribute_new(), attr_offset_new() or attr_offset_array_new(). |
Referenced by ext_main(), and jit_class_addattr().
Adds a method to a previously defined object class.
c | The class pointer |
m | Function to be called when the method is invoked |
name | C-string defining the message (message selector) |
... | One or more integers specifying the arguments to the message, in the standard Max type list format (see Chapter 3 of the Writing Externals in Max document for more information). |
m
, to respond to the message string name
in the leftmost inlet of the object. Referenced by ext_main(), jit_class_addmethod(), jit_class_new(), and max_jit_class_ob3d_wrap().
Registers an alias for a previously defined object class.
c | The class pointer |
aliasname | A symbol who's name will become an alias for the given class |
Wraps user gettable attributes with a method that gets the values and sends out dumpout outlet.
c | The class pointer |
Finds the class pointer for a class, given the class's namespace and name.
name_space | The desired class's name space. Typically, either the constant CLASS_BOX, for obex classes which can instantiate inside of a Max patcher (e.g. boxes, UI objects, etc.), or the constant CLASS_NOBOX, for classes which will only be used internally. Developers can define their own name spaces as well, but this functionality is currently undocumented. |
classname | The name of the class to be looked up |
Referenced by jit_class_findbyname().
Finds the class pointer for a class, given the class's namespace and name.
name_space | The desired class's name space. Typically, either the constant CLASS_BOX, for obex classes which can instantiate inside of a Max patcher (e.g. boxes, UI objects, etc.), or the constant CLASS_NOBOX, for classes which will only be used internally. Developers can define their own name spaces as well, but this functionality is currently undocumented. |
classname | The name of the class to be looked up (case free) |
Frees a previously defined object class.
This function is not typically used by external developers.
c | The class pointer |
Referenced by jit_class_free().
long class_is_ui | ( | t_class * | c | ) |
Determine if a class is a user interface object.
c | The class pointer. |
Retrieves the name of a class, given the class's pointer.
c | The class pointer |
Referenced by jit_class_nameget().
t_class* class_new | ( | C74_CONST char * | name, |
C74_CONST method | mnew, | ||
C74_CONST method | mfree, | ||
long | size, | ||
C74_CONST method | mmenu, | ||
short | type, | ||
... | |||
) |
Initializes a class by informing Max of its name, instance creation and free functions, size and argument types.
Developers wishing to use obex class features (attributes, etc.) must use class_new() instead of the traditional setup() function.
name | The class's name, as a C-string |
mnew | The instance creation function |
mfree | The instance free function |
size | The size of the object's data structure in bytes. Usually you use the C sizeof operator here. |
mmenu | Obsolete - pass NULL. In Max 4 this was a function pointer for UI objects called when the user created a new object of the class from the Patch window's palette. |
type | A standard Max type list as explained in Chapter 3 of the Writing Externals in Max document (in the Max SDK). The final argument of the type list should be a 0. Generally, obex objects have a single type argument, A_GIMME, followed by a 0. |
Referenced by ext_main(), and jit_class_new().
long class_obexoffset_get | ( | t_class * | c | ) |
Retrieves the byte-offset of the obex member of the class's data structure.
c | The class pointer |
void class_obexoffset_set | ( | t_class * | c, |
long | offset | ||
) |
Registers the byte-offset of the obex member of the class's data structure with the previously defined object class.
Use of this function is required for obex-class objects. It must be called from main()
.
c | The class pointer |
offset | The byte-offset to the obex member of the object's data structure. Conventionally, the macro calcoffset is used to calculate the offset. |
Referenced by ext_main().
Registers a previously defined object class.
This function is required, and should be called at the end of main()
.
name_space | The desired class's name space. Typically, either the constant CLASS_BOX, for obex classes which can instantiate inside of a Max patcher (e.g. boxes, UI objects, etc.), or the constant CLASS_NOBOX, for classes which will only be used internally. Developers can define their own name spaces as well, but this functionality is currently undocumented. |
c | The class pointer |
Referenced by ext_main(), and jit_class_register().
Define a subclass of an existing class.
First call class_new on the subclass, then pass in to class_subclass. If constructor or destructor are NULL will use the superclass constructor.
superclass | The superclass pointer. |
subclass | The subclass pointer. |
Call super class constructor.
Use this instead of object_alloc if you want to call the super class constructor, but allocating enough memory for subclass.
c | The (sub)class pointer. |
... | Args to super class constructor. |
BEGIN_USING_C_LINKAGE void C74_EXPORT ext_main | ( | void * | r | ) |
ext_main() is the entry point for an extern to be loaded, which all externs must implement this shared/common prototype ensures that it will be exported correctly on all platforms.
r | Pointer to resources for the external, if applicable. |
References A_CANT, A_FLOAT, A_GIMME, A_LONG, addbang(), addfloat(), addint(), addmess(), attr_offset_array_new(), attr_offset_new(), ATTR_SET_OPAQUE, ATTR_SET_OPAQUE_USER, calcoffset, class_addattr(), class_addmethod(), CLASS_BOX, class_new(), class_obexoffset_set(), class_register(), object_obex_dumpout(), object_obex_quickref(), and setup().