Wrapped PH7_VM_CONFIG_IMPORT_PATH

This commit is contained in:
Brandon Dyck 2022-11-28 10:06:31 -07:00
parent 13d3d640ec
commit 2ac1f6bac8
3 changed files with 11 additions and 1 deletions

4
cgo.c
View File

@ -23,3 +23,7 @@ int vm_config_err_report(ph7_vm *pVm) {
int vm_output_length(ph7_vm *pVm, unsigned int *pLength) { int vm_output_length(ph7_vm *pVm, unsigned int *pLength) {
return ph7_vm_config(pVm, PH7_VM_OUTPUT_LENGTH, pLength); return ph7_vm_config(pVm, PH7_VM_OUTPUT_LENGTH, pLength);
} }
int vm_add_import_path(ph7_vm *pVm, const char *zIncludePath) {
return ph7_vm_config(pVm, PH7_VM_CONFIG_IMPORT_PATH, zIncludePath);
}

1
cgo.h
View File

@ -5,6 +5,7 @@ int engine_config_err_log(ph7 *pEngine, const char **pzPtr, int *pLen);
int vm_extract_output(ph7_vm *pVm, const char **pzPtr, int *pLen); int vm_extract_output(ph7_vm *pVm, const char **pzPtr, int *pLen);
int vm_config_err_report(ph7_vm *pVm); int vm_config_err_report(ph7_vm *pVm);
int vm_output_length(ph7_vm *pVm, unsigned int *pLength); int vm_output_length(ph7_vm *pVm, unsigned int *pLength);
int vm_add_import_path(ph7_vm *pVm, const char *zIncludePath);
extern int write_vm_output(void*, unsigned int, void*); extern int write_vm_output(void*, unsigned int, void*);
int vm_set_output_callback(ph7_vm *pVm, void *pUserData); int vm_set_output_callback(ph7_vm *pVm, void *pUserData);

7
ph7.go
View File

@ -493,7 +493,12 @@ func (vm *VM) SetOutputWriter(w io.Writer) error {
return newError(C.vm_set_output_callback(vm.ptr, vm.pointerKey)) return newError(C.vm_set_output_callback(vm.ptr, vm.pointerKey))
} }
// TODO PH7_VM_CONFIG_IMPORT_PATH func (vm *VM) AddImportPath(path string) error {
cpath := C.CString(path)
defer C.free(unsafe.Pointer(cpath))
return newError(C.vm_add_import_path(vm.ptr, cpath))
}
// TODO PH7_VM_CONFIG_RECURSION_DEPTH // TODO PH7_VM_CONFIG_RECURSION_DEPTH
func (vm *VM) OutputLength() (uint, error) { func (vm *VM) OutputLength() (uint, error) {