Skip to content

Commit 4a31036

Browse files
committed
Rename native StringToInt64Ex to StringToI64
1 parent 9812a80 commit 4a31036

3 files changed

Lines changed: 62 additions & 62 deletions

File tree

core/logic/smn_string.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static cell_t StringToInt64(IPluginContext *pCtx, const cell_t *params)
155155
return dummy - str;
156156
}
157157

158-
static cell_t StringToInt64Ex(IPluginContext *pCtx, const cell_t *params)
158+
static cell_t StringToI64(IPluginContext *pCtx, const cell_t *params)
159159
{
160160
cell_t* out;
161161
if (int err = pCtx->LocalToPhysAddr(params[1], &out); err != SP_ERROR_NONE)
@@ -165,12 +165,12 @@ static cell_t StringToInt64Ex(IPluginContext *pCtx, const cell_t *params)
165165
if (int err = pCtx->LocalToString(params[2], &str); err != SP_ERROR_NONE)
166166
return pCtx->ThrowNativeErrorEx(err, "Invalid str (error %d)", err);
167167

168-
cell_t *bytes;
169-
if (int err = pCtx->LocalToPhysAddr(params[3], &bytes); err != SP_ERROR_NONE)
170-
return pCtx->ThrowNativeErrorEx(err, "Invalid bytes (error %d)", err);
168+
cell_t *consumed;
169+
if (int err = pCtx->LocalToPhysAddr(params[4], &consumed); err != SP_ERROR_NONE)
170+
return pCtx->ThrowNativeErrorEx(err, "Invalid nConsumed (error %d)", err);
171171

172-
*reinterpret_cast<int64_t*>(out) = strtoll(str, &dummy, params[4]);
173-
*bytes = dummy - str;
172+
*reinterpret_cast<int64_t*>(out) = strtoll(str, &dummy, params[3]);
173+
*consumed = dummy - str;
174174
return 0;
175175
}
176176

@@ -655,7 +655,7 @@ REGISTER_NATIVES(basicStrings)
655655
{"StringToInt", sm_strconvint},
656656
{"StringToIntEx", StringToIntEx},
657657
{"StringToInt64", StringToInt64},
658-
{"StringToInt64Ex", StringToInt64Ex},
658+
{"StringToI64", StringToI64},
659659
{"StringToFloat", sm_strtofloat},
660660
{"StringToFloatEx", StringToFloatEx},
661661
{"StripQuotes", StripQuotes},

