Add C API for registering native AerScript classes
Build / AerScript (push) Successful in 24s

This commit is contained in:
2026-11-14 23:26:28 +01:00
parent d98f6a8e91
commit 61006fe848
9 changed files with 896 additions and 87 deletions
+12 -1
View File
@@ -756,6 +756,8 @@ struct ph7_context {
*/
ph7_vm *pVm; /* Virtual machine that own this context */
sxi32 iFlags; /* Call flags */
ph7_value *pThis; /* Stable borrowed native method receiver */
sxi32 bResultSet; /* Distinguish explicit NULL from a bare return */
};
/*
* Each hashmap entry [i.e: array(4,5,6)] is recorded in an instance
@@ -1014,6 +1016,7 @@ struct ph7_vm_func {
*/
void *pUserData; /* Upper layer private data associated with this instance */
ph7_vm_func *pNextName; /* Next VM function with the same name as this one */
ph7_user_func sNative; /* Native method body and overload-specific data */
};
/* Forward reference */
typedef struct ph7_builtin_constant ph7_builtin_constant;
@@ -1067,6 +1070,7 @@ struct ph7_class {
SySet aBase; /* Direct class bases in extends order */
SySet aMro; /* C3 linearization, including this class first */
sxi32 iMroState; /* 0: unbuilt, 1: building, 2: ready */
sxi32 bNative; /* Public native declaration */
};
/* Class configuration flags */
#define PH7_CLASS_FINAL 0x001 /* Class is final [cannot be extended] */
@@ -1089,6 +1093,7 @@ struct ph7_class_attr {
sxu32 nType; /* Class attribute data type */
sxu32 nIdx; /* Attribute index */
sxu32 nLine; /* Line number on which this attribute was defined */
ph7_value *pNativeInitial; /* Owned native declaration snapshot, if present */
};
/* Attribute configuration */
#define PH7_CLASS_ATTR_STATIC 0x001 /* Static attribute */
@@ -1383,7 +1388,6 @@ struct VmShutdownCB {
int nArg; /* Total number of given arguments */
};
/* Uncaught exception code value */
#define PH7_EXCEPTION -255
/*
* Allowed value for ph7_vm.nMagic
@@ -1734,6 +1738,13 @@ PH7_PRIVATE sxi32 PH7_VmInstallForeignFunction(ph7_vm *pVm, const SyString *pNam
PH7_PRIVATE sxi32 PH7_VmInstallClass(ph7_vm *pVm, ph7_class *pClass);
PH7_PRIVATE sxi32 PH7_VmBlobConsumer(const void *pSrc, unsigned int nLen, void *pUserData);
PH7_PRIVATE ph7_value *PH7_ReserveMemObj(ph7_vm *pVm);
PH7_PRIVATE sxi32 PH7_VmInternType(ph7_vm *pVm, const SyString *pName, sxu32 *pType);
PH7_PRIVATE sxi32 PH7_MemObjSnapshot(ph7_value *pSrc, ph7_value *pDest);
PH7_PRIVATE sxi32 PH7_MemObjDeclareType(ph7_value *pValue, sxu32 nType, sxi32 bResolve);
PH7_PRIVATE sxi32 PH7_IsIdentifier(const char *zName, sxi32 bKeyword);
PH7_PRIVATE sxi32 PH7_IsMethodName(const char *zName);
PH7_PRIVATE sxi32 PH7_IsReservedConstant(const SyString *pName);
PH7_PRIVATE sxi32 PH7_VmCreateNativeClass(ph7_vm *pVm, const ph7_class_def *pDef);
PH7_PRIVATE ph7_value *PH7_ReserveConstObj(ph7_vm *pVm, sxu32 *pIndex);
PH7_PRIVATE sxi32 PH7_VmOutputConsume(ph7_vm *pVm, SyString *pString);
PH7_PRIVATE sxi32 PH7_VmOutputConsumeAp(ph7_vm *pVm, const char *zFormat, va_list ap);