Changeset - r27351:5b8cef9d2152
[Not reviewed]
master
0 2 0
Rubidium - 13 months ago 2023-05-04 20:57:11
rubidium@openttd.org
Add: method to call script functions with std::string
2 files changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/script/squirrel.cpp
Show inline comments
 
@@ -442,6 +442,15 @@ bool Squirrel::CallStringMethodStrdup(HS
 
	return true;
 
}
 

	
 
bool Squirrel::CallStringMethod(HSQOBJECT instance, const char *method_name, std::string *res, int suspend)
 
{
 
	HSQOBJECT ret;
 
	if (!this->CallMethod(instance, method_name, &ret, suspend)) return false;
 
	if (ret._type != OT_STRING) return false;
 
	*res = StrMakeValid(ObjectToString(&ret));
 
	return true;
 
}
 

	
 
bool Squirrel::CallIntegerMethod(HSQOBJECT instance, const char *method_name, int *res, int suspend)
 
{
 
	HSQOBJECT ret;
src/script/squirrel.hpp
Show inline comments
 
@@ -160,6 +160,7 @@ public:
 
	bool CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT *ret, int suspend);
 
	bool CallMethod(HSQOBJECT instance, const char *method_name, int suspend) { return this->CallMethod(instance, method_name, nullptr, suspend); }
 
	bool CallStringMethodStrdup(HSQOBJECT instance, const char *method_name, const char **res, int suspend);
 
	bool CallStringMethod(HSQOBJECT instance, const char *method_name, const std::string *res, int suspend);
 
	bool CallIntegerMethod(HSQOBJECT instance, const char *method_name, int *res, int suspend);
 
	bool CallBoolMethod(HSQOBJECT instance, const char *method_name, bool *res, int suspend);
 

	
0 comments (0 inline, 0 general)