void cbeLoadLibrary(CBEnchanted *cb) { bool t = cb->popValue().toBool(); typedef void (*cbeInitializeLibraryFuncType)(CBEnchanted *); const ISString &path = cb->popValue().toString(); void * dll = loadDLL(path); if (!dll) { cb->errors->createError("Cannot open dll file " + path.getStdString()); cb->pushValue(0); return; } cbeInitializeLibraryFuncType cbeInitializeLibrary = (cbeInitializeLibraryFuncType)getDLLFunction(dll, "cbeInitializeLibrary"); if (!cbeInitializeLibrary) { cb->errors->createError("Cannot find cbeInitilizeLibrary function from " + path.getStdString()); cb->pushValue(0); return; } cbeInitializeLibrary(cb); if (t) cb->getCustomFunctionHandler()->link(); cb->pushValue(1); }
bool CBDLL::load(const ISString &f) { dll = loadDLL(f); return dll != 0; }