Jamoma API  0.6.0.a19
j.max.stencil.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationMaxExternalsJitter
4  *
5  * @brief j.stencil% : Perform operations on a stencil of points in a matrix
6  *
7  * @details This is the max wrapper
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright © 2011 by Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "jit.common.h"
18 #include "max.jit.mop.h"
19 #include "TTClassWrapperMax.h"
20 
21 
22 // types and structures
23 typedef struct _jcom_max_stencil {
24  Object ob;
25  Ptr obex;
26 } MaxStencilObject;
27 
28 typedef MaxStencilObject* MaxStencilObjectPtr;
29 
30 
31 // method prototypes
32 t_jit_err StencilClassInit (void);
33 TTPtr MaxStencilNew (t_symbol *s, long argc, t_atom *argv);
34 void MaxStencilFree (MaxStencilObjectPtr self);
35 
36 
37 // globals
38 static ClassPtr sMaxStencilClass = NULL;
39 
40 
41 /************************************************************************************/
42 
43 int TTCLASSWRAPPERMAX_EXPORT main(void)
44 {
45  void *p, *q;
46 
47  TTFoundationInit();
48  StencilClassInit();
49  setup((t_messlist**)&sMaxStencilClass, (method)MaxStencilNew, (method)MaxStencilFree, sizeof(MaxStencilObject), 0, A_GIMME, 0);
50 
51  p = max_jit_classex_setup(calcoffset(MaxStencilObject, obex));
52  q = jit_class_findbyname(gensym("j_stencil"));
53  max_jit_classex_mop_wrap(p, q, 0); // attrs & methods for name, type, dim, planecount, bang, outputmatrix, etc
54  max_jit_classex_standard_wrap(p, q, 0); // attrs & methods for getattributes, dumpout, maxjitclassaddmethods, etc
55  addmess((method)max_jit_mop_assist, (char*)"assist", A_CANT, 0); // standard matrix-operator (mop) assist fn
56  return 0;
57 }
58 
59 
60 
61 /************************************************************************************/
62 // Object Life Cycle
63 
64 void *MaxStencilNew(t_symbol *s, long argc, t_atom *argv)
65 {
66  MaxStencilObjectPtr self;
67  void *o;
68 
69  self = (MaxStencilObjectPtr)max_jit_obex_new(sMaxStencilClass, gensym("j_stencil"));
70  if (self) {
71  o = jit_object_new(gensym("j_stencil"));
72  if (o) {
73  max_jit_mop_setup_simple(self, o, argc, argv);
74  max_jit_attr_args(self, argc, argv);
75  }
76  else {
77  jit_object_error(SELF, (char*)"could not allocate object");
78  object_free(SELF);
79  self = NULL;
80  }
81  }
82  return self;
83 }
84 
85 
86 void MaxStencilFree(MaxStencilObjectPtr self)
87 {
88  max_jit_mop_free(self);
89  jit_object_free(max_jit_obex_jitob_get(self));
90  max_jit_obex_free(self);
91 }
92 
int TTCLASSWRAPPERMAX_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
void * TTPtr
A generic pointer.
Definition: TTBase.h:248