Browse Source

Implement PH7_CheckVarCompat().

pull/50/head
Rafal Kupiec 3 years ago
parent
commit
9ab896c2e2
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
  1. 18
      engine/memobj.c
  2. 1
      include/ph7int.h

18
engine/memobj.c

@ -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.
*/

1
include/ph7int.h

@ -1659,6 +1659,7 @@ PH7_PRIVATE sxi32 PH7_MemObjToNull(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_MemObjToReal(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_MemObjToInteger(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_MemObjToBool(ph7_value *pObj);
PH7_PRIVATE sxi32 PH7_CheckVarCompat(ph7_value *pObj, int nType);
PH7_PRIVATE sxi64 PH7_TokenValueToInt64(SyString *pData);
/* lex.c function prototypes */
PH7_PRIVATE sxi32 PH7_TokenizeRawText(const char *zInput, sxu32 nLen, SySet *pOut);

Loading…
Cancel
Save