* angelscript接入

This commit is contained in:
2024-09-06 19:00:30 +08:00
parent e001346c46
commit 08e4233eaf
11 changed files with 179 additions and 5 deletions
@@ -8,7 +8,10 @@
#include <locale.h> // setlocale()
#endif
using namespace std;
//using namespace std;
using std::string;
using std::unordered_map;
using std::ostringstream;
// This macro is used to avoid warnings about unused variables.
// Usually where the variables are only used in debug mode.
@@ -335,6 +338,11 @@ static string AddBoolString(bool b, const string &str)
stream << (b ? "true" : "false");
return stream.str() + str;
}
static string AddStringString(const string& str0, const string& str1)
{
return str0 + str1;
}
#endif
static char *StringCharAt(unsigned int i, string &str)
@@ -773,7 +781,7 @@ void RegisterStdString_Native(asIScriptEngine *engine)
// Need to use a wrapper for operator== otherwise gcc 4.7 fails to compile
r = engine->RegisterObjectMethod("string", "bool opEquals(const string &in) const", asFUNCTIONPR(StringEquals, (const string &, const string &), bool), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "int opCmp(const string &in) const", asFUNCTION(StringCmp), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "string opAdd(const string &in) const", asFUNCTIONPR(operator +, (const string &, const string &), string), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
r = engine->RegisterObjectMethod("string", "string opAdd(const string &in) const", asFUNCTIONPR(AddStringString, (const string &, const string &), string), asCALL_CDECL_OBJFIRST); assert( r >= 0 );
// The string length can be accessed through methods or through virtual property
// TODO: Register as size() for consistency with other types