Enable classes to inherit or implement built-in classes

This commit is contained in:
yvan-burrie 2018-08-02 07:41:37 +02:00
parent eb30745e6e
commit 5fb05d4ef7
1 changed files with 30 additions and 1 deletions

View File

@ -336,6 +336,22 @@ PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub, ph7_class *pBase) {
SyHashEntry *pEntry;
SyString *pName;
sxi32 rc;
/* Copy flags */
if( pBase->iFlags & PH7_CLASS_THROWABLE ){
pSub->iFlags |= PH7_CLASS_THROWABLE;
}
if( pBase->iFlags & PH7_CLASS_ARRAYACCESS ){
pSub->iFlags |= PH7_CLASS_ARRAYACCESS;
}
if( pBase->iFlags & PH7_CLASS_COUNTABLE ){
pSub->iFlags |= PH7_CLASS_COUNTABLE;
}
if( pBase->iFlags & PH7_CLASS_TRAVERSE ){
pSub->iFlags |= PH7_CLASS_TRAVERSE;
}
if( pBase->iFlags & PH7_CLASS_CALLABLE ){
pSub->iFlags |= PH7_CLASS_CALLABLE;
}
/* Install in the derived hashtable */
SyHashInsert(&pBase->hDerived, (const void *)SyStringData(&pSub->sName), SyStringLength(&pSub->sName), pSub);
SyHashResetLoopCursor(&pBase->hAttr);
@ -389,6 +405,19 @@ PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_class *pMain, ph7_class *pInterface) {
SyHashEntry *pEntry;
SyString *pName;
sxi32 rc;
/* Copy flags */
if( pInterface->iFlags & PH7_CLASS_THROWABLE ){
pMain->iFlags |= PH7_CLASS_THROWABLE;
}
if( pInterface->iFlags & PH7_CLASS_ARRAYACCESS ){
pMain->iFlags |= PH7_CLASS_ARRAYACCESS;
}
if( pInterface->iFlags & PH7_CLASS_COUNTABLE ){
pMain->iFlags |= PH7_CLASS_COUNTABLE;
}
if( pInterface->iFlags & PH7_CLASS_TRAVERSE ){
pMain->iFlags |= PH7_CLASS_TRAVERSE;
}
/* First off,copy all constants declared inside the interface */
SyHashResetLoopCursor(&pInterface->hAttr);
while((pEntry = SyHashGetNextEntry(&pInterface->hAttr)) != 0) {
@ -821,7 +850,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCmp(ph7_class_instance *pLeft, ph7_class_inst
* are identical if and only if they refer to the same instance
* of the same class.
*/
return !(pLeft == pRight);
return pLeft != pRight;
}
/*
* Attribute comparison.