Fix compatibility issue in Call_PushStringEx.
When we changed the C++ API, we forgot to add a compatibility workaround for functions.inc which had matching constants. Fix that now in smn_functions.cpp. Bug: issue #2481
This commit is contained in:
@@ -512,6 +512,8 @@ static cell_t sm_CallPushString(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static_assert(SM_PARAM_COPYBACK == (1 << 0), "SM_PARAM_COPYBACK should match functions.inc");
|
||||
|
||||
static cell_t sm_CallPushStringEx(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
char *value;
|
||||
@@ -524,7 +526,17 @@ static cell_t sm_CallPushStringEx(IPluginContext *pContext, const cell_t *params
|
||||
if (int err = pContext->LocalToString(params[1], &value); err != SP_ERROR_NONE)
|
||||
return pContext->ThrowNativeErrorEx(err, nullptr);
|
||||
|
||||
sArgs.PushString(value, params[2], params[3] | params[4]);
|
||||
int sz_flags = params[3];
|
||||
int cp_flags = params[4];
|
||||
int translated_flags = cp_flags;
|
||||
if (sz_flags & (1 << 0))
|
||||
translated_flags |= SM_PARAM_STRING_UTF8;
|
||||
if (sz_flags & (1 << 1))
|
||||
translated_flags |= SM_PARAM_STRING_COPY;
|
||||
if (sz_flags & (1 << 2))
|
||||
translated_flags |= SM_PARAM_STRING_BINARY;
|
||||
|
||||
sArgs.PushString(value, params[2], translated_flags);
|
||||
|
||||
if (sArgs.error)
|
||||
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user