Jamoma API  0.6.0.a19
TTModularClassWrapperMax.cpp
1 /*
2  * TTModularClassWrapperMax
3  * An automated class wrapper to make Jamoma object's available as objects for Max/MSP
4  * Copyright © 2008 by Timothy Place
5  *
6  * License: This code is licensed under the terms of the GNU LGPL
7  * http://www.gnu.org/licenses/lgpl.html
8  */
9 
11 #include "ext_hashtab.h"
12 
13 
14 /** A hash of all wrapped clases, keyed on the Max class name. */
15 static t_hashtab* wrappedMaxClasses = NULL;
16 
17 
18 t_object *wrappedModularClass_new(t_symbol *name, long argc, t_atom *argv)
19 {
20  WrappedClass* wrappedMaxClass = NULL;
22  TTErr err = kTTErrNone;
23 #ifdef UI_EXTERNAL
24  long flags;
25  t_dictionary* d = NULL;
26 
27  if (!(d=object_dictionaryarg(argc,argv)))
28  return NULL;
29 #endif
30 
31  // Find the WrappedClass
32  hashtab_lookup(wrappedMaxClasses, name, (t_object**)&wrappedMaxClass);
33 
34  // If the WrappedClass has a validity check defined, then call the validity check function.
35  // If it returns an error, then we won't instantiate the object.
36  if (wrappedMaxClass) {
37  if (wrappedMaxClass->validityCheck)
38  err = wrappedMaxClass->validityCheck(wrappedMaxClass->validityCheckArgument);
39  else
40  err = kTTErrNone;
41  }
42  else
43  err = kTTErrGeneric;
44 
45  if (!err)
46  x = (WrappedModularInstancePtr)object_alloc(wrappedMaxClass->maxClass);
47 
48  if (x) {
49 
50  x->wrappedClassDefinition = wrappedMaxClass;
51 
52  x->useInternals = NO;
53  x->internals = new TTHash();
54  x->address = kTTAdrsEmpty;
55  x->argv = NULL;
56  x->iterateInternals = NO;
57 
58 #ifdef ARRAY_EXTERNAL
59  x->arrayFormatInteger = TTString();
60  x->arrayFormatString = TTString();
61 #endif
62 
63  x->patcherPtr = NULL;
64  x->patcherContext = kTTSymEmpty;
65  x->patcherClass = kTTSymEmpty;
66  x->patcherName = kTTSymEmpty;
67  x->patcherAddress = kTTAdrsEmpty;
68 
69  // dumpout
70  object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL));
71 
72 #ifdef UI_EXTERNAL
73  flags = 0
74  | JBOX_DRAWFIRSTIN // 0
75  | JBOX_NODRAWBOX // 1
76  | JBOX_DRAWINLAST // 2
77  // | JBOX_TRANSPARENT // 3
78  // | JBOX_NOGROW // 4
79  // | JBOX_GROWY // 5
80  | JBOX_GROWBOTH // 6
81  // | JBOX_IGNORELOCKCLICK // 7
82  // | JBOX_HILITE // 8
83  // | JBOX_BACKGROUND // 9
84  // | JBOX_NOFLOATINSPECTOR // 10
85  // | JBOX_TEXTFIELD // 11
86  // | JBOX_MOUSEDRAGDELTA // 12
87  // | JBOX_COLOR // 13
88  // | JBOX_BINBUF // 14
89  // | JBOX_DRAWIOLOCKED // 15
90  // | JBOX_DRAWBACKGROUND // 16
91  // | JBOX_NOINSPECTFIRSTIN // 17
92  // | JBOX_DEFAULTNAMES // 18
93  // | JBOX_FIXWIDTH // 19
94  ;
95 
96  jbox_new(&x->box, flags, argc, argv);
97  x->box.b_firstin = (t_object *)x;
98  attr_dictionary_process(x,d);
99  jbox_ready((t_jbox *)x);
100 #endif
101 
102  // Make specific things
103  ModularSpec *spec = (ModularSpec*)wrappedMaxClass->specificities;
104  if (spec) {
105  if (spec->_new)
106  spec->_new((TTPtr)x, argc, argv);
107  }
108  else
109  // handle attribute args
110  attr_args_process(x, argc, argv);
111  }
112  return (t_object*)x;
113 }
114 
115 
116 void wrappedModularClass_unregister(WrappedModularInstancePtr x)
117 {
118  TTValue keys, v;
119  TTSymbol name;
120  TTAddress objectAddress;
121  TTErr err;
122 
123 #ifndef ARRAY_EXTERNAL
124 
125  x->subscriberObject = TTObject();
126 
127  // check the wrappedObject is still valid because it could have been released in spec->_free method
128  if (x->wrappedObject.valid()) {
129 
130  // don't release the local application
132 
133  if (x->wrappedObject.instance()->getReferenceCount() > 1)
134  object_error((t_object*)x, "there are still unreleased reference of the wrappedObject (refcount = %d)", x->wrappedObject.instance()->getReferenceCount() - 1);
135 
136  // this line should release the last instance of the wrapped object
137  // otherwise there is something wrong
138  x->wrappedObject = TTObject();
139  }
140  }
141 
142 #endif
143 
144  if (!x->internals->isEmpty()) {
145 
146  err = x->internals->getKeys(keys);
147 
148  if (!err) {
149 
150  x->iterateInternals = YES;
151 
152  for (int i = 0; i < (TTInt32) keys.size(); i++) {
153 
154  name = keys[i];
155  err = x->internals->lookup(name, v);
156 
157  if (!err) {
158 
159  TTObject o = v[0];
160 
161  if (o.name() == kTTSym_Sender || o.name() == kTTSym_Receiver || o.name() == kTTSym_Viewer)
162  o.set(kTTSym_address, kTTAdrsEmpty);
163 
164  // absolute registration case : remove the address
165  if (v.size() == 2) {
166  objectAddress = v[1];
167 
168  JamomaDebug object_post((t_object*)x, "Remove internal %s object at : %s", name.c_str(), objectAddress.c_str());
169  JamomaApplication.send("ObjectUnregister", objectAddress);
170  }
171  }
172  }
173  x->iterateInternals = NO;
174  }
175  x->internals->clear();
176  }
177 }
178 
179 
180 void wrappedModularClass_free(WrappedModularInstancePtr x)
181 {
182  ModularSpec* spec = (ModularSpec*)x->wrappedClassDefinition->specificities;
183 
184  // call specific free method before freeing internal stuff
185  if (spec && spec->_free)
186  spec->_free(x);
187 
188  wrappedModularClass_unregister(x);
189 
190  if (x->argv)
191  sysmem_freeptr(x->argv);
192 
193 #ifdef UI_EXTERNAL
194  notify_free((t_object *)x);
195  jbox_free((t_jbox *)x);
196 #endif
197 
198  x->argv = NULL;
199 
200  delete x->internals;
201  x->internals = NULL;
202 }
203 
204 
205 t_max_err wrappedModularClass_notify(TTPtr self, t_symbol *s, t_symbol *msg, void *sender, void *data)
206 {
208  ModularSpec* spec = (ModularSpec*)x->wrappedClassDefinition->specificities;
209  TTValue v;
210  TTAddress contextAddress;
211 
212 #ifndef ARRAY_EXTERNAL
213  t_object * context;
214 
215  if (x->subscriberObject.valid()) {
216 
217  x->subscriberObject.get("context", v);
218  context = (t_object*)((TTPtr)v[0]);
219 
220  // if the patcher is deleted
221  if (sender == context) {
222  if (msg == _sym_free) {
223 
224  // delete the context node if it exists
225  x->subscriberObject.get("contextAddress", v);
226  contextAddress = v[0];
227 
228  JamomaApplication.send("ObjectUnregister", contextAddress);
229 
230  // delete
231  x->subscriberObject = TTObject();
232 
233  // no more notification
234  object_detach_byptr((t_object*)x, context);
235  }
236  }
237  }
238 #endif
239 
240  if (spec->_notify)
241  spec->_notify(self, s, msg, sender, data);
242 
243 #ifdef UI_EXTERNAL
244  if (msg == _sym_modified)
245  jbox_redraw(&x->box);
246  else if ((msg == _sym_attr_modified) && (sender == x))
247  jbox_redraw(&x->box);
248 
249  return jbox_notify((t_jbox*)x, s, msg, sender, data);
250 #else
251  return MAX_ERR_NONE;
252 #endif
253 }
254 
255 
256 void wrappedModularClass_shareContextNode(TTPtr self, TTNodePtr *contextNode)
257 {
258  TTValue v;
259 #ifndef ARRAY_EXTERNAL
261 
262  if (x->subscriberObject.valid()) {
263  x->subscriberObject.get("contextNode", v);
264  *contextNode = TTNodePtr((TTPtr)v[0]);
265  }
266  else
267 #endif
268  *contextNode = NULL;
269 }
270 
271 
272 t_max_err wrappedModularClass_attrGet(TTPtr self, t_object *attr, long* argc, t_atom** argv)
273 {
274  t_symbol *attrName = (t_symbol*)object_method(attr, _sym_getname);
275  TTValue v;
277  t_max_err err;
278  TTPtr ptr;
279 
280  err = hashtab_lookup(x->wrappedClassDefinition->maxNamesToTTNames, attrName, (t_object**)&ptr);
281  if (err)
282  return err;
283 
284  TTSymbol ttAttrName(ptr);
285 
286  if (selectedObject)
287  {
288  selectedObject->getAttributeValue(ttAttrName, v);
289  jamoma_ttvalue_to_Atom(v, argc, argv);
290  }
291 
292  return MAX_ERR_NONE;
293 }
294 
295 
296 t_max_err wrappedModularClass_attrSet(TTPtr self, t_object *attr, long argc, const t_atom *argv)
297 {
299  t_symbol *attrName = (t_symbol*)object_method(attr, _sym_getname);
300  TTValue v;
301  long ac = 0;
302  t_atom *av = NULL;
303  t_max_err m_err;
304  TTErr err;
305  TTPtr ptr;
306 
307  // for an array of wrapped object
308  if (x->useInternals && !x->iterateInternals) {
309 
310  TTValue keys;
311 
312  // temporary set x->iterateInternals to YES
313  x->iterateInternals = YES;
314 
315  // then recall this method for each element of the array
316  if (!x->internals->isEmpty()) {
317  err = x->internals->getKeys(keys);
318  if (!err) {
319  for (TTUInt32 i = 0; i < keys.size(); i++) {
320  x->cursor = keys[i];
321  wrappedModularClass_attrSet(self, attr, argc, argv);
322  }
323  }
324  }
325 
326  // reset x->iterateInternals to NO
327  x->iterateInternals = NO;
328 
329  return MAX_ERR_NONE;
330  }
331 
332  m_err = hashtab_lookup(x->wrappedClassDefinition->maxNamesToTTNames, attrName, (t_object**)&ptr);
333  if (m_err)
334  return m_err;
335 
336  TTSymbol ttAttrName(ptr);
337 
338  // set attribute's value
339  if (argc && argv) {
340 
341  jamoma_ttvalue_from_Atom(v, _sym_nothing, argc, argv);
342 
343  if (selectedObject) {
344  selectedObject->setAttributeValue(ttAttrName, v);
345  return MAX_ERR_NONE;
346  }
347  else
348  return MAX_ERR_GENERIC;
349 
350  }
351  // or get it and dumpout his value
352  else {
353 
354  if (selectedObject) {
355  // don't consider array case here (they should have all the same attribute value)
356  selectedObject->getAttributeValue(ttAttrName, v);
357 
358  jamoma_ttvalue_to_Atom(v, &ac, &av);
359  object_obex_dumpout(self, attrName, ac, av);
360  sysmem_freeptr(av);
361  return MAX_ERR_NONE;
362  }
363  else
364  return MAX_ERR_GENERIC;
365  }
366 
367  return MAX_ERR_GENERIC;
368 }
369 
370 
371 void wrappedModularClass_anything(TTPtr self, t_symbol *s, long argc, t_atom *argv)
372 {
374  ModularSpec* spec = (ModularSpec*)x->wrappedClassDefinition->specificities;
375  TTErr err;
376 
377  // for an array of wrapped object
378  if (x->useInternals && !x->iterateInternals) {
379 
380  // temporary set x->iterateInternals to YES
381  x->iterateInternals = YES;
382 
383  // then recall this method for each element of the array
384  if (!x->internals->isEmpty()) {
385 
386  TTUInt32 i = 0;
387  TTValue keys;
388  TTSymbol memoCursor;
389 
390  err = x->internals->getKeys(keys);
391  if (!err) {
392 
393  memoCursor = x->cursor;
394  while (i < keys.size() && !err) {
395 
396  x->cursor = keys[i];
397 
398  // Is it a message of the wrapped object ?
399  err = wrappedModularClass_sendMessage(self, s, argc, argv);
400 
401  // Is it an attribute of the wrapped object ?
402  if (err)
403  err = wrappedModularClass_setAttribute(self, s, argc, argv);
404 
405  // if error : stop the while because this is an array and all objects are the same
406  if (err)
407  break;
408 
409  i++;
410  }
411  x->cursor = memoCursor;
412  }
413 
414  // don't iterate the specific anything method on each object of the array
415  if (err && spec->_any)
416  spec->_any(self, s, argc, argv);
417  }
418 
419  // reset x->iterateInternals to NO
420  x->iterateInternals = NO;
421  }
422 
423  // for single wrapped object
424  else {
425 
426  // Is it a message of the wrapped object ?
427  if (!wrappedModularClass_sendMessage(self, s, argc, argv))
428  return;
429 
430  // It could be an extended attribute (not registered in maxNamesToTTNames)
431  // Is it an attribute of the wrapped object ?
432  if (!wrappedModularClass_setAttribute(self, s, argc, argv))
433  return;
434 
435  if (spec->_any)
436  spec->_any(self, s, argc, argv);
437  }
438 }
439 
440 
441 TTErr wrappedModularClass_sendMessage(TTPtr self, t_symbol *s, long argc, const t_atom *argv)
442 {
444  TTValue inputValue, outputValue;
445  TTSymbol ttName;
446  TTMessagePtr aMessage = NULL;
447  long ac = 0;
448  t_atom *av = NULL;
449  t_max_err m_err;
450  TTErr err;
451  TTPtr ptr;
452 
453  m_err = hashtab_lookup(x->wrappedClassDefinition->maxNamesToTTNames, s, (t_object**)&ptr);
454  if (!m_err) {
455 
456  // Is it a message of the wrapped object ?
457  ttName = TTSymbol(ptr);
458  err = selectedObject->findMessage(ttName, &aMessage);
459  if (!err) {
460  // send message
461  if (argc && argv) {
462 
463  jamoma_ttvalue_from_Atom(inputValue, _sym_nothing, argc, argv);
464  selectedObject->sendMessage(ttName, inputValue, outputValue);
465 
466  jamoma_ttvalue_to_Atom(outputValue, &ac, &av);
467  object_obex_dumpout(self, s, ac, av);
468  sysmem_freeptr(av);
469  }
470  else
471  selectedObject->sendMessage(ttName);
472  }
473 
474  return err;
475  }
476  else
477  return kTTErrGeneric;
478 }
479 
480 
481 TTErr wrappedModularClass_setAttribute(TTPtr self, t_symbol *s, long argc, const t_atom *argv)
482 {
484  TTValue inputValue, outputValue;
485  TTSymbol ttName;
486  TTAttributePtr anAttribute= NULL;
487  long ac = 0;
488  t_atom *av = NULL;
489  TTErr err;
490 
491  err = selectedObject->findAttribute(TTSymbol(s->s_name), &anAttribute);
492  if (!err) {
493 
494  // set attribute's value
495  if (argc && argv) {
496  jamoma_ttvalue_from_Atom(inputValue, _sym_nothing, argc, argv);
497  selectedObject->setAttributeValue(TTSymbol(s->s_name), inputValue);
498  }
499  // or get it and dumpout his value
500  else {
501  selectedObject->getAttributeValue(TTSymbol(s->s_name), outputValue);
502 
503  jamoma_ttvalue_to_Atom(outputValue, &ac, &av);
504  object_obex_dumpout(self, s, ac, av);
505  sysmem_freeptr(av);
506  }
507  }
508 
509  return err;
510 }
511 
512 
513 void wrappedModularClass_dump(TTPtr self)
514 {
516  TTValue names, v;
517  TTUInt32 i;
518  TTSymbol aName, address;
519  t_symbol *s;
520  long ac;
521  t_atom *av;
522 
523 #ifndef ARRAY_EXTERNAL
524  t_atom a;
525 
526  if (x->subscriberObject.valid())
527  {
528  // send out the absolute address of the subscriber
529  x->subscriberObject.get("nodeAddress", v);
530  address = v[0];
531  atom_setsym(&a, gensym((char *) address.c_str()));
532  object_obex_dumpout(self, gensym("address"), 1, &a);
533  }
534 #endif
535 
536  selectedObject->getAttributeNames(names);
537 
538  for (i = 0; i < names.size(); i++) {
539 
540  aName = names[i];
541 
542  selectedObject->getAttributeValue(aName, v);
543 
544  s = jamoma_TTName_To_MaxName(aName);
545 
546  ac = 0;
547  av = NULL;
548  jamoma_ttvalue_to_Atom(v, &ac, &av);
549  object_obex_dumpout(self, s, ac, av);
550  sysmem_freeptr(av);
551  }
552 }
553 
554 
555 #ifdef UI_EXTERNAL
556 void wrappedModularClass_paint(WrappedModularInstancePtr x, t_object *view)
557 {
558  t_rect rect;
559  t_rect r;
560  t_jgraphics *g;
561  t_jsurface *jsurface;
562  unsigned char* data;
563  TTValue v;
564  TTErr err;
565  TTInt32 width;
566  TTInt32 height;
567  TTInt32 stride;
568 
569  g = (t_jgraphics*)patcherview_get_jgraphics(view); // obtain graphics context
570  jbox_get_rect_for_view((t_object *)x, view, &rect); // this is the box rectangle -- but we draw relative to 0 0, and thus only care about width & height
571 
572  v.resize(2);
573  v[0] = rect.width;
574  v[1] = rect.height;
575  err = selectedObject->sendMessage(TTSymbol("resize"), v);
576  err = selectedObject->sendMessage(TTSymbol("paint"));
577  err = selectedObject->sendMessage(TTSymbol("getData"), v);
578  if (!err) {
579  data = (unsigned char*)TTPtr(v);
580  v[1] width;
581  v[2] height;
582  v[3] stride;
583 
584  jsurface = jgraphics_image_surface_create_for_data(data, JGRAPHICS_FORMAT_ARGB32, width, height, stride, NULL, NULL);
585 
586  r.x = 0;
587  r.y = 0;
588  r.width = rect.width;
589  r.height = rect.height;
590  jgraphics_image_surface_draw(g, jsurface, r, r);
591  jgraphics_surface_destroy(jsurface);
592  }
593 }
594 
595 
596 TTPtr wrappedModularClass_oksize(TTPtr self, t_rect *newrect)
597 {
599  TTValue v;
600 
601  v.resize(4);
602  v[0] = 0.0;
603  v[1] = 0.0;
604  v[2] = newrect->width;
605  v[3] = newrect->height;
606 
607  selectedObject->sendMessage(TTSymbol("verifyResize"), v);
608 
609  v[2] newrect->width;
610  v[3] newrect->height;
611  return (void *)1;
612 }
613 
614 
615 void wrappedModularClass_mousedblclick(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
616 {
618  TTValue v;
619 
620  vresize(3);
621  v[0] = pt.x;
622  v[1] = pt.y;
623  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
624  selectedObject->sendMessage(TTSymbol("mouseDoubleClicked"), v);
625  jbox_redraw((t_jbox *)x);
626 }
627 
628 
629 void wrappedModularClass_mousedown(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
630 {
632  TTValue v;
633 
634  vresize(3);
635  v[0] = pt.x;
636  v[1] = pt.y;
637  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
638  selectedObject->sendMessage(TTSymbol("mouseDown"), v);
639  jbox_redraw((t_jbox *)x);
640 }
641 
642 
643 void wrappedModularClass_mousedrag(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
644 {
646  TTValue v;
647 
648  vresize(3);
649  v[0] = pt.x;
650  v[1] = pt.y;
651  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
652  selectedObject->sendMessage(TTSymbol("mouseDragged"), v);
653  jbox_redraw((t_jbox *)x);
654 }
655 
656 
657 void wrappedModularClass_mouseup(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
658 {
660  TTValue v;
661 
662  vresize(3);
663  v[0] = pt.x;
664  v[1] = pt.y;
665  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
666  selectedObject->sendMessage(TTSymbol("mouseUp"), v);
667  jbox_redraw((t_jbox *)x);
668 }
669 
670 
671 void wrappedModularClass_mouseenter(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
672 {
674  TTValue v;
675 
676  vresize(3);
677  v[0] = pt.x;
678  v[1] = pt.y;
679  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
680  selectedObject->sendMessage(TTSymbol("mouseEntered"), v);
681  jbox_redraw((t_jbox *)x);
682 }
683 
684 
685 void wrappedModularClass_mousemove(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
686 {
688  TTValue v;
689 
690  vresize(3);
691  v[0] = pt.x;
692  v[1] = pt.y;
693  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
694  selectedObject->sendMessage(TTSymbol("mouseMoved"), v);
695  jbox_redraw((t_jbox *)x);
696 }
697 
698 
699 void wrappedModularClass_mouseleave(TTPtr self, t_object *patcherview, t_pt pt, long modifiers)
700 {
702  TTValue v;
703 
704  vresize(3);
705  v[0] = pt.x;
706  v[1] = pt.y;
707  v[2] = convertModifiersFromMaxToTTGraphics(modifiers);
708  selectedObject->sendMessage(TTSymbol("mouseExited"), v);
709  jbox_redraw((t_jbox *)x);
710 }
711 
712 
713 int convertModifiersFromMaxToTTGraphics(int maxModifiers)
714 {
715  int ttGraphicsModifiers = 0;
716 
717  if (maxModifiers & eCapsLock)
718  ttGraphicsModifiers |= TTModifierCapslock;
719  else if (maxModifiers & eShiftKey)
720  ttGraphicsModifiers |= TTModifierShiftKey;
721  else if (maxModifiers & eControlKey)
722  ttGraphicsModifiers |= TTModifierControlKey;
723  else if (maxModifiers & eAltKey)
724  ttGraphicsModifiers |= TTModifierAltKey;
725  else if (maxModifiers & eCommandKey)
726  ttGraphicsModifiers |= TTModifierCommandKey;
727 
728  return ttGraphicsModifiers;
729 }
730 #endif
731 
732 
733 TTErr wrapTTModularClassAsMaxClass(TTSymbol& ttblueClassName, const char* maxClassName, WrappedClassPtr* c, ModularSpec* specificities)
734 {
735  TTObject o;
736  TTValue v, args;
737  WrappedClass* wrappedMaxClass = NULL;
738  TTSymbol TTName;
739  t_symbol *MaxName = NULL;
740  TTUInt16 i;
741 
742  jamoma_init();
743  common_symbols_init();
744 
745 #ifdef UI_EXTERNAL
746  TTGraphicsInit();
747 #endif
748 
749  if (!wrappedMaxClasses)
750  wrappedMaxClasses = hashtab_new(0);
751 
752  wrappedMaxClass = new WrappedClass;
753  wrappedMaxClass->maxClassName = gensym(maxClassName);
754  wrappedMaxClass->maxClass = class_new( maxClassName,
755  (method)wrappedModularClass_new,
756  (method)wrappedModularClass_free,
757  sizeof(WrappedModularInstance),
758  (method)0L,
759  A_GIMME,
760  0);
761  wrappedMaxClass->ttblueClassName = ttblueClassName;
762  wrappedMaxClass->validityCheck = NULL;
763  wrappedMaxClass->validityCheckArgument = NULL;
764  wrappedMaxClass->options = NULL;
765  wrappedMaxClass->maxNamesToTTNames = hashtab_new(0);
766 
767  wrappedMaxClass->specificities = specificities;
768 
769 #ifdef UI_EXTERNAL
770  jbox_initclass(wrappedMaxClass->maxClass, flags);
771  wrappedMaxClass->maxClass->c_flags |= CLASS_FLAG_NEWDICTIONARY; // to specify dictionary constructor
772 #endif
773 
774 #ifdef AUDIO_EXTERNAL
775  // Setup our class to work with MSP
776  class_dspinit(wrappedMaxClass->maxClass);
777 #endif
778 
779  // Create a temporary instance of the class so that we can query it.
780  o = TTObject(ttblueClassName);
781 
782  // Register Messages as Max method
783  o.messages(v);
784  for (i = 0; i < v.size(); i++) {
785  TTName = v[i];
786 
787 #ifdef UI_EXTERNAL
788  if (TTName == TTSymbol("mouseDown"))
789  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mousedown, "mousedown", A_CANT, 0);
790  else if (TTName == TTSymbol("mouseDragged"))
791  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mousedrag, "mousedrag", A_CANT, 0);
792  else if (TTName == TTSymbol("mouseUp"))
793  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mouseup, "mouseup", A_CANT, 0);
794  else if (TTName == TTSymbol("mouseEntered"))
795  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mouseenter, "mouseenter", A_CANT, 0);
796  else if (TTName == TTSymbol("mouseExited"))
797  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mouseleave, "mouseleave", A_CANT, 0);
798  else if (TTName == TTSymbol("mouseMoved"))
799  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mousemove, "mousemove", A_CANT, 0);
800  else if (TTName == TTSymbol("mouseDoubleClicked"))
801  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_mousedblclick,"mousedoubleclick", A_CANT, 0);
802  else if (TTName == TTSymbol("verifyResize"))
803  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedUIClass_oksize, "oksize", A_CANT, 0);
804  else
805 #endif
806  if (TTName == TTSymbol("test") ||
807  TTName == TTSymbol("getProcessingBenchmark") ||
808  TTName == TTSymbol("resetBenchmarking"))
809  continue;
810  else if ((MaxName = jamoma_TTName_To_MaxName(TTName))) {
811  hashtab_store(wrappedMaxClass->maxNamesToTTNames, MaxName, (t_object*)(TTName.rawpointer()));
812  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_anything, MaxName->s_name, A_GIMME, 0);
813  }
814  }
815 
816  // Register Attributes as Max attr
817  o.attributes(v);
818  for (i = 0; i < v.size(); i++) {
819  TTAttributePtr attr = NULL;
820  t_symbol *maxType = _sym_long;
821 
822  TTName = v[i];
823 
824 #ifdef AUDIO_EXTERNAL
825  // the enable word is already used by a message declared in the dsp_init method
826  if (TTName == TTSymbol("enable"))
827  continue;
828 #endif
829 
830  // we want to hide service attribute for Max external
831  if (TTName == TTSymbol("service"))
832  continue;
833 
834  if ((MaxName = jamoma_TTName_To_MaxName(TTName))) {
835 
836  if (TTName == kTTSym_bypass && wrappedMaxClass->maxClassName != gensym("j.in") && wrappedMaxClass->maxClassName != gensym("j.in~"))
837  continue;
838 
839  o.instance()->findAttribute(TTName, &attr);
840 
841  if (attr->type == kTypeFloat32)
842  maxType = _sym_float32;
843  else if (attr->type == kTypeFloat64)
844  maxType = _sym_float64;
845  else if (attr->type == kTypeSymbol || attr->type == kTypeString)
846  maxType = _sym_symbol;
847  else if (attr->type == kTypeLocalValue)
848  maxType = _sym_atom;
849 
850  hashtab_store(wrappedMaxClass->maxNamesToTTNames, MaxName, (t_object*)(TTName.rawpointer()));
851  class_addattr(wrappedMaxClass->maxClass, attr_offset_new(MaxName->s_name, maxType, 0, (method)wrappedModularClass_attrGet, (method)wrappedModularClass_attrSet, 0));
852 
853  // Add display styles for the Max 5 inspector
854  if (attr->type == kTypeBoolean)
855  CLASS_ATTR_STYLE(wrappedMaxClass->maxClass, (char*)TTName.c_str(), 0, "onoff");
856  if (TTName == TTSymbol("fontFace"))
857  CLASS_ATTR_STYLE(wrappedMaxClass->maxClass, "fontFace", 0, "font");
858  }
859  }
860 
861 #ifdef UI_EXTERNAL
862  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedClass_paint, "paint", A_CANT, 0L);
863 #endif
864  class_addmethod(wrappedMaxClass->maxClass, (method)stdinletinfo, "inletinfo", A_CANT, 0);
865  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_notify, "notify", A_CANT, 0);
866  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_shareContextNode, "share_context_node", A_CANT, 0);
867  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_anything, "anything", A_GIMME, 0);
868 
869  // Register specific methods and do specific things
870  if (specificities) {
871  if (specificities->_wrap)
872  specificities->_wrap(wrappedMaxClass);
873  }
874 
875  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_dump, "dump", A_GIMME, 0);
876 
877 #ifdef UI_EXTERNAL
878  CLASS_ATTR_DEFAULT(wrappedMaxClass->maxClass, "patching_rect", 0, "0. 0. 160. 160.");
879  CLASS_ATTR_MIN(wrappedMaxClass->maxClass, "patching_size", 0, "1. 1.");
880 #endif
881 
882 #ifdef ARRAY_EXTERNAL
883 
884  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_ArraySelect, "array/select", A_GIMME,0);
885  class_addmethod(wrappedMaxClass->maxClass, (method)wrappedModularClass_ArrayResize, "array/resize", A_LONG,0);
886 
887  CLASS_ATTR_SYM(wrappedMaxClass->maxClass, "format", 0, WrappedModularInstance, arrayAttrFormat);
888  CLASS_ATTR_ACCESSORS(wrappedMaxClass->maxClass, "format", wrappedModularClass_FormatGet, wrappedModularClass_FormatSet);
889  CLASS_ATTR_ENUM(wrappedMaxClass->maxClass, "format", 0, "single array");
890 #endif
891 
892  class_register(_sym_box, wrappedMaxClass->maxClass);
893  if (c)
894  *c = wrappedMaxClass;
895 
896  hashtab_store(wrappedMaxClasses, wrappedMaxClass->maxClassName, (t_object*)(wrappedMaxClass));
897  return kTTErrNone;
898 }
899 
900 
901 TTErr makeInternals_data(TTPtr self, TTAddress address, TTSymbol name, t_symbol *callbackMethod, TTPtr context, TTSymbol service, TTObject& returnedData, TTBoolean deferlow)
902 {
904  TTValue baton, v, out;
905  TTAddress dataAddress;
906  TTSymbol dataName;
907 
908  returnedData = TTObject(kTTSym_Data, service);
909 
910  baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
911 
912  returnedData.set(kTTSym_baton, baton);
913  returnedData.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
914 
915  // absolute registration
916  dataAddress = address.appendAddress(TTAddress(name));
917  v = TTValue(dataAddress, returnedData, context);
918  out = JamomaApplication.send("ObjectRegister", v);
919 
920  dataAddress = out[0];
921  dataName = dataAddress.getNameInstance();
922 
923  // absolute registration case : set the address in second position (see in unregister method)
924  v = TTValue(returnedData, dataAddress);
925  x->internals->append(dataName, v);
926 
927  JamomaDebug object_post((t_object*)x, "makes internal \"%s\" %s at : %s", dataName.c_str(), service.c_str(), dataAddress.c_str());
928 
929  return kTTErrNone;
930 }
931 
932 
933 TTErr makeInternals_explorer(TTPtr self, TTSymbol name, t_symbol *callbackMethod, TTObject& returnedExplorer, TTBoolean deferlow)
934 {
936  TTValue v, args, baton;
937  TTObject returnValueCallback;
938 
939  // check the internals do not exist yet
940  if (!x->internals->lookup(name, v)) {
941  returnedExplorer = v[0];
942  JamomaDebug object_post((t_object*)x, "makeInternals_explorer : \"%s\" internal already exists", name.c_str());
943  return kTTErrNone;
944  }
945 
946  // prepare arguments
947  returnValueCallback = TTObject("callback");
948 
949  baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
950 
951  returnValueCallback.set(kTTSym_baton, baton);
952  returnValueCallback.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
953  args.append(returnValueCallback);
954 
956 
957  returnedExplorer = TTObject(kTTSym_Explorer, args);
958 
959  // default registration case : store object only (see in unregister method)
960  x->internals->append(name, returnedExplorer);
961 
962  JamomaDebug object_post((t_object*)x, "makes internal \"%s\" explorer", name.c_str());
963 
964  return kTTErrNone;
965 }
966 
967 
968 TTErr makeInternals_viewer(TTPtr self, TTAddress address, TTSymbol name, t_symbol *callbackMethod, TTObject& returnedViewer, TTBoolean deferlow)
969 {
971  TTValue v, baton;
972  TTAddress adrs;
973 
974  // check the internals do not exist yet
975  if (!x->internals->lookup(name, v)) {
976  returnedViewer = v[0];
977  JamomaDebug object_post((t_object*)x, "makeInternals_viewer : \"%s\" internal already exists", name.c_str());
978  return kTTErrNone;
979  }
980 
981  returnedViewer = TTObject(kTTSym_Viewer);
982 
983  baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
984  returnedViewer.set(kTTSym_baton, baton);
985  returnedViewer.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
986 
987  // edit address
988  adrs = address.appendAddress(TTAddress(name));
989 
990  // default registration case : store object only (see in unregister method)
991  x->internals->append(name, returnedViewer);
992 
993  // set address attribute (after registration as the value can be updated in the same time)
994  returnedViewer.set(kTTSym_address, adrs);
995 
996  JamomaDebug object_post((t_object*)x, "makes internal \"%s\" viewer to bind on : %s", name.c_str(), adrs.c_str());
997 
998  return kTTErrNone;
999 }
1000 
1001 
1002 TTErr makeInternals_receiver(TTPtr self, TTAddress address, TTSymbol name, t_symbol *callbackMethod, TTObject& returnedReceiver, TTBoolean deferlow, TTBoolean appendNameAsAttribute)
1003 {
1005  TTValue v, args, baton;
1006  TTObject returnValueCallback, empty;
1007  TTAddress adrs;
1008 
1009  // check the internals do not exist yet
1010  if (!x->internals->lookup(name, v)) {
1011  returnedReceiver = v[0];
1012  JamomaDebug object_post((t_object*)x, "makeInternals_receiver : \"%s\" internal already exists", name.c_str());
1013  returnedReceiver.send("Get");
1014  return kTTErrNone;
1015  }
1016 
1017  // prepare arguments
1018 
1019  // we don't want the address back
1020  args.append(empty);
1021 
1022  returnValueCallback = TTObject("callback");
1023 
1024  baton = TTValue(TTPtr(x), TTPtr(callbackMethod), deferlow);
1025 
1026  returnValueCallback.set(kTTSym_baton, baton);
1027  returnValueCallback.set(kTTSym_function, TTPtr(&jamoma_callback_return_value));
1028  args.append(returnValueCallback);
1029 
1030  returnedReceiver = TTObject(kTTSym_Receiver, args);
1031 
1032  // edit address
1033  if (appendNameAsAttribute)
1034  adrs = address.appendAttribute(name);
1035  else
1036  adrs = address.appendAddress(TTAddress(name.c_str()));
1037 
1038  // default registration case : store object only (see in unregister method)
1039  x->internals->append(name, returnedReceiver);
1040 
1041  // set address attribute (after registration as the value can be updated in the same time)
1042  returnedReceiver.set(kTTSym_address, adrs);
1043 
1044  JamomaDebug object_post((t_object*)x, "makes internal \"%s\" receiver to bind on : %s", name.c_str(), adrs.c_str());
1045 
1046  return kTTErrNone;
1047 }
1048 
1049 TTErr makeInternals_sender(TTPtr self, TTAddress address, TTSymbol name, TTObject& returnedSender, TTBoolean appendNameAsAttribute)
1050 {
1052  TTValue v;
1053  TTAddress adrs;
1054 
1055  // check the internals do not exist yet
1056  if (!x->internals->lookup(name, v)) {
1057  returnedSender = v[0];
1058  JamomaDebug object_post((t_object*)x, "makeInternals_sender : \"%s\" internal already exists", name.c_str());
1059  return kTTErrNone;
1060  }
1061 
1062  returnedSender = TTObject(kTTSym_Sender);
1063 
1064  // edit address
1065  if (appendNameAsAttribute)
1066  adrs = address.appendAttribute(name);
1067  else
1068  adrs = address.appendAddress(TTAddress(name.c_str()));
1069 
1070  // default registration case : store object only (see in unregister method)
1071  x->internals->append(name, returnedSender);
1072 
1073  // set address attribute
1074  returnedSender.set(kTTSym_address, adrs);
1075 
1076  JamomaDebug object_post((t_object*)x, "makes internal \"%s\" sender to bind on : %s", name.c_str(), adrs.c_str());
1077 
1078  return kTTErrNone;
1079 }
1080 
1081 TTErr removeInternals_data(TTPtr self, TTAddress address, TTAddress name)
1082 {
1084  TTValue v;
1085  TTAddress dataAddress;
1086  TTErr err;
1087 
1088  err = x->internals->lookup(name, v);
1089 
1090  if (!err) {
1091 
1092  dataAddress = v[1];
1093 
1094  JamomaDebug object_post((t_object*)x, "Remove internal %s object at : %s", name.c_str(), dataAddress.c_str());
1095  JamomaApplication.send("ObjectUnregister", dataAddress);
1096 
1097  x->internals->remove(name);
1098  }
1099 
1100  return kTTErrNone;
1101 }
1102 
1103 
1105 {
1106  if (x->useInternals) {
1107  TTValue v;
1108  TTObject o;
1109  TTErr err;
1110 
1111  err = x->internals->lookup(x->cursor, v);
1112  if (!err)
1113  o = v[0];
1114 
1115  return o.instance();
1116  }
1117 #ifndef ARRAY_EXTERNAL
1118  else
1119  return x->wrappedObject.instance();
1120 #else
1121  else
1122  return NULL;
1123 #endif
1124 }
1125 
1126 
1127 void copy_msg_argc_argv(TTPtr self, t_symbol *msg, long argc, const t_atom *argv)
1128 {
1130  TTBoolean copyMsg = false;
1131  TTUInt32 i;
1132 
1133  if (msg != _sym_nothing && msg != _sym_int && msg != _sym_float && msg != _sym_symbol && msg != _sym_list)
1134  copyMsg = true;
1135 
1136  x->msg = msg;
1137 
1138  // prepare memory if needed
1139  if (x->argv == NULL) {
1140  x->argc = argc + copyMsg;
1141  x->argv = (t_atom*)sysmem_newptr(sizeof(t_atom) * x->argc);
1142  }
1143  // or resize memory if needed
1144  else if (x->argc != argc + copyMsg) {
1145  x->argc = argc + copyMsg;
1146  sysmem_freeptr(x->argv);
1147  x->argv = (t_atom*)sysmem_newptr(sizeof(t_atom) * x->argc);
1148  }
1149 
1150  // copy
1151  if (x->argc && x->argv) {
1152 
1153  if (copyMsg) {
1154  atom_setsym(&x->argv[0], msg);
1155  for (i = 1; i < (TTUInt32) x->argc; i++)
1156  x->argv[i] = argv[i-1];
1157  }
1158  else
1159  for (i = 0; i < (TTUInt32) x->argc; i++)
1160  x->argv[i] = argv[i];
1161  }
1162 }
1163 
1164 
1165 #ifdef ARRAY_EXTERNAL
1166 t_max_err wrappedModularClass_FormatGet(TTPtr self, TTPtr attr, long *ac, t_atom **av)
1167 {
1169 
1170  if ((*ac)&&(*av)) {
1171  //memory passed in, use it
1172  } else {
1173  //otherwise allocate memory
1174  *ac = 1;
1175  if (!(*av = (t_atom*)getbytes(sizeof(t_atom)*(*ac)))) {
1176  *ac = 0;
1177  return MAX_ERR_OUT_OF_MEM;
1178  }
1179  }
1180 
1181  atom_setsym(*av, x->arrayAttrFormat);
1182 
1183  return MAX_ERR_NONE;
1184 }
1185 
1186 
1187 t_max_err wrappedModularClass_FormatSet(TTPtr self, TTPtr attr, long ac, const t_atom *av)
1188 {
1190 
1191  if (ac&&av) {
1192  x->arrayAttrFormat = atom_getsym(av);
1193  } else {
1194  // no args, set to single
1195  x->arrayAttrFormat = gensym("single");
1196  }
1197  return MAX_ERR_NONE;
1198 }
1199 
1200 
1201 void wrappedModularClass_ArraySelect(TTPtr self, t_symbol *msg, long ac, const t_atom *av)
1202 {
1204  t_symbol *instanceAddress;
1205  TTUInt8 i;
1206  TTValue v;
1207 
1208  if (!x->internals->isEmpty()) {
1209 
1210  if (ac && av) {
1211  if (atom_gettype(av) == A_LONG) {
1212  i = atom_getlong(av);
1213  if (i > 0 && i <= x->arraySize) {
1214  x->arrayIndex = i;
1215  jamoma_edit_numeric_instance(x->arrayFormatInteger, &instanceAddress, i);
1216  x->cursor = TTSymbol(instanceAddress->s_name);
1217  }
1218  else
1219  object_error((t_object*)x, "array/select : %ld is not a valid index", i);
1220  }
1221  else if (atom_gettype(av) == A_SYM) {
1222 
1223  if (atom_getsym(av) == gensym("*")) {
1224  x->arrayIndex = 0;
1225  jamoma_edit_numeric_instance(x->arrayFormatInteger, &instanceAddress, 1);
1226  x->cursor = TTSymbol(instanceAddress->s_name);
1227  }
1228  else
1229  object_error((t_object*)x, "array/select : %s is not a valid index", atom_getsym(av)->s_name);
1230  }
1231  }
1232  else {
1233  if (msg == gensym("*")) {
1234  x->arrayIndex = 0;
1235  jamoma_edit_numeric_instance(x->arrayFormatInteger, &instanceAddress, 1);
1236  x->cursor = TTSymbol(instanceAddress->s_name);
1237  }
1238  else
1239  object_error((t_object*)x, "array/select : %s is not a valid index", msg->s_name);
1240  }
1241  }
1242  else
1243  object_error((t_object*)x, "array/select : the array is empty");
1244 }
1245 
1246 
1247 void wrappedModularClass_ArrayResize(TTPtr self, long newSize)
1248 {
1250  t_symbol *instanceAddress;
1251  TTString s_bracket;
1252  TTValue v;
1253 
1254  if (newSize >= 0) {
1255 
1256  v = TTInt64(newSize);
1257  v.toString();
1258 
1259  s_bracket = "[";
1260  s_bracket += TTString(v[0]);
1261  s_bracket += "]";
1262 
1263  jamoma_edit_string_instance(x->arrayFormatString, &instanceAddress, s_bracket.c_str());
1264 
1265  object_method((t_object*)x, gensym("address"), instanceAddress, 0, NULL);
1266  JamomaDebug object_post((t_object*)x, "array/resize : to %s address", instanceAddress->s_name);
1267  }
1268  else
1269  object_error((t_object*)x, "array/resize : %d is not a valid size", newSize);
1270 }
1271 #endif
1272 
TTAddress appendAddress(const TTAddress &toAppend)
Return a new TTAddress with the appended part.
Definition: TTAddress.h:167
TTObject subscriberObject
The instance of a TTSubscriber object used to register the wrapped object in the tree structure...
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
Definition: TTObject.cpp:135
void JAMOMA_EXPORT jamoma_edit_numeric_instance(TTString format, t_symbol **returnedName, long i)
Edit a new instance of the given format address using interger.
TTAddress appendAttribute(TTSymbol anAttribute)
Return a new TTAddress with attribute part.
Definition: TTAddress.h:161
void messages(TTValue &returnedMessageNames) const
Return a list of names of the available messages.
Definition: TTObject.cpp:123
This class represents a single message, as used by the TTObjectBase class.
Definition: TTMessage.h:55
TTErr wrapTTModularClassAsMaxClass(TTSymbol &ttblueClassName, const char *maxClassName, WrappedClassPtr *c, ModularSpec *specificities)
Wrap a Jamoma class as a Max class.
TTString toString(TTBoolean quotes=YES) const
Return the content as a single string with spaces between elements.
Definition: TTValue.h:351
TTErr lookup(const TTSymbol key, TTValue &value)
Find the value for the given key.
Definition: TTHash.cpp:76
We build a directory of TTNodes, and you can request a pointer for any TTNode, or add an observer to ...
Definition: TTNode.h:59
TTDataType type
The data type of the attribute value.
Definition: TTAttribute.h:84
TTAddress address
sometime external needs to store an address (e.g. send, receive, view, ...)
TTSymbol patcherClass
the patcher class in which the external is
const char * c_str() const
Return a pointer to the internal C-string.
Definition: TTString.h:83
The TTAddress class is used to represent a string and efficiently pass and compare that string...
Definition: TTAddress.h:29
Create and use Jamoma object instances.
Definition: TTObject.h:29
size_type size() const noexcept
Return the number of elements.
TTHashPtr JAMOMA_EXPORT jamoma_explorer_default_filter_bank(void)
void JAMOMA_EXPORT jamoma_callback_return_value(const TTValue &baton, const TTValue &v)
Return the value to a j.
t_object * patcherPtr
the patcher in which the external is (ignoring subpatcher)
TTErr getKeys(TTValue &hashKeys)
Get an array of all of the keys for the hash table.
Definition: TTHash.cpp:126
This class represents a single attribute, as used by the TTObjectBase class.
Definition: TTAttribute.h:79
Base class for all first-class Jamoma objects.
Definition: TTObjectBase.h:109
TTHashPtr internals
An hash table to store any internal TTObjectBases (like TTData, TTViewer, ...)
TTErr wrappedModularClass_sendMessage(TTPtr self, t_symbol *s, long argc, const t_atom *argv)
Maintain a collection of TTValue objects indexed by TTSymbol pointers.
Definition: TTHash.h:36
t_max_err wrappedModularClass_attrSet(TTPtr self, t_object *attr, long argc, const t_atom *argv)
Symbol type.
Definition: TTBase.h:282
t_max_err wrappedModularClass_attrGet(TTPtr self, t_object *attr, long *argc, t_atom **argv)
This is a special type used by TTAttribute to indicate that a value is a TTValue and is locally maint...
Definition: TTBase.h:286
void append(const T &anElementValueToAppend)
Insert a single TTElement at the end.
Definition: TTValue.h:243
void * TTPtr
A generic pointer.
Definition: TTBase.h:248
std::int64_t TTInt64
64 bit signed integer
Definition: TTBase.h:179
TTErr get(const TTSymbol aName, T &aReturnedValue) const
Get an attribute value for an object.
WrappedClassPtr wrappedClassDefinition
A pointer to the class definition.
TTPtr rawpointer() const
Get the value of the raw pointer into the symbol table.
Definition: TTSymbol.h:134
64-bit floating point
Definition: TTBase.h:272
void JAMOMA_EXPORT jamoma_ttvalue_to_Atom(const TTValue &v, long *argc, t_atom **argv)
Make an Atom array from a TTValue.
TTSymbol name() const
Return the name of this class.
Definition: TTObject.cpp:129
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
void copy_msg_argc_argv(TTPtr self, t_symbol *msg, long argc, const t_atom *argv)
tools to copy msg, argc and argv into the member msg, argc and argv of the WrappedModularInstance ...
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr append(const TTSymbol key, const TTValue &value)
Insert an item into the hash table.
Definition: TTHash.cpp:70
#define accessApplicationLocal
Access to local application.
t_symbol JAMOMA_EXPORT * jamoma_TTName_To_MaxName(TTSymbol TTName)
Convert a TTSymbol "MyObjectMessage" into a t_symbol *"my/object/message" or return NULL if the TTSym...
TTAddress patcherAddress
the patcher address in which the external is
Boolean (1/0) or (true/false) flag.
Definition: TTBase.h:281
TTBoolean iterateInternals
The flag is true when an iteration is done on the internals.
TTObject wrappedObject
The instance of the Jamoma object we are wrapping.
TTBoolean isEmpty()
Return true if the hash has nothing stored in it.
Definition: TTHash.cpp:205
TTSymbol getNameInstance()
Get the name.instance part.
Definition: TTAddress.h:142
void wrappedModularClass_anything(TTPtr self, t_symbol *s, long argc, t_atom *argv)
This method handles "anything" messages to the Max object that wraps the #TTModularClass.
const char * c_str() const
Return a pointer to the internal string as a C-string.
Definition: TTSymbol.h:77
std::int32_t TTInt32
32 bit signed integer
Definition: TTBase.h:177
TTErr clear()
Remove all items from the hash table.
Definition: TTHash.cpp:117
void JAMOMA_EXPORT jamoma_ttvalue_from_Atom(TTValue &v, t_symbol *msg, long argc, const t_atom *argv)
Make a TTValue from Atom array.
32-bit floating point
Definition: TTBase.h:271
Data Structure for this object.
Something went wrong, but what exactly is not known. Typically used for context-specific problems...
Definition: TTBase.h:344
TTErr remove(const TTSymbol key)
Remove an item from the hash table.
Definition: TTHash.cpp:108
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
Wraps Jamoma Core classes as objects for Max/MSP.
void attributes(TTValue &returnedAttributeNames) const
Return a list of names of the available attributes.
Definition: TTObject.cpp:111
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
TTSymbol patcherContext
the patcher context in which the external is (model, view)
TTBoolean useInternals
The hash table can be used as an array of wrappedObject.
TTSymbol patcherName
the patcher name in which the external is
TTErr wrappedModularClass_setAttribute(TTPtr self, t_symbol *s, long argc, const t_atom *argv)
TTObjectBase * instance() const
Return a direct pointer to the internal instance.
Definition: TTObject.cpp:105
No Error.
Definition: TTBase.h:343
The TTString class is used to represent a string.
Definition: TTString.h:34
TTSymbol cursor
to select an entry in x->internals
t_object * wrappedModularClass_new(t_symbol *name, long argc, t_atom *argv)
Wrapped methods ('self' has to be TTPtr because different wrappers (such as the ui wrapper) have diff...
String type.
Definition: TTBase.h:285
TTBoolean valid() const
Determine if the object contained by this TTObject is truly ready for use.
Definition: TTObject.cpp:179
void resize(size_type n)
Change the number of elements.
WrappedModularInstance * WrappedModularInstancePtr
Pointer to a wrapped instance of our object.
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
void JAMOMA_EXPORT jamoma_edit_string_instance(TTString format, t_symbol **returnedName, TTString s)
Edit a new instance of the given format address using string.
TTUInt16 getReferenceCount()
Query an object to get its current reference count.
Definition: TTObjectBase.h:144
TTObjectBasePtr getSelectedObject(WrappedModularInstancePtr x)
In case internals table is used as an array of wrappedObject here is a method usefull to get the sele...
TTErr findAttribute(const TTSymbol name, TTAttribute **attr)
Find an attribute.
unsigned char TTUInt8
8 bit unsigned integer (char)
Definition: TTBase.h:174