Compare commits
1 Commits
master
...
release/v0
Author | SHA1 | Date |
---|---|---|
Rafal Kupiec | 7076a6f3ed |
24
.build.yml
24
.build.yml
|
@ -1,14 +1,10 @@
|
||||||
kind: pipeline
|
pipeline:
|
||||||
type: exec
|
step: compile
|
||||||
name: AerScript Build
|
commands:
|
||||||
|
- make debug
|
||||||
steps:
|
step: install
|
||||||
- name: compile
|
commands:
|
||||||
commands:
|
- make install
|
||||||
- make release
|
step: test
|
||||||
- name: install
|
commands:
|
||||||
commands:
|
- make tests
|
||||||
- make install
|
|
||||||
- name: test
|
|
||||||
commands:
|
|
||||||
- make tests
|
|
||||||
|
|
|
@ -879,7 +879,7 @@ const char *ph7_value_to_string(ph7_value *pValue, int *pLen) {
|
||||||
*/
|
*/
|
||||||
void *ph7_value_to_resource(ph7_value *pValue) {
|
void *ph7_value_to_resource(ph7_value *pValue) {
|
||||||
if((pValue->nType & MEMOBJ_RES) == 0) {
|
if((pValue->nType & MEMOBJ_RES) == 0) {
|
||||||
/* Not a resource, return NULL */
|
/* Not a resource,return NULL */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return pValue->x.pOther;
|
return pValue->x.pOther;
|
||||||
|
|
232
engine/builtin.c
232
engine/builtin.c
|
@ -220,7 +220,7 @@ static int PH7_builtin_round(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
double r;
|
double r;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ static int PH7_builtin_round(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_dechex(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_dechex(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iVal;
|
int iVal;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ static int PH7_builtin_dechex(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_decoct(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_decoct(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iVal;
|
int iVal;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ static int PH7_builtin_decoct(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_decbin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_decbin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iVal;
|
int iVal;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ static int PH7_builtin_hexdec(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_int64 iVal;
|
ph7_int64 iVal;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return -1 */
|
/* Missing arguments,return -1 */
|
||||||
ph7_result_int(pCtx, -1);
|
ph7_result_int(pCtx, -1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ static int PH7_builtin_bindec(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_int64 iVal;
|
ph7_int64 iVal;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return -1 */
|
/* Missing arguments,return -1 */
|
||||||
ph7_result_int(pCtx, -1);
|
ph7_result_int(pCtx, -1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ static int PH7_builtin_octdec(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_int64 iVal;
|
ph7_int64 iVal;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return -1 */
|
/* Missing arguments,return -1 */
|
||||||
ph7_result_int(pCtx, -1);
|
ph7_result_int(pCtx, -1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ static int PH7_builtin_substr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zSource = ph7_value_to_string(apArg[0], &nSrcLen);
|
zSource = ph7_value_to_string(apArg[0], &nSrcLen);
|
||||||
if(nSrcLen < 1) {
|
if(nSrcLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ static int PH7_builtin_substr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract the length */
|
/* Extract the length */
|
||||||
nLen = ph7_value_to_int(apArg[2]);
|
nLen = ph7_value_to_int(apArg[2]);
|
||||||
if(nLen == 0) {
|
if(nLen == 0) {
|
||||||
/* Invalid length, return an empty string */
|
/* Invalid length,return an empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
} else if(nLen < 0) {
|
} else if(nLen < 0) {
|
||||||
|
@ -653,14 +653,14 @@ static int PH7_builtin_substr_compare(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
int iCase = 0;
|
int iCase = 0;
|
||||||
int rc;
|
int rc;
|
||||||
if(nArg < 3) {
|
if(nArg < 3) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zSource = ph7_value_to_string(apArg[0], &nSrcLen);
|
zSource = ph7_value_to_string(apArg[0], &nSrcLen);
|
||||||
if(nSrcLen < 1) {
|
if(nSrcLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -668,7 +668,7 @@ static int PH7_builtin_substr_compare(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
/* Extract the substring */
|
/* Extract the substring */
|
||||||
zSub = ph7_value_to_string(apArg[1], &nSublen);
|
zSub = ph7_value_to_string(apArg[1], &nSublen);
|
||||||
if(nSublen < 1 || nSublen > nSrcLen) {
|
if(nSublen < 1 || nSublen > nSrcLen) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -749,7 +749,7 @@ static int PH7_builtin_substr_count(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
/* Point to the neddle */
|
/* Point to the neddle */
|
||||||
zPattern = ph7_value_to_string(apArg[1], &nPatlen);
|
zPattern = ph7_value_to_string(apArg[1], &nPatlen);
|
||||||
if(nTextlen < 1 || nPatlen < 1 || nPatlen > nTextlen) {
|
if(nTextlen < 1 || nPatlen < 1 || nPatlen > nTextlen) {
|
||||||
/* NOOP, return zero */
|
/* NOOP,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -758,7 +758,7 @@ static int PH7_builtin_substr_count(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
/* Extract the offset */
|
/* Extract the offset */
|
||||||
nOfft = ph7_value_to_int(apArg[2]);
|
nOfft = ph7_value_to_int(apArg[2]);
|
||||||
if(nOfft < 0 || nOfft > nTextlen) {
|
if(nOfft < 0 || nOfft > nTextlen) {
|
||||||
/* Invalid offset, return zero */
|
/* Invalid offset,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -774,7 +774,7 @@ static int PH7_builtin_substr_count(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
/* Extract the length */
|
/* Extract the length */
|
||||||
nLen = ph7_value_to_int(apArg[3]);
|
nLen = ph7_value_to_int(apArg[3]);
|
||||||
if(nLen < 0 || nLen > nTextlen) {
|
if(nLen < 0 || nLen > nTextlen) {
|
||||||
/* Invalid length, return 0 */
|
/* Invalid length,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -817,7 +817,7 @@ static int PH7_builtin_chunk_split(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const char *zIn, *zEnd, *zSep = "\r\n";
|
const char *zIn, *zEnd, *zSep = "\r\n";
|
||||||
int nSepLen, nChunkLen, nLen;
|
int nSepLen, nChunkLen, nLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Nothing to split, return null */
|
/* Nothing to split,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ static int PH7_builtin_chunk_split(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
}
|
}
|
||||||
/* Perform the requested operation */
|
/* Perform the requested operation */
|
||||||
if(nChunkLen > nLen) {
|
if(nChunkLen > nLen) {
|
||||||
/* Nothing to split, return the string and the separator */
|
/* Nothing to split,return the string and the separator */
|
||||||
ph7_result_string_format(pCtx, "%.*s%.*s", nLen, zIn, nSepLen, zSep);
|
ph7_result_string_format(pCtx, "%.*s%.*s", nLen, zIn, nSepLen, zSep);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -917,7 +917,7 @@ static int cSlashCheckMask(int c, const char *zMask, int nLen) {
|
||||||
const char *zEnd = &zMask[nLen];
|
const char *zEnd = &zMask[nLen];
|
||||||
while(zMask < zEnd) {
|
while(zMask < zEnd) {
|
||||||
if(zMask[0] == c) {
|
if(zMask[0] == c) {
|
||||||
/* Character present, return TRUE */
|
/* Character present,return TRUE */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Advance the pointer */
|
/* Advance the pointer */
|
||||||
|
@ -1116,7 +1116,7 @@ static int PH7_builtin_htmlspecialchars(ph7_context *pCtx, int nArg, ph7_value *
|
||||||
int iFlags = 0x01 | 0x40; /* ENT_COMPAT | ENT_HTML401 */
|
int iFlags = 0x01 | 0x40; /* ENT_COMPAT | ENT_HTML401 */
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1197,7 @@ static int PH7_builtin_htmlspecialchars_decode(ph7_context *pCtx, int nArg, ph7_
|
||||||
int iFlags = 0x01; /* ENT_COMPAT */
|
int iFlags = 0x01; /* ENT_COMPAT */
|
||||||
int nLen, nJump;
|
int nLen, nJump;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1338,7 +1338,7 @@ static int PH7_builtin_htmlentities(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1402,7 @@ static int PH7_builtin_html_entity_decode(ph7_context *pCtx, int nArg, ph7_value
|
||||||
int nLen;
|
int nLen;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1673,7 +1673,7 @@ static int PH7_builtin_implode(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
struct implode_data imp_data;
|
struct implode_data imp_data;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return NULL */
|
/* Missing argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1737,7 +1737,7 @@ static int PH7_builtin_implode_recursive(ph7_context *pCtx, int nArg, ph7_value
|
||||||
struct implode_data imp_data;
|
struct implode_data imp_data;
|
||||||
int i = 1;
|
int i = 1;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return NULL */
|
/* Missing argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1812,21 +1812,21 @@ static int PH7_builtin_explode(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the delimiter */
|
/* Extract the delimiter */
|
||||||
zDelim = ph7_value_to_string(apArg[0], &nDelim);
|
zDelim = ph7_value_to_string(apArg[0], &nDelim);
|
||||||
if(nDelim < 1) {
|
if(nDelim < 1) {
|
||||||
/* Empty delimiter, return FALSE */
|
/* Empty delimiter,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the string */
|
/* Extract the string */
|
||||||
zString = ph7_value_to_string(apArg[1], &nStrlen);
|
zString = ph7_value_to_string(apArg[1], &nStrlen);
|
||||||
if(nStrlen < 1) {
|
if(nStrlen < 1) {
|
||||||
/* Empty delimiter, return FALSE */
|
/* Empty delimiter,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1836,7 +1836,7 @@ static int PH7_builtin_explode(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pArray = ph7_context_new_array(pCtx);
|
pArray = ph7_context_new_array(pCtx);
|
||||||
pValue = ph7_context_new_scalar(pCtx);
|
pValue = ph7_context_new_scalar(pCtx);
|
||||||
if(pArray == 0 || pValue == 0) {
|
if(pArray == 0 || pValue == 0) {
|
||||||
/* Out of memory, return FALSE */
|
/* Out of memory,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1905,14 +1905,14 @@ static int PH7_builtin_trim(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zString;
|
const char *zString;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1998,14 +1998,14 @@ static int PH7_builtin_rtrim(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zString;
|
const char *zString;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2074,14 +2074,14 @@ static int PH7_builtin_ltrim(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zString;
|
const char *zString;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2144,14 +2144,14 @@ static int PH7_builtin_strtolower(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
const char *zString, *zCur, *zEnd;
|
const char *zString, *zCur, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2197,14 +2197,14 @@ static int PH7_builtin_strtoupper(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
const char *zString, *zCur, *zEnd;
|
const char *zString, *zCur, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2251,14 +2251,14 @@ static int PH7_builtin_ucfirst(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zString, *zEnd;
|
const char *zString, *zEnd;
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2290,14 +2290,14 @@ static int PH7_builtin_lcfirst(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zString, *zEnd;
|
const char *zString, *zEnd;
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2329,14 +2329,14 @@ static int PH7_builtin_ord(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const unsigned char *zString;
|
const unsigned char *zString;
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return -1 */
|
/* Missing arguments,return -1 */
|
||||||
ph7_result_int(pCtx, -1);
|
ph7_result_int(pCtx, -1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zString = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return -1 */
|
/* Empty string,return -1 */
|
||||||
ph7_result_int(pCtx, -1);
|
ph7_result_int(pCtx, -1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2358,7 +2358,7 @@ static int PH7_builtin_ord(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_chr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_chr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int c;
|
int c;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2391,14 +2391,14 @@ static int PH7_builtin_bin2hex(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zString;
|
const char *zString;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return */
|
/* Empty string,return */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2480,7 +2480,7 @@ static int PH7_builtin_strstr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2493,7 +2493,7 @@ static int PH7_builtin_strstr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Perform the lookup */
|
/* Perform the lookup */
|
||||||
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
/* Pattern not found, return FALSE */
|
/* Pattern not found,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2532,7 +2532,7 @@ static int PH7_builtin_stristr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2545,7 +2545,7 @@ static int PH7_builtin_stristr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Perform the lookup */
|
/* Perform the lookup */
|
||||||
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
/* Pattern not found, return FALSE */
|
/* Pattern not found,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2585,7 +2585,7 @@ static int PH7_builtin_strpos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2612,7 +2612,7 @@ static int PH7_builtin_strpos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Perform the lookup */
|
/* Perform the lookup */
|
||||||
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
/* Pattern not found, return FALSE */
|
/* Pattern not found,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2645,7 +2645,7 @@ static int PH7_builtin_stripos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2672,7 +2672,7 @@ static int PH7_builtin_stripos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Perform the lookup */
|
/* Perform the lookup */
|
||||||
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
rc = xPatternMatch(zBlob, (sxu32)nLen, zPattern, (sxu32)nPatLen, &nOfft);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
/* Pattern not found, return FALSE */
|
/* Pattern not found,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2705,7 +2705,7 @@ static int PH7_builtin_strrpos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2752,13 +2752,13 @@ static int PH7_builtin_strrpos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
}
|
}
|
||||||
rc = xPatternMatch((const void *)zPtr, (sxu32)(zEnd - zPtr), (const void *)zPattern, (sxu32)nPatLen, &nOfft);
|
rc = xPatternMatch((const void *)zPtr, (sxu32)(zEnd - zPtr), (const void *)zPattern, (sxu32)nPatLen, &nOfft);
|
||||||
if(rc == SXRET_OK) {
|
if(rc == SXRET_OK) {
|
||||||
/* Pattern found, return it's position */
|
/* Pattern found,return it's position */
|
||||||
ph7_result_int64(pCtx, (ph7_int64)(&zPtr[nOfft] - zStart));
|
ph7_result_int64(pCtx, (ph7_int64)(&zPtr[nOfft] - zStart));
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
zPtr--;
|
zPtr--;
|
||||||
}
|
}
|
||||||
/* Pattern not found, return FALSE */
|
/* Pattern not found,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
} else {
|
} else {
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
|
@ -2787,7 +2787,7 @@ static int PH7_builtin_strripos(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
sxu32 nOfft;
|
sxu32 nOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2834,13 +2834,13 @@ static int PH7_builtin_strripos(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
}
|
}
|
||||||
rc = xPatternMatch((const void *)zPtr, (sxu32)(zEnd - zPtr), (const void *)zPattern, (sxu32)nPatLen, &nOfft);
|
rc = xPatternMatch((const void *)zPtr, (sxu32)(zEnd - zPtr), (const void *)zPattern, (sxu32)nPatLen, &nOfft);
|
||||||
if(rc == SXRET_OK) {
|
if(rc == SXRET_OK) {
|
||||||
/* Pattern found, return it's position */
|
/* Pattern found,return it's position */
|
||||||
ph7_result_int64(pCtx, (ph7_int64)(&zPtr[nOfft] - zStart));
|
ph7_result_int64(pCtx, (ph7_int64)(&zPtr[nOfft] - zStart));
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
zPtr--;
|
zPtr--;
|
||||||
}
|
}
|
||||||
/* Pattern not found, return FALSE */
|
/* Pattern not found,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
} else {
|
} else {
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
|
@ -2865,7 +2865,7 @@ static int PH7_builtin_strrchr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zBlob;
|
const char *zBlob;
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2888,7 +2888,7 @@ static int PH7_builtin_strrchr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Perform the lookup */
|
/* Perform the lookup */
|
||||||
rc = SyByteFind2(zBlob, (sxu32)nLen, c, &nOfft);
|
rc = SyByteFind2(zBlob, (sxu32)nLen, c, &nOfft);
|
||||||
if(rc != SXRET_OK) {
|
if(rc != SXRET_OK) {
|
||||||
/* No such entry, return FALSE */
|
/* No such entry,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2912,7 +2912,7 @@ static int PH7_builtin_strrev(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zIn, *zEnd;
|
const char *zIn, *zEnd;
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2952,7 +2952,7 @@ static int PH7_builtin_ucwords(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zIn, *zCur, *zEnd;
|
const char *zIn, *zCur, *zEnd;
|
||||||
int nLen, c;
|
int nLen, c;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3023,7 +3023,7 @@ static int PH7_builtin_str_repeat(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
int nLen, nMul;
|
int nLen, nMul;
|
||||||
int rc;
|
int rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3072,14 +3072,14 @@ static int PH7_builtin_nl2br(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int is_xhtml = 0;
|
int is_xhtml = 0;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the target string */
|
/* Extract the target string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &nLen);
|
zIn = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return null */
|
/* Empty string,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3811,7 +3811,7 @@ static int PH7_builtin_sprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zFormat;
|
const char *zFormat;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return the empty string */
|
/* Missing/Invalid arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3851,7 +3851,7 @@ static int PH7_builtin_printf(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zFormat;
|
const char *zFormat;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return 0 */
|
/* Missing/Invalid arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3884,7 +3884,7 @@ static int PH7_builtin_vprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
SySet sArg;
|
SySet sArg;
|
||||||
int nLen, n;
|
int nLen, n;
|
||||||
if(nArg < 2 || !ph7_value_is_string(apArg[0]) || !ph7_value_is_array(apArg[1])) {
|
if(nArg < 2 || !ph7_value_is_string(apArg[0]) || !ph7_value_is_array(apArg[1])) {
|
||||||
/* Missing/Invalid arguments, return 0 */
|
/* Missing/Invalid arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3922,7 +3922,7 @@ static int PH7_builtin_vsprintf(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
SySet sArg;
|
SySet sArg;
|
||||||
int nLen, n;
|
int nLen, n;
|
||||||
if(nArg < 2 || !ph7_value_is_string(apArg[0]) || !ph7_value_is_array(apArg[1])) {
|
if(nArg < 2 || !ph7_value_is_string(apArg[0]) || !ph7_value_is_array(apArg[1])) {
|
||||||
/* Missing/Invalid arguments, return the empty string */
|
/* Missing/Invalid arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3964,14 +3964,14 @@ static int PH7_builtin_size_format(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
ph7_int64 iSize;
|
ph7_int64 iSize;
|
||||||
int c = -1; /* index in zUnit[] */
|
int c = -1; /* index in zUnit[] */
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return the empty string */
|
/* Missing argument,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the given size */
|
/* Extract the given size */
|
||||||
iSize = ph7_value_to_int64(apArg[0]);
|
iSize = ph7_value_to_int64(apArg[0]);
|
||||||
if(iSize < 100 /* Bytes */) {
|
if(iSize < 100 /* Bytes */) {
|
||||||
/* Don't bother formatting, return immediately */
|
/* Don't bother formatting,return immediately */
|
||||||
ph7_result_string(pCtx, "0.1 KB", (int)sizeof("0.1 KB") - 1);
|
ph7_result_string(pCtx, "0.1 KB", (int)sizeof("0.1 KB") - 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4015,7 +4015,7 @@ static int PH7_builtin_md5(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const void *pIn;
|
const void *pIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4058,7 +4058,7 @@ static int PH7_builtin_sha1(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const void *pIn;
|
const void *pIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4097,7 +4097,7 @@ static int PH7_builtin_crc32(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nCRC;
|
sxu32 nCRC;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return 0 */
|
/* Missing arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4220,7 +4220,7 @@ static int PH7_builtin_str_getcsv(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
int escape = '\\'; /* Escape character */
|
int escape = '\\'; /* Escape character */
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4434,7 +4434,7 @@ static int PH7_builtin_strip_tags(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
int nTaglen = 0;
|
int nTaglen = 0;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return the empty string */
|
/* Missing/Invalid arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4462,7 +4462,7 @@ static int PH7_builtin_str_shuffle(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
int nLen, i, c;
|
int nLen, i, c;
|
||||||
sxu32 iR;
|
sxu32 iR;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4505,14 +4505,14 @@ static int PH7_builtin_str_split(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
int split_len;
|
int split_len;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the target string */
|
/* Point to the target string */
|
||||||
zString = ph7_value_to_string(apArg[0], &nLen);
|
zString = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Nothing to process, return FALSE */
|
/* Nothing to process,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4521,7 +4521,7 @@ static int PH7_builtin_str_split(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
/* Split length */
|
/* Split length */
|
||||||
split_len = ph7_value_to_int(apArg[1]);
|
split_len = ph7_value_to_int(apArg[1]);
|
||||||
if(split_len < 1) {
|
if(split_len < 1) {
|
||||||
/* Invalid length, return FALSE */
|
/* Invalid length,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4689,7 +4689,7 @@ static int PH7_builtin_strspn(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iCount = 0;
|
int iCount = 0;
|
||||||
int rc;
|
int rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing agruments, return zero */
|
/* Missing agruments,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4698,7 +4698,7 @@ static int PH7_builtin_strspn(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract the mask */
|
/* Extract the mask */
|
||||||
zMask = ph7_value_to_string(apArg[1], &iMasklen);
|
zMask = ph7_value_to_string(apArg[1], &iMasklen);
|
||||||
if(iLen < 1 || iMasklen < 1) {
|
if(iLen < 1 || iMasklen < 1) {
|
||||||
/* Nothing to process, return zero */
|
/* Nothing to process,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4779,7 +4779,7 @@ static int PH7_builtin_strcspn(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iCount = 0;
|
int iCount = 0;
|
||||||
int rc;
|
int rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing agruments, return zero */
|
/* Missing agruments,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4788,12 +4788,12 @@ static int PH7_builtin_strcspn(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract the mask */
|
/* Extract the mask */
|
||||||
zMask = ph7_value_to_string(apArg[1], &iMasklen);
|
zMask = ph7_value_to_string(apArg[1], &iMasklen);
|
||||||
if(iLen < 1) {
|
if(iLen < 1) {
|
||||||
/* Nothing to process, return zero */
|
/* Nothing to process,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
if(iMasklen < 1) {
|
if(iMasklen < 1) {
|
||||||
/* No given mask, return the string length */
|
/* No given mask,return the string length */
|
||||||
ph7_result_int(pCtx, iLen);
|
ph7_result_int(pCtx, iLen);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4860,7 +4860,7 @@ static int PH7_builtin_strpbrk(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nOfft, nMax;
|
sxu32 nOfft, nMax;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4868,7 +4868,7 @@ static int PH7_builtin_strpbrk(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
zString = ph7_value_to_string(apArg[0], &iLen);
|
zString = ph7_value_to_string(apArg[0], &iLen);
|
||||||
zList = ph7_value_to_string(apArg[1], &iListLen);
|
zList = ph7_value_to_string(apArg[1], &iListLen);
|
||||||
if(iLen < 1) {
|
if(iLen < 1) {
|
||||||
/* Nothing to process, return FALSE */
|
/* Nothing to process,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4886,7 +4886,7 @@ static int PH7_builtin_strpbrk(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(nOfft == SXU32_HIGH) {
|
if(nOfft == SXU32_HIGH) {
|
||||||
/* No such substring, return FALSE */
|
/* No such substring,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
} else {
|
} else {
|
||||||
/* Return the substring */
|
/* Return the substring */
|
||||||
|
@ -4921,7 +4921,7 @@ static int PH7_builtin_soundex(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,
|
1, 2, 6, 2, 3, 0, 1, 0, 2, 0, 2, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4967,14 +4967,14 @@ static int PH7_builtin_wordwrap(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
const char *zIn, *zEnd, *zBreak;
|
const char *zIn, *zEnd, *zBreak;
|
||||||
int iLen, iBreaklen, iChunk;
|
int iLen, iBreaklen, iChunk;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the input string */
|
/* Extract the input string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &iLen);
|
zIn = ph7_value_to_string(apArg[0], &iLen);
|
||||||
if(iLen < 1) {
|
if(iLen < 1) {
|
||||||
/* Nothing to process, return the empty string */
|
/* Nothing to process,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5114,7 +5114,7 @@ static int PH7_builtin_strtok(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract top aux data */
|
/* Extract top aux data */
|
||||||
pAux = (strtok_aux_data *)ph7_context_peek_aux_data(pCtx);
|
pAux = (strtok_aux_data *)ph7_context_peek_aux_data(pCtx);
|
||||||
if(pAux == 0) {
|
if(pAux == 0) {
|
||||||
/* No aux data, return FALSE */
|
/* No aux data,return FALSE */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5125,7 +5125,7 @@ static int PH7_builtin_strtok(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
zMask = ph7_value_to_string(apArg[0], &nMasklen);
|
zMask = ph7_value_to_string(apArg[0], &nMasklen);
|
||||||
}
|
}
|
||||||
if(nMasklen < 1) {
|
if(nMasklen < 1) {
|
||||||
/* Invalid mask, return FALSE */
|
/* Invalid mask,return FALSE */
|
||||||
ph7_context_free_chunk(pCtx, (void *)pAux->zDup);
|
ph7_context_free_chunk(pCtx, (void *)pAux->zDup);
|
||||||
ph7_context_free_chunk(pCtx, pAux);
|
ph7_context_free_chunk(pCtx, pAux);
|
||||||
(void)ph7_context_pop_aux_data(pCtx);
|
(void)ph7_context_pop_aux_data(pCtx);
|
||||||
|
@ -5151,7 +5151,7 @@ static int PH7_builtin_strtok(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract the raw input */
|
/* Extract the raw input */
|
||||||
zCur = zInput = ph7_value_to_string(apArg[0], &nLen);
|
zCur = zInput = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty input, return FALSE */
|
/* Empty input,return FALSE */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5218,7 +5218,7 @@ static int PH7_builtin_str_pad(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iLen, iPadlen, iType, i, iDiv, iStrpad, iRealPad, jPad;
|
int iLen, iPadlen, iType, i, iDiv, iStrpad, iRealPad, jPad;
|
||||||
const char *zIn, *zPad;
|
const char *zIn, *zPad;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return the empty string */
|
/* Missing arguments,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5391,7 +5391,7 @@ static int StringReplaceWalker(ph7_value *pKey, ph7_value *pData, void *pUserDat
|
||||||
/* Extract the target and the replace */
|
/* Extract the target and the replace */
|
||||||
zTarget = ph7_value_to_string(pKey, &tLen);
|
zTarget = ph7_value_to_string(pKey, &tLen);
|
||||||
if(tLen < 1) {
|
if(tLen < 1) {
|
||||||
/* Empty target, return immediately */
|
/* Empty target,return immediately */
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Perform a pattern search */
|
/* Perform a pattern search */
|
||||||
|
@ -5478,7 +5478,7 @@ static int PH7_builtin_str_replace(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
int nByte;
|
int nByte;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 3) {
|
if(nArg < 3) {
|
||||||
/* Missing/Invalid arguments, return null */
|
/* Missing/Invalid arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5493,7 +5493,7 @@ static int PH7_builtin_str_replace(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Extract the subject */
|
/* Extract the subject */
|
||||||
zIn = ph7_value_to_string(apArg[2], &nByte);
|
zIn = ph7_value_to_string(apArg[2], &nByte);
|
||||||
if(nByte < 1) {
|
if(nByte < 1) {
|
||||||
/* Nothing to replace, return the empty string */
|
/* Nothing to replace,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5610,7 +5610,7 @@ static int PH7_builtin_strtr(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zIn;
|
const char *zIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Nothing to replace, return FALSE */
|
/* Nothing to replace,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5882,7 +5882,7 @@ static int PH7_builtin_parse_ini_string(ph7_context *pCtx, int nArg, ph7_value *
|
||||||
const char *zIni;
|
const char *zIni;
|
||||||
int nByte;
|
int nByte;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE*/
|
/* Missing/Invalid arguments,return FALSE*/
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -6676,7 +6676,7 @@ static int PH7_builtin_date(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int nLen;
|
int nLen;
|
||||||
Sytm sTm;
|
Sytm sTm;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return FALSE */
|
/* Missing/Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -6736,7 +6736,7 @@ static int PH7_builtin_strftime(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
int nLen;
|
int nLen;
|
||||||
Sytm sTm;
|
Sytm sTm;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return FALSE */
|
/* Missing/Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -6776,7 +6776,7 @@ static int PH7_builtin_strftime(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
/* Format the given string */
|
/* Format the given string */
|
||||||
PH7_Strftime(pCtx, zFormat, nLen, &sTm);
|
PH7_Strftime(pCtx, zFormat, nLen, &sTm);
|
||||||
if(ph7_context_result_buf_length(pCtx) < 1) {
|
if(ph7_context_result_buf_length(pCtx) < 1) {
|
||||||
/* Nothing was formatted, return FALSE */
|
/* Nothing was formatted,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
}
|
}
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
|
@ -6800,7 +6800,7 @@ static int PH7_builtin_gmdate(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int nLen;
|
int nLen;
|
||||||
Sytm sTm;
|
Sytm sTm;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return FALSE */
|
/* Missing/Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -7028,7 +7028,7 @@ static int PH7_builtin_idate(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int nLen;
|
int nLen;
|
||||||
Sytm sTm;
|
Sytm sTm;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return -1 */
|
/* Missing/Invalid argument,return -1 */
|
||||||
ph7_result_int(pCtx, -1);
|
ph7_result_int(pCtx, -1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -7289,14 +7289,14 @@ static int PH7_builtin_base64_encode(ph7_context *pCtx, int nArg, ph7_value **ap
|
||||||
const char *zIn;
|
const char *zIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the input string */
|
/* Extract the input string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &nLen);
|
zIn = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Nothing to process, return FALSE */
|
/* Nothing to process,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -7318,14 +7318,14 @@ static int PH7_builtin_base64_decode(ph7_context *pCtx, int nArg, ph7_value **ap
|
||||||
const char *zIn;
|
const char *zIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the input string */
|
/* Extract the input string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &nLen);
|
zIn = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Nothing to process, return FALSE */
|
/* Nothing to process,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -7348,14 +7348,14 @@ static int PH7_builtin_urlencode(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
const char *zIn;
|
const char *zIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the input string */
|
/* Extract the input string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &nLen);
|
zIn = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Nothing to process, return FALSE */
|
/* Nothing to process,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -7377,14 +7377,14 @@ static int PH7_builtin_urldecode(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
const char *zIn;
|
const char *zIn;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Extract the input string */
|
/* Extract the input string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &nLen);
|
zIn = ph7_value_to_string(apArg[0], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Nothing to process, return FALSE */
|
/* Nothing to process,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1421,10 +1421,8 @@ static sxi32 PH7_CompileBreak(ph7_gen_state *pGen) {
|
||||||
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "A 'break' statement may only be used within a loop or switch");
|
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "A 'break' statement may only be used within a loop or switch");
|
||||||
} else {
|
} else {
|
||||||
sxu32 nInstrIdx;
|
sxu32 nInstrIdx;
|
||||||
if((pLoop->iFlags & GEN_BLOCK_SWITCH) == 0) {
|
/* Emit the OP_LF_STOP instruction to leave the loop frame */
|
||||||
/* Emit the OP_LF_STOP instruction to leave the loop frame */
|
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_LF_STOP, 0, 0, 0, 0);
|
||||||
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_LF_STOP, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
rc = PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_JMP, 0, 0, 0, &nInstrIdx);
|
rc = PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_JMP, 0, 0, 0, &nInstrIdx);
|
||||||
if(rc == SXRET_OK) {
|
if(rc == SXRET_OK) {
|
||||||
/* Fix the jump later when the jump destination is resolved */
|
/* Fix the jump later when the jump destination is resolved */
|
||||||
|
@ -2642,59 +2640,6 @@ static sxi32 PH7_CompileUsing(ph7_gen_state *pGen) {
|
||||||
);
|
);
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* Compile the 'import' statement
|
|
||||||
*/
|
|
||||||
static sxi32 PH7_CompileImport(ph7_gen_state *pGen) {
|
|
||||||
char *zModule;
|
|
||||||
sxu32 nLine = pGen->pIn->nLine;
|
|
||||||
/* Jump the 'import' keyword */
|
|
||||||
pGen->pIn++;
|
|
||||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & (PH7_TK_SSTR | PH7_TK_DSTR)) == 0) {
|
|
||||||
if(pGen->pIn >= pGen->pEnd) {
|
|
||||||
pGen->pIn--;
|
|
||||||
}
|
|
||||||
/* Unexpected token */
|
|
||||||
PH7_GenCompileError(&(*pGen), E_ERROR, nLine, "Include: Unexpected token '%z'", &pGen->pIn->sData);
|
|
||||||
}
|
|
||||||
zModule = SyMemBackendStrDup(&pGen->pVm->sAllocator, pGen->pIn->sData.zString, pGen->pIn->sData.nByte);
|
|
||||||
pGen->pIn++;
|
|
||||||
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI/*';'*/) == 0) {
|
|
||||||
/* Unexpected token */
|
|
||||||
PH7_GenCompileError(&(*pGen), E_ERROR, nLine, "Include: Unexpected token '%z', expecting ';'",
|
|
||||||
&pGen->pIn->sData);
|
|
||||||
}
|
|
||||||
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_IMPORT, 0, 0, zModule, 0);
|
|
||||||
return SXRET_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compile the 'include' and 'require' statements
|
|
||||||
*/
|
|
||||||
static sxi32 PH7_CompileInclude(ph7_gen_state *pGen) {
|
|
||||||
char *zFile;
|
|
||||||
sxu32 nKey = (sxu32)(SX_PTR_TO_INT(pGen->pIn->pUserData));
|
|
||||||
sxu32 nLine = pGen->pIn->nLine;
|
|
||||||
sxi32 iP1 = (nKey == PH7_KEYWORD_REQUIRE) ? 1 : 0;
|
|
||||||
/* Jump the 'include' or 'require' keyword */
|
|
||||||
pGen->pIn++;
|
|
||||||
if(pGen->pIn >= pGen->pEnd || (pGen->pIn->nType & (PH7_TK_SSTR | PH7_TK_DSTR)) == 0) {
|
|
||||||
if(pGen->pIn >= pGen->pEnd) {
|
|
||||||
pGen->pIn--;
|
|
||||||
}
|
|
||||||
/* Unexpected token */
|
|
||||||
PH7_GenCompileError(&(*pGen), E_ERROR, nLine, "Include: Unexpected token '%z'", &pGen->pIn->sData);
|
|
||||||
}
|
|
||||||
zFile = SyMemBackendStrDup(&pGen->pVm->sAllocator, pGen->pIn->sData.zString, pGen->pIn->sData.nByte);
|
|
||||||
pGen->pIn++;
|
|
||||||
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_SEMI/*';'*/) == 0) {
|
|
||||||
/* Unexpected token */
|
|
||||||
PH7_GenCompileError(&(*pGen), E_ERROR, nLine, "Include: Unexpected token '%z', expecting ';'",
|
|
||||||
&pGen->pIn->sData);
|
|
||||||
}
|
|
||||||
PH7_VmEmitInstr(pGen->pVm, nLine, PH7_OP_INCLUDE, iP1, 0, zFile, 0);
|
|
||||||
return SXRET_OK;
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Process default argument values. That is,a function may define C++-style default value
|
* Process default argument values. That is,a function may define C++-style default value
|
||||||
* as follows:
|
* as follows:
|
||||||
|
@ -4945,37 +4890,31 @@ static const LangConstruct aLangConstruct[] = {
|
||||||
{ PH7_KEYWORD_THROW, PH7_CompileThrow }, /* throw statement */
|
{ PH7_KEYWORD_THROW, PH7_CompileThrow }, /* throw statement */
|
||||||
{ PH7_KEYWORD_GOTO, PH7_CompileGoto }, /* goto statement */
|
{ PH7_KEYWORD_GOTO, PH7_CompileGoto }, /* goto statement */
|
||||||
{ PH7_KEYWORD_CONST, PH7_CompileConstant }, /* const statement */
|
{ PH7_KEYWORD_CONST, PH7_CompileConstant }, /* const statement */
|
||||||
{ PH7_KEYWORD_INCLUDE, PH7_CompileInclude }, /* include statement */
|
|
||||||
{ PH7_KEYWORD_REQUIRE, PH7_CompileInclude }, /* require statement */
|
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* Return a pointer to the global scope handler routine associated
|
* Return a pointer to the global scope handler routine associated
|
||||||
*/
|
*/
|
||||||
static ProcLangConstruct PH7_GenStateGetGlobalScopeHandler(
|
static ProcLangConstruct PH7_GenStateGetGlobalScopeHandler(
|
||||||
sxu32 nKeywordID /* Keyword ID */
|
sxu32 nKeywordID, /* Keyword ID */
|
||||||
|
SyToken *pLookahead /* Look-ahead token */
|
||||||
) {
|
) {
|
||||||
switch(nKeywordID) {
|
if(pLookahead) {
|
||||||
case PH7_KEYWORD_DEFINE:
|
if(nKeywordID == PH7_KEYWORD_DEFINE) {
|
||||||
return PH7_CompileDefine;
|
return PH7_CompileDefine;
|
||||||
case PH7_KEYWORD_INTERFACE:
|
} else if(nKeywordID == PH7_KEYWORD_INTERFACE) {
|
||||||
return PH7_CompileClassInterface;
|
return PH7_CompileClassInterface;
|
||||||
case PH7_KEYWORD_FINAL:
|
} else if(nKeywordID == PH7_KEYWORD_FINAL || nKeywordID == PH7_KEYWORD_VIRTUAL) {
|
||||||
case PH7_KEYWORD_VIRTUAL:
|
|
||||||
return PH7_CompileFinalVirtualClass;
|
return PH7_CompileFinalVirtualClass;
|
||||||
case PH7_KEYWORD_CLASS:
|
} else if(nKeywordID == PH7_KEYWORD_CLASS) {
|
||||||
return PH7_CompileClass;
|
return PH7_CompileClass;
|
||||||
case PH7_KEYWORD_NAMESPACE:
|
} else if(nKeywordID == PH7_KEYWORD_NAMESPACE) {
|
||||||
return PH7_CompileNamespace;
|
return PH7_CompileNamespace;
|
||||||
case PH7_KEYWORD_USING:
|
} else if(nKeywordID == PH7_KEYWORD_USING) {
|
||||||
return PH7_CompileUsing;
|
return PH7_CompileUsing;
|
||||||
case PH7_KEYWORD_IMPORT:
|
}
|
||||||
return PH7_CompileImport;
|
|
||||||
case PH7_KEYWORD_REQUIRE:
|
|
||||||
return PH7_CompileInclude;
|
|
||||||
default:
|
|
||||||
/* Not a global scope language construct */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
/* Not a global scope language construct */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Return a pointer to the statement handler routine associated
|
* Return a pointer to the statement handler routine associated
|
||||||
|
@ -4990,7 +4929,7 @@ static ProcLangConstruct PH7_GenStateGetStatementHandler(
|
||||||
if(nKeywordID == PH7_KEYWORD_STATIC && pLookahead && (pLookahead->nType & PH7_TK_OP)) {
|
if(nKeywordID == PH7_KEYWORD_STATIC && pLookahead && (pLookahead->nType & PH7_TK_OP)) {
|
||||||
const ph7_expr_op *pOp = (const ph7_expr_op *)pLookahead->pUserData;
|
const ph7_expr_op *pOp = (const ph7_expr_op *)pLookahead->pUserData;
|
||||||
if(pOp && pOp->iOp == EXPR_OP_DC /*::*/) {
|
if(pOp && pOp->iOp == EXPR_OP_DC /*::*/) {
|
||||||
/* 'static' (class context), return null */
|
/* 'static' (class context),return null */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5015,8 +4954,10 @@ static ProcLangConstruct PH7_GenStateGetStatementHandler(
|
||||||
* Return TRUE if the given ID represent a language construct. FALSE otherwise.
|
* Return TRUE if the given ID represent a language construct. FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
static int PH7_IsLangConstruct(sxu32 nKeywordID) {
|
static int PH7_IsLangConstruct(sxu32 nKeywordID) {
|
||||||
if(nKeywordID == PH7_KEYWORD_EVAL || nKeywordID == PH7_KEYWORD_STATIC || nKeywordID == PH7_KEYWORD_NEW || nKeywordID == PH7_KEYWORD_CLONE) {
|
if(nKeywordID == PH7_KEYWORD_IMPORT || nKeywordID == PH7_KEYWORD_INCLUDE || nKeywordID == PH7_KEYWORD_REQUIRE
|
||||||
return TRUE;
|
|| nKeywordID == PH7_KEYWORD_EVAL || nKeywordID == PH7_KEYWORD_STATIC
|
||||||
|
|| nKeywordID == PH7_KEYWORD_NEW || nKeywordID == PH7_KEYWORD_CLONE) {
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
/* Not a language construct */
|
/* Not a language construct */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -5107,7 +5048,7 @@ static sxi32 PH7_GenStateCompileGlobalScope(
|
||||||
if(pGen->pIn->nType & PH7_TK_KEYWORD) {
|
if(pGen->pIn->nType & PH7_TK_KEYWORD) {
|
||||||
sxu32 nKeyword = (sxu32)SX_PTR_TO_INT(pGen->pIn->pUserData);
|
sxu32 nKeyword = (sxu32)SX_PTR_TO_INT(pGen->pIn->pUserData);
|
||||||
/* Try to extract a language construct handler */
|
/* Try to extract a language construct handler */
|
||||||
xCons = PH7_GenStateGetGlobalScopeHandler(nKeyword);
|
xCons = PH7_GenStateGetGlobalScopeHandler(nKeyword, (&pGen->pIn[1] < pGen->pEnd) ? &pGen->pIn[1] : 0);
|
||||||
if(xCons == 0) {
|
if(xCons == 0) {
|
||||||
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "Syntax error: Unexpected keyword '%z'", &pGen->pIn->sData);
|
PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "Syntax error: Unexpected keyword '%z'", &pGen->pIn->sData);
|
||||||
}
|
}
|
||||||
|
@ -5306,7 +5247,7 @@ PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen, sxi32 nErrType, sxu32
|
||||||
/* Peek the processed file path if available */
|
/* Peek the processed file path if available */
|
||||||
pFile = (SyString *)SySetPeek(&pGen->pVm->aFiles);
|
pFile = (SyString *)SySetPeek(&pGen->pVm->aFiles);
|
||||||
if(pGen->xErr == 0) {
|
if(pGen->xErr == 0) {
|
||||||
/* No available error consumer, return immediately */
|
/* No available error consumer,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
switch(nErrType) {
|
switch(nErrType) {
|
||||||
|
|
373
engine/debug.c
373
engine/debug.c
|
@ -1,373 +0,0 @@
|
||||||
/**
|
|
||||||
* @PROJECT PH7 Engine for the AerScript Interpreter
|
|
||||||
* @COPYRIGHT See COPYING in the top level directory
|
|
||||||
* @FILE engine/debug.c
|
|
||||||
* @DESCRIPTION AerScript Virtual Machine Debugger for the PH7 Engine
|
|
||||||
* @DEVELOPERS Symisc Systems <devel@symisc.net>
|
|
||||||
* Rafal Kupiec <belliash@codingworkshop.eu.org>
|
|
||||||
*/
|
|
||||||
#include "ph7int.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine is used to dump the debug stacktrace based on all active frames.
|
|
||||||
*/
|
|
||||||
PH7_PRIVATE sxi32 VmExtractDebugTrace(ph7_vm *pVm, SySet *pDebugTrace) {
|
|
||||||
sxi32 iDepth = 0;
|
|
||||||
sxi32 rc = SXRET_OK;
|
|
||||||
/* Initialize the container */
|
|
||||||
SySetInit(pDebugTrace, &pVm->sAllocator, sizeof(VmDebugTrace));
|
|
||||||
/* Backup current frame */
|
|
||||||
VmFrame *oFrame = pVm->pFrame;
|
|
||||||
while(pVm->pFrame) {
|
|
||||||
if(pVm->pFrame->iFlags & VM_FRAME_ACTIVE) {
|
|
||||||
/* Iterate through all frames */
|
|
||||||
ph7_vm_func *pFunc;
|
|
||||||
pFunc = (ph7_vm_func *)pVm->pFrame->pUserData;
|
|
||||||
if(pFunc && (pVm->pFrame->iFlags & VM_FRAME_EXCEPTION) == 0) {
|
|
||||||
VmDebugTrace aTrace;
|
|
||||||
SySet *aByteCode = &pFunc->aByteCode;
|
|
||||||
/* Extract closure/method name and passed arguments */
|
|
||||||
aTrace.pFuncName = &pFunc->sName;
|
|
||||||
aTrace.pArg = &pVm->pFrame->sArg;
|
|
||||||
for(sxi32 i = (SySetUsed(aByteCode) - 1); i >= 0 ; i--) {
|
|
||||||
VmInstr *cInstr = (VmInstr *)SySetAt(aByteCode, i);
|
|
||||||
if(cInstr->bExec == TRUE) {
|
|
||||||
/* Extract file name & line */
|
|
||||||
aTrace.pFile = cInstr->pFile;
|
|
||||||
aTrace.nLine = cInstr->iLine;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(aTrace.pFile) {
|
|
||||||
aTrace.pClassName = NULL;
|
|
||||||
aTrace.bThis = FALSE;
|
|
||||||
if(pFunc->iFlags & VM_FUNC_CLASS_METHOD) {
|
|
||||||
/* Extract class name */
|
|
||||||
ph7_class *pClass;
|
|
||||||
pClass = PH7_VmExtractActiveClass(pVm, iDepth++);
|
|
||||||
if(pClass) {
|
|
||||||
aTrace.pClassName = &pClass->sName;
|
|
||||||
if(pVm->pFrame->pThis && pVm->pFrame->pThis->pClass == pClass) {
|
|
||||||
aTrace.bThis = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rc = SySetPut(pDebugTrace, (const void *)&aTrace);
|
|
||||||
if(rc != SXRET_OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Roll frame */
|
|
||||||
pVm->pFrame = pVm->pFrame->pParent;
|
|
||||||
}
|
|
||||||
/* Restore original frame */
|
|
||||||
pVm->pFrame = oFrame;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Return a string representation of the given PH7 OP code.
|
|
||||||
* This function never fail and always return a pointer
|
|
||||||
* to a null terminated string.
|
|
||||||
*/
|
|
||||||
static const char *VmInstrToString(sxi32 nOp) {
|
|
||||||
const char *zOp = "UNKNOWN";
|
|
||||||
switch(nOp) {
|
|
||||||
case PH7_OP_DONE:
|
|
||||||
zOp = "DONE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_HALT:
|
|
||||||
zOp = "HALT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_IMPORT:
|
|
||||||
zOp = "IMPORT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_INCLUDE:
|
|
||||||
zOp = "INCLUDE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_DECLARE:
|
|
||||||
zOp = "DECLARE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOADV:
|
|
||||||
zOp = "LOADV";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOADC:
|
|
||||||
zOp = "LOADC";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOAD_MAP:
|
|
||||||
zOp = "LOAD_MAP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOAD_IDX:
|
|
||||||
zOp = "LOAD_IDX";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOAD_CLOSURE:
|
|
||||||
zOp = "LOAD_CLOSR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_NOOP:
|
|
||||||
zOp = "NOOP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_JMP:
|
|
||||||
zOp = "JMP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_JMPZ:
|
|
||||||
zOp = "JMPZ";
|
|
||||||
break;
|
|
||||||
case PH7_OP_JMPNZ:
|
|
||||||
zOp = "JMPNZ";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LF_START:
|
|
||||||
zOp = "LF_START";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LF_STOP:
|
|
||||||
zOp = "LF_STOP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_POP:
|
|
||||||
zOp = "POP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CVT_INT:
|
|
||||||
zOp = "CVT_INT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CVT_STR:
|
|
||||||
zOp = "CVT_STR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CVT_REAL:
|
|
||||||
zOp = "CVT_FLOAT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CALL:
|
|
||||||
zOp = "CALL";
|
|
||||||
break;
|
|
||||||
case PH7_OP_UMINUS:
|
|
||||||
zOp = "UMINUS";
|
|
||||||
break;
|
|
||||||
case PH7_OP_UPLUS:
|
|
||||||
zOp = "UPLUS";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BITNOT:
|
|
||||||
zOp = "BITNOT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LNOT:
|
|
||||||
zOp = "LOGNOT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_MUL:
|
|
||||||
zOp = "MUL";
|
|
||||||
break;
|
|
||||||
case PH7_OP_DIV:
|
|
||||||
zOp = "DIV";
|
|
||||||
break;
|
|
||||||
case PH7_OP_MOD:
|
|
||||||
zOp = "MOD";
|
|
||||||
break;
|
|
||||||
case PH7_OP_ADD:
|
|
||||||
zOp = "ADD";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SUB:
|
|
||||||
zOp = "SUB";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SHL:
|
|
||||||
zOp = "SHL";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SHR:
|
|
||||||
zOp = "SHR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LT:
|
|
||||||
zOp = "LT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LE:
|
|
||||||
zOp = "LE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_GT:
|
|
||||||
zOp = "GT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_GE:
|
|
||||||
zOp = "GE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_EQ:
|
|
||||||
zOp = "EQ";
|
|
||||||
break;
|
|
||||||
case PH7_OP_NEQ:
|
|
||||||
zOp = "NEQ";
|
|
||||||
break;
|
|
||||||
case PH7_OP_NULLC:
|
|
||||||
zOp = "NULLC";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BAND:
|
|
||||||
zOp = "BITAND";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BXOR:
|
|
||||||
zOp = "BITXOR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BOR:
|
|
||||||
zOp = "BITOR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LAND:
|
|
||||||
zOp = "LOGAND";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOR:
|
|
||||||
zOp = "LOGOR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LXOR:
|
|
||||||
zOp = "LOGXOR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_STORE:
|
|
||||||
zOp = "STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_STORE_IDX:
|
|
||||||
zOp = "STORE_IDX";
|
|
||||||
break;
|
|
||||||
case PH7_OP_PULL:
|
|
||||||
zOp = "PULL";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SWAP:
|
|
||||||
zOp = "SWAP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_YIELD:
|
|
||||||
zOp = "YIELD";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CVT_BOOL:
|
|
||||||
zOp = "CVT_BOOL";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CVT_OBJ:
|
|
||||||
zOp = "CVT_OBJ";
|
|
||||||
break;
|
|
||||||
case PH7_OP_INCR:
|
|
||||||
zOp = "INCR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_DECR:
|
|
||||||
zOp = "DECR";
|
|
||||||
break;
|
|
||||||
case PH7_OP_NEW:
|
|
||||||
zOp = "NEW";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CLONE:
|
|
||||||
zOp = "CLONE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_ADD_STORE:
|
|
||||||
zOp = "ADD_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SUB_STORE:
|
|
||||||
zOp = "SUB_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_MUL_STORE:
|
|
||||||
zOp = "MUL_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_DIV_STORE:
|
|
||||||
zOp = "DIV_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_MOD_STORE:
|
|
||||||
zOp = "MOD_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SHL_STORE:
|
|
||||||
zOp = "SHL_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SHR_STORE:
|
|
||||||
zOp = "SHR_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BAND_STORE:
|
|
||||||
zOp = "BAND_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BOR_STORE:
|
|
||||||
zOp = "BOR_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_BXOR_STORE:
|
|
||||||
zOp = "BXOR_STORE";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CONSUME:
|
|
||||||
zOp = "CONSUME";
|
|
||||||
break;
|
|
||||||
case PH7_OP_MEMBER:
|
|
||||||
zOp = "MEMBER";
|
|
||||||
break;
|
|
||||||
case PH7_OP_IS:
|
|
||||||
zOp = "IS";
|
|
||||||
break;
|
|
||||||
case PH7_OP_SWITCH:
|
|
||||||
zOp = "SWITCH";
|
|
||||||
break;
|
|
||||||
case PH7_OP_LOAD_EXCEPTION:
|
|
||||||
zOp = "LOAD_EXCEP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_POP_EXCEPTION:
|
|
||||||
zOp = "POP_EXCEP";
|
|
||||||
break;
|
|
||||||
case PH7_OP_THROW:
|
|
||||||
zOp = "THROW";
|
|
||||||
break;
|
|
||||||
case PH7_OP_CLASS_INIT:
|
|
||||||
zOp = "CLASS_INIT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_INTERFACE_INIT:
|
|
||||||
zOp = "INTER_INIT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_FOREACH_INIT:
|
|
||||||
zOp = "4EACH_INIT";
|
|
||||||
break;
|
|
||||||
case PH7_OP_FOREACH_STEP:
|
|
||||||
zOp = "4EACH_STEP";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return zOp;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* This routine is used to dump PH7 byte-code instructions to a human readable
|
|
||||||
* format.
|
|
||||||
* The dump is redirected to the given consumer callback which is responsible
|
|
||||||
* of consuming the generated dump perhaps redirecting it to its standard output
|
|
||||||
* (STDOUT).
|
|
||||||
*/
|
|
||||||
static sxi32 VmByteCodeDump(
|
|
||||||
SySet *pByteCode, /* Bytecode container */
|
|
||||||
ProcConsumer xConsumer, /* Dump consumer callback */
|
|
||||||
void *pUserData /* Last argument to xConsumer() */
|
|
||||||
) {
|
|
||||||
static const char zDump[] = {
|
|
||||||
"========================================================================================================\n"
|
|
||||||
" SEQ | OP | INSTRUCTION | P1 | P2 | P3 | LINE | SOURCE FILE \n"
|
|
||||||
"========================================================================================================\n"
|
|
||||||
};
|
|
||||||
VmInstr *pInstr, *pEnd;
|
|
||||||
sxi32 rc = SXRET_OK;
|
|
||||||
sxu32 n;
|
|
||||||
/* Point to the PH7 instructions */
|
|
||||||
pInstr = (VmInstr *)SySetBasePtr(pByteCode);
|
|
||||||
pEnd = &pInstr[SySetUsed(pByteCode)];
|
|
||||||
n = 1;
|
|
||||||
xConsumer((const void *)zDump, sizeof(zDump) - 1, pUserData);
|
|
||||||
/* Dump instructions */
|
|
||||||
for(;;) {
|
|
||||||
if(pInstr >= pEnd) {
|
|
||||||
/* No more instructions */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Format and call the consumer callback */
|
|
||||||
rc = SyProcFormat(xConsumer, pUserData, " #%08u | %4d | %-11s | %8d | %8u | %#10x | %6u | %z\n",
|
|
||||||
n, pInstr->iOp, VmInstrToString(pInstr->iOp), pInstr->iP1, pInstr->iP2,
|
|
||||||
SX_PTR_TO_INT(pInstr->p3), pInstr->iLine, pInstr->pFile);
|
|
||||||
if(rc != SXRET_OK) {
|
|
||||||
/* Consumer routine request an operation abort */
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
++n;
|
|
||||||
pInstr++; /* Next instruction in the stream */
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Dump PH7 bytecodes instructions to a human readable format.
|
|
||||||
* The xConsumer() callback which is an used defined function
|
|
||||||
* is responsible of consuming the generated dump.
|
|
||||||
*/
|
|
||||||
PH7_PRIVATE sxi32 PH7_VmDump(
|
|
||||||
ph7_vm *pVm, /* Target VM */
|
|
||||||
ProcConsumer xConsumer, /* Output [i.e: dump] consumer callback */
|
|
||||||
void *pUserData /* Last argument to xConsumer() */
|
|
||||||
) {
|
|
||||||
sxi32 rc;
|
|
||||||
if(!pVm->bDebug) {
|
|
||||||
return SXRET_OK;
|
|
||||||
}
|
|
||||||
rc = VmByteCodeDump(&pVm->aInstrSet, xConsumer, pUserData);
|
|
||||||
return rc;
|
|
||||||
}
|
|
208
engine/hashmap.c
208
engine/hashmap.c
|
@ -227,7 +227,7 @@ static sxi32 HashmapGrowBucket(ph7_hashmap *pMap) {
|
||||||
pMap->apBucket = apNew;
|
pMap->apBucket = apNew;
|
||||||
pMap->nSize = nNew;
|
pMap->nSize = nNew;
|
||||||
if(apOld == 0) {
|
if(apOld == 0) {
|
||||||
/* First allocated table [i.e: no entry], return immediately */
|
/* First allocated table [i.e: no entry],return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Rehash old entries */
|
/* Rehash old entries */
|
||||||
|
@ -1315,7 +1315,7 @@ PH7_PRIVATE void PH7_HashmapResetLoopCursor(ph7_hashmap *pMap) {
|
||||||
PH7_PRIVATE ph7_hashmap_node *PH7_HashmapGetNextEntry(ph7_hashmap *pMap) {
|
PH7_PRIVATE ph7_hashmap_node *PH7_HashmapGetNextEntry(ph7_hashmap *pMap) {
|
||||||
ph7_hashmap_node *pCur = pMap->pCur;
|
ph7_hashmap_node *pCur = pMap->pCur;
|
||||||
if(pCur == 0) {
|
if(pCur == 0) {
|
||||||
/* End of the list, return null */
|
/* End of the list,return null */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Advance the node cursor */
|
/* Advance the node cursor */
|
||||||
|
@ -1782,7 +1782,7 @@ static int ph7_hashmap_sort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1802,7 +1802,7 @@ static int ph7_hashmap_sort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Rehash [Do not maintain index association as requested by the PHP specification] */
|
/* Rehash [Do not maintain index association as requested by the PHP specification] */
|
||||||
HashmapSortRehash(pMap);
|
HashmapSortRehash(pMap);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1825,7 +1825,7 @@ static int ph7_hashmap_asort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1847,7 +1847,7 @@ static int ph7_hashmap_asort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1870,7 +1870,7 @@ static int ph7_hashmap_arsort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1892,7 +1892,7 @@ static int ph7_hashmap_arsort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1915,7 +1915,7 @@ static int ph7_hashmap_ksort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1937,7 +1937,7 @@ static int ph7_hashmap_ksort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1960,7 +1960,7 @@ static int ph7_hashmap_krsort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1982,7 +1982,7 @@ static int ph7_hashmap_krsort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2005,7 +2005,7 @@ static int ph7_hashmap_rsort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2025,7 +2025,7 @@ static int ph7_hashmap_rsort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Rehash [Do not maintain index association as requested by the PHP specification] */
|
/* Rehash [Do not maintain index association as requested by the PHP specification] */
|
||||||
HashmapSortRehash(pMap);
|
HashmapSortRehash(pMap);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2047,7 +2047,7 @@ static int ph7_hashmap_usort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2069,7 +2069,7 @@ static int ph7_hashmap_usort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Rehash [Do not maintain index association as requested by the PHP specification] */
|
/* Rehash [Do not maintain index association as requested by the PHP specification] */
|
||||||
HashmapSortRehash(pMap);
|
HashmapSortRehash(pMap);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2092,7 +2092,7 @@ static int ph7_hashmap_uasort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2116,7 +2116,7 @@ static int ph7_hashmap_uasort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2139,7 +2139,7 @@ static int ph7_hashmap_uksort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2163,7 +2163,7 @@ static int ph7_hashmap_uksort(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2181,7 +2181,7 @@ static int ph7_hashmap_shuffle(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return FALSE */
|
/* Missing/Invalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2195,7 +2195,7 @@ static int ph7_hashmap_shuffle(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pMap->pLast = pMap->pLast->pPrev;
|
pMap->pLast = pMap->pLast->pPrev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2217,7 +2217,7 @@ static int ph7_hashmap_count(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int bRecursive = FALSE;
|
int bRecursive = FALSE;
|
||||||
sxi64 iCount;
|
sxi64 iCount;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return 0 */
|
/* Missing arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2248,13 +2248,13 @@ static int ph7_hashmap_count(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int ph7_hashmap_key_exists(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_key_exists(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[1])) {
|
if(!ph7_value_is_array(apArg[1])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2275,19 +2275,19 @@ static int ph7_hashmap_key_exists(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
static int ph7_hashmap_pop(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_pop(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return null */
|
/* Invalid argument,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
if(pMap->nEntry < 1) {
|
if(pMap->nEntry < 1) {
|
||||||
/* Noting to pop, return NULL */
|
/* Noting to pop,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
} else {
|
} else {
|
||||||
ph7_hashmap_node *pLast = pMap->pLast;
|
ph7_hashmap_node *pLast = pMap->pLast;
|
||||||
|
@ -2322,13 +2322,13 @@ static int ph7_hashmap_push(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return 0 */
|
/* Missing arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return 0 */
|
/* Invalid argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2356,20 +2356,20 @@ static int ph7_hashmap_push(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int ph7_hashmap_shift(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_shift(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return null */
|
/* Missing arguments,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return null */
|
/* Invalid argument,return null */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the internal representation of the hashmap */
|
/* Point to the internal representation of the hashmap */
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
if(pMap->nEntry < 1) {
|
if(pMap->nEntry < 1) {
|
||||||
/* Empty hashmap, return NULL */
|
/* Empty hashmap,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
} else {
|
} else {
|
||||||
ph7_hashmap_node *pEntry = pMap->pFirst;
|
ph7_hashmap_node *pEntry = pMap->pFirst;
|
||||||
|
@ -2411,7 +2411,7 @@ static sxi32 HashmapCurrentValue(ph7_context *pCtx, ph7_hashmap *pMap, int iDire
|
||||||
ph7_hashmap_node *pCur = pMap->pCur;
|
ph7_hashmap_node *pCur = pMap->pCur;
|
||||||
ph7_value *pVal;
|
ph7_value *pVal;
|
||||||
if(pCur == 0) {
|
if(pCur == 0) {
|
||||||
/* Cursor does not point to anything, return FALSE */
|
/* Cursor does not point to anything,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2426,7 +2426,7 @@ static sxi32 HashmapCurrentValue(ph7_context *pCtx, ph7_hashmap *pMap, int iDire
|
||||||
pCur = pMap->pCur;
|
pCur = pMap->pCur;
|
||||||
}
|
}
|
||||||
if(pCur == 0) {
|
if(pCur == 0) {
|
||||||
/* End of input reached, return FALSE */
|
/* End of input reached,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2453,13 +2453,13 @@ static sxi32 HashmapCurrentValue(ph7_context *pCtx, ph7_hashmap *pMap, int iDire
|
||||||
*/
|
*/
|
||||||
static int ph7_hashmap_current(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_current(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2478,13 +2478,13 @@ static int ph7_hashmap_current(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
*/
|
*/
|
||||||
static int ph7_hashmap_next(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_next(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2503,13 +2503,13 @@ static int ph7_hashmap_next(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
*/
|
*/
|
||||||
static int ph7_hashmap_prev(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_prev(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2527,13 +2527,13 @@ static int ph7_hashmap_prev(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int ph7_hashmap_end(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_end(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2556,13 +2556,13 @@ static int ph7_hashmap_end(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int ph7_hashmap_reset(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int ph7_hashmap_reset(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2590,20 +2590,20 @@ static int ph7_hashmap_simple_key(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
ph7_hashmap_node *pCur;
|
ph7_hashmap_node *pCur;
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
pCur = pMap->pCur;
|
pCur = pMap->pCur;
|
||||||
if(pCur == 0) {
|
if(pCur == 0) {
|
||||||
/* Cursor does not point to anything, return NULL */
|
/* Cursor does not point to anything,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2637,20 +2637,20 @@ static int ph7_hashmap_each(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pVal;
|
ph7_value *pVal;
|
||||||
ph7_value sKey;
|
ph7_value sKey;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the internal representation that describe the input hashmap */
|
/* Point to the internal representation that describe the input hashmap */
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
if(pMap->pCur == 0) {
|
if(pMap->pCur == 0) {
|
||||||
/* Cursor does not point to anything, return FALSE */
|
/* Cursor does not point to anything,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2757,13 +2757,13 @@ static int ph7_hashmap_values(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2814,13 +2814,13 @@ static int ph7_hashmap_keys(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2884,7 +2884,7 @@ static int ph7_hashmap_merge(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pArray;
|
ph7_value *pArray;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2964,7 +2964,7 @@ static int ph7_hashmap_slice(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int bPreserve;
|
int bPreserve;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2977,7 +2977,7 @@ static int ph7_hashmap_slice(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
iOfft = (int)pSrc->nEntry + iOfft;
|
iOfft = (int)pSrc->nEntry + iOfft;
|
||||||
}
|
}
|
||||||
if(iOfft < 0 || iOfft > (int)pSrc->nEntry) {
|
if(iOfft < 0 || iOfft > (int)pSrc->nEntry) {
|
||||||
/* Invalid offset, return the last entry */
|
/* Invalid offset,return the last entry */
|
||||||
iOfft = (int)pSrc->nEntry - 1;
|
iOfft = (int)pSrc->nEntry - 1;
|
||||||
}
|
}
|
||||||
/* Get the length */
|
/* Get the length */
|
||||||
|
@ -3001,7 +3001,7 @@ static int ph7_hashmap_slice(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
if(iLength < 1) {
|
if(iLength < 1) {
|
||||||
/* Don't bother processing, return the empty array */
|
/* Don't bother processing,return the empty array */
|
||||||
ph7_result_value(pCtx, pArray);
|
ph7_result_value(pCtx, pArray);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3066,7 +3066,7 @@ static int ph7_hashmap_splice(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int iLength, iOfft;
|
int iLength, iOfft;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3099,7 +3099,7 @@ static int ph7_hashmap_splice(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
if(iLength < 1) {
|
if(iLength < 1) {
|
||||||
/* Don't bother processing, return the empty array */
|
/* Don't bother processing,return the empty array */
|
||||||
ph7_result_value(pCtx, pArray);
|
ph7_result_value(pCtx, pArray);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3184,7 +3184,7 @@ static int ph7_hashmap_in_array(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
int bStrict;
|
int bStrict;
|
||||||
int rc;
|
int rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing argument, return FALSE */
|
/* Missing argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3230,13 +3230,13 @@ static int ph7_hashmap_search(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int rc;
|
int rc;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing argument, return FALSE*/
|
/* Missing argument,return FALSE*/
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
bStrict = FALSE;
|
bStrict = FALSE;
|
||||||
if(!ph7_value_is_array(apArg[1])) {
|
if(!ph7_value_is_array(apArg[1])) {
|
||||||
/* hasystack must be an array, return FALSE */
|
/* hasystack must be an array,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3266,7 +3266,7 @@ static int ph7_hashmap_search(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
PH7_MemObjRelease(&sVal);
|
PH7_MemObjRelease(&sVal);
|
||||||
PH7_MemObjRelease(&sNeedle);
|
PH7_MemObjRelease(&sNeedle);
|
||||||
if(rc == 0) {
|
if(rc == 0) {
|
||||||
/* Match found, return key */
|
/* Match found,return key */
|
||||||
if(pEntry->iType == HASHMAP_INT_NODE) {
|
if(pEntry->iType == HASHMAP_INT_NODE) {
|
||||||
/* INT key */
|
/* INT key */
|
||||||
ph7_result_int64(pCtx, pEntry->xKey.iKey);
|
ph7_result_int64(pCtx, pEntry->xKey.iKey);
|
||||||
|
@ -3282,7 +3282,7 @@ static int ph7_hashmap_search(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pEntry = pEntry->pPrev; /* Reverse link */
|
pEntry = pEntry->pPrev; /* Reverse link */
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
/* No such value, return FALSE */
|
/* No such value,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3309,7 +3309,7 @@ static int ph7_hashmap_diff(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3393,7 +3393,7 @@ static int ph7_hashmap_udiff(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3472,7 +3472,7 @@ static int ph7_hashmap_diff_assoc(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3566,7 +3566,7 @@ static int ph7_hashmap_diff_uassoc(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3656,7 +3656,7 @@ static int ph7_hashmap_diff_key(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3735,7 +3735,7 @@ static int ph7_hashmap_intersect(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3813,7 +3813,7 @@ static int ph7_hashmap_intersect_assoc(ph7_context *pCtx, int nArg, ph7_value **
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3901,7 +3901,7 @@ static int ph7_hashmap_intersect_key(ph7_context *pCtx, int nArg, ph7_value **ap
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -3987,7 +3987,7 @@ static int ph7_hashmap_uintersect(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Missing/Invalid arguments, return NULL */
|
/* Missing/Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4060,7 +4060,7 @@ static int ph7_hashmap_fill(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pArray;
|
ph7_value *pArray;
|
||||||
int i, nEntry;
|
int i, nEntry;
|
||||||
if(nArg < 3) {
|
if(nArg < 3) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4099,13 +4099,13 @@ static int ph7_hashmap_fill_keys(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
ph7_value *pArray;
|
ph7_value *pArray;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4147,13 +4147,13 @@ static int ph7_hashmap_combine(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pArray;
|
ph7_value *pArray;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0]) || !ph7_value_is_array(apArg[1])) {
|
if(!ph7_value_is_array(apArg[0]) || !ph7_value_is_array(apArg[1])) {
|
||||||
/* Invalid argument, return FALSE */
|
/* Invalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4161,7 +4161,7 @@ static int ph7_hashmap_combine(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
pKey = (ph7_hashmap *)apArg[0]->x.pOther;
|
pKey = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
pValue = (ph7_hashmap *)apArg[1]->x.pOther;
|
pValue = (ph7_hashmap *)apArg[1]->x.pOther;
|
||||||
if(pKey->nEntry != pValue->nEntry) {
|
if(pKey->nEntry != pValue->nEntry) {
|
||||||
/* Array length differs, return FALSE */
|
/* Array length differs,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4202,13 +4202,13 @@ static int ph7_hashmap_reverse(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int bPreserve;
|
int bPreserve;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4259,13 +4259,13 @@ static int ph7_hashmap_unique(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4317,13 +4317,13 @@ static int ph7_hashmap_flip(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value sVal;
|
ph7_value sVal;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return NULL */
|
/* Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return NULL */
|
/* Invalid argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4432,19 +4432,19 @@ static int ph7_hashmap_sum(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return 0 */
|
/* Missing arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return 0 */
|
/* Invalid argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
if(pMap->nEntry < 1) {
|
if(pMap->nEntry < 1) {
|
||||||
/* Nothing to compute, return 0 */
|
/* Nothing to compute,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4534,19 +4534,19 @@ static int ph7_hashmap_product(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
ph7_value *pObj;
|
ph7_value *pObj;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return 0 */
|
/* Missing arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Make sure we are dealing with a valid hashmap */
|
/* Make sure we are dealing with a valid hashmap */
|
||||||
if(!ph7_value_is_array(apArg[0])) {
|
if(!ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid argument, return 0 */
|
/* Invalid argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
if(pMap->nEntry < 1) {
|
if(pMap->nEntry < 1) {
|
||||||
/* Nothing to compute, return 0 */
|
/* Nothing to compute,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4583,7 +4583,7 @@ static int ph7_hashmap_rand(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
int nItem = 1;
|
int nItem = 1;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return NULL */
|
/* Missing argument,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4595,7 +4595,7 @@ static int ph7_hashmap_rand(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Point to the internal representation of the input hashmap */
|
/* Point to the internal representation of the input hashmap */
|
||||||
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
pMap = (ph7_hashmap *)apArg[0]->x.pOther;
|
||||||
if(pMap->nEntry < 1) {
|
if(pMap->nEntry < 1) {
|
||||||
/* Empty hashmap, return NULL */
|
/* Empty hashmap,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4698,7 +4698,7 @@ static int ph7_hashmap_chunk(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxu32 nSize;
|
sxu32 nSize;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid arguments, return NULL */
|
/* Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4779,7 +4779,7 @@ static int ph7_hashmap_pad(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pArray;
|
ph7_value *pArray;
|
||||||
int nEntry;
|
int nEntry;
|
||||||
if(nArg < 3 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 3 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid arguments, return NULL */
|
/* Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4850,7 +4850,7 @@ static int ph7_hashmap_replace(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value *pArray;
|
ph7_value *pArray;
|
||||||
int i;
|
int i;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Invalid arguments, return NULL */
|
/* Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4896,7 +4896,7 @@ static int ph7_hashmap_filter(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int keep;
|
int keep;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid arguments, return NULL */
|
/* Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4958,7 +4958,7 @@ static int ph7_hashmap_map(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[1])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[1])) {
|
||||||
/* Invalid arguments, return NULL */
|
/* Invalid arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5023,7 +5023,7 @@ static int ph7_hashmap_reduce(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_value sResult;
|
ph7_value sResult;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid/Missing arguments, return NULL */
|
/* Invalid/Missing arguments,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5076,7 +5076,7 @@ static int ph7_hashmap_walk(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
sxu32 n;
|
sxu32 n;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid/Missing arguments, return FALSE */
|
/* Invalid/Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5105,7 +5105,7 @@ static int ph7_hashmap_walk(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Point to the next entry */
|
/* Point to the next entry */
|
||||||
pEntry = pEntry->pPrev; /* Reverse link */
|
pEntry = pEntry->pPrev; /* Reverse link */
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -5177,7 +5177,7 @@ static int ph7_hashmap_walk_recursive(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
ph7_hashmap *pMap;
|
ph7_hashmap *pMap;
|
||||||
sxi32 rc;
|
sxi32 rc;
|
||||||
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_array(apArg[0])) {
|
||||||
/* Invalid/Missing arguments, return FALSE */
|
/* Invalid/Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ PH7_PRIVATE SyHashEntry *SyHashGet(SyHash *pHash, const void *pKey, sxu32 nKeyLe
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(pHash->nEntry < 1 || nKeyLen < 1) {
|
if(pHash->nEntry < 1 || nKeyLen < 1) {
|
||||||
/* Don't bother hashing, return immediately */
|
/* Don't bother hashing,return immediately */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pEntry = HashGetEntry(&(*pHash), pKey, nKeyLen);
|
pEntry = HashGetEntry(&(*pHash), pKey, nKeyLen);
|
||||||
|
|
|
@ -673,7 +673,7 @@ static void PH7_ClassInstanceRelease(ph7_class_instance *pThis) {
|
||||||
ph7_vm *pVm;
|
ph7_vm *pVm;
|
||||||
if(pThis->iFlags & CLASS_INSTANCE_DESTROYED) {
|
if(pThis->iFlags & CLASS_INSTANCE_DESTROYED) {
|
||||||
/*
|
/*
|
||||||
* Already destroyed, return immediately.
|
* Already destroyed,return immediately.
|
||||||
* This could happend if someone perform unset($this) in the destructor body.
|
* This could happend if someone perform unset($this) in the destructor body.
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
|
@ -979,7 +979,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCallMagicMethod(
|
||||||
/* Make sure the magic method is available */
|
/* Make sure the magic method is available */
|
||||||
pMeth = PH7_ClassExtractMethod(&(*pClass), zMethod, nByte);
|
pMeth = PH7_ClassExtractMethod(&(*pClass), zMethod, nByte);
|
||||||
if(pMeth == 0) {
|
if(pMeth == 0) {
|
||||||
/* No such method, return immediately */
|
/* No such method,return immediately */
|
||||||
return SXERR_NOTFOUND;
|
return SXERR_NOTFOUND;
|
||||||
}
|
}
|
||||||
nArg = 0;
|
nArg = 0;
|
||||||
|
|
50
engine/vfs.c
50
engine/vfs.c
|
@ -134,7 +134,7 @@ static int PH7_vfs_getcwd(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(pVfs == 0 || pVfs->xGetcwd == 0) {
|
if(pVfs == 0 || pVfs->xGetcwd == 0) {
|
||||||
SXUNUSED(nArg); /* cc warning */
|
SXUNUSED(nArg); /* cc warning */
|
||||||
SXUNUSED(apArg);
|
SXUNUSED(apArg);
|
||||||
/* IO routine not implemented, return NULL */
|
/* IO routine not implemented,return NULL */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -172,7 +172,7 @@ static int PH7_vfs_rmdir(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Point to the underlying vfs */
|
/* Point to the underlying vfs */
|
||||||
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
||||||
if(pVfs == 0 || pVfs->xRmdir == 0) {
|
if(pVfs == 0 || pVfs->xRmdir == 0) {
|
||||||
/* IO routine not implemented, return NULL */
|
/* IO routine not implemented,return NULL */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -209,7 +209,7 @@ static int PH7_vfs_is_dir(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Point to the underlying vfs */
|
/* Point to the underlying vfs */
|
||||||
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
||||||
if(pVfs == 0 || pVfs->xIsdir == 0) {
|
if(pVfs == 0 || pVfs->xIsdir == 0) {
|
||||||
/* IO routine not implemented, return NULL */
|
/* IO routine not implemented,return NULL */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -422,13 +422,13 @@ static int PH7_vfs_usleep(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_vfs *pVfs;
|
ph7_vfs *pVfs;
|
||||||
int nSleep;
|
int nSleep;
|
||||||
if(nArg < 1 || !ph7_value_is_int(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_int(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return immediately */
|
/* Missing/Invalid argument,return immediately */
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the underlying vfs */
|
/* Point to the underlying vfs */
|
||||||
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
||||||
if(pVfs == 0 || pVfs->xSleep == 0) {
|
if(pVfs == 0 || pVfs->xSleep == 0) {
|
||||||
/* IO routine not implemented, return NULL */
|
/* IO routine not implemented,return NULL */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -438,7 +438,7 @@ static int PH7_vfs_usleep(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Amount to sleep */
|
/* Amount to sleep */
|
||||||
nSleep = ph7_value_to_int(apArg[0]);
|
nSleep = ph7_value_to_int(apArg[0]);
|
||||||
if(nSleep < 0) {
|
if(nSleep < 0) {
|
||||||
/* Invalid value, return immediately */
|
/* Invalid value,return immediately */
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Perform the requested operation (Microseconds) */
|
/* Perform the requested operation (Microseconds) */
|
||||||
|
@ -1175,14 +1175,14 @@ static int PH7_vfs_filetype(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
const char *zPath;
|
const char *zPath;
|
||||||
ph7_vfs *pVfs;
|
ph7_vfs *pVfs;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return 'unknown' */
|
/* Missing/Invalid argument,return 'unknown' */
|
||||||
ph7_result_string(pCtx, "unknown", sizeof("unknown") - 1);
|
ph7_result_string(pCtx, "unknown", sizeof("unknown") - 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the underlying vfs */
|
/* Point to the underlying vfs */
|
||||||
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
||||||
if(pVfs == 0 || pVfs->xFiletype == 0) {
|
if(pVfs == 0 || pVfs->xFiletype == 0) {
|
||||||
/* IO routine not implemented, return NULL */
|
/* IO routine not implemented,return NULL */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -1424,7 +1424,7 @@ static int PH7_vfs_putenv(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Point to the underlying vfs */
|
/* Point to the underlying vfs */
|
||||||
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
||||||
if(pVfs == 0 || pVfs->xSetenv == 0) {
|
if(pVfs == 0 || pVfs->xSetenv == 0) {
|
||||||
/* IO routine not implemented, return NULL */
|
/* IO routine not implemented,return NULL */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -1551,7 +1551,7 @@ static int PH7_builtin_basename(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
const char *zPath, *zBase, *zEnd;
|
const char *zPath, *zBase, *zEnd;
|
||||||
int c, d, iLen;
|
int c, d, iLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return the empty string */
|
/* Missing/Invalid argument,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1691,7 +1691,7 @@ static int PH7_builtin_pathinfo(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
SyString *pComp;
|
SyString *pComp;
|
||||||
int iLen;
|
int iLen;
|
||||||
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_string(apArg[0])) {
|
||||||
/* Missing/Invalid argument, return the empty string */
|
/* Missing/Invalid argument,return the empty string */
|
||||||
ph7_result_string(pCtx, "", 0);
|
ph7_result_string(pCtx, "", 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1755,7 +1755,7 @@ static int PH7_builtin_pathinfo(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
pArray = ph7_context_new_array(pCtx);
|
pArray = ph7_context_new_array(pCtx);
|
||||||
pValue = ph7_context_new_scalar(pCtx);
|
pValue = ph7_context_new_scalar(pCtx);
|
||||||
if(pArray == 0 || pValue == 0) {
|
if(pArray == 0 || pValue == 0) {
|
||||||
/* Out of mem, return NULL */
|
/* Out of mem,return NULL */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -2174,7 +2174,7 @@ static int PH7_vfs_umask(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Point to the underlying vfs */
|
/* Point to the underlying vfs */
|
||||||
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
pVfs = (ph7_vfs *)ph7_context_user_data(pCtx);
|
||||||
if(pVfs == 0 || pVfs->xUmask == 0) {
|
if(pVfs == 0 || pVfs->xUmask == 0) {
|
||||||
/* IO routine not implemented, return -1 */
|
/* IO routine not implemented,return -1 */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -2209,7 +2209,7 @@ static int PH7_vfs_sys_get_temp_dir(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
if(pVfs == 0 || pVfs->xTempDir == 0) {
|
if(pVfs == 0 || pVfs->xTempDir == 0) {
|
||||||
SXUNUSED(nArg); /* cc warning */
|
SXUNUSED(nArg); /* cc warning */
|
||||||
SXUNUSED(apArg);
|
SXUNUSED(apArg);
|
||||||
/* IO routine not implemented, return "" */
|
/* IO routine not implemented,return "" */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -2264,7 +2264,7 @@ static int PH7_vfs_getmypid(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(pVfs == 0 || pVfs->xProcessId == 0) {
|
if(pVfs == 0 || pVfs->xProcessId == 0) {
|
||||||
SXUNUSED(nArg); /* cc warning */
|
SXUNUSED(nArg); /* cc warning */
|
||||||
SXUNUSED(apArg);
|
SXUNUSED(apArg);
|
||||||
/* IO routine not implemented, return -1 */
|
/* IO routine not implemented,return -1 */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -2294,7 +2294,7 @@ static int PH7_vfs_getmyuid(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(pVfs == 0 || pVfs->xUid == 0) {
|
if(pVfs == 0 || pVfs->xUid == 0) {
|
||||||
SXUNUSED(nArg); /* cc warning */
|
SXUNUSED(nArg); /* cc warning */
|
||||||
SXUNUSED(apArg);
|
SXUNUSED(apArg);
|
||||||
/* IO routine not implemented, return -1 */
|
/* IO routine not implemented,return -1 */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -2324,7 +2324,7 @@ static int PH7_vfs_getmygid(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(pVfs == 0 || pVfs->xGid == 0) {
|
if(pVfs == 0 || pVfs->xGid == 0) {
|
||||||
SXUNUSED(nArg); /* cc warning */
|
SXUNUSED(nArg); /* cc warning */
|
||||||
SXUNUSED(apArg);
|
SXUNUSED(apArg);
|
||||||
/* IO routine not implemented, return -1 */
|
/* IO routine not implemented,return -1 */
|
||||||
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING,
|
||||||
"IO routine(%s) not implemented in the underlying VFS",
|
"IO routine(%s) not implemented in the underlying VFS",
|
||||||
ph7_function_name(pCtx)
|
ph7_function_name(pCtx)
|
||||||
|
@ -2922,12 +2922,12 @@ static ph7_int64 StreamReadLine(io_private *pDev, const char **pzData, ph7_int64
|
||||||
/* Try to extract a line */
|
/* Try to extract a line */
|
||||||
rc = GetLine(pDev, &n, pzData);
|
rc = GetLine(pDev, &n, pzData);
|
||||||
if(rc == SXRET_OK) {
|
if(rc == SXRET_OK) {
|
||||||
/* Got one, return immediately */
|
/* Got one,return immediately */
|
||||||
pDev->nOfft += (sxu32)n;
|
pDev->nOfft += (sxu32)n;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
if(nMaxLen > 0 && (SyBlobLength(&pDev->sBuffer) - pDev->nOfft >= nMaxLen)) {
|
if(nMaxLen > 0 && (SyBlobLength(&pDev->sBuffer) - pDev->nOfft >= nMaxLen)) {
|
||||||
/* Read limit reached, return the available data */
|
/* Read limit reached,return the available data */
|
||||||
*pzData = (const char *)SyBlobDataAt(&pDev->sBuffer, pDev->nOfft);
|
*pzData = (const char *)SyBlobDataAt(&pDev->sBuffer, pDev->nOfft);
|
||||||
n = SyBlobLength(&pDev->sBuffer) - pDev->nOfft;
|
n = SyBlobLength(&pDev->sBuffer) - pDev->nOfft;
|
||||||
/* Reset the working buffer */
|
/* Reset the working buffer */
|
||||||
|
@ -2937,7 +2937,7 @@ static ph7_int64 StreamReadLine(io_private *pDev, const char **pzData, ph7_int64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(SyBlobLength(&pDev->sBuffer) - pDev->nOfft > 0) {
|
if(SyBlobLength(&pDev->sBuffer) - pDev->nOfft > 0) {
|
||||||
/* Read limit reached, return the available data */
|
/* Read limit reached,return the available data */
|
||||||
*pzData = (const char *)SyBlobDataAt(&pDev->sBuffer, pDev->nOfft);
|
*pzData = (const char *)SyBlobDataAt(&pDev->sBuffer, pDev->nOfft);
|
||||||
n = SyBlobLength(&pDev->sBuffer) - pDev->nOfft;
|
n = SyBlobLength(&pDev->sBuffer) - pDev->nOfft;
|
||||||
/* Reset the working buffer */
|
/* Reset the working buffer */
|
||||||
|
@ -3836,7 +3836,7 @@ static int PH7_builtin_file_put_contents(ph7_context *pCtx, int nArg, ph7_value
|
||||||
/* Data to write */
|
/* Data to write */
|
||||||
zData = ph7_value_to_string(apArg[1], &nLen);
|
zData = ph7_value_to_string(apArg[1], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Nothing to write, return immediately */
|
/* Nothing to write,return immediately */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4544,7 +4544,7 @@ static int PH7_builtin_fprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
/* Extract the string format */
|
/* Extract the string format */
|
||||||
zFormat = ph7_value_to_string(apArg[1], &nLen);
|
zFormat = ph7_value_to_string(apArg[1], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return zero */
|
/* Empty string,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4604,7 +4604,7 @@ static int PH7_builtin_vfprintf(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
/* Extract the string format */
|
/* Extract the string format */
|
||||||
zFormat = ph7_value_to_string(apArg[1], &nLen);
|
zFormat = ph7_value_to_string(apArg[1], &nLen);
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return zero */
|
/* Empty string,return zero */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -4700,7 +4700,7 @@ static int StrModeToFlags(ph7_context *pCtx, const char *zMode, int nLen) {
|
||||||
}
|
}
|
||||||
} else if(c == 'x' || c == 'X') {
|
} else if(c == 'x' || c == 'X') {
|
||||||
/* Exclusive access.
|
/* Exclusive access.
|
||||||
* If the file already exists, return immediately with a failure code.
|
* If the file already exists,return immediately with a failure code.
|
||||||
* Otherwise create a new file.
|
* Otherwise create a new file.
|
||||||
*/
|
*/
|
||||||
iFlag = PH7_IO_OPEN_WRONLY | PH7_IO_OPEN_EXCL;
|
iFlag = PH7_IO_OPEN_WRONLY | PH7_IO_OPEN_EXCL;
|
||||||
|
@ -4848,7 +4848,7 @@ static int PH7_builtin_fopen(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_context_free_chunk(pCtx, pDev);
|
ph7_context_free_chunk(pCtx, pDev);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* All done, return the io_private instance as a resource */
|
/* All done,return the io_private instance as a resource */
|
||||||
ph7_result_resource(pCtx, pDev);
|
ph7_result_resource(pCtx, pDev);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
|
747
engine/vm.c
747
engine/vm.c
File diff suppressed because it is too large
Load Diff
|
@ -136,8 +136,6 @@ static sxi32 PH7_CompileHalt(ph7_gen_state *pGen);
|
||||||
static sxi32 PH7_CompileVar(ph7_gen_state *pGen);
|
static sxi32 PH7_CompileVar(ph7_gen_state *pGen);
|
||||||
static sxi32 PH7_CompileNamespace(ph7_gen_state *pGen);
|
static sxi32 PH7_CompileNamespace(ph7_gen_state *pGen);
|
||||||
static sxi32 PH7_CompileUsing(ph7_gen_state *pGen);
|
static sxi32 PH7_CompileUsing(ph7_gen_state *pGen);
|
||||||
static sxi32 PH7_CompileImport(ph7_gen_state *pGen);
|
|
||||||
static sxi32 PH7_CompileInclude(ph7_gen_state *pGen);
|
|
||||||
static sxi32 PH7_GenStateProcessArgValue(ph7_gen_state *pGen, ph7_vm_func_arg *pArg, SyToken *pIn, SyToken *pEnd);
|
static sxi32 PH7_GenStateProcessArgValue(ph7_gen_state *pGen, ph7_vm_func_arg *pArg, SyToken *pIn, SyToken *pEnd);
|
||||||
static sxi32 PH7_GenStateCollectFuncArgs(ph7_vm_func *pFunc, ph7_gen_state *pGen, SyToken *pEnd);
|
static sxi32 PH7_GenStateCollectFuncArgs(ph7_vm_func *pFunc, ph7_gen_state *pGen, SyToken *pEnd);
|
||||||
static sxi32 PH7_GenStateCompileFuncBody(ph7_gen_state *pGen, ph7_vm_func *pFunc);
|
static sxi32 PH7_GenStateCompileFuncBody(ph7_gen_state *pGen, ph7_vm_func *pFunc);
|
||||||
|
|
|
@ -360,7 +360,6 @@ typedef sxi64 ph7_int64;
|
||||||
#define PH7_AERSCRIPT_CODE 0x01 /* AerScript Code */
|
#define PH7_AERSCRIPT_CODE 0x01 /* AerScript Code */
|
||||||
#define PH7_AERSCRIPT_CHNK 0x02 /* AerScript Chunk of Code */
|
#define PH7_AERSCRIPT_CHNK 0x02 /* AerScript Chunk of Code */
|
||||||
#define PH7_AERSCRIPT_EXPR 0x04 /* AerScript Expression */
|
#define PH7_AERSCRIPT_EXPR 0x04 /* AerScript Expression */
|
||||||
#define PH7_AERSCRIPT_FILE 0x08 /* AerScript File Inclusion */
|
|
||||||
/*
|
/*
|
||||||
* Call Context Error Message Severity Level.
|
* Call Context Error Message Severity Level.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1376,8 +1376,6 @@ enum iErrCode {
|
||||||
enum ph7_vm_op {
|
enum ph7_vm_op {
|
||||||
PH7_OP_DONE = 1, /* Done */
|
PH7_OP_DONE = 1, /* Done */
|
||||||
PH7_OP_HALT, /* Halt */
|
PH7_OP_HALT, /* Halt */
|
||||||
PH7_OP_IMPORT, /* Import AerScript module */
|
|
||||||
PH7_OP_INCLUDE, /* Include another source file */
|
|
||||||
PH7_OP_DECLARE, /* Declare a variable */
|
PH7_OP_DECLARE, /* Declare a variable */
|
||||||
PH7_OP_LOADV, /* Load variable */
|
PH7_OP_LOADV, /* Load variable */
|
||||||
PH7_OP_LOADC, /* Load constant */
|
PH7_OP_LOADC, /* Load constant */
|
||||||
|
@ -1669,7 +1667,6 @@ PH7_PRIVATE sxi32 PH7_VmOutputConsumeAp(ph7_vm *pVm, const char *zFormat, va_lis
|
||||||
PH7_PRIVATE sxi32 PH7_VmMemoryError(ph7_vm *pVm);
|
PH7_PRIVATE sxi32 PH7_VmMemoryError(ph7_vm *pVm);
|
||||||
PH7_PRIVATE sxi32 PH7_VmThrowError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...);
|
PH7_PRIVATE sxi32 PH7_VmThrowError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...);
|
||||||
PH7_PRIVATE void PH7_VmExpandConstantValue(ph7_value *pVal, void *pUserData);
|
PH7_PRIVATE void PH7_VmExpandConstantValue(ph7_value *pVal, void *pUserData);
|
||||||
PH7_PRIVATE sxi32 VmExtractDebugTrace(ph7_vm *pVm, SySet *pDebugTrace);
|
|
||||||
PH7_PRIVATE sxi32 PH7_VmDump(ph7_vm *pVm, ProcConsumer xConsumer, void *pUserData);
|
PH7_PRIVATE sxi32 PH7_VmDump(ph7_vm *pVm, ProcConsumer xConsumer, void *pUserData);
|
||||||
PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine, sxbool bDebug);
|
PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine, sxbool bDebug);
|
||||||
PH7_PRIVATE sxi32 PH7_VmConfigure(ph7_vm *pVm, sxi32 nOp, va_list ap);
|
PH7_PRIVATE sxi32 PH7_VmConfigure(ph7_vm *pVm, sxi32 nOp, va_list ap);
|
||||||
|
|
|
@ -21,7 +21,7 @@ static int PH7_builtin_ctype_alnum(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ static int PH7_builtin_ctype_alnum(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ static int PH7_builtin_ctype_alnum(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ static int PH7_builtin_ctype_alpha(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ static int PH7_builtin_ctype_alpha(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ static int PH7_builtin_ctype_alpha(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ static int PH7_builtin_ctype_cntrl(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ static int PH7_builtin_ctype_cntrl(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ static int PH7_builtin_ctype_cntrl(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ static int PH7_builtin_ctype_digit(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ static int PH7_builtin_ctype_digit(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ static int PH7_builtin_ctype_digit(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ static int PH7_builtin_ctype_xdigit(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ static int PH7_builtin_ctype_xdigit(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ static int PH7_builtin_ctype_xdigit(ph7_context *pCtx, int nArg, ph7_value **apA
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ static int PH7_builtin_ctype_graph(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ static int PH7_builtin_ctype_graph(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ static int PH7_builtin_ctype_graph(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ static int PH7_builtin_ctype_print(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ static int PH7_builtin_ctype_print(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ static int PH7_builtin_ctype_print(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +340,7 @@ static int PH7_builtin_ctype_punct(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,7 @@ static int PH7_builtin_ctype_punct(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ static int PH7_builtin_ctype_punct(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ static int PH7_builtin_ctype_space(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ static int PH7_builtin_ctype_space(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ static int PH7_builtin_ctype_space(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@ static int PH7_builtin_ctype_lower(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ static int PH7_builtin_ctype_lower(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ static int PH7_builtin_ctype_lower(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -476,7 +476,7 @@ static int PH7_builtin_ctype_upper(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
const unsigned char *zIn, *zEnd;
|
const unsigned char *zIn, *zEnd;
|
||||||
int nLen;
|
int nLen;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ static int PH7_builtin_ctype_upper(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
zIn = (const unsigned char *)ph7_value_to_string(apArg[0], &nLen);
|
||||||
zEnd = &zIn[nLen];
|
zEnd = &zIn[nLen];
|
||||||
if(nLen < 1) {
|
if(nLen < 1) {
|
||||||
/* Empty string, return FALSE */
|
/* Empty string,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ static int PH7_builtin_ctype_upper(ph7_context *pCtx, int nArg, ph7_value **apAr
|
||||||
/* Point to the next character */
|
/* Point to the next character */
|
||||||
zIn++;
|
zIn++;
|
||||||
}
|
}
|
||||||
/* The test failed, return FALSE */
|
/* The test failed,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@ static sxi32 VmJsonEncode(
|
||||||
static int VmJsonArrayEncode(ph7_value *pKey, ph7_value *pValue, void *pUserData) {
|
static int VmJsonArrayEncode(ph7_value *pKey, ph7_value *pValue, void *pUserData) {
|
||||||
json_private_data *pJson = (json_private_data *)pUserData;
|
json_private_data *pJson = (json_private_data *)pUserData;
|
||||||
if(pJson->nRecCount > 31) {
|
if(pJson->nRecCount > 31) {
|
||||||
/* Recursion limit reached, return immediately */
|
/* Recursion limit reached,return immediately */
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
if(!pJson->isFirst) {
|
if(!pJson->isFirst) {
|
||||||
|
@ -296,7 +296,7 @@ static int VmJsonArrayEncode(ph7_value *pKey, ph7_value *pValue, void *pUserData
|
||||||
static int VmJsonObjectEncode(const char *zAttr, ph7_value *pValue, void *pUserData) {
|
static int VmJsonObjectEncode(const char *zAttr, ph7_value *pValue, void *pUserData) {
|
||||||
json_private_data *pJson = (json_private_data *)pUserData;
|
json_private_data *pJson = (json_private_data *)pUserData;
|
||||||
if(pJson->nRecCount > 31) {
|
if(pJson->nRecCount > 31) {
|
||||||
/* Recursion limit reached, return immediately */
|
/* Recursion limit reached,return immediately */
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
if(!pJson->isFirst) {
|
if(!pJson->isFirst) {
|
||||||
|
@ -336,7 +336,7 @@ static int VmJsonObjectEncode(const char *zAttr, ph7_value *pValue, void *pUserD
|
||||||
static int vm_builtin_json_encode(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_json_encode(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
json_private_data sJson;
|
json_private_data sJson;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing arguments, return FALSE */
|
/* Missing arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -748,7 +748,7 @@ static sxi32 VmJsonDecode(
|
||||||
}
|
}
|
||||||
if((pDecoder->pIn->nType & JSON_TK_STR) == 0 || &pDecoder->pIn[1] >= pDecoder->pEnd
|
if((pDecoder->pIn->nType & JSON_TK_STR) == 0 || &pDecoder->pIn[1] >= pDecoder->pEnd
|
||||||
|| (pDecoder->pIn[1].nType & JSON_TK_COLON) == 0) {
|
|| (pDecoder->pIn[1].nType & JSON_TK_COLON) == 0) {
|
||||||
/* Syntax error, return immediately */
|
/* Syntax error,return immediately */
|
||||||
*pDecoder->pErr = JSON_ERROR_SYNTAX;
|
*pDecoder->pErr = JSON_ERROR_SYNTAX;
|
||||||
return SXERR_ABORT;
|
return SXERR_ABORT;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +841,7 @@ static int vm_builtin_json_decode(ph7_context *pCtx, int nArg, ph7_value **apArg
|
||||||
/* Extract the JSON string */
|
/* Extract the JSON string */
|
||||||
zIn = ph7_value_to_string(apArg[0], &nByte);
|
zIn = ph7_value_to_string(apArg[0], &nByte);
|
||||||
if(nByte < 1) {
|
if(nByte < 1) {
|
||||||
/* Empty string, return NULL */
|
/* Empty string,return NULL */
|
||||||
ph7_result_null(pCtx);
|
ph7_result_null(pCtx);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ static void PH7_M_EULER_Const(ph7_value *pVal, void *pUserData) {
|
||||||
static int PH7_builtin_sqrt(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_sqrt(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ static int PH7_builtin_sqrt(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_exp(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_exp(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ static int PH7_builtin_exp(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_floor(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_floor(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ static int PH7_builtin_floor(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_cos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_cos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ static int PH7_builtin_cos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_acos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_acos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ static int PH7_builtin_acos(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_cosh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_cosh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ static int PH7_builtin_cosh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_sin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_sin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ static int PH7_builtin_sin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_asin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_asin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ static int PH7_builtin_asin(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_sinh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_sinh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ static int PH7_builtin_sinh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_ceil(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_ceil(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ static int PH7_builtin_ceil(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_tan(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_tan(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ static int PH7_builtin_tan(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_atan(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_atan(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,7 @@ static int PH7_builtin_atan(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_tanh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_tanh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -450,7 +450,7 @@ static int PH7_builtin_tanh(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_atan2(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_atan2(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x, y;
|
double r, x, y;
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing arguments, return 0 */
|
/* Missing arguments,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ static int PH7_builtin_atan2(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_abs(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_abs(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
int is_float;
|
int is_float;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ static int PH7_builtin_abs(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_log(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_log(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -534,7 +534,7 @@ static int PH7_builtin_log(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_log10(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_log10(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x;
|
double r, x;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -561,7 +561,7 @@ static int PH7_builtin_log10(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
static int PH7_builtin_pow(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_pow(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
double r, x, y;
|
double r, x, y;
|
||||||
if(nArg < 1) {
|
if(nArg < 1) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ static int PH7_builtin_hypot(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
*/
|
*/
|
||||||
static int PH7_builtin_max(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_max(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -682,7 +682,7 @@ static int PH7_builtin_max(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
*/
|
*/
|
||||||
static int PH7_builtin_min(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int PH7_builtin_min(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
if(nArg < 2) {
|
if(nArg < 2) {
|
||||||
/* Missing argument, return 0 */
|
/* Missing argument,return 0 */
|
||||||
ph7_result_int(pCtx, 0);
|
ph7_result_int(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,14 +348,14 @@ static int vm_builtin_xml_parser_create_ns(ph7_context *pCtx, int nArg, ph7_valu
|
||||||
static int vm_builtin_xml_parser_free(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_parser_free(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -403,14 +403,14 @@ static int vm_builtin_xml_parser_free(ph7_context *pCtx, int nArg, ph7_value **a
|
||||||
static int vm_builtin_xml_set_element_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_element_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ static int vm_builtin_xml_set_element_handler(ph7_context *pCtx, int nArg, ph7_v
|
||||||
PH7_MemObjStore(apArg[2]/* User callback*/, &pEngine->aCB[PH7_XML_END_TAG]);
|
PH7_MemObjStore(apArg[2]/* User callback*/, &pEngine->aCB[PH7_XML_END_TAG]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -451,14 +451,14 @@ static int vm_builtin_xml_set_element_handler(ph7_context *pCtx, int nArg, ph7_v
|
||||||
static int vm_builtin_xml_set_character_data_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_character_data_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ static int vm_builtin_xml_set_character_data_handler(ph7_context *pCtx, int nArg
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_CDATA]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_CDATA]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -493,14 +493,14 @@ static int vm_builtin_xml_set_character_data_handler(ph7_context *pCtx, int nArg
|
||||||
static int vm_builtin_xml_set_default_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_default_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,7 @@ static int vm_builtin_xml_set_default_handler(ph7_context *pCtx, int nArg, ph7_v
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_DEF]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_DEF]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -534,14 +534,14 @@ static int vm_builtin_xml_set_default_handler(ph7_context *pCtx, int nArg, ph7_v
|
||||||
static int vm_builtin_xml_set_end_namespace_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_end_namespace_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -549,7 +549,7 @@ static int vm_builtin_xml_set_end_namespace_decl_handler(ph7_context *pCtx, int
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_NS_END]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_NS_END]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -577,14 +577,14 @@ static int vm_builtin_xml_set_end_namespace_decl_handler(ph7_context *pCtx, int
|
||||||
static int vm_builtin_xml_set_start_namespace_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_start_namespace_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,7 @@ static int vm_builtin_xml_set_start_namespace_decl_handler(ph7_context *pCtx, in
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_NS_START]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_NS_START]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -620,14 +620,14 @@ static int vm_builtin_xml_set_start_namespace_decl_handler(ph7_context *pCtx, in
|
||||||
static int vm_builtin_xml_set_processing_instruction_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_processing_instruction_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -635,7 +635,7 @@ static int vm_builtin_xml_set_processing_instruction_handler(ph7_context *pCtx,
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_PI]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_PI]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -670,14 +670,14 @@ static int vm_builtin_xml_set_processing_instruction_handler(ph7_context *pCtx,
|
||||||
static int vm_builtin_xml_set_unparsed_entity_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_unparsed_entity_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +685,7 @@ static int vm_builtin_xml_set_unparsed_entity_decl_handler(ph7_context *pCtx, in
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_UNPED]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_UNPED]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -718,14 +718,14 @@ static int vm_builtin_xml_set_unparsed_entity_decl_handler(ph7_context *pCtx, in
|
||||||
static int vm_builtin_xml_set_notation_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_notation_decl_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -733,7 +733,7 @@ static int vm_builtin_xml_set_notation_decl_handler(ph7_context *pCtx, int nArg,
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_ND]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_ND]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -769,14 +769,14 @@ static int vm_builtin_xml_set_notation_decl_handler(ph7_context *pCtx, int nArg,
|
||||||
static int vm_builtin_xml_set_external_entity_ref_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_external_entity_ref_handler(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -784,7 +784,7 @@ static int vm_builtin_xml_set_external_entity_ref_handler(ph7_context *pCtx, int
|
||||||
/* Save the user callback for later invocation */
|
/* Save the user callback for later invocation */
|
||||||
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_EER]);
|
PH7_MemObjStore(apArg[1]/* User callback*/, &pEngine->aCB[PH7_XML_EER]);
|
||||||
}
|
}
|
||||||
/* All done, return TRUE */
|
/* All done,return TRUE */
|
||||||
ph7_result_bool(pCtx, 1);
|
ph7_result_bool(pCtx, 1);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -802,14 +802,14 @@ static int vm_builtin_xml_set_external_entity_ref_handler(ph7_context *pCtx, int
|
||||||
static int vm_builtin_xml_get_current_line_number(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_get_current_line_number(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -833,14 +833,14 @@ static int vm_builtin_xml_get_current_byte_index(ph7_context *pCtx, int nArg, ph
|
||||||
SyStream *pStream;
|
SyStream *pStream;
|
||||||
SyToken *pToken;
|
SyToken *pToken;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -873,14 +873,14 @@ static int vm_builtin_xml_get_current_byte_index(ph7_context *pCtx, int nArg, ph
|
||||||
static int vm_builtin_xml_set_object(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_set_object(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_object(apArg[1])) {
|
if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_object(apArg[1])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -909,14 +909,14 @@ static int vm_builtin_xml_get_current_column_number(ph7_context *pCtx, int nArg,
|
||||||
SyStream *pStream;
|
SyStream *pStream;
|
||||||
SyToken *pToken;
|
SyToken *pToken;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -947,14 +947,14 @@ static int vm_builtin_xml_get_current_column_number(ph7_context *pCtx, int nArg,
|
||||||
static int vm_builtin_xml_get_error_code(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_get_error_code(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 1 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1052,7 +1052,7 @@ static sxi32 VmXMLStartElementHandler(SyXMLRawStr *pStart, SyXMLRawStr *pNS, sxu
|
||||||
pCallback = &pEngine->aCB[PH7_XML_START_TAG];
|
pCallback = &pEngine->aCB[PH7_XML_START_TAG];
|
||||||
/* Make sure the given callback is callable */
|
/* Make sure the given callback is callable */
|
||||||
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
||||||
/* Not callable, return immediately*/
|
/* Not callable,return immediately*/
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Create a ph7_value holding the tag name */
|
/* Create a ph7_value holding the tag name */
|
||||||
|
@ -1061,7 +1061,7 @@ static sxi32 VmXMLStartElementHandler(SyXMLRawStr *pStart, SyXMLRawStr *pNS, sxu
|
||||||
pAttr = VmXMLAttrValue(pEngine, aAttr, nAttr);
|
pAttr = VmXMLAttrValue(pEngine, aAttr, nAttr);
|
||||||
if(pTag == 0 || pAttr == 0) {
|
if(pTag == 0 || pAttr == 0) {
|
||||||
SXUNUSED(pNS); /* cc warning */
|
SXUNUSED(pNS); /* cc warning */
|
||||||
/* Out of mem, return immediately */
|
/* Out of mem,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Invoke the user callback */
|
/* Invoke the user callback */
|
||||||
|
@ -1090,14 +1090,14 @@ static sxi32 VmXMLEndElementHandler(SyXMLRawStr *pEnd, SyXMLRawStr *pNS, void *p
|
||||||
pCallback = &pEngine->aCB[PH7_XML_END_TAG];
|
pCallback = &pEngine->aCB[PH7_XML_END_TAG];
|
||||||
/* Make sure the given callback is callable */
|
/* Make sure the given callback is callable */
|
||||||
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
||||||
/* Not callable, return immediately*/
|
/* Not callable,return immediately*/
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Create a ph7_value holding the tag name */
|
/* Create a ph7_value holding the tag name */
|
||||||
pTag = VmXMLValue(pEngine, pEnd, pNS);
|
pTag = VmXMLValue(pEngine, pEnd, pNS);
|
||||||
if(pTag == 0) {
|
if(pTag == 0) {
|
||||||
SXUNUSED(pNS); /* cc warning */
|
SXUNUSED(pNS); /* cc warning */
|
||||||
/* Out of mem, return immediately */
|
/* Out of mem,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Invoke the user callback */
|
/* Invoke the user callback */
|
||||||
|
@ -1126,13 +1126,13 @@ static sxi32 VmXMLTextHandler(SyXMLRawStr *pText, void *pUserData) {
|
||||||
pCallback = &pEngine->aCB[PH7_XML_CDATA];
|
pCallback = &pEngine->aCB[PH7_XML_CDATA];
|
||||||
/* Make sure the given callback is callable */
|
/* Make sure the given callback is callable */
|
||||||
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
||||||
/* Not callable, return immediately*/
|
/* Not callable,return immediately*/
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Create a ph7_value holding the data */
|
/* Create a ph7_value holding the data */
|
||||||
pData = VmXMLValue(pEngine, &(*pText), 0);
|
pData = VmXMLValue(pEngine, &(*pText), 0);
|
||||||
if(pData == 0) {
|
if(pData == 0) {
|
||||||
/* Out of mem, return immediately */
|
/* Out of mem,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Invoke the user callback */
|
/* Invoke the user callback */
|
||||||
|
@ -1161,14 +1161,14 @@ static sxi32 VmXMLPIHandler(SyXMLRawStr *pTargetStr, SyXMLRawStr *pDataStr, void
|
||||||
pCallback = &pEngine->aCB[PH7_XML_PI];
|
pCallback = &pEngine->aCB[PH7_XML_PI];
|
||||||
/* Make sure the given callback is callable */
|
/* Make sure the given callback is callable */
|
||||||
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
||||||
/* Not callable, return immediately*/
|
/* Not callable,return immediately*/
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Get a ph7_value holding the data */
|
/* Get a ph7_value holding the data */
|
||||||
pTarget = VmXMLValue(pEngine, &(*pTargetStr), 0);
|
pTarget = VmXMLValue(pEngine, &(*pTargetStr), 0);
|
||||||
pData = VmXMLValue(pEngine, &(*pDataStr), 0);
|
pData = VmXMLValue(pEngine, &(*pDataStr), 0);
|
||||||
if(pTarget == 0 || pData == 0) {
|
if(pTarget == 0 || pData == 0) {
|
||||||
/* Out of mem, return immediately */
|
/* Out of mem,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Invoke the user callback */
|
/* Invoke the user callback */
|
||||||
|
@ -1198,14 +1198,14 @@ static sxi32 VmXMLNSStartHandler(SyXMLRawStr *pUriStr, SyXMLRawStr *pPrefixStr,
|
||||||
pCallback = &pEngine->aCB[PH7_XML_NS_START];
|
pCallback = &pEngine->aCB[PH7_XML_NS_START];
|
||||||
/* Make sure the given callback is callable */
|
/* Make sure the given callback is callable */
|
||||||
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
||||||
/* Not callable, return immediately*/
|
/* Not callable,return immediately*/
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Get a ph7_value holding the PREFIX/URI */
|
/* Get a ph7_value holding the PREFIX/URI */
|
||||||
pUri = VmXMLValue(pEngine, pUriStr, 0);
|
pUri = VmXMLValue(pEngine, pUriStr, 0);
|
||||||
pPrefix = VmXMLValue(pEngine, pPrefixStr, 0);
|
pPrefix = VmXMLValue(pEngine, pPrefixStr, 0);
|
||||||
if(pUri == 0 || pPrefix == 0) {
|
if(pUri == 0 || pPrefix == 0) {
|
||||||
/* Out of mem, return immediately */
|
/* Out of mem,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Invoke the user callback */
|
/* Invoke the user callback */
|
||||||
|
@ -1233,13 +1233,13 @@ static sxi32 VmXMLNSEndHandler(SyXMLRawStr *pPrefixStr, void *pUserData) {
|
||||||
pCallback = &pEngine->aCB[PH7_XML_NS_END];
|
pCallback = &pEngine->aCB[PH7_XML_NS_END];
|
||||||
/* Make sure the given callback is callable */
|
/* Make sure the given callback is callable */
|
||||||
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
if(!PH7_VmIsCallable(pEngine->pVm, pCallback, 0)) {
|
||||||
/* Not callable, return immediately*/
|
/* Not callable,return immediately*/
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Get a ph7_value holding the prefix */
|
/* Get a ph7_value holding the prefix */
|
||||||
pPrefix = VmXMLValue(pEngine, pPrefixStr, 0);
|
pPrefix = VmXMLValue(pEngine, pPrefixStr, 0);
|
||||||
if(pPrefix == 0) {
|
if(pPrefix == 0) {
|
||||||
/* Out of mem, return immediately */
|
/* Out of mem,return immediately */
|
||||||
return SXRET_OK;
|
return SXRET_OK;
|
||||||
}
|
}
|
||||||
/* Invoke the user callback */
|
/* Invoke the user callback */
|
||||||
|
@ -1288,14 +1288,14 @@ static int vm_builtin_xml_parse(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
const char *zData;
|
const char *zData;
|
||||||
int nByte;
|
int nByte;
|
||||||
if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_string(apArg[1])) {
|
if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_string(apArg[1])) {
|
||||||
/* Missing/Ivalid arguments, return FALSE */
|
/* Missing/Ivalid arguments,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1362,14 +1362,14 @@ static int vm_builtin_xml_parse(ph7_context *pCtx, int nArg, ph7_value **apArg)
|
||||||
static int vm_builtin_xml_parser_set_option(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
static int vm_builtin_xml_parser_set_option(ph7_context *pCtx, int nArg, ph7_value **apArg) {
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
if(nArg < 2 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1393,14 +1393,14 @@ static int vm_builtin_xml_parser_get_option(ph7_context *pCtx, int nArg, ph7_val
|
||||||
ph7_xml_engine *pEngine;
|
ph7_xml_engine *pEngine;
|
||||||
int nOp;
|
int nOp;
|
||||||
if(nArg < 2 || !ph7_value_is_resource(apArg[0])) {
|
if(nArg < 2 || !ph7_value_is_resource(apArg[0])) {
|
||||||
/* Missing/Ivalid argument, return FALSE */
|
/* Missing/Ivalid argument,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
/* Point to the XML engine */
|
/* Point to the XML engine */
|
||||||
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
pEngine = (ph7_xml_engine *)ph7_value_to_resource(apArg[0]);
|
||||||
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
if(IS_INVALID_XML_ENGINE(pEngine)) {
|
||||||
/* Corrupt engine, return FALSE */
|
/* Corrupt engine,return FALSE */
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
return PH7_OK;
|
return PH7_OK;
|
||||||
}
|
}
|
||||||
|
@ -1416,7 +1416,7 @@ static int vm_builtin_xml_parser_get_option(ph7_context *pCtx, int nArg, ph7_val
|
||||||
ph7_result_string(pCtx, "UTF-8", (int)sizeof("UTF-8") - 1);
|
ph7_result_string(pCtx, "UTF-8", (int)sizeof("UTF-8") - 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* Unknown option, return FALSE*/
|
/* Unknown option,return FALSE*/
|
||||||
ph7_result_bool(pCtx, 0);
|
ph7_result_bool(pCtx, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
class Beaufort {
|
|
||||||
private string $cipher;
|
|
||||||
|
|
||||||
public string __construct(string $text, string $key) {
|
|
||||||
string $alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
||||||
for(int $i = 0; $i < strlen($text); $i++) {
|
|
||||||
int $j;
|
|
||||||
char $c0 = $text[$i];
|
|
||||||
char $c1 = $key[$i % strlen($key)];
|
|
||||||
int $start = 0;
|
|
||||||
for($j = 0; $j < 26; $j++) {
|
|
||||||
if($alphabet[$j] == strtoupper($c0)) {
|
|
||||||
$start = $j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int $offset = 0;
|
|
||||||
for($j = $start; $j < $start + 26; $j++) {
|
|
||||||
int $letter = $j %26;
|
|
||||||
if($alphabet[$letter] == strtoupper($c1)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$offset++;
|
|
||||||
}
|
|
||||||
$this->cipher += $alphabet[$offset];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getCipher() {
|
|
||||||
return $this->cipher;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Program {
|
|
||||||
|
|
||||||
public void main() {
|
|
||||||
object $beaufort = new Beaufort('thisisasecretmessage', 'youwillneverguessit');
|
|
||||||
var_dump($beaufort->getCipher());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
string(20 'FHMEATLVATNNNIAAAINU')
|
|
|
@ -1,8 +0,0 @@
|
||||||
class BaseClass {
|
|
||||||
|
|
||||||
protected void run() {
|
|
||||||
printf('Test launched...');
|
|
||||||
include 'data/includes/include_test.aer';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
printf("OK!\n");
|
|
|
@ -1,3 +0,0 @@
|
||||||
class Test {
|
|
||||||
string $test = 'This is a test';
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
require 'data/includes/base_class.aer';
|
|
||||||
|
|
||||||
class Program extends BaseClass {
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
$this->run();
|
|
||||||
require 'data/includes/test_class.aer';
|
|
||||||
object $test = new Test();
|
|
||||||
var_dump($test);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
Test launched...OK!
|
|
||||||
object(Test) {
|
|
||||||
['test'] =>
|
|
||||||
string(14 'This is a test')
|
|
||||||
}
|
|
|
@ -1,5 +1,3 @@
|
||||||
import 'math';
|
|
||||||
|
|
||||||
class Program {
|
class Program {
|
||||||
|
|
||||||
private string num2alpha(int $n) {
|
private string num2alpha(int $n) {
|
||||||
|
@ -21,6 +19,7 @@ class Program {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void main() {
|
public void main() {
|
||||||
|
import('math');
|
||||||
var_dump($this->alpha2num("Salut"), $this->num2alpha(1723), $this->num2alpha(9854), $this->alpha2num("Base64"));
|
var_dump($this->alpha2num("Salut"), $this->num2alpha(1723), $this->num2alpha(9854), $this->alpha2num("Base64"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import 'dummy';
|
|
||||||
|
|
||||||
final class Program {
|
final class Program {
|
||||||
public void main() {
|
public void main() {
|
||||||
var_dump(function_exists('dummy_function'));
|
var_dump(function_exists('dummy_function'));
|
||||||
|
var_dump(import('dummy'));
|
||||||
|
var_dump(function_exists('dummy_function'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
|
bool(FALSE)
|
||||||
|
bool(TRUE)
|
||||||
bool(TRUE)
|
bool(TRUE)
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
import 'math';
|
|
||||||
|
|
||||||
class Sudoku {
|
|
||||||
public int[] $board;
|
|
||||||
int $size;
|
|
||||||
|
|
||||||
public void __construct(int[] $board) {
|
|
||||||
$this->board = $board;
|
|
||||||
$this->size = sizeof($this->board);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool isSafe(int $row, int $col, int $n) {
|
|
||||||
for(int $d = 0; $d < $this->size; $d++) {
|
|
||||||
if($this->board[$row][$d] == $n) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int $r = 0; $r < $this->size; $r++) {
|
|
||||||
if($this->board[$r][$col] == $n) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int $sqrt = (int) sqrt($this->size);
|
|
||||||
int $boxRowStart = $row - $row % $sqrt;
|
|
||||||
int $boxColStart = $col - $col % $sqrt;
|
|
||||||
for(int $w = $boxRowStart; $w < $boxRowStart + $sqrt; $w++) {
|
|
||||||
for(int $q = $boxColStart; $q < $boxColStart + $sqrt; $q++) {
|
|
||||||
if($this->board[$w][$q] == $n) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void print() {
|
|
||||||
for(int $r = 0; $r < $this->size; $r++) {
|
|
||||||
for(int $d = 0; $d < $this->size; $d++) {
|
|
||||||
print($this->board[$r][$d] + " ");
|
|
||||||
}
|
|
||||||
print("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool solve() {
|
|
||||||
int $row = -1;
|
|
||||||
int $col = -1;
|
|
||||||
bool $isEmpty = true;
|
|
||||||
for(int $i = 0; $i < $this->size; $i++) {
|
|
||||||
for(int $j = 0; $j < $this->size; $j++) {
|
|
||||||
if($this->board[$i][$j] == 0) {
|
|
||||||
$row = $i;
|
|
||||||
$col = $j;
|
|
||||||
$isEmpty = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!$isEmpty) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($isEmpty) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for(int $n = 1; $n <= $this->size; $n++) {
|
|
||||||
if($this->isSafe($row, $col, $n)) {
|
|
||||||
$this->board[$row][$col] = $n;
|
|
||||||
if($this->solve()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
$this->board[$row][$col] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Program {
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
int[] $board = {
|
|
||||||
{3, 0, 6, 5, 0, 8, 4, 0, 0},
|
|
||||||
{5, 2, 0, 0, 0, 0, 0, 0, 0},
|
|
||||||
{0, 8, 7, 0, 0, 0, 0, 3, 1},
|
|
||||||
{0, 0, 3, 0, 1, 0, 0, 8, 0},
|
|
||||||
{9, 0, 0, 8, 6, 3, 0, 0, 5},
|
|
||||||
{0, 5, 0, 0, 9, 0, 6, 0, 0},
|
|
||||||
{1, 3, 0, 0, 0, 0, 2, 5, 0},
|
|
||||||
{0, 0, 0, 0, 0, 0, 0, 7, 4},
|
|
||||||
{0, 0, 5, 2, 0, 6, 3, 0, 0}
|
|
||||||
};
|
|
||||||
object $sudoku = new Sudoku($board);
|
|
||||||
$sudoku->print();
|
|
||||||
print("=================\n");
|
|
||||||
if($sudoku->solve()) {
|
|
||||||
$sudoku->print();
|
|
||||||
} else {
|
|
||||||
print("No solution found\n");
|
|
||||||
$sudoku->print();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
3 0 6 5 0 8 4 0 0
|
|
||||||
5 2 0 0 0 0 0 0 0
|
|
||||||
0 8 7 0 0 0 0 3 1
|
|
||||||
0 0 3 0 1 0 0 8 0
|
|
||||||
9 0 0 8 6 3 0 0 5
|
|
||||||
0 5 0 0 9 0 6 0 0
|
|
||||||
1 3 0 0 0 0 2 5 0
|
|
||||||
0 0 0 0 0 0 0 7 4
|
|
||||||
0 0 5 2 0 6 3 0 0
|
|
||||||
=================
|
|
||||||
3 1 6 5 7 8 4 9 2
|
|
||||||
5 2 9 1 3 4 7 6 8
|
|
||||||
4 8 7 6 2 9 5 3 1
|
|
||||||
2 6 3 4 1 5 9 8 7
|
|
||||||
9 7 4 8 6 3 1 2 5
|
|
||||||
8 5 1 7 9 2 6 4 3
|
|
||||||
1 3 8 9 4 7 2 5 6
|
|
||||||
6 9 2 3 5 1 8 7 4
|
|
||||||
7 4 5 2 8 6 3 1 9
|
|
|
@ -1,22 +0,0 @@
|
||||||
class Hanoi {
|
|
||||||
|
|
||||||
public void towerOfHanoi(int $diskCount, int $fromPole, int $toPole, int $viaPole) {
|
|
||||||
if($diskCount == 1) {
|
|
||||||
printf('Move disk from pole ' + $fromPole + ' to pole ' + $toPole + "\n");
|
|
||||||
} else {
|
|
||||||
$this->towerOfHanoi($diskCount - 1, $fromPole, $viaPole, $toPole);
|
|
||||||
$this->towerOfHanoi(1, $fromPole, $toPole, $viaPole);
|
|
||||||
$this->towerOfHanoi($diskCount - 1, $viaPole, $toPole, $fromPole);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Program {
|
|
||||||
|
|
||||||
public void main() {
|
|
||||||
object $hanoi = new Hanoi();
|
|
||||||
$hanoi->towerOfHanoi(4, 1, 2, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
Move disk from pole 1 to pole 3
|
|
||||||
Move disk from pole 1 to pole 2
|
|
||||||
Move disk from pole 3 to pole 2
|
|
||||||
Move disk from pole 1 to pole 3
|
|
||||||
Move disk from pole 2 to pole 1
|
|
||||||
Move disk from pole 2 to pole 3
|
|
||||||
Move disk from pole 1 to pole 3
|
|
||||||
Move disk from pole 1 to pole 2
|
|
||||||
Move disk from pole 3 to pole 2
|
|
||||||
Move disk from pole 3 to pole 1
|
|
||||||
Move disk from pole 2 to pole 1
|
|
||||||
Move disk from pole 3 to pole 2
|
|
||||||
Move disk from pole 1 to pole 3
|
|
||||||
Move disk from pole 1 to pole 2
|
|
||||||
Move disk from pole 3 to pole 2
|
|
Loading…
Reference in New Issue