Implement PH7_HashmapCast().
The build was successful.
Details
The build was successful.
Details
This commit is contained in:
parent
45f4a00b05
commit
14f958a4b2
|
@ -5625,3 +5625,35 @@ PH7_PRIVATE sxi32 PH7_HashmapWalk(
|
|||
/* All done */
|
||||
return SXRET_OK;
|
||||
}
|
||||
PH7_PRIVATE sxi32 PH7_HashmapCast(ph7_value *pObj, sxi32 nType) {
|
||||
sxi32 rc;
|
||||
if((pObj->iFlags & MEMOBJ_HASHMAP)) {
|
||||
ph7_hashmap *pMap;
|
||||
ph7_hashmap_node *pNode;
|
||||
ph7_value pValue, pKey;
|
||||
pMap = (ph7_hashmap *) pObj->x.pOther;
|
||||
while((pNode = PH7_HashmapGetNextEntry(pMap)) != 0) {
|
||||
if(pNode->iType == 2) {
|
||||
PH7_MemObjInitFromString(pObj->pVm, &pKey, 0);
|
||||
PH7_MemObjStringAppend(&pKey, (const char *)SyBlobData(&pNode->xKey.sKey), SyBlobLength(&pNode->xKey.sKey));
|
||||
} else {
|
||||
PH7_MemObjInitFromInt(pObj->pVm, &pKey, pNode->xKey.iKey);
|
||||
}
|
||||
PH7_MemObjInit(pObj->pVm, &pValue);
|
||||
PH7_HashmapExtractNodeValue(pNode, &pValue, FALSE);
|
||||
rc = PH7_HashmapCast(&pValue, nType);
|
||||
if(rc == SXERR_NOMATCH) {
|
||||
return SXERR_NOMATCH;
|
||||
}
|
||||
PH7_HashmapInsert(pMap, &pKey, &pValue);
|
||||
}
|
||||
pObj->iFlags = MEMOBJ_HASHMAP | nType;
|
||||
} else {
|
||||
if(pObj->iFlags != nType && PH7_CheckVarCompat(pObj, nType) != SXRET_OK) {
|
||||
return SXERR_NOMATCH;
|
||||
}
|
||||
ProcMemObjCast xCast = PH7_MemObjCastMethod(nType);
|
||||
xCast(pObj);
|
||||
}
|
||||
return SXRET_OK;
|
||||
}
|
||||
|
|
|
@ -1750,6 +1750,7 @@ PH7_PRIVATE void PH7_HashmapExtractNodeKey(ph7_hashmap_node *pNode, ph7_value *p
|
|||
PH7_PRIVATE void PH7_RegisterHashmapFunctions(ph7_vm *pVm);
|
||||
PH7_PRIVATE sxi32 PH7_HashmapDump(SyBlob *pOut, ph7_hashmap *pMap, int ShowType, int nTab, int nDepth);
|
||||
PH7_PRIVATE sxi32 PH7_HashmapWalk(ph7_hashmap *pMap, int (*xWalk)(ph7_value *, ph7_value *, void *), void *pUserData);
|
||||
PH7_PRIVATE sxi32 PH7_HashmapCast(ph7_value *pObj, sxi32 nType);
|
||||
PH7_PRIVATE int PH7_HashmapValuesToSet(ph7_hashmap *pMap, SySet *pOut);
|
||||
/* builtin.c function prototypes */
|
||||
PH7_PRIVATE sxi32 PH7_InputFormat(int (*xConsumer)(ph7_context *, const char *, int, void *),
|
||||
|
|
Loading…
Reference in New Issue