Skip to content

hernad/ziher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is ziher? Find here.

ziher

python

C:\dev\ziher\ziher_mono\ziher\src\bazel-bin\test>dir f18ziherpy.pyd
 Volume in drive C has no label.
 Volume Serial Number is F0E2-A75E

 Directory of C:\dev\ziher\ziher_mono\ziher\src\bazel-bin\test

27. 08. 2022.  15:41            16.896 f18ziherpy.pyd
               1 File(s)         16.896 bytes
               0 Dir(s)  762.793.041.920 bytes free

Python API Reference

Below is a summary of the f18ziherpy module's API:

Python call Description
vminit(startMain, initRT, releaseConsole) Initialize the Ziher VM
vmquit(releaseRT) Quit the Ziher VM
con_init() Initialize console I/O
con_release() Release console I/O
run(funcName, initConsole=0, releaseConsole=0) Call a Ziher function (no return value)
run_get(funcName, initConsole=0, releaseConsole=0, returnType=0) Call a Ziher function and get its return (str or int)
put_get(funcName, param, initConsole=0, releaseConsole=0) Call a Ziher function with a string parameter and get its return (str)
hash(hashName, initConsole=0, releaseConsole=0) Pass a Ziher hash in/out and return a Python dict
set_callback(callback) Register a Python callable for Ziher to invoke via PY_CALLBACK
system(command) Execute a shell command via system()
f18(command) Execute an f18 command (e.g., --help or run in VM)

For callback support, the ziher_set_py_callback function (in zh_zero/zh_python.c) saves the Python callable, and the Ziher function PY_CALLBACK can be used in Ziher code to invoke back into Python.

C:\dev\ziher\ziher_mono\ziher\src\bazel-bin\test>dumpbin /dependents f18ziherpy.pyd

Dump of file f18ziherpy.pyd

File Type: DLL

  Image has the following dependencies:
    ziher.dll
    hello_py.dll
    python3.dll
    VCRUNTIME140.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    KERNEL32.dll

  Summary

        1000 .data
        1000 .pdata
        2000 .rdata
        1000 .reloc
        2000 .text
C:\dev\ziher\ziher_mono\ziher\src\bazel-bin\test>dumpbin /exports f18ziherpy.pyd
Dump of file f18ziherpy.pyd
File Type: DLL
  Section contains the following exports for f18ziherpy.dll

    00000000 characteristics
    FFFFFFFF time date stamp
        0.00 version
           1 ordinal base
           2 number of functions
           2 number of names

    ordinal hint RVA      name

          1    0 00001720 PyInit_f18ziherpy = PyInit_f18ziherpy
          2    1 00001000 hello_py_ext_101 = hello_py_ext_101

Ziher from python

run parametri: MAIN - ime funkcije, 1 - init console, 1 - release console

>>> import f18ziherpy
>>> f18ziherpy.vminit();f18ziherpy.run("MAIN",1,1);f18ziherpy.run("MAIN",1,1);quit()

callback lamda funkcija

Definišemo lamda funkciju x+y+3. Poziv init console=1, release console=1 f18ziherpy.hash('ZIHER_TO_PY',1,1). Hash vraća python dict objekat napunjen unutar ziher kao hash varijabla.

python -c "callback = lambda x,y: x+y+3;import f18ziherpy;f18ziherpy.vminit();f18ziherpy.set_callback(callback);ret=f18ziherpy.hash('ZIHER_TO_PY',1,1);print(ret);quit()"

dva setovanja callback-a i dva hash poziva

python -c "callback = lambda x,y: x+y+3;import f18ziherpy;f18ziherpy.vminit();f18ziherpy.set_callback(callback);ret=f18ziherpy.hash('ZIHER_TO_PY',1,1);print(ret);callback2 = lambda x,y: x+y+23;f18ziherpy.set_callback(callback2);print(f18ziherpy.hash('ZIHER_TO_PY',1,1));quit()"

About

Software. Past -> Rethink -> Future.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published