Beispiel #1
0
void CBDLL::call(const string &name, const void *in, int32_t inSize, void *out, int32_t outSize) {
	if (dll == 0) return;
	CBDLLFunction func = functions[name];
	if (func == 0) {
		func = (CBDLLFunction) getDLLFunction(dll, name);
		if (func == 0) {
			CBEnchanted::instance()->errors->createError("Can't call dll function", "Can't call dll function \"" + name + "\"");
			return;
		}
		functions[name] = func;
	}
	func(in, inSize, out, outSize);
}
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);
}