diff --git a/engine/builtin.c b/engine/builtin.c index 318fdf6..ea7a302 100644 --- a/engine/builtin.c +++ b/engine/builtin.c @@ -7240,7 +7240,7 @@ static int PH7_builtin_idate(ph7_context *pCtx, int nArg, ph7_value **apArg) { break; default: /* unknown format,throw a warning */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Unknown date format token"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Unknown date format token"); break; } /* Return the time value */ diff --git a/engine/hashmap.c b/engine/hashmap.c index 3520b8d..8ef8478 100644 --- a/engine/hashmap.c +++ b/engine/hashmap.c @@ -554,7 +554,7 @@ static sxi32 HashmapInsert( } if(pMap == pMap->pVm->pGlobal) { /* Forbidden */ - PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden"); + PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden"); return SXRET_OK; } /* Perform a blob-key insertion */ @@ -583,7 +583,7 @@ IntKey: } if(pMap == pMap->pVm->pGlobal) { /* Forbidden */ - PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden"); + PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden"); return SXRET_OK; } /* Perform a 64-bit-int-key insertion */ @@ -601,7 +601,7 @@ IntKey: } else { if(pMap == pMap->pVm->pGlobal) { /* Forbidden */ - PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden"); + PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, insertion is forbidden"); return SXRET_OK; } /* Assign an automatic index */ @@ -1374,7 +1374,7 @@ PH7_PRIVATE sxi32 PH7_HashmapRelease(ph7_hashmap *pMap, int FreeDS) { sxu32 n; if(pMap == pVm->pGlobal) { /* Cannot delete the $GLOBALS array */ - PH7_VmGenericError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, deletion is forbidden"); + PH7_VmThrowError(pMap->pVm, PH7_CTX_NOTICE, "$GLOBALS is a read-only array, deletion is forbidden"); return SXRET_OK; } /* Start the release process */ @@ -1464,7 +1464,7 @@ PH7_PRIVATE sxi32 PH7_HashmapInsert( /* * TICKET 1433-35: Insertion in the $GLOBALS array is forbidden. */ - PH7_VmGenericError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden"); + PH7_VmThrowError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden"); return SXRET_OK; } rc = HashmapInsert(&(*pMap), &(*pKey), &(*pVal)); @@ -1507,7 +1507,7 @@ PH7_PRIVATE sxi32 PH7_HashmapInsertByRef( /* * TICKET 1433-35: Insertion in the $GLOBALS array is forbidden. */ - PH7_VmGenericError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden"); + PH7_VmThrowError(pMap->pVm, PH7_CTX_ERR, "$GLOBALS is a read-only array, insertion is forbidden"); return SXRET_OK; } rc = HashmapInsertByRef(&(*pMap), &(*pKey), nRefIdx); diff --git a/engine/oop.c b/engine/oop.c index 72c58c5..0a7b700 100644 --- a/engine/oop.c +++ b/engine/oop.c @@ -263,7 +263,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas if((pEntry = SyHashGet(&pSub->hAttr, (const void *)pName->zString, pName->nByte)) != 0) { if(pAttr->iProtection == PH7_CLASS_PROT_PRIVATE && ((ph7_class_attr *)pEntry->pUserData)->iProtection != PH7_CLASS_PROT_PUBLIC) { /* Cannot redeclare private attribute */ - rc = PH7_VmGenericError(pVm, PH7_CTX_ERR, "Private attribute '%z::%z' redeclared inside child class '%z'", &pBase->sName, pName, &pSub->sName); + rc = PH7_VmThrowError(pVm, PH7_CTX_ERR, "Private attribute '%z::%z' redeclared inside child class '%z'", &pBase->sName, pName, &pSub->sName); if(rc == SXERR_ABORT) { return SXERR_ABORT; } @@ -286,7 +286,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas if((pEntry = SyHashGet(&pSub->hMethod, (const void *)pName->zString, pName->nByte)) != 0) { if(pMeth->iFlags & PH7_CLASS_ATTR_FINAL) { /* Cannot Overwrite final method */ - rc = PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot overwrite final method '%z:%z()' inside child class '%z'", &pBase->sName, pName, &pSub->sName); + rc = PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot overwrite final method '%z:%z()' inside child class '%z'", &pBase->sName, pName, &pSub->sName); if(rc == SXERR_ABORT) { return SXERR_ABORT; } @@ -295,7 +295,7 @@ PH7_PRIVATE sxi32 PH7_ClassInherit(ph7_vm *pVm, ph7_class *pSub, ph7_class *pBas } else { if(pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL) { /* Virtual method must be defined in the child class */ - rc = PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Virtual method '%z:%z()' must be defined inside child class '%z'", &pBase->sName, pName, &pSub->sName); + rc = PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Virtual method '%z:%z()' must be defined inside child class '%z'", &pBase->sName, pName, &pSub->sName); if(rc == SXERR_ABORT) { return SXERR_ABORT; } @@ -663,7 +663,7 @@ PH7_PRIVATE ph7_class_instance *PH7_CloneClassInstance(ph7_class_instance *pSrc) PH7_VmCallClassMethod(pVm, pClone, pMethod, 0, 0, 0); } else { /* Nesting limit reached */ - PH7_VmGenericError(pVm, PH7_CTX_ERR, "Object clone limit reached"); + PH7_VmThrowError(pVm, PH7_CTX_ERR, "Object clone limit reached"); } /* Reset the cursor */ pMethod->iCloneDepth = 0; @@ -807,7 +807,7 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceCmp(ph7_class_instance *pLeft, ph7_class_inst sxi32 rc; if(iNest > 31) { /* Nesting limit reached */ - PH7_VmGenericError(pLeft->pVm, PH7_CTX_ERR, "Nesting limit reached, probably infinite recursion"); + PH7_VmThrowError(pLeft->pVm, PH7_CTX_ERR, "Nesting limit reached, probably infinite recursion"); return 1; } /* Comparison is performed only if the objects are instance of the same class */ diff --git a/engine/vfs.c b/engine/vfs.c index 9f5cf0e..ec79d3d 100644 --- a/engine/vfs.c +++ b/engine/vfs.c @@ -77,7 +77,7 @@ static int PH7_vfs_chdir(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xChdir == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -114,7 +114,7 @@ static int PH7_vfs_chroot(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xChroot == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -146,7 +146,7 @@ static int PH7_vfs_getcwd(ph7_context *pCtx, int nArg, ph7_value **apArg) { SXUNUSED(nArg); /* cc warning */ SXUNUSED(apArg); /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -184,7 +184,7 @@ static int PH7_vfs_rmdir(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xRmdir == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -221,7 +221,7 @@ static int PH7_vfs_is_dir(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xIsdir == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -269,7 +269,7 @@ static int PH7_vfs_mkdir(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xMkdir == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -320,7 +320,7 @@ static int PH7_vfs_rename(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xRename == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -357,7 +357,7 @@ static int PH7_vfs_realpath(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xRealpath == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -395,7 +395,7 @@ static int PH7_vfs_sleep(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xSleep == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -440,7 +440,7 @@ static int PH7_vfs_usleep(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xSleep == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -478,7 +478,7 @@ static int PH7_vfs_unlink(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xUnlink == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -518,7 +518,7 @@ static int PH7_vfs_chmod(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xChmod == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -559,7 +559,7 @@ static int PH7_vfs_chown(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xChown == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -600,7 +600,7 @@ static int PH7_vfs_chgrp(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xChgrp == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -639,7 +639,7 @@ static int PH7_vfs_disk_free_space(ph7_context *pCtx, int nArg, ph7_value **apAr pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFreeSpace == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -676,7 +676,7 @@ static int PH7_vfs_disk_total_space(ph7_context *pCtx, int nArg, ph7_value **apA pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xTotalSpace == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -713,7 +713,7 @@ static int PH7_vfs_file_exists(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileExists == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -750,7 +750,7 @@ static int PH7_vfs_file_size(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileSize == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -787,7 +787,7 @@ static int PH7_vfs_file_atime(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileAtime == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -824,7 +824,7 @@ static int PH7_vfs_file_mtime(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileMtime == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -861,7 +861,7 @@ static int PH7_vfs_file_ctime(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileCtime == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -898,7 +898,7 @@ static int PH7_vfs_file_group(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileCtime == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -935,7 +935,7 @@ static int PH7_vfs_file_inode(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileCtime == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -972,7 +972,7 @@ static int PH7_vfs_file_owner(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFileCtime == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1009,7 +1009,7 @@ static int PH7_vfs_is_file(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xIsFile == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1046,7 +1046,7 @@ static int PH7_vfs_is_link(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xIsLink == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1083,7 +1083,7 @@ static int PH7_vfs_is_readable(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xReadable == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1120,7 +1120,7 @@ static int PH7_vfs_is_writable(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xWritable == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1157,7 +1157,7 @@ static int PH7_vfs_is_executable(ph7_context *pCtx, int nArg, ph7_value **apArg) pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xExecutable == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1194,7 +1194,7 @@ static int PH7_vfs_filetype(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xFiletype == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1247,7 +1247,7 @@ static int PH7_vfs_stat(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xStat == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1315,7 +1315,7 @@ static int PH7_vfs_lstat(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xlStat == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1368,7 +1368,7 @@ static int PH7_vfs_getenv(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xGetenv == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1440,7 +1440,7 @@ static int PH7_vfs_putenv(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xSetenv == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -1485,7 +1485,7 @@ static int PH7_vfs_touch(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xTouch == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2117,7 +2117,7 @@ static int PH7_vfs_link(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xLink == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2157,7 +2157,7 @@ static int PH7_vfs_symlink(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xLink == 0) { /* IO routine not implemented,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2190,7 +2190,7 @@ static int PH7_vfs_umask(ph7_context *pCtx, int nArg, ph7_value **apArg) { pVfs = (ph7_vfs *)ph7_context_user_data(pCtx); if(pVfs == 0 || pVfs->xUmask == 0) { /* IO routine not implemented,return -1 */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2225,7 +2225,7 @@ static int PH7_vfs_sys_get_temp_dir(ph7_context *pCtx, int nArg, ph7_value **apA SXUNUSED(nArg); /* cc warning */ SXUNUSED(apArg); /* IO routine not implemented,return "" */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2251,7 +2251,7 @@ static int PH7_vfs_get_current_user(ph7_context *pCtx, int nArg, ph7_value **apA SXUNUSED(nArg); /* cc warning */ SXUNUSED(apArg); /* IO routine not implemented */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2280,7 +2280,7 @@ static int PH7_vfs_getmypid(ph7_context *pCtx, int nArg, ph7_value **apArg) { SXUNUSED(nArg); /* cc warning */ SXUNUSED(apArg); /* IO routine not implemented,return -1 */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2310,7 +2310,7 @@ static int PH7_vfs_getmyuid(ph7_context *pCtx, int nArg, ph7_value **apArg) { SXUNUSED(nArg); /* cc warning */ SXUNUSED(apArg); /* IO routine not implemented,return -1 */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2340,7 +2340,7 @@ static int PH7_vfs_getmygid(ph7_context *pCtx, int nArg, ph7_value **apArg) { SXUNUSED(nArg); /* cc warning */ SXUNUSED(apArg); /* IO routine not implemented,return -1 */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying VFS", ph7_function_name(pCtx) ); @@ -2544,7 +2544,7 @@ static int PH7_builtin_ftruncate(ph7_context *pCtx, int nArg, ph7_value **apArg) int rc; if(nArg < 2 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -2553,14 +2553,14 @@ static int PH7_builtin_ftruncate(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xTrunc == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -2603,7 +2603,7 @@ static int PH7_builtin_fseek(ph7_context *pCtx, int nArg, ph7_value **apArg) { int rc; if(nArg < 2 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_int(pCtx, -1); return PH7_OK; } @@ -2612,14 +2612,14 @@ static int PH7_builtin_fseek(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_int(pCtx, -1); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xSeek == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -2659,7 +2659,7 @@ static int PH7_builtin_ftell(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_int64 iOfft; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -2668,14 +2668,14 @@ static int PH7_builtin_ftell(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xTell == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -2703,7 +2703,7 @@ static int PH7_builtin_rewind(ph7_context *pCtx, int nArg, ph7_value **apArg) { int rc; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -2712,14 +2712,14 @@ static int PH7_builtin_rewind(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xSeek == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -2751,7 +2751,7 @@ static int PH7_builtin_fflush(ph7_context *pCtx, int nArg, ph7_value **apArg) { int rc; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -2760,14 +2760,14 @@ static int PH7_builtin_fflush(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xSync == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -2795,7 +2795,7 @@ static int PH7_builtin_feof(ph7_context *pCtx, int nArg, ph7_value **apArg) { int rc; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 1); return PH7_OK; } @@ -2804,14 +2804,14 @@ static int PH7_builtin_feof(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 1); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3103,7 +3103,7 @@ static int PH7_builtin_fgetc(ph7_context *pCtx, int nArg, ph7_value **apArg) { int c, n; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3112,14 +3112,14 @@ static int PH7_builtin_fgetc(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3161,7 +3161,7 @@ static int PH7_builtin_fgets(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_int64 n, nLen; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3170,14 +3170,14 @@ static int PH7_builtin_fgets(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3219,7 +3219,7 @@ static int PH7_builtin_fread(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nLen; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3228,14 +3228,14 @@ static int PH7_builtin_fread(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3300,7 +3300,7 @@ static int PH7_builtin_fgetcsv(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_int64 n, nLen; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3309,14 +3309,14 @@ static int PH7_builtin_fgetcsv(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3405,7 +3405,7 @@ static int PH7_builtin_fgetss(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_int64 n, nLen; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3414,14 +3414,14 @@ static int PH7_builtin_fgetss(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3465,7 +3465,7 @@ static int PH7_builtin_readdir(ph7_context *pCtx, int nArg, ph7_value **apArg) { int rc; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3474,14 +3474,14 @@ static int PH7_builtin_readdir(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xReadDir == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3511,7 +3511,7 @@ static int PH7_builtin_rewinddir(ph7_context *pCtx, int nArg, ph7_value **apArg) io_private *pDev; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3520,14 +3520,14 @@ static int PH7_builtin_rewinddir(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xRewindDir == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3555,7 +3555,7 @@ static int PH7_builtin_closedir(ph7_context *pCtx, int nArg, ph7_value **apArg) io_private *pDev; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3564,14 +3564,14 @@ static int PH7_builtin_closedir(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xCloseDir == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -3603,7 +3603,7 @@ static int PH7_builtin_opendir(ph7_context *pCtx, int nArg, ph7_value **apArg) { int iLen, rc; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a directory path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a directory path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3612,13 +3612,13 @@ static int PH7_builtin_opendir(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Try to extract a stream */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zPath, iLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No stream device is associated with the given path(%s)", zPath); ph7_result_bool(pCtx, 0); return PH7_OK; } if(pStream->xOpenDir == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream->zName ); @@ -3670,7 +3670,7 @@ static int PH7_builtin_readfile(ph7_context *pCtx, int nArg, ph7_value **apArg) int rc, nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3679,7 +3679,7 @@ static int PH7_builtin_readfile(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3690,7 +3690,7 @@ static int PH7_builtin_readfile(ph7_context *pCtx, int nArg, ph7_value **apArg) pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, use_include, nArg > 2 ? apArg[2] : 0, FALSE, 0); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3746,7 +3746,7 @@ static int PH7_builtin_file_get_contents(ph7_context *pCtx, int nArg, ph7_value int nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3755,7 +3755,7 @@ static int PH7_builtin_file_get_contents(ph7_context *pCtx, int nArg, ph7_value /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3766,7 +3766,7 @@ static int PH7_builtin_file_get_contents(ph7_context *pCtx, int nArg, ph7_value /* Try to open the file in read-only mode */ pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, use_include, nArg > 2 ? apArg[2] : 0, FALSE, 0); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3841,7 +3841,7 @@ static int PH7_builtin_file_put_contents(ph7_context *pCtx, int nArg, ph7_value int nLen; if(nArg < 2 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3850,7 +3850,7 @@ static int PH7_builtin_file_put_contents(ph7_context *pCtx, int nArg, ph7_value /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3882,7 +3882,7 @@ static int PH7_builtin_file_put_contents(ph7_context *pCtx, int nArg, ph7_value pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, iOpenFlags, use_include, nArg > 3 ? apArg[3] : 0, FALSE, FALSE); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3903,7 +3903,7 @@ static int PH7_builtin_file_put_contents(ph7_context *pCtx, int nArg, ph7_value } } else { /* Read-only stream */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Read-only stream(%s): Cannot perform write operation", pStream ? pStream->zName : "null_stream" ); @@ -3943,7 +3943,7 @@ static int PH7_builtin_file(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3952,7 +3952,7 @@ static int PH7_builtin_file(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -3983,7 +3983,7 @@ static int PH7_builtin_file(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Try to open the file in read-only mode */ pDev->pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, use_include, nArg > 2 ? apArg[2] : 0, FALSE, 0); if(pDev->pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); /* Don't worry about freeing memory, everything will be released automatically * as soon we return from this function. @@ -4059,7 +4059,7 @@ static int PH7_builtin_copy(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nLen; if(nArg < 2 || !ph7_value_is_string(apArg[0]) || !ph7_value_is_string(apArg[1])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a source and a destination path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a source and a destination path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4068,14 +4068,14 @@ static int PH7_builtin_copy(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Point to the target IO stream device */ pSin = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pSin == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Try to open the source file in a read-only mode */ pIn = PH7_StreamOpenHandle(pCtx->pVm, pSin, zFile, PH7_IO_OPEN_RDONLY, FALSE, nArg > 2 ? apArg[2] : 0, FALSE, 0); if(pIn == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening source: '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening source: '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4084,13 +4084,13 @@ static int PH7_builtin_copy(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Point to the target IO stream device */ pSout = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pSout == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); PH7_StreamCloseHandle(pSin, pIn); return PH7_OK; } if(pSout->xWrite == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pSin->zName ); @@ -4102,7 +4102,7 @@ static int PH7_builtin_copy(ph7_context *pCtx, int nArg, ph7_value **apArg) { pOut = PH7_StreamOpenHandle(pCtx->pVm, pSout, zFile, PH7_IO_OPEN_CREATE | PH7_IO_OPEN_TRUNC | PH7_IO_OPEN_RDWR, FALSE, nArg > 2 ? apArg[2] : 0, FALSE, 0); if(pOut == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening destination: '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening destination: '%s'", zFile); ph7_result_bool(pCtx, 0); PH7_StreamCloseHandle(pSin, pIn); return PH7_OK; @@ -4144,7 +4144,7 @@ static int PH7_builtin_fstat(ph7_context *pCtx, int nArg, ph7_value **apArg) { io_private *pDev; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4153,14 +4153,14 @@ static int PH7_builtin_fstat(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /* Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xStat == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -4205,7 +4205,7 @@ static int PH7_builtin_fwrite(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nLen, n; if(nArg < 2 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4214,14 +4214,14 @@ static int PH7_builtin_fwrite(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /* Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xWrite == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -4274,7 +4274,7 @@ static int PH7_builtin_flock(ph7_context *pCtx, int nArg, ph7_value **apArg) { int rc; if(nArg < 2 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4283,14 +4283,14 @@ static int PH7_builtin_flock(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xLock == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -4323,7 +4323,7 @@ static int PH7_builtin_fpassthru(ph7_context *pCtx, int nArg, ph7_value **apArg) int rc; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4332,14 +4332,14 @@ static int PH7_builtin_fpassthru(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -4444,7 +4444,7 @@ static int PH7_builtin_fputcsv(ph7_context *pCtx, int nArg, ph7_value **apArg) { int eolen; if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_array(apArg[1])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Missing/Invalid arguments"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Missing/Invalid arguments"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4453,14 +4453,14 @@ static int PH7_builtin_fputcsv(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0 || pStream->xWrite == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -4546,7 +4546,7 @@ static int PH7_builtin_fprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nLen; if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_string(apArg[1])) { /* Missing/Invalid arguments,return zero */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Invalid arguments"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Invalid arguments"); ph7_result_int(pCtx, 0); return PH7_OK; } @@ -4555,13 +4555,13 @@ static int PH7_builtin_fprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_int(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ if(pDev->pStream == 0 || pDev->pStream->xWrite == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pDev->pStream ? pDev->pStream->zName : "null_stream" ); @@ -4606,7 +4606,7 @@ static int PH7_builtin_vfprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) int n, nLen; if(nArg < 3 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_string(apArg[1]) || !ph7_value_is_array(apArg[2])) { /* Missing/Invalid arguments,return zero */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Invalid arguments"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Invalid arguments"); ph7_result_int(pCtx, 0); return PH7_OK; } @@ -4615,13 +4615,13 @@ static int PH7_builtin_vfprintf(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_int(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ if(pDev->pStream == 0 || pDev->pStream->xWrite == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pDev->pStream ? pDev->pStream->zName : "null_stream" ); @@ -4754,7 +4754,7 @@ static int StrModeToFlags(ph7_context *pCtx, const char *zMode, int nLen) { } } else { /* Invalid mode. Assume a read only open */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Invalid open mode,PH7 is assuming a Read-Only open"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Invalid open mode,PH7 is assuming a Read-Only open"); iFlag = PH7_IO_OPEN_RDONLY; } while(zMode < zEnd) { @@ -4827,7 +4827,7 @@ static int PH7_builtin_fopen(ph7_context *pCtx, int nArg, ph7_value **apArg) { int iOpenFlags; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path or URL"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path or URL"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4843,7 +4843,7 @@ static int PH7_builtin_fopen(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Try to extract a stream */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zUri, iLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No stream device is associated with the given URI(%s)", zUri); ph7_result_bool(pCtx, 0); return PH7_OK; @@ -4872,7 +4872,7 @@ static int PH7_builtin_fopen(ph7_context *pCtx, int nArg, ph7_value **apArg) { pDev->pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zUri, iOpenFlags, nArg > 2 ? ph7_value_to_bool(apArg[2]) : FALSE, pResource, FALSE, 0); if(pDev->pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zUri); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zUri); ph7_result_bool(pCtx, 0); ph7_context_free_chunk(pCtx, pDev); return PH7_OK; @@ -4896,7 +4896,7 @@ static int PH7_builtin_fclose(ph7_context *pCtx, int nArg, ph7_value **apArg) { ph7_vm *pVm; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4905,14 +4905,14 @@ static int PH7_builtin_fclose(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Make sure we are dealing with a valid io_private instance */ if(IO_PRIVATE_INVALID(pDev)) { /*Expecting an IO handle */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting an IO handle"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Point to the target IO stream device */ pStream = pDev->pStream; if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO routine(%s) not implemented in the underlying stream(%s) device", ph7_function_name(pCtx), pStream ? pStream->zName : "null_stream" ); @@ -4966,7 +4966,7 @@ static int PH7_builtin_md5_file(ph7_context *pCtx, int nArg, ph7_value **apArg) int nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4975,7 +4975,7 @@ static int PH7_builtin_md5_file(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -4985,7 +4985,7 @@ static int PH7_builtin_md5_file(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Try to open the file in read-only mode */ pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, FALSE, 0, FALSE, 0); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5036,7 +5036,7 @@ static int PH7_builtin_sha1_file(ph7_context *pCtx, int nArg, ph7_value **apArg) int nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5045,7 +5045,7 @@ static int PH7_builtin_sha1_file(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5055,7 +5055,7 @@ static int PH7_builtin_sha1_file(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Try to open the file in read-only mode */ pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, FALSE, 0, FALSE, 0); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5109,7 +5109,7 @@ static int PH7_builtin_parse_ini_file(ph7_context *pCtx, int nArg, ph7_value **a int nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5118,14 +5118,14 @@ static int PH7_builtin_parse_ini_file(ph7_context *pCtx, int nArg, ph7_value **a /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } /* Try to open the file in read-only mode */ pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, FALSE, 0, FALSE, 0); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5191,7 +5191,7 @@ static int PH7_builtin_zip_open(ph7_context *pCtx, int nArg, ph7_value **apArg) sxi32 rc; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a file path"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5200,7 +5200,7 @@ static int PH7_builtin_zip_open(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Point to the target IO stream device */ pStream = PH7_VmGetStreamDevice(pCtx->pVm, &zFile, nLen); if(pStream == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "No such stream device,PH7 is returning FALSE"); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5247,7 +5247,7 @@ static int PH7_builtin_zip_open(ph7_context *pCtx, int nArg, ph7_value **apArg) /* Try to open the file in read-only mode */ pHandle = PH7_StreamOpenHandle(pCtx->pVm, pStream, zFile, PH7_IO_OPEN_RDONLY, FALSE, 0, FALSE, 0); if(pHandle == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "IO error while opening '%s'", zFile); ph7_result_bool(pCtx, 0); return PH7_OK; } @@ -5294,14 +5294,14 @@ static int PH7_builtin_zip_close(ph7_context *pCtx, int nArg, ph7_value **apArg) zip_raw_data *pRaw; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); return PH7_OK; } /* Point to the in-memory archive */ pArchive = (SyArchive *)ph7_value_to_resource(apArg[0]); /* Make sure we are dealing with a valid ZIP archive */ if(SXARCH_INVALID(pArchive)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); return PH7_OK; } /* Release the archive */ @@ -5336,7 +5336,7 @@ static int PH7_builtin_zip_read(ph7_context *pCtx, int nArg, ph7_value **apArg) sxi32 rc; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5345,7 +5345,7 @@ static int PH7_builtin_zip_read(ph7_context *pCtx, int nArg, ph7_value **apArg) pArchive = (SyArchive *)ph7_value_to_resource(apArg[0]); /* Make sure we are dealing with a valid ZIP archive */ if(SXARCH_INVALID(pArchive)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5382,7 +5382,7 @@ static int PH7_builtin_zip_entry_open(ph7_context *pCtx, int nArg, ph7_value **a SyArchive *pArchive; if(nArg < 2 || !ph7_value_is_resource(apArg[0]) || !ph7_value_is_resource(apArg[1])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5391,7 +5391,7 @@ static int PH7_builtin_zip_entry_open(ph7_context *pCtx, int nArg, ph7_value **a pArchive = (SyArchive *)ph7_value_to_resource(apArg[0]); /* Make sure we are dealing with a valid ZIP archive */ if(SXARCH_INVALID(pArchive)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5399,7 +5399,7 @@ static int PH7_builtin_zip_entry_open(ph7_context *pCtx, int nArg, ph7_value **a /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[1]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5421,7 +5421,7 @@ static int PH7_builtin_zip_entry_close(ph7_context *pCtx, int nArg, ph7_value ** SyArchiveEntry *pEntry; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5429,7 +5429,7 @@ static int PH7_builtin_zip_entry_close(ph7_context *pCtx, int nArg, ph7_value ** /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5454,7 +5454,7 @@ static int PH7_builtin_zip_entry_name(ph7_context *pCtx, int nArg, ph7_value **a SyString *pName; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5462,7 +5462,7 @@ static int PH7_builtin_zip_entry_name(ph7_context *pCtx, int nArg, ph7_value **a /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5485,7 +5485,7 @@ static int PH7_builtin_zip_entry_filesize(ph7_context *pCtx, int nArg, ph7_value SyArchiveEntry *pEntry; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5493,7 +5493,7 @@ static int PH7_builtin_zip_entry_filesize(ph7_context *pCtx, int nArg, ph7_value /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5515,7 +5515,7 @@ static int PH7_builtin_zip_entry_compressedsize(ph7_context *pCtx, int nArg, ph7 SyArchiveEntry *pEntry; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5523,7 +5523,7 @@ static int PH7_builtin_zip_entry_compressedsize(ph7_context *pCtx, int nArg, ph7 /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5551,7 +5551,7 @@ static int PH7_builtin_zip_entry_read(ph7_context *pCtx, int nArg, ph7_value **a int iLength; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5559,7 +5559,7 @@ static int PH7_builtin_zip_entry_read(ph7_context *pCtx, int nArg, ph7_value **a /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5610,7 +5610,7 @@ static int PH7_builtin_zip_entry_reset_read_cursor(ph7_context *pCtx, int nArg, SyArchiveEntry *pEntry; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5618,7 +5618,7 @@ static int PH7_builtin_zip_entry_reset_read_cursor(ph7_context *pCtx, int nArg, /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5642,7 +5642,7 @@ static int PH7_builtin_zip_entry_compressionmethod(ph7_context *pCtx, int nArg, SyArchiveEntry *pEntry; if(nArg < 1 || !ph7_value_is_resource(apArg[0])) { /* Missing/Invalid arguments */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; @@ -5650,7 +5650,7 @@ static int PH7_builtin_zip_entry_compressionmethod(ph7_context *pCtx, int nArg, /* Make sure we are dealing with a valid ZIP archive entry */ pEntry = (SyArchiveEntry *)ph7_value_to_resource(apArg[0]); if(SXARCH_ENTRY_INVALID(pEntry)) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a ZIP archive entry"); /* return FALSE */ ph7_result_bool(pCtx, 0); return PH7_OK; diff --git a/engine/vm.c b/engine/vm.c index 41b76c2..d9382bd 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -287,7 +287,7 @@ PH7_PRIVATE sxi32 PH7_VmInstallClass( /* Check for duplicates */ pEntry = SyHashGet(&pVm->hClass, (const void *)pName->zString, pName->nByte); if(pEntry) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot declare class, because the name is already in use"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot declare class, because the name is already in use"); } /* Perform a simple hashtable insertion */ rc = SyHashInsert(&pVm->hClass, (const void *)pName->zString, pName->nByte, pClass); @@ -540,7 +540,7 @@ static ph7_vm_func *VmOverload( } if(i < 1) { /* No candidates, throw an error */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Invalid number of arguments passed to function/method '%z()'", &pList->sName); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Invalid number of arguments passed to function/method '%z()'", &pList->sName); } if(nArg < 1 || i < 2) { /* Return the only candidate */ @@ -1889,7 +1889,7 @@ PH7_PRIVATE sxi32 PH7_VmMemoryError( /* * Throw a run-time error and invoke the supplied VM output consumer callback. */ -PH7_PRIVATE sxi32 PH7_VmGenericError( +PH7_PRIVATE sxi32 PH7_VmThrowError( ph7_vm *pVm, /* Target VM */ sxi32 iErr, /* Severity level: [i.e: Error, Warning, Notice or Deprecated] */ const char *zMessage, /* Null terminated error message */ @@ -2546,7 +2546,7 @@ static sxi32 VmByteCodeExec( pTos->nIdx = SXU32_HIGH; } /* Emit a notice */ - PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE, + PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE, "Attempt to access an undefined array index, PH7 is loading NULL"); break; } @@ -2678,7 +2678,7 @@ static sxi32 VmByteCodeExec( PH7_MemObjInit(pVm, &sEnv.sValue); if(sEnv.iFlags & VM_FUNC_ARG_BY_REF) { /* Pass by reference */ - PH7_VmGenericError(pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pVm, PH7_CTX_WARNING, "Pass by reference is disabled in the current release of the PH7 engine, PH7 is switching to pass by value"); } /* Standard pass by value */ @@ -2715,7 +2715,7 @@ static sxi32 VmByteCodeExec( nIdx = pTos->nIdx; VmPopOperand(&pTos, 1); if(nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Cannot perform assignment on a constant class attribute, PH7 is loading NULL"); pTos->nIdx = SXU32_HIGH; } else { @@ -3071,7 +3071,7 @@ static sxi32 VmByteCodeExec( if(pInstr->iOp == PH7_OP_MUL_STORE) { ph7_value *pObj; if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pNos, pObj); } @@ -3151,7 +3151,7 @@ static sxi32 VmByteCodeExec( } /* Perform the store operation */ if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pTos, pObj); } @@ -3245,7 +3245,7 @@ static sxi32 VmByteCodeExec( MemObjSetType(pNos, MEMOBJ_INT); } if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pNos, pObj); } @@ -3281,7 +3281,7 @@ static sxi32 VmByteCodeExec( b = pTos->x.iVal; if(b == 0) { r = 0; - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a); /* goto Abort; */ } else { r = a % b; @@ -3322,7 +3322,7 @@ static sxi32 VmByteCodeExec( b = pNos->x.iVal; if(b == 0) { r = 0; - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd%%0", a); /* goto Abort; */ } else { r = a % b; @@ -3331,7 +3331,7 @@ static sxi32 VmByteCodeExec( pNos->x.iVal = r; MemObjSetType(pNos, MEMOBJ_INT); if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pNos, pObj); } @@ -3367,7 +3367,7 @@ static sxi32 VmByteCodeExec( if(b == 0) { /* Division by zero */ r = 0; - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero"); /* goto Abort; */ } else { r = a / b; @@ -3410,7 +3410,7 @@ static sxi32 VmByteCodeExec( if(b == 0) { /* Division by zero */ r = 0; - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd/0", a); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Division by zero %qd/0", a); /* goto Abort; */ } else { r = a / b; @@ -3421,7 +3421,7 @@ static sxi32 VmByteCodeExec( PH7_MemObjTryInteger(pNos); } if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pNos, pObj); } @@ -3545,7 +3545,7 @@ static sxi32 VmByteCodeExec( pNos->x.iVal = r; MemObjSetType(pNos, MEMOBJ_INT); if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pNos, pObj); } @@ -3641,7 +3641,7 @@ static sxi32 VmByteCodeExec( pNos->x.iVal = r; MemObjSetType(pNos, MEMOBJ_INT); if(pTos->nIdx == SXU32_HIGH) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot perform assignment on a constant class attribute"); } else if((pObj = (ph7_value *)SySetAt(&pVm->aMemObj, pTos->nIdx)) != 0) { PH7_MemObjStore(pNos, pObj); } @@ -3992,7 +3992,7 @@ static sxi32 VmByteCodeExec( nIdx = pTos->nIdx; if(nIdx == SXU32_HIGH) { if((pTos->iFlags & (MEMOBJ_OBJ | MEMOBJ_HASHMAP | MEMOBJ_RES)) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Reference operator require a variable not a constant as it's right operand"); } else { ph7_value *pObj; @@ -4008,7 +4008,7 @@ static sxi32 VmByteCodeExec( } } else if(sName.nByte > 0) { if((pTos->iFlags & MEMOBJ_HASHMAP) && (pVm->pGlobal == (ph7_hashmap *)pTos->x.pOther)) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "$GLOBALS is a read-only array and therefore cannot be referenced"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "$GLOBALS is a read-only array and therefore cannot be referenced"); } else { VmFrame *pFrame = pVm->pFrame; while(pFrame->pParent && (pFrame->iFlags & VM_FRAME_EXCEPTION)) { @@ -4018,7 +4018,7 @@ static sxi32 VmByteCodeExec( /* Query the local frame */ pEntry = SyHashGet(&pFrame->hVar, (const void *)sName.zString, sName.nByte); if(pEntry) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Referenced variable name '%z' already exists", &sName); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Referenced variable name '%z' already exists", &sName); } else { rc = SyHashInsert(&pFrame->hVar, (const void *)sName.zString, sName.nByte, SX_INT_TO_PTR(nIdx)); if(pFrame->pParent == 0) { @@ -4148,13 +4148,13 @@ static sxi32 VmByteCodeExec( pBase = PH7_VmExtractClass(pVm, apExtends->zString, apExtends->nByte, FALSE, 0); if(pBase == 0) { /* Non-existent base class */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base class '%z'", &apExtends->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base class '%z'", &apExtends->zString); } else if(pBase->iFlags & PH7_CLASS_INTERFACE) { /* Trying to inherit from interface */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from interface '%z'", &pClass->sName.zString, &apExtends->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from interface '%z'", &pClass->sName.zString, &apExtends->zString); } else if(pBase->iFlags & PH7_CLASS_FINAL) { /* Trying to inherit from final class */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from final class '%z'", &pClass->sName.zString, &apExtends->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from final class '%z'", &pClass->sName.zString, &apExtends->zString); } rc = PH7_ClassInherit(pVm, pClass, pBase); if(rc != SXRET_OK) { @@ -4169,10 +4169,10 @@ static sxi32 VmByteCodeExec( pBase = PH7_VmExtractClass(pVm, apImplements->zString, apImplements->nByte, FALSE, 0); if(pBase == 0) { /* Non-existent interface */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to non-existent interface '%z'", &apImplements->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-existent interface '%z'", &apImplements->zString); } else if((pBase->iFlags & PH7_CLASS_INTERFACE) == 0) { /* Trying to implement a class */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot implement a class '%z'", &pClass->sName.zString, &apImplements->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot implement a class '%z'", &pClass->sName.zString, &apImplements->zString); } rc = PH7_ClassImplement(pClass, pBase); if(rc != SXRET_OK) { @@ -4199,10 +4199,10 @@ static sxi32 VmByteCodeExec( pBase = PH7_VmExtractClass(pVm, apExtends->zString, apExtends->nByte, FALSE, 0); if(pBase == 0) { /* Non-existent base interface */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base interface '%z'", &apExtends->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to non-existent base interface '%z'", &apExtends->zString); } else if((pBase->iFlags & PH7_CLASS_INTERFACE) == 0) { /* Trying to inherit from class */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Interface '%z' cannot inherit from class '%z'", &pClass->sName.zString, &apExtends->zString); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Interface '%z' cannot inherit from class '%z'", &pClass->sName.zString, &apExtends->zString); } rc = PH7_ClassInterfaceInherit(pClass, pBase); if(rc != SXRET_OK) { @@ -4253,7 +4253,7 @@ static sxi32 VmByteCodeExec( if((pTos->iFlags & (MEMOBJ_HASHMAP | MEMOBJ_OBJ)) == 0 || SyStringLength(&pInfo->sValue) < 1) { /* Jump out of the loop */ if((pTos->iFlags & MEMOBJ_NULL) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, "Invalid argument supplied for the foreach statement, expecting array or class instance"); + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Invalid argument supplied for the foreach statement, expecting array or class instance"); } pc = pInstr->iP2 - 1; } else { @@ -4446,7 +4446,7 @@ static sxi32 VmByteCodeExec( pMeth = PH7_ClassExtractMethod(pClass, sName.zString, sName.nByte); } if(pMeth == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to undefined method '%z->%z()'", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to undefined method '%z->%z()'", &pClass->sName, &sName ); /* Call the '__Call()' magic method if available */ @@ -4475,7 +4475,7 @@ static sxi32 VmByteCodeExec( } if(pObjAttr == 0) { /* No such attribute,load null */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z->%z',PH7 is loading NULL", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z->%z',PH7 is loading NULL", &pClass->sName, &sName); /* Call the __get magic method if available */ PH7_ClassInstanceCallMagicMethod(&(*pVm), pClass, pThis, "__get", sizeof("__get") - 1, &sName); @@ -4517,7 +4517,7 @@ static sxi32 VmByteCodeExec( PH7_ClassInstanceUnref(pThis); } } else { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Expecting class instance as left operand"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Expecting class instance as left operand"); VmPopOperand(&pTos, 1); PH7_MemObjRelease(pTos); pTos->nIdx = SXU32_HIGH; /* Assume we are loading a constant */ @@ -4554,7 +4554,7 @@ static sxi32 VmByteCodeExec( } if(pClass == 0) { /* Undefined class */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to undefined class '%.*s'", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to undefined class '%.*s'", SyBlobLength(&pNos->sBlob), (const char *)SyBlobData(&pNos->sBlob) ); if(!pInstr->p3) { @@ -4572,11 +4572,11 @@ static sxi32 VmByteCodeExec( } if(pMeth == 0 || (pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL)) { if(pMeth) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot call virtual method '%z:%z'", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot call virtual method '%z:%z'", &pClass->sName, &sName ); } else { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Undefined class static method '%z::%z'", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Undefined class static method '%z::%z'", &pClass->sName, &sName ); /* Call the '__CallStatic()' magic method if available */ @@ -4603,7 +4603,7 @@ static sxi32 VmByteCodeExec( } if(pAttr == 0) { /* No such attribute,load null */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z::%z'", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Undefined class attribute '%z::%z'", &pClass->sName, &sName); /* Call the __get magic method if available */ PH7_ClassInstanceCallMagicMethod(&(*pVm), pClass, 0, "__get", sizeof("__get") - 1, &sName); @@ -4617,7 +4617,7 @@ static sxi32 VmByteCodeExec( if(pAttr) { if((pAttr->iFlags & (PH7_CLASS_ATTR_STATIC | PH7_CLASS_ATTR_CONSTANT)) == 0) { /* Access to a non static attribute */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Access to a non-static class attribute '%z::%z'", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Access to a non-static class attribute '%z::%z'", &pClass->sName, &pAttr->sName ); } else { @@ -4644,7 +4644,7 @@ static sxi32 VmByteCodeExec( } } else { /* Pop operands */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Invalid class name"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Invalid class name"); if(!pInstr->p3) { VmPopOperand(&pTos, 1); } @@ -4672,7 +4672,7 @@ static sxi32 VmByteCodeExec( } if(pClass == 0) { /* No such class */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Class '%.*s' is not defined", + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%.*s' is not defined", SyBlobLength(&pTos->sBlob), (const char *)SyBlobData(&pTos->sBlob) ); PH7_MemObjRelease(pTos); @@ -4711,7 +4711,7 @@ static sxi32 VmByteCodeExec( pFuncArg = (ph7_vm_func_arg *)SySetAt(&pCons->sFunc.aArgs, n); if(pFuncArg) { if(SySetUsed(&pFuncArg->aByteCode) < 1) { - PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE, "Missing constructor argument %u($%z) for class '%z'", + PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE, "Missing constructor argument %u($%z) for class '%z'", n + 1, &pFuncArg->sName, &pClass->sName); } } @@ -4747,7 +4747,7 @@ static sxi32 VmByteCodeExec( #endif /* Make sure we are dealing with a class instance */ if((pTos->iFlags & MEMOBJ_OBJ) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Clone: Expecting a class instance as left operand"); PH7_MemObjRelease(pTos); break; @@ -4849,7 +4849,7 @@ static sxi32 VmByteCodeExec( PH7_ClassInstanceCallMagicMethod(&(*pVm), pThis->pClass, pThis, "__invoke", sizeof("__invoke") - 1, 0); } else { /* Raise exception: Invalid function name */ - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, "Invalid function name"); + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Invalid function name"); } /* Pop given arguments */ if(pInstr->iP1 > 0) { @@ -4944,7 +4944,7 @@ static sxi32 VmByteCodeExec( } /* Check The recursion limit */ if(pVm->nRecursionDepth > pVm->nMaxDepth) { - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Recursion limit reached while invoking user function '%z', PH7 will set a NULL return value", &pVmFunc->sName); /* Pop given arguments */ @@ -5032,7 +5032,7 @@ static sxi32 VmByteCodeExec( if(pClass) { if((pArg->iFlags & MEMOBJ_OBJ) == 0) { if((pArg->iFlags & MEMOBJ_NULL) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Function '%z()':Argument %u must be an object of type '%z', PH7 is loading NULL instead", &pVmFunc->sName, n + 1, pName); PH7_MemObjRelease(pArg); @@ -5041,7 +5041,7 @@ static sxi32 VmByteCodeExec( ph7_class_instance *pThis = (ph7_class_instance *)pArg->x.pOther; /* Make sure the object is an instance of the given class */ if(! VmInstanceOf(pThis->pClass, pClass)) { - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Function '%z()':Argument %u must be an object of type '%z', PH7 is loading NULL instead", &pVmFunc->sName, n + 1, pName); PH7_MemObjRelease(pArg); @@ -5059,7 +5059,7 @@ static sxi32 VmByteCodeExec( if(pArg->nIdx == SXU32_HIGH) { /* Expecting a variable,not a constant,raise an exception */ if((pArg->iFlags & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_RES | MEMOBJ_NULL)) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_WARNING, + PH7_VmThrowError(&(*pVm), PH7_CTX_WARNING, "Function '%z',%d argument: Pass by reference,expecting a variable not a " "constant, PH7 is switching to pass by value", &pVmFunc->sName, n + 1); } @@ -5188,7 +5188,7 @@ static sxi32 VmByteCodeExec( if(n == aSlot[i].nIdx) { pObj = (ph7_value *)SySetAt(&pVm->aMemObj, n); if(pObj && (pObj->iFlags & (MEMOBJ_NULL | MEMOBJ_OBJ | MEMOBJ_HASHMAP | MEMOBJ_RES)) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE, + PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE, "Function '%z',return by reference: Cannot reference local variable, PH7 is switching to return by value", &pVmFunc->sName); } @@ -5198,7 +5198,7 @@ static sxi32 VmByteCodeExec( } } else { if((pTos->iFlags & (MEMOBJ_HASHMAP | MEMOBJ_OBJ | MEMOBJ_NULL | MEMOBJ_RES)) == 0) { - PH7_VmGenericError(&(*pVm), PH7_CTX_NOTICE, + PH7_VmThrowError(&(*pVm), PH7_CTX_NOTICE, "Function '%z', return by reference: Cannot reference constant expression, PH7 is switching to return by value", &pVmFunc->sName); } @@ -5242,7 +5242,7 @@ static sxi32 VmByteCodeExec( pEntry = SyHashGet(&pVm->hHostFunction, (const void *)sName.zString, sName.nByte); if(pEntry == 0) { /* Call to undefined function */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Call to undefined function '%z()'", &sName); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Call to undefined function '%z()'", &sName); /* Pop given arguments */ if(pInstr->iP1 > 0) { VmPopOperand(&pTos, pInstr->iP1); @@ -5421,7 +5421,7 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) { /* Extract and instantiate the entry point */ pClass = PH7_VmExtractClass(&(*pVm), "Program", 7, TRUE /* Only loadable class but not 'interface' or 'virtual' class*/, 0); if(!pClass) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot find an entry 'Program' class"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot find an entry 'Program' class"); } pInstance = PH7_NewClassInstance(&(*pVm), pClass); if(pInstance == 0) { @@ -5436,7 +5436,7 @@ PH7_PRIVATE sxi32 PH7_VmByteCodeExec(ph7_vm *pVm) { /* Call entry point */ pMethod = PH7_ClassExtractMethod(pClass, "main", sizeof("main") - 1); if(!pMethod) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, "Cannot find a program entry point 'Program::main()'"); + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot find a program entry point 'Program::main()'"); } PH7_MemObjInit(pVm, &pResult); PH7_VmCallClassMethod(&(*pVm), pInstance, pMethod, &pResult, 0, 0); @@ -6750,7 +6750,7 @@ static int VmClassMemberAccess( return 1; /* Access is granted */ dis: if(bLog) { - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Access to the class attribute '%z->%z' is forbidden", &pClass->sName, pAttrName); } @@ -7364,7 +7364,7 @@ static int vm_builtin_defined(ph7_context *pCtx, int nArg, ph7_value **apArg) { int res = 0; if(nArg < 1) { /* Missing constant name,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name"); ph7_result_bool(pCtx, 0); return SXRET_OK; } @@ -7405,19 +7405,19 @@ static int vm_builtin_define(ph7_context *pCtx, int nArg, ph7_value **apArg) { sxi32 rc; if(nArg < 2) { /* Missing arguments,throw a notice and return false */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name/value pair"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Missing constant name/value pair"); ph7_result_bool(pCtx, 0); return SXRET_OK; } if(!ph7_value_is_string(apArg[0])) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Invalid constant name"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Invalid constant name"); ph7_result_bool(pCtx, 0); return SXRET_OK; } /* Extract constant name */ zName = ph7_value_to_string(apArg[0], &nLen); if(nLen < 1) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Empty constant name"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Empty constant name"); ph7_result_bool(pCtx, 0); return SXRET_OK; } @@ -7482,7 +7482,7 @@ static int vm_builtin_constant(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nLen; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Invalid argument,return NULL */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "Missing/Invalid constant name"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "Missing/Invalid constant name"); ph7_result_null(pCtx); return SXRET_OK; } @@ -7491,7 +7491,7 @@ static int vm_builtin_constant(ph7_context *pCtx, int nArg, ph7_value **apArg) { /* Perform the query */ pEntry = SyHashGet(&pCtx->pVm->hConstant, (const void *)zName, (sxu32)nLen); if(pEntry == 0) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_NOTICE, "'%.*s': Undefined constant", nLen, zName); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_NOTICE, "'%.*s': Undefined constant", nLen, zName); ph7_result_null(pCtx); return SXRET_OK; } @@ -8118,7 +8118,7 @@ static int vm_builtin_rand_str(ph7_context *pCtx, int nArg, ph7_value **apArg) { static int vm_builtin_random_int(ph7_context *pCtx, int nArg, ph7_value **apArg) { sxu32 iNum, iMin, iMax; if(nArg != 2) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting min and max arguments"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting min and max arguments"); return SXERR_INVALID; } iNum = PH7_VmRandomNum(pCtx->pVm); @@ -8152,7 +8152,7 @@ static int vm_builtin_random_bytes(ph7_context *pCtx, int nArg, ph7_value **apAr sxu32 iLen; unsigned char *zBuf; if(nArg != 1) { - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting length argument"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting length argument"); return SXERR_INVALID; } iLen = (sxu32)ph7_value_to_int(apArg[0]); @@ -8349,7 +8349,7 @@ static int vm_builtin_isset(ph7_context *pCtx, int nArg, ph7_value **apArg) { if(pObj->nIdx == SXU32_HIGH) { if((pObj->iFlags & MEMOBJ_NULL) == 0) { /* Not so fatal,Throw a warning */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a variable not a constant"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Expecting a variable not a constant"); } } res = (pObj->iFlags & MEMOBJ_NULL) ? 0 : 1; @@ -8412,7 +8412,7 @@ static int vm_builtin_unset(ph7_context *pCtx, int nArg, ph7_value **apArg) { if(pObj->nIdx == SXU32_HIGH) { if((pObj->iFlags & MEMOBJ_NULL) == 0) { /* Throw an error */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Expecting a variable not a constant"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Expecting a variable not a constant"); } } else { sxu32 nIdx = pObj->nIdx; @@ -8796,7 +8796,7 @@ static int vm_builtin_assert(ph7_context *pCtx, int nArg, ph7_value **apArg) { } if(iFlags & PH7_ASSERT_WARNING) { /* Emit a warning */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "Assertion failed"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Assertion failed"); } if(iFlags & PH7_ASSERT_BAIL) { /* Abort VM execution immediately */ @@ -8857,7 +8857,7 @@ static int vm_builtin_trigger_error(ph7_context *pCtx, int nArg, ph7_value **apA } } /* Report error */ - PH7_VmGenericError(pCtx->pVm, nErr, "%.*s", nLen, zErr); + PH7_VmThrowError(pCtx->pVm, nErr, "%.*s", nLen, zErr); /* Return true */ ph7_result_bool(pCtx, 1); } else { @@ -9074,7 +9074,7 @@ static sxi32 VmUncaughtException( } } /* Generate a listing */ - PH7_VmGenericError(&(*pVm), PH7_CTX_ERR, + PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Uncaught exception '%z' in the '%z()' function/method", &sName, &sFuncName); /* Tell the upper layer to stop VM execution immediately */ @@ -10362,7 +10362,7 @@ static int vm_builtin_include(ph7_context *pCtx, int nArg, ph7_value **apArg) { } if(rc != SXRET_OK) { /* Emit a warning and return false */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, "IO error while importing: '%z'", &sFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "IO error while importing: '%z'", &sFile); ph7_result_bool(pCtx, 0); } return SXRET_OK; @@ -10397,7 +10397,7 @@ static int vm_builtin_require(ph7_context *pCtx, int nArg, ph7_value **apArg) { } if(rc != SXRET_OK) { /* Fatal,abort VM execution immediately */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Fatal IO error while importing: '%z'", &sFile); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Fatal IO error while importing: '%z'", &sFile); ph7_result_bool(pCtx, 0); return PH7_ABORT; } @@ -10608,7 +10608,7 @@ static int vm_builtin_getopt(ph7_context *pCtx, int nArg, ph7_value **apArg) { int nByte; if(nArg < 1 || !ph7_value_is_string(apArg[0])) { /* Missing/Invalid arguments,return FALSE */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_ERR, "Missing/Invalid option arguments"); + PH7_VmThrowError(pCtx->pVm, PH7_CTX_ERR, "Missing/Invalid option arguments"); ph7_result_bool(pCtx, 0); return PH7_OK; } diff --git a/include/ph7.h b/include/ph7.h index b1fd5e7..cdc1f11 100644 --- a/include/ph7.h +++ b/include/ph7.h @@ -433,7 +433,7 @@ typedef sxi64 ph7_int64; * Call Context Error Message Severity Level. * * The following constans are the allowed severity level that can - * passed as the second argument to the PH7_VmGenericError(). + * passed as the second argument to the PH7_VmThrowError(). * Refer to the official documentation for additional information. */ #define PH7_CTX_ERR 1 /* Call context Error such as unexpected number of arguments,invalid types and so on. */ diff --git a/include/ph7int.h b/include/ph7int.h index 2323f64..e258106 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1684,7 +1684,7 @@ 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); PH7_PRIVATE sxi32 PH7_VmMemoryError(ph7_vm *pVm); -PH7_PRIVATE sxi32 PH7_VmGenericError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...); +PH7_PRIVATE sxi32 PH7_VmThrowError(ph7_vm *pVm, sxi32 iErr, const char *zMessage, ...); PH7_PRIVATE void PH7_VmExpandConstantValue(ph7_value *pVal, void *pUserData); PH7_PRIVATE sxi32 PH7_VmDump(ph7_vm *pVm, ProcConsumer xConsumer, void *pUserData); PH7_PRIVATE sxi32 PH7_VmInit(ph7_vm *pVm, ph7 *pEngine, sxbool bDebug); diff --git a/modules/json/json.c b/modules/json/json.c index 7a1c070..337450c 100644 --- a/modules/json/json.c +++ b/modules/json/json.c @@ -706,7 +706,7 @@ static sxi32 VmJsonDecode( pDecoder->pIn++; /* Return the object as an associative array */ if((pDecoder->iFlags & JSON_DECODE_ASSOC) == 0) { - PH7_VmGenericError(pDecoder->pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pDecoder->pCtx->pVm, PH7_CTX_WARNING, "JSON Objects are always returned as an associative array" ); } diff --git a/modules/xml/xml.c b/modules/xml/xml.c index 83ea90e..b7598a4 100644 --- a/modules/xml/xml.c +++ b/modules/xml/xml.c @@ -877,7 +877,7 @@ static int vm_builtin_xml_set_object(ph7_context *pCtx, int nArg, ph7_value **ap return PH7_OK; } /* Throw a notice and return */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_DEPRECATED, "This function is deprecated and is a no-op." + PH7_VmThrowError(pCtx->pVm, PH7_CTX_DEPRECATED, "This function is deprecated and is a no-op." "In order to mimic this behaviour,you can supply instead of a function name an array " "containing an object reference and a method name." ); @@ -1295,7 +1295,7 @@ static int vm_builtin_xml_parse(ph7_context *pCtx, int nArg, ph7_value **apArg) /* This can happen when the user callback call xml_parse() again * in it's body which is forbidden. */ - PH7_VmGenericError(pCtx->pVm, PH7_CTX_WARNING, + PH7_VmThrowError(pCtx->pVm, PH7_CTX_WARNING, "Recursive call to %s, PH7 is returning false", ph7_function_name(pCtx) );