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