Implement PH7_CheckVarCompat().
All checks were successful
The build was successful.

This commit is contained in:
2018-11-28 20:37:07 +01:00
parent f3f1723104
commit 9ab896c2e2
2 changed files with 19 additions and 0 deletions

View File

@@ -359,6 +359,24 @@ static ph7_real MemObjCharValue(ph7_value *pObj) {
/* NOT REACHED */
return 0;
}
/*
* Checks a ph7_value variable compatibility with nType data type.
*/
PH7_PRIVATE sxi32 PH7_CheckVarCompat(ph7_value *pObj, int nType) {
if(nType == MEMOBJ_REAL && (pObj->iFlags & MEMOBJ_INT)) {
return SXRET_OK;
} else if(nType == MEMOBJ_CHAR && (pObj->iFlags & MEMOBJ_INT)) {
return SXRET_OK;
} else if(nType == MEMOBJ_CHAR && (pObj->iFlags & MEMOBJ_STRING)) {
int len = SyBlobLength(&pObj->sBlob);
if(len == 0 || len == 1) {
return SXRET_OK;
}
} else if(nType == MEMOBJ_CALL && (pObj->iFlags & MEMOBJ_STRING)) {
return SXRET_OK;
}
return SXERR_NOMATCH;
}
/*
* Convert a ph7_value to type integer.Invalidate any prior representations.
*/