Jamoma API  0.6.0.a19
JamomaForPd.h
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationPdLibrary
4  *
5  * @brief Various utilities for interfacing with Pd that are not specific to JamomaModular as such.
6  *
7  * @details Functions and resources used by Pd objects.
8  *
9  * @authors Tim Place, Théo de la Hogue, Trond Lossius, Antoine Villeret
10  *
11  * @copyright Copyright © 2013, Tim Place & Théo de la Hogue @n
12  * Copyright © 2015, Antoine Villeret@n
13  * This code is licensed under the terms of the "New BSD License" @n
14  * http://creativecommons.org/licenses/BSD/
15  */
16 
17 #ifndef __JAMOMA_FOR_PD_H__
18 #define __JAMOMA_FOR_PD_H__
19 
20 typedef unsigned int t_fourcc; // Max specific type
21 
22 // define Pd log level
23 #define PD_LOG_WARN 2
24 #define MAX_FILENAME_CHARS MAXPDSTRING
25 
26 
27 #ifdef WIN_VERSION
28 #pragma warning(disable:4083) //warning C4083: expected 'newline'; found identifier 's'
29 #endif // WIN_VERSION
30 
31 #ifdef __APPLE__
32 #include <Carbon/Carbon.h>
33 #endif
34 
35 #ifdef TT_PLATFORM_WIN
36 
37  #include "windows.h"
38  #define JAMOMA_EXPORT_MAXOBJ __declspec(dllexport)
39 
40  #ifdef JAMOMA_EXPORTS
41  #define JAMOMA_EXPORT __declspec(dllexport)
42 
43  #else
44  #ifdef JAMOMA_STATIC
45  #define JAMOMA_EXPORT
46 
47  #else
48  #define JAMOMA_EXPORT __declspec(dllimport)
49 
50  #endif
51  #endif
52 
53 #else // TT_PLATFORM_MAC
54 
55  #define JAMOMA_EXPORT_MAXOBJ __attribute__((visibility("default")))
56 
57  #ifdef JAMOMA_EXPORTS
58  #define JAMOMA_EXPORT __attribute__((visibility("default")))
59  #else
60  #define JAMOMA_EXPORT
61  #endif
62 
63 #endif
64 
65 // Jamoma Core includes
66 #include "TTFoundationAPI.h"
67 #include "TTModular.h"
68 
69 // CicmWrapper
70 #ifdef __cplusplus
71 extern "C"
72 {
73 #endif
74  #include "cicm_wrapper.h"
75 #ifdef __cplusplus
76 }
77 #endif
78 #include "commonsyms.h"
79 
80 // standard includes
81 #include <math.h>
82 #include <stdlib.h>
83 
84 // Jamoma Pd includes
85 #include "JamomaPdVersion.h"
86 #include "JamomaObject.h"
87 #include "JamomaPdObjectTypes.h"
88 #include "JamomaSymbols.h"
89 #include "JamomaModularForPd.h"
90 // #include "JamomaPdSymbols.h"
91 
92 #define JAMOMA "Jamoma"
93 #define JAMOMA_UNIT_HEIGHT 35.0
94 #define JAMOMA_UNIT_WIDTH 150.0
95 #define JAMOMA_MENU_FONT "Arial"
96 #define JAMOMA_MENU_FONTSIZE 11.0
97 #define JAMOMA_DEFAULT_FONT "Verdana"
98 #define JAMOMA_DEFAULT_FONTSIZE 9.0
99 #define JAMOMA_BUTTON_FONT JAMOMA_DEFAULT_FONT
100 
101 // some more max to pd translation
102 #define sysmem_freeptr free
103 #define sysmem_newptr malloc
104 #define object_classname eobj_getclassname
105 #define MAX_PATH_CHARS 2048
106 #define attr_args_offset atoms_get_attributes_offset
107 #define attr_args_process ebox_attrprocess_viatoms
108 
109 void JAMOMA_EXPORT jamoma_init(void);
110 
111 
112 /** Utility function to perform an atom copy.
113  @param dst The destination t_atom.
114  @param src The t_atom to be copied.
115  */
116 void JAMOMA_EXPORT jamoma_atom_copy(t_atom *dst, t_atom *src);
117 
118 
119 /** Utility function to compare two t_atoms.
120  @param type The atom type of a1.
121  @param a1 A t_atom.
122  @param a2 The t_atom to compare against.
123  @return true if the t_atom's are the same.
124  */
125 bool JAMOMA_EXPORT jamoma_atom_compare(t_symbol *type, t_atom *a1, t_atom *a2);
126 
127 /** Compare two strings.
128  @param s1 Pointer to the first of the two strings to compare-
129  @param s2 Pointer to the second of the two strings to compare.
130  @return true if the strings are the same.
131  */
132 bool JAMOMA_EXPORT jamoma_string_compare(char *s1, char *s2);
133 
134 
135 /** Load obex externals for use within other externals.
136  @param objectname The object name (i.e. SymbolGen("j.send")).
137  @param argc Number of arguments to the external to be loaded.
138  @param argv Pointer to the first of an array of atom arguments to the external that is to be loaded.
139  @param object If the object is loaded successfully, this will be a pointer to the object pointer.
140  @return true if successfully loaded, otherwise false.
141  */
142 bool JAMOMA_EXPORT jamoma_loadextern(t_symbol *objectname, long argc, t_atom *argv, t_object **object);
143 
144 // prototype for some Max specific functions wrapped
145 t_symbol* JAMOMA_EXPORT object_attr_getsym(void *x, t_symbol *s); // Retrieves the value of an attribute, given its parent object and name.
146 void* JAMOMA_EXPORT object_attr_getobj(void *x, t_symbol *s);
147 method JAMOMA_EXPORT object_getmethod(void* x, t_symbol* s);
148 void* JAMOMA_EXPORT object_method(void *x, t_symbol *s);
149 void* JAMOMA_EXPORT object_method_typed(void* x, t_symbol* method, t_symbol* s, long argc, t_atom* argv);
150 // void* object_method_dsp64(void* x, t_symbol* method, void* s, void method2, long argc, void* argv);
151 short JAMOMA_EXPORT locatefile_extended(char *name, short *outvol, t_fourcc *outtype, const t_fourcc *filetypelist, short numtypes);
152 short JAMOMA_EXPORT path_topathname(const short path, const char *file, char *name);
153 
154 #endif //__JAMOMA_FOR_PD__
155 
Data types for Max objects that fit more naturally with the Jamoma coding style.
bool JAMOMA_EXPORT jamoma_loadextern(t_symbol *objectname, long argc, t_atom *argv, t_object **object)
Load obex externals for use within other externals.
The global Jamoma object.
bool JAMOMA_EXPORT jamoma_string_compare(char *s1, char *s2)
Compare two strings.
Jamoma symbols cached to avoid repeated calls to the expensive SymbolGen() function.
bool JAMOMA_EXPORT jamoma_atom_compare(t_symbol *type, t_atom *a1, t_atom *a2)
Utility function to compare two t_atoms.
JamomaModular For Max Shared Library.
void JAMOMA_EXPORT jamoma_atom_copy(t_atom *dst, t_atom *src)
Utility function to perform an atom copy.
the Modular Application Programming Interface