Another bunch of fixes for object type.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2018-09-24 13:34:22 +02:00
parent 550107235c
commit 2db1954779
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 18 additions and 12 deletions

View File

@ -105,9 +105,11 @@ static sxi32 MemObjCallClassCastMethod(
sxu32 nLen, /* Method name length */
ph7_value *pResult /* OUT: Store the return value of the magic method here */
) {
ph7_class_method *pMethod;
ph7_class_method *pMethod = 0;
/* Check if the method is available */
pMethod = PH7_ClassExtractMethod(pThis->pClass, zMethod, nLen);
if(pThis) {
pMethod = PH7_ClassExtractMethod(pThis->pClass, zMethod, nLen);
}
if(pMethod == 0) {
/* No such method */
return SXERR_NOTFOUND;
@ -757,12 +759,14 @@ PH7_PRIVATE sxi32 PH7_MemObjStore(ph7_value *pSrc, ph7_value *pDest) {
ph7_class_instance *pObj = 0;
ph7_hashmap *pMap = 0;
sxi32 rc;
if(pSrc->iFlags & MEMOBJ_HASHMAP) {
/* Increment reference count */
((ph7_hashmap *)pSrc->x.pOther)->iRef++;
} else if(pSrc->iFlags & MEMOBJ_OBJ) {
/* Increment reference count */
((ph7_class_instance *)pSrc->x.pOther)->iRef++;
if(pSrc->x.pOther) {
if(pSrc->iFlags & MEMOBJ_HASHMAP) {
/* Increment reference count */
((ph7_hashmap *)pSrc->x.pOther)->iRef++;
} else if(pSrc->iFlags & MEMOBJ_OBJ) {
/* Increment reference count */
((ph7_class_instance *)pSrc->x.pOther)->iRef++;
}
}
if(pDest->iFlags & MEMOBJ_HASHMAP) {
pMap = (ph7_hashmap *)pDest->x.pOther;

View File

@ -717,10 +717,12 @@ static void PH7_ClassInstanceRelease(ph7_class_instance *pThis) {
* If the reference count reaches zero,release the whole instance.
*/
PH7_PRIVATE void PH7_ClassInstanceUnref(ph7_class_instance *pThis) {
pThis->iRef--;
if(pThis->iRef < 1) {
/* No more reference to this instance */
PH7_ClassInstanceRelease(&(*pThis));
if(pThis) {
pThis->iRef--;
if(pThis->iRef < 1) {
/* No more reference to this instance */
PH7_ClassInstanceRelease(&(*pThis));
}
}
}
/*