plugins/include/string.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ native int StringToIntEx(const char[] str, int &result, int nBase=10);
213213
native int StringToInt64(const char[] str, int result[2], int nBase=10);
214214
215215
/**
216-
* Converts a string to an int64 value.
216+
* Converts a string to an int64 type value.
217217
*
218218
* @param str String to convert.
219-
* @param bytes Number of characters consumed.
220219
* @param nBase Numerical base to use. 10 is default.
220+
* @param nConsumed Number of characters consumed.
221221
* @return int64 conversion of string, or 0 on failure.
222222
*/
223-
native int64 StringToInt64Ex(const char[] str, int &bytes=0, int nBase=10);
223+
native int64 StringToI64(const char[] str, int nBase=10, int &nConsumed=0);
224224
225225
/**
226226
* Converts an integer to a string.

plugins/testsuite/mock/test_string.sp

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,102 +7,102 @@
77

88
public void OnPluginStart()
99
{
10-
Test_StringToInt64Ex();
10+
Test_StringToI64();
1111
}
1212

1313

14-
void Test_StringToInt64Ex()
14+
void Test_StringToI64()
1515
{
16-
SetTestContext("Test StringToInt64Ex");
16+
SetTestContext("Test StringToI64");
1717

18-
AssertInt64Eq("DEC 0", StringToInt64Ex("0"), 0);
19-
AssertInt64Eq("DEC 1234567", StringToInt64Ex("1234567"), 1234567);
20-
AssertInt64Eq("DEC 1234567654321", StringToInt64Ex("1234567654321"), 1234567654321);
21-
AssertInt64Eq("DEC 9223372036854775807", StringToInt64Ex("9223372036854775807"), 9223372036854775807);
22-
AssertInt64Eq("DEC -1234567", StringToInt64Ex("-1234567"), -1234567);
23-
AssertInt64Eq("DEC -1234567654321", StringToInt64Ex("-1234567654321"), -1234567654321);
24-
AssertInt64Eq("DEC -9223372036854775807", StringToInt64Ex("-9223372036854775807"), -9223372036854775807);
18+
AssertInt64Eq("DEC 0", StringToI64("0"), 0);
19+
AssertInt64Eq("DEC 1234567", StringToI64("1234567"), 1234567);
20+
AssertInt64Eq("DEC 1234567654321", StringToI64("1234567654321"), 1234567654321);
21+
AssertInt64Eq("DEC 9223372036854775807", StringToI64("9223372036854775807"), 9223372036854775807);
22+
AssertInt64Eq("DEC -1234567", StringToI64("-1234567"), -1234567);
23+
AssertInt64Eq("DEC -1234567654321", StringToI64("-1234567654321"), -1234567654321);
24+
AssertInt64Eq("DEC -9223372036854775807", StringToI64("-9223372036854775807"), -9223372036854775807);
2525

26-
int bytes;
26+
int nConsumed;
2727

28-
// bytes
28+
// nConsumed
2929
AssertInt64Eq(
30-
"result 0",
31-
StringToInt64Ex("0", bytes),
30+
"result 0",
31+
StringToI64("0", .nConsumed=nConsumed),
3232
0);
33-
AssertEq("bytes 0", bytes, 1);
33+
AssertEq("nConsumed 0", nConsumed, 1);
3434

3535
AssertInt64Eq(
36-
"result 1234567",
37-
StringToInt64Ex("1234567", bytes),
36+
"result 1234567",
37+
StringToI64("1234567", .nConsumed=nConsumed),
3838
1234567);
39-
AssertEq("bytes 1234567", bytes, 7);
39+
AssertEq("nConsumed 1234567", nConsumed, 7);
4040

4141
AssertInt64Eq(
42-
"result 1234567654321",
43-
StringToInt64Ex("1234567654321", bytes),
42+
"result 1234567654321",
43+
StringToI64("1234567654321", .nConsumed=nConsumed),
4444
1234567654321);
45-
AssertEq("bytes 1234567654321", bytes, 13);
45+
AssertEq("nConsumed 1234567654321", nConsumed, 13);
4646

4747
AssertInt64Eq(
48-
"result 9223372036854775807",
49-
StringToInt64Ex("9223372036854775807", bytes),
48+
"result 9223372036854775807",
49+
StringToI64("9223372036854775807", .nConsumed=nConsumed),
5050
9223372036854775807);
51-
AssertEq("bytes 9223372036854775807", bytes, 19);
51+
AssertEq("nConsumed 9223372036854775807", nConsumed, 19);
5252

5353
AssertInt64Eq(
54-
"result -1234567",
55-
StringToInt64Ex("-1234567", bytes),
54+
"result -1234567",
55+
StringToI64("-1234567", .nConsumed=nConsumed),
5656
-1234567);
57-
AssertEq("bytes -1234567", bytes, 8);
57+
AssertEq("nConsumed -1234567", nConsumed, 8);
5858

5959
AssertInt64Eq(
60-
"result -1234567654321",
61-
StringToInt64Ex("-1234567654321", bytes),
60+
"result -1234567654321",
61+
StringToI64("-1234567654321", .nConsumed=nConsumed),
6262
-1234567654321);
63-
AssertEq("bytes -1234567654321", bytes, 14);
63+
AssertEq("nConsumed -1234567654321", nConsumed, 14);
6464

6565
AssertInt64Eq(
66-
"result -9223372036854775807",
67-
StringToInt64Ex("-9223372036854775807", bytes),
66+
"result -9223372036854775807",
67+
StringToI64("-9223372036854775807", .nConsumed=nConsumed),
6868
-9223372036854775807);
69-
AssertEq("bytes -9223372036854775807", bytes, 20);
69+
AssertEq("nConsumed -9223372036854775807", nConsumed, 20);
7070

7171
// Special nBase
7272
AssertInt64Eq(
73-
"result 10001111101110001111101110110101110110001",
74-
StringToInt64Ex("10001111101110001111101110110101110110001", bytes, 2),
73+
"result 10001111101110001111101110110101110110001",
74+
StringToI64("10001111101110001111101110110101110110001", 2, nConsumed),
7575
1234567654321);
76-
AssertEq("bytes 10001111101110001111101110110101110110001", bytes, 41);
76+
AssertEq("nConsumed 10001111101110001111101110110101110110001", nConsumed, 41);
7777

7878
AssertInt64Eq(
79-
"result 21756175665661",
80-
StringToInt64Ex("21756175665661", bytes, 8),
79+
"result 21756175665661",
80+
StringToI64("21756175665661", 8, nConsumed),
8181
1234567654321);
82-
AssertEq("bytes 11F71F76BB1", bytes, 14);
82+
AssertEq("nConsumed 21756175665661", nConsumed, 14);
8383

8484
AssertInt64Eq(
85-
"result 11F71F76BB1",
86-
StringToInt64Ex("11F71F76BB1", bytes, 16),
85+
"result 11F71F76BB1",
86+
StringToI64("11F71F76BB1", 16, nConsumed),
8787
1234567654321);
88-
AssertEq("bytes 11F71F76BB1", bytes, 11);
88+
AssertEq("nConsumed 11F71F76BB1", nConsumed, 11);
8989

90-
// Orther
90+
// Other
9191
AssertInt64Eq(
92-
"result a1b2c3d4e5f6g7",
93-
StringToInt64Ex("a1b2c3d4e5f6g7", bytes),
92+
"result a1b2c3d4e5f6g7",
93+
StringToI64("a1b2c3d4e5f6g7", .nConsumed=nConsumed),
9494
0);
95-
AssertEq("bytes a1b2c3d4e5f6g7", bytes, 0);
95+
AssertEq("nConsumed a1b2c3d4e5f6g7", nConsumed, 0);
9696

9797
AssertInt64Eq(
98-
"result 0b10101",
99-
StringToInt64Ex("0b10101", bytes),
98+
"result 0b10101",
99+
StringToI64("0b10101", .nConsumed=nConsumed),
100100
0);
101-
AssertEq("bytes 0b10101", bytes, 1);
101+
AssertEq("nConsumed 0b10101", nConsumed, 1);
102102

103103
AssertInt64Eq(
104-
"result 1_234_567",
105-
StringToInt64Ex("1_234_567", bytes),
104+
"result 1_234_567",
105+
StringToI64("1_234_567", .nConsumed=nConsumed),
106106
1);
107-
AssertEq("bytes 1_234_567", bytes, 1);
107+
AssertEq("nConsumed 1_234_567", nConsumed, 1);
108108
}

0 commit comments

Comments
 (0)