18 #if defined(TT_PLATFORM_WIN)
26 static long initialized =
false;
27 static std::map<std::string,std::string> *map_modules = NULL;
49 TTString* DocumentationFormat = NULL;
54 void jamoma_init(
void)
57 t_fourcc outtype, filetype =
'TEXT';
58 char name[MAX_PATH_CHARS];
63 t_object *pd_obj = (t_object *) SymbolGen(
"pd")->s_thing;
64 TTString JamomaConfigurationFilePath;
71 char mainBundleStr[4096];
72 mainBundleStr[0]=
'\0';
74 #if defined(TT_PLATFORM_WIN)
79 LPCSTR moduleName =
"JamomaFoundation.dll";
80 HMODULE hmodule = GetModuleHandle(moduleName);
82 GetModuleFileName(hmodule, (LPSTR)temppath, 4096);
84 if (!FAILED(hmodule) && temppath[0])
89 fullpath = fullpath.substr(0, fullpath.length() - (strlen(moduleName) + 1));
90 lRes = SHCreateDirectory(NULL, (LPCWSTR)fullpath.c_str());
93 strncpy(mainBundleStr, fullpath.c_str(), 4095);
97 if (dladdr((
const void*)jamoma_init, &info))
101 strncpy(mainBundleStr, info.dli_fname, 4095);
102 c = strrchr(mainBundleStr,
'/');
105 strcat(mainBundleStr,
"/../support");
108 TTLogError(
"support folder : %s \n", mainBundleStr);
115 JamomaApplicationManager =
TTObject(
"ApplicationManager");
118 err = JamomaApplicationManager.
send(
"ApplicationInstantiateLocal", kTTSym_Jamoma, out);
121 TTLogError(
"Error : can't create Jamoma application \n");
125 JamomaApplication = out[0];
128 long size = TTFoundationBinaryPath.
size() - std::string(
"support").size();
129 size = size > 0 ? size : 0;
130 JamomaConfigurationFilePath = TTFoundationBinaryPath.
substr(0,size);
131 JamomaConfigurationFilePath +=
"misc/JamomaConfiguration.xml";
138 TTObject anXmlHandler(kTTSym_XmlHandler);
139 anXmlHandler.
set(kTTSym_object, JamomaApplication);
140 err = anXmlHandler.
send(kTTSym_Read,
TTSymbol(JamomaConfigurationFilePath));
142 post(
"error %d : can't load configuration file \"%s\"", err, JamomaConfigurationFilePath.
c_str() );
145 common_symbols_init();
158 ModelPatcherFormat =
new TTString(
"%s.model.pd");
159 ModelPresetFormat =
new TTString(
"%s.model.presets.txt");
160 ViewPresetFormat =
new TTString(
"%s.view.presets.txt");
161 HelpPatcherFormat =
new TTString(
"%s.model");
162 RefpageFormat =
new TTString(
"%s.model");
163 DocumentationFormat =
new TTString(
"%s.model.html");
167 post(
"Jamoma for Pd version %s - %s | jamoma.org",JAMOMA_PD_VERSION, JAMOMA_PD_REV);
174 #pragma mark Utilities
181 memcpy(src, dst,
sizeof(t_atom));
190 if (atom_getfloat(a1) == atom_getfloat(a2))
194 if (atom_getint(a1) == atom_getint(a2))
198 if (atom_getsymbol(a1) == atom_getsymbol(a2))
204 if (a1->a_w.w_float == a2->a_w.w_float)
220 if ((a1->a_type == A_FLOAT) && (a2->a_type == A_FLOAT)) {
221 if (a1->a_w.w_float == a2->a_w.w_float)
224 else if ((a1->a_type == A_SYMBOL) && (a2->a_type == A_SYMBOL)) {
225 if (a1->a_w.w_symbol == a2->a_w.w_symbol)
230 error(
"atom_compare: cannot do comparison on this data type");
238 short len1 = strlen(s1);
239 short len2 = strlen(s2);
241 bool keepgoing =
true;
246 for (i =0 ; i < len1 && keepgoing; i++) {
251 else if (s1[i] > s2[i])
289 t_symbol *object_attr_getsym(
void *x, t_symbol *s){
292 t_symbol*retsym = _sym_nothing;
293 eclass_attr_getter((t_object *) x, s, &argc, &argv);
294 if ( argv && argv[0].a_type == A_SYMBOL){
295 retsym = argv[0].a_w.w_symbol;
301 void* object_attr_getobj(
void *x, t_symbol *attrname){
303 if ( attrname == _sym_parentpatcher ){
304 return ((t_canvas*)x)->gl_owner;
306 else if ( attrname == _sym_firstobject )
308 return ((t_canvas*)x)->gl_list;
329 method object_getmethod(
void* x, t_symbol* s)
331 return (method)zgetfn((t_pd *)x, s);
334 void* object_method_typed(
void* x, t_symbol* method, t_symbol* s,
long argc, t_atom* argv)
336 t_ret_method nrmethod = (t_ret_method)zgetfn((t_pd *)x, method);
337 return nrmethod(x, s, argc, argv);
340 void* object_method(
void *x, t_symbol *s)
342 t_ret_method nrmethod = (t_ret_method)zgetfn((t_pd *)x, s);
346 short locatefile_extended(
char *name,
short *outvol, t_fourcc *outtype,
const t_fourcc *filetypelist,
short numtypes)
350 char realname[MAXPDSTRING], dirbuf[MAXPDSTRING], *basename;
351 fd = open_via_path(
"", name,
"", dirbuf, &basename, MAXPDSTRING, 0);
355 short path_topathname(
const short path,
const char *file,
char *name)
359 char realname[MAXPDSTRING], dirbuf[MAXPDSTRING], *basename;
360 fd = open_via_path(NULL, file,
"", name, &basename, MAXPDSTRING, 0);
361 strcat(name,basename);
JAMOMA_EXPORT t_symbol * jps_generic
Pointer to the symbol "generic", one of the parameter and message data types.
JAMOMA_EXPORT t_symbol * jps_decimal
Pointer to the symbol "decimal", one of the parameter and message data types.
TTRegex * ttRegexForView
A global regex to parse .view.
TTErr send(const TTSymbol aName)
Send a message to this object with no arguments.
TTRegex * ttRegexForJcom
A global regex to parse j.
const char * c_str() const
Return a pointer to the internal C-string.
Create and use Jamoma object instances.
Various utilities for interfacing with Pd that are not specific to JamomaModular as such...
void jamoma_object_initclass(void)
Set up the class.
bool jamoma_string_compare(char *s1, char *s2)
Compare two strings.
void jamoma_atom_copy(t_atom *dst, t_atom *src)
Utility function to perform an atom copy.
JAMOMA_EXPORT t_symbol * jps_string
Pointer to the symbol "string", one of the parameter and message data types.
JAMOMA_EXPORT t_symbol * jps_integer
Pointer to the symbol "integer", one of the parameter and message data types.
TTRegex * ttRegexForModel
A global regex to parse .model.
TTRegex * ttRegexForJmod
A global regex to parse jmod. (usefull to detect a 0.5 module)
TTErr set(const TTSymbol aName, T aValue)
Set an attribute value for an object.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
void TTFOUNDATION_EXPORT TTLogError(TTImmutableCString message,...)
Platform and host independent method for posting errors.
JAMOMA_EXPORT t_symbol * jps_boolean
Pointer to the symbol "boolean", one of the parameter and message data types.
bool jamoma_atom_compare(t_symbol *type, t_atom *a1, t_atom *a2)
Utility function to compare two t_atoms.
TTString substr(size_t pos=0, size_t n=1) const
Returns a string object with its contents initialized to a substring of the current object...
TTRegex * ttRegexForPdpat
A global regex to parse .maxpat.
TTRegex * ttRegexForModule
A global regex to parse .module.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
size_t size() const
Find out the length of a string.
void TTMODULAR_EXPORT TTModularInit(const char *binaries=nullptr, bool loadFromBuiltinPaths=false)
Initialize the Modular library and intanciate the TTModular object.
The TTString class is used to represent a string.
JAMOMA_EXPORT t_symbol * jps_array
This is deprecated, please use #jps_list, jps_decimalArray or jps_integerArray instead.
TTRegex * ttRegexForBracket
A global regex to parse [ and ].
TTRegex * ttRegexForPdhelp
A global regex to parse .maxhelp.
[doxygenAppendixC_copyExample]
JAMOMA_EXPORT t_symbol * jps_decimalArray
Pointer to the symbol "decimalArray", one of the parameter and message data types. Used for arrays of decimal values.