1 /************************************************************************ 2 ************************************************************************ 3 Copyright (C) 2003-2017 GRAME, Centre National de Creation Musicale 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU Lesser General Public License as published by 7 the Free Software Foundation; either version 2.1 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 ************************************************************************ 20 ************************************************************************/ 21 22 #ifndef LIBFAUST_H 23 #define LIBFAUST_H 24 25 #include <string> 26 #include <string.h> 27 28 /*! 29 \addtogroup libfaustcpp C++ interface for the tools API. 30 @{ 31 */ 32 33 #ifdef _WIN32 34 #define LIBEXPORT __declspec(dllexport) 35 #else 36 #define LIBEXPORT 37 #endif 38 39 /** 40 * Generate SHA1 key from a string. 41 * 42 * @param data - the string to be converted in SHA1 key 43 * 44 * @return the SHA key. 45 */ 46 LIBEXPORT std::string generateSHA1(const std::string& data); 47 48 /** 49 * Expand a DSP source code into a self-contained DSP where all library import have been inlined starting from a 50 * filename. 51 * 52 * @param filename - the DSP filename 53 * @param argc - the number of parameters in argv array 54 * @param argv - the array of parameters (Warning : aux files generation options will be filtered (-svg, ...) --> use 55 * generateAuxFiles) 56 * @param sha_key - a SHA key to be filled by for the resulting DSP 57 * @param error_msg - the error string to be filled 58 * 59 * @return the expanded DSP or an empty string in case of failure. 60 */ 61 LIBEXPORT std::string expandDSPFromFile(const std::string& filename, int argc, const char* argv[], std::string& sha_key, 62 std::string& error_msg); 63 64 /** 65 * Expand a DSP source code into a self-contained DSP where all library import have been inlined starting from a string. 66 * 67 * @param filename - the DSP filename 68 * @param argc - the number of parameters in argv array 69 * @param argv - the array of parameters (Warning : aux files generation options will be filtered (-svg, ...) --> use 70 * generateAuxFiles) 71 * @param sha_key - a SHA key to be filled by for the resulting DSP 72 * @param error_msg - the error string to be filled 73 * 74 * @return the expanded DSP or a empty string in case of failure. 75 */ 76 LIBEXPORT std::string expandDSPFromString(const std::string& name_app, const std::string& dsp_content, int argc, 77 const char* argv[], std::string& sha_key, std::string& error_msg); 78 79 /** 80 * Generate additional file (other backends, SVG, XML, JSON...) starting from a filename. 81 * 82 * @param filename - the DSP filename 83 * @param argc - the number of parameters in argv array 84 * @param argv - the array of parameters 85 * @param error_msg - the error string to be filled 86 * 87 * @return the expanded DSP or an empty string in case of failure. 88 */ 89 LIBEXPORT bool generateAuxFilesFromFile(const std::string& filename, int argc, const char* argv[], 90 std::string& error_msg); 91 92 /** 93 * Generate additional file (other backends, SVG, XML, JSON...) starting from a string. 94 * 95 * @param filename - the DSP filename 96 * @param argc - the number of parameters in argv array 97 * @param argv - the array of parameters 98 * @param error_msg - the error string to be filled 99 * 100 * @return the expanded DSP or a empty string in case of failure. 101 */ 102 LIBEXPORT bool generateAuxFilesFromString(const std::string& name_app, const std::string& dsp_content, int argc, 103 const char* argv[], std::string& error_msg); 104 105 /** 106 * The free function to be used on memory returned by getCDSPMachineTarget, getCName, getCSHAKey, 107 * getCDSPCode, getCLibraryList, getAllCDSPFactories, writeCDSPFactoryToBitcode, 108 * writeCDSPFactoryToIR, writeCDSPFactoryToMachine,expandCDSPFromString and expandCDSPFromFile. 109 * 110 * This is MANDATORY on Windows when otherwise all nasty runtime version related crashes can occur. 111 * 112 * @param ptr - the pointer to be deleted. 113 */ 114 #ifdef EMCC 115 extern "C" void freeCMemory(void* ptr); 116 #else 117 extern "C" LIBEXPORT void freeCMemory(void* ptr); 118 #endif 119 120 /*! 121 @} 122 */ 123 124 #endif 125