57 std::string clean = line;
58 clean.erase(std::remove(clean.begin(), clean.end(),
';'), clean.end());
60 size_t paren = clean.find(
'(');
61 if (paren == std::string::npos)
64 std::string retAndName = clean.substr(0, paren);
65 std::string paramStr = clean.substr(paren + 1, clean.find(
')') - paren - 1);
67 std::istringstream iss(retAndName);
70 paramStr =
trim(paramStr);
71 if (paramStr.empty() || paramStr ==
"void")
74 std::istringstream pstream(paramStr);
76 while (std::getline(pstream, param,
','))
82 std::istringstream ps(param);
166 std::string inputFile =
"winapi.h";
167 std::string outputFile =
"phasor_winapi.cpp";
171 if (argc >= 4 && std::string(argv[2]) ==
"-o")
172 outputFile = argv[3];
174 std::ifstream infile(inputFile);
175 std::ofstream outfile(outputFile);
177 outfile <<
"#define PHASOR_FFI_BUILD_DLL\n";
178 outfile <<
"#include <PhasorFFI.h>\n";
179 outfile <<
"#include <windows.h>\n";
180 outfile <<
"#include \"../src/Bindings/win32/handle.hpp\"\n\n";
181 outfile <<
"// =====BEGIN PATCHES=====\n";
182 for (
const auto &patch :
PATCHES)
184 outfile << patch <<
"\n";
186 outfile <<
"// ======END PATCHES======\n\n";
190 std::vector<Function> funcs;
192 while (std::getline(infile, line))
203 for (
const auto &f : funcs)
206 outfile <<
"PHASOR_FFI_EXPORT void phasor_plugin_entry(const PhasorAPI* api, PhasorVM* vm) {\n";
207 for (
const auto &f : funcs)
209 outfile <<
" api->register_function(vm, \"win32_" << f.name <<
"\", win32_" << f.name <<
");\n";
bool isSupportedParam(const std::string &type)
std::string trim(const std::string &str)
const std::vector< std::string > PATCHES
bool isHandleType(const std::string &type)
Function parseFunction(const std::string &line, int lineNumber)
void generateWrapper(const Function &f, std::ostream &out)