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
+18
View File
@@ -677,6 +677,15 @@ int ph7_create_function(ph7_vm *pVm, const char *zName, int (*xFunc)(ph7_context
rc = PH7_VmInstallForeignFunction(&(*pVm), &sName, xFunc, pUserData);
return rc;
}
ph7_value *ph7_context_this(ph7_context *pCtx) {
return pCtx ? pCtx->pThis : 0;
}
int ph7_create_class(ph7_vm *pVm, const ph7_class_def *pDef) {
if(PH7_VM_MISUSE(pVm) || pDef == 0) {
return PH7_CORRUPT;
}
return PH7_VmCreateNativeClass(pVm, pDef);
}
/*
* [CAPIREF: ph7_delete_function()]
* Please refer to the official documentation for function purpose and expected parameters.
@@ -923,6 +932,7 @@ int ph7_value_compare(ph7_value *pLeft, ph7_value *pRight, int bStrict) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_int(ph7_context *pCtx, int iValue) {
pCtx->bResultSet = TRUE;
return ph7_value_int(pCtx->pRet, iValue);
}
/*
@@ -930,6 +940,7 @@ int ph7_result_int(ph7_context *pCtx, int iValue) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_int64(ph7_context *pCtx, ph7_int64 iValue) {
pCtx->bResultSet = TRUE;
return ph7_value_int64(pCtx->pRet, iValue);
}
/*
@@ -937,6 +948,7 @@ int ph7_result_int64(ph7_context *pCtx, ph7_int64 iValue) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_bool(ph7_context *pCtx, int iBool) {
pCtx->bResultSet = TRUE;
return ph7_value_bool(pCtx->pRet, iBool);
}
/*
@@ -944,6 +956,7 @@ int ph7_result_bool(ph7_context *pCtx, int iBool) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_double(ph7_context *pCtx, double Value) {
pCtx->bResultSet = TRUE;
return ph7_value_double(pCtx->pRet, Value);
}
/*
@@ -951,6 +964,7 @@ int ph7_result_double(ph7_context *pCtx, double Value) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_null(ph7_context *pCtx) {
pCtx->bResultSet = TRUE;
/* Invalidate any prior representation and set the NULL flag */
PH7_MemObjRelease(pCtx->pRet);
return PH7_OK;
@@ -960,6 +974,7 @@ int ph7_result_null(ph7_context *pCtx) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_string(ph7_context *pCtx, const char *zString, int nLen) {
pCtx->bResultSet = TRUE;
return ph7_value_string(pCtx->pRet, zString, nLen);
}
/*
@@ -971,6 +986,7 @@ int ph7_result_string_format(ph7_context *pCtx, const char *zFormat, ...) {
va_list ap;
int rc;
p = pCtx->pRet;
pCtx->bResultSet = TRUE;
if((p->nType & MEMOBJ_STRING) == 0) {
/* Invalidate any prior representation */
PH7_MemObjRelease(p);
@@ -988,6 +1004,7 @@ int ph7_result_string_format(ph7_context *pCtx, const char *zFormat, ...) {
*/
int ph7_result_value(ph7_context *pCtx, ph7_value *pValue) {
int rc = PH7_OK;
pCtx->bResultSet = TRUE;
if(pValue == 0) {
PH7_MemObjRelease(pCtx->pRet);
} else {
@@ -1000,6 +1017,7 @@ int ph7_result_value(ph7_context *pCtx, ph7_value *pValue) {
* Please refer to the official documentation for function purpose and expected parameters.
*/
int ph7_result_resource(ph7_context *pCtx, void *pUserData) {
pCtx->bResultSet = TRUE;
return ph7_value_resource(pCtx->pRet, pUserData);
}
/*