koffi 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CMakeLists.txt +1 -1
  2. package/ChangeLog.md +13 -1
  3. package/build/qemu/1.3.5/koffi_darwin_arm64.tar.gz +0 -0
  4. package/build/qemu/1.3.5/koffi_darwin_x64.tar.gz +0 -0
  5. package/build/qemu/1.3.5/koffi_freebsd_arm64.tar.gz +0 -0
  6. package/build/qemu/1.3.5/koffi_freebsd_ia32.tar.gz +0 -0
  7. package/build/qemu/1.3.5/koffi_freebsd_x64.tar.gz +0 -0
  8. package/build/qemu/1.3.5/koffi_linux_arm32hf.tar.gz +0 -0
  9. package/build/qemu/1.3.5/koffi_linux_arm64.tar.gz +0 -0
  10. package/build/qemu/1.3.5/koffi_linux_ia32.tar.gz +0 -0
  11. package/build/qemu/1.3.5/koffi_linux_riscv64hf64.tar.gz +0 -0
  12. package/build/qemu/1.3.5/koffi_linux_x64.tar.gz +0 -0
  13. package/build/qemu/1.3.5/koffi_openbsd_ia32.tar.gz +0 -0
  14. package/build/qemu/1.3.5/koffi_openbsd_x64.tar.gz +0 -0
  15. package/build/qemu/1.3.5/koffi_win32_arm64.tar.gz +0 -0
  16. package/build/qemu/1.3.5/koffi_win32_ia32.tar.gz +0 -0
  17. package/build/qemu/1.3.5/koffi_win32_x64.tar.gz +0 -0
  18. package/doc/dist/doctrees/changes.doctree +0 -0
  19. package/doc/dist/doctrees/environment.pickle +0 -0
  20. package/doc/dist/doctrees/functions.doctree +0 -0
  21. package/doc/dist/doctrees/index.doctree +0 -0
  22. package/doc/dist/doctrees/memory.doctree +0 -0
  23. package/doc/dist/doctrees/start.doctree +0 -0
  24. package/doc/dist/doctrees/types.doctree +0 -0
  25. package/doc/dist/html/_sources/functions.md.txt +16 -14
  26. package/doc/dist/html/_sources/memory.md.txt +6 -3
  27. package/doc/dist/html/_sources/start.md.txt +3 -3
  28. package/doc/dist/html/_sources/types.md.txt +10 -8
  29. package/doc/dist/html/changes.html +15 -1
  30. package/doc/dist/html/functions.html +16 -19
  31. package/doc/dist/html/index.html +4 -2
  32. package/doc/dist/html/memory.html +8 -3
  33. package/doc/dist/html/objects.inv +0 -0
  34. package/doc/dist/html/platforms.html +1 -1
  35. package/doc/dist/html/searchindex.js +1 -1
  36. package/doc/dist/html/start.html +3 -3
  37. package/doc/dist/html/types.html +9 -8
  38. package/doc/functions.md +16 -14
  39. package/doc/memory.md +6 -3
  40. package/doc/start.md +3 -3
  41. package/doc/types.md +10 -8
  42. package/package.json +2 -2
  43. package/qemu/registry/machines.json +6 -11
  44. package/src/abi_x86.cc +0 -5
  45. package/src/call.cc +2 -1
  46. package/src/ffi.cc +71 -22
  47. package/src/ffi.hh +11 -4
  48. package/test/async.js +1 -1
  49. package/build/qemu/1.3.4/koffi_darwin_arm64.tar.gz +0 -0
  50. package/build/qemu/1.3.4/koffi_darwin_x64.tar.gz +0 -0
  51. package/build/qemu/1.3.4/koffi_freebsd_arm64.tar.gz +0 -0
  52. package/build/qemu/1.3.4/koffi_freebsd_ia32.tar.gz +0 -0
  53. package/build/qemu/1.3.4/koffi_freebsd_x64.tar.gz +0 -0
  54. package/build/qemu/1.3.4/koffi_linux_arm32hf.tar.gz +0 -0
  55. package/build/qemu/1.3.4/koffi_linux_arm64.tar.gz +0 -0
  56. package/build/qemu/1.3.4/koffi_linux_ia32.tar.gz +0 -0
  57. package/build/qemu/1.3.4/koffi_linux_riscv64hf64.tar.gz +0 -0
  58. package/build/qemu/1.3.4/koffi_linux_x64.tar.gz +0 -0
  59. package/build/qemu/1.3.4/koffi_openbsd_ia32.tar.gz +0 -0
  60. package/build/qemu/1.3.4/koffi_openbsd_x64.tar.gz +0 -0
  61. package/build/qemu/1.3.4/koffi_win32_arm64.tar.gz +0 -0
  62. package/build/qemu/1.3.4/koffi_win32_ia32.tar.gz +0 -0
  63. package/build/qemu/1.3.4/koffi_win32_x64.tar.gz +0 -0
@@ -1 +1 @@
1
- Search.setIndex({"docnames": ["benchmarks", "changes", "contribute", "functions", "index", "memory", "platforms", "start", "types"], "filenames": ["benchmarks.md", "changes.md", "contribute.md", "functions.md", "index.rst", "memory.md", "platforms.md", "start.md", "types.md"], "titles": ["Benchmarks", "Changelog", "Contributing", "Function calls", "Koffi 1.3.4", "Memory usage", "Supported platforms", "Quick start", "Data types"], "terms": {"here": [0, 2, 3, 4, 8], "quick": [0, 4], "overview": 0, "execut": [0, 3], "time": [0, 2, 7], "koffi": [0, 2, 3, 5, 6, 7, 8], "call": [0, 1, 4, 5, 6, 7, 8], "three": [0, 7, 8], "test": [0, 1, 4, 6], "case": [2, 3, 8], "one": [0, 3, 5, 7, 8], "base": [0, 3, 4, 8], "around": [0, 5, 8], "compar": 0, "theoret": 0, "ideal": 0, "implement": [0, 8], "These": [0, 2, 3, 8], "ar": [0, 2, 3, 5, 6, 7, 8], "detail": 0, "explain": 0, "below": [0, 1, 2, 3, 7, 8], "node": [0, 2, 3, 4, 6, 7], "ffi": [0, 3, 4, 7], "napi": 0, "thi": [0, 1, 2, 3, 4, 7, 8], "repeat": 0, "simpl": [0, 2, 3, 8], "standard": [0, 3, 8], "c": [0, 1, 2, 4, 5, 6, 7], "function": [0, 1, 2, 4, 7, 8], "ha": [0, 2, 3, 8], "first": [0, 2, 3, 7, 8], "refer": [0, 4, 8], "through": [0, 3, 8], "an": [0, 3, 5, 8], "n": [0, 2, 6, 7, 8], "api": [0, 2, 3, 7, 8], "modul": [0, 1, 4], "close": [0, 8], "limit": 0, "perfect": 0, "overhead": [0, 4], "js": [0, 1, 2, 3, 4, 6, 8], "second": [0, 3, 7, 8], "third": [0, 8], "us": [0, 1, 2, 4, 5, 6, 7, 8], "offici": [0, 2, 6], "becaus": [0, 2, 3, 8], "pretti": [0, 2], "small": [0, 3, 4], "clearli": 0, "visibl": 0, "The": [0, 1, 2, 3, 5, 6, 7, 8], "were": 0, "measur": 0, "my": [0, 2], "machin": [0, 2], "amd": 0, "ryzen": 0, "7": 0, "4700u": 0, "iter": [0, 8], "total": [0, 8], "rel": 0, "perform": [0, 4], "rand_napi": 0, "20000000": 0, "1": [0, 2, 5, 6, 8], "44": 0, "baselin": 0, "rand_koffi": 0, "2": [0, 4, 5, 6, 8], "60": 0, "x0": 0, "55": 0, "81": [0, 2], "rand_node_ffi": 0, "107": 0, "58": 0, "01": 0, "7400": 0, "intel": 0, "core": 0, "i5": 0, "4460": 0, "10": 0, "3": [0, 2, 6, 8], "87": 0, "54": 0, "84": 0, "02": 0, "4100": 0, "similar": [0, 3], "which": [0, 2, 6, 7], "take": [0, 8], "string": [0, 1, 2, 3, 5, 7], "paramet": [0, 4, 7, 8], "javascript": [0, 4, 8], "v8": [0, 3], "convers": [0, 1, 8], "slow": [0, 2], "heavi": 0, "atoi_napi": 0, "97": 0, "atoi_koffi": 0, "5": [0, 3, 8], "07": 0, "71": 0, "atoi_node_ffi": 0, "693": 0, "16": [0, 8], "005": 0, "23000": 0, "91": 0, "50": 0, "99": 0, "479": 0, "34": 0, "006": 0, "16000": 0, "cpu": 0, "imag": 0, "draw": 0, "much": [0, 2], "heavier": 0, "than": [0, 5], "thu": 0, "reduc": 0, "In": [0, 3, 8], "full": [0, 2, 8], "version": [0, 1, 2, 3, 4, 6, 8], "code": [0, 1, 3, 4, 5], "nativ": [0, 3], "wrapper": [0, 2], "raylib_cc": 0, "100": 0, "9": [0, 1], "31": 0, "x1": 0, "17": 0, "15": [0, 8], "raylib_node_raylib": 0, "90": 0, "raylib_koffi": 0, "12": [0, 2, 6], "86": 0, "18": [0, 8], "raylib_node_ffi": 0, "35": 0, "76": 0, "30": [0, 8], "228": 0, "67": 0, "05": 0, "14": [0, 1, 8], "23": 0, "63": 0, "27": [0, 3], "270": 0, "open": [0, 3, 8], "consol": [0, 3, 5, 8], "go": [0, 2], "cnoke": [0, 2], "befor": [0, 1, 2, 8], "do": [0, 2, 8], "anyth": 0, "els": [0, 8], "cd": [0, 2], "onc": [0, 2, 3, 5, 7, 8], "done": [0, 2, 3, 8], "you": [0, 2, 3, 4, 6, 7, 8], "can": [0, 1, 2, 3, 4, 5, 6, 7, 8], "each": [0, 2, 3, 8], "e": [0, 3, 8], "g": [0, 2, 3, 8], "build": [0, 1, 4, 6, 8], "option": [0, 2, 3, 4, 8], "defin": [0, 8], "custom": 0, "number": [0, 5, 8], "10000000": 0, "main": [1, 3], "fix": [1, 2, 4], "support": [1, 2, 3, 4, 8], "compil": [0, 1, 6], "mode": 1, "grace": 1, "degrad": 1, "older": [1, 6], "toolchain": 1, "linux": [1, 2, 4, 6], "debian": [1, 2], "prebuilt": [1, 2, 6], "binari": [1, 2, 6], "when": [1, 2, 3, 5, 8], "instal": [1, 2, 6, 7], "rebuild": 1, "happen": [1, 3, 5, 8], "fail": [1, 2, 3, 8], "load": [1, 3, 7, 8], "major": [1, 2], "chang": [1, 2, 3, 5, 8], "expand": 1, "move": 1, "document": [1, 8], "http": [1, 2, 4], "dev": [1, 2], "arrai": [1, 2, 4], "typedarrai": [1, 8], "pointer": [1, 3, 4], "argument": [1, 3, 8], "input": [1, 3, 8], "output": [1, 4, 7, 8], "mix": [1, 2, 8], "other": [1, 3, 8], "convert": [1, 3, 8], "null": [1, 3, 7, 8], "instead": [1, 2, 8], "crash": 1, "return": [1, 3, 8], "valu": [1, 3, 4, 7, 8], "struct": [1, 2, 4, 5, 7], "member": [1, 3, 8], "callback": [1, 4, 5, 6, 8], "default": [1, 2, 3, 4, 8], "hint": [1, 8], "char": [1, 3, 7, 8], "char16": [1, 8], "char16_t": [1, 8], "definit": [1, 4, 8], "long": [1, 8], "type": [1, 2, 3, 4, 7], "window": [1, 4, 6], "x64": 1, "llp64": [1, 8], "model": 1, "restrict": [1, 2], "automat": [1, 2, 3], "sign": [1, 8], "detect": 1, "float": [1, 3, 6, 8], "point": [1, 8], "abi": [1, 2, 6, 8], "arm32": [1, 6], "risc": [1, 6], "v": [1, 6], "forbid": 1, "duplic": 1, "name": [1, 2, 3, 8], "new": [1, 3, 5, 8], "featur": [1, 4], "arm64": [1, 2, 6], "now": [1, 2, 7, 8], "A": [1, 6, 8], "maco": [1, 2, 6], "m1": 1, "includ": [1, 2, 3, 6, 8], "entri": 1, "sinc": [1, 4], "cdecl": [1, 3, 6], "stdcall": [1, 3, 6, 7], "all": [1, 6, 8], "platform": [1, 3, 4, 5, 8], "64": [1, 3, 6, 8], "lp64d": [1, 6], "lp64": [1, 6, 8], "untest": [1, 6], "expos": [1, 8], "set": [1, 4], "memori": [1, 2, 3, 4, 8], "usag": [1, 4], "synchron": [1, 4, 5], "asynchron": [1, 4, 5], "transpar": [1, 8], "between": 1, "buffer": [1, 8], "tent": 1, "excess": 1, "stack": [1, 5], "align": [1, 8], "x86": [1, 3, 6, 7], "potenti": [1, 8], "problem": 1, "big": [1, 5, 8], "int64_t": [1, 7, 8], "uint64_t": [1, 8], "possibl": [1, 2, 8], "layout": 1, "error": [1, 3, 8], "push": [1, 8], "pop": 1, "issu": [1, 2, 3], "incomplet": 1, "buggi": 1, "hfa": [1, 2], "openbsd": [1, 6], "caus": [1, 3], "miss": [1, 2], "map_stack": 1, "flag": 1, "non": [1, 3, 8], "sens": 1, "intern": [1, 8], "fals": [1, 8], "normal": [1, 5, 8], "make": [1, 2], "sure": [1, 2], "we": [1, 2, 8], "have": [1, 2, 7, 8], "redzon": 1, "architectur": [1, 2, 3, 4, 6, 8], "slower": 1, "alloc": [1, 2, 5, 8], "object": [1, 2, 3, 5, 8], "repositori": 2, "luigi": 2, "monorepo": 2, "contain": [2, 8], "multipl": 2, "project": 2, "idea": 2, "github": 2, "com": 2, "koromix": 2, "program": [2, 3, 4], "assembl": [2, 5], "specif": [2, 5], "It": [2, 3, 7, 8], "addon": 2, "interact": 2, "person": 2, "prefer": 2, "goe": 2, "rather": 2, "like": [2, 7, 8], "care": 2, "templat": 2, "mainli": 2, "littl": 2, "orient": [2, 8], "i": [2, 8], "strongli": 2, "tag": 2, "union": 2, "over": 2, "inherit": 2, "virtual": 2, "method": 2, "except": [2, 3], "disabl": [1, 2], "provid": [2, 3, 8], "packag": [2, 6], "npm": [2, 6, 7], "archiv": 2, "so": [2, 3, 7, 8], "most": [2, 3, 8], "should": 2, "If": 2, "want": 2, "hack": 2, "follow": [2, 3, 6, 8], "instruct": [2, 3], "depend": [2, 3, 8], "met": 2, "desktop": 2, "develop": 2, "workload": 2, "visual": 2, "studio": 2, "2022": 2, "2019": 2, "tool": 2, "compon": 2, "cmake": 2, "meta": 2, "system": [2, 7], "later": [2, 4, 6], "command": 2, "benchmark": [2, 4], "directori": [2, 8], "what": 2, "gcc": 2, "8": [2, 3, 8], "newer": 2, "gnu": [2, 4], "emul": 2, "acceler": 2, "qemu": 2, "need": [2, 3, 8], "even": 2, "gui": 2, "ubuntu": 2, "directli": [2, 8], "licens": 2, "size": [2, 4, 5], "reason": [2, 8], "thei": [2, 3, 8], "avail": [2, 5], "file": [2, 3, 8], "For": [2, 3, 5, 6, 8], "exampl": [2, 4, 8], "wget": 2, "q": 2, "o": [2, 8], "qemu_debian_arm64": 2, "tar": 2, "zst": 2, "zstd": 2, "d": [2, 3, 8], "xv": 2, "sha256sum": 2, "ignor": [2, 3], "registri": 2, "txt": 2, "note": [2, 8], "disk": 2, "content": [2, 8], "mai": [2, 3], "checksum": 2, "been": 2, "least": [2, 5], "And": [2, 7], "sever": [2, 3], "help": 2, "patient": 2, "ccach": 2, "subsequ": [2, 5], "step": 2, "get": [2, 5, 7, 8], "more": [2, 3, 4, 5, 8], "toler": 2, "By": [2, 3, 8], "start": [2, 3, 4], "stop": 2, "But": [2, 8], "ahead": 2, "without": [2, 6], "shut": 2, "down": 2, "again": 2, "everyth": 2, "also": [2, 8], "subset": 2, "cycl": 2, "debian_x64": 2, "debian_i386": 2, "separ": 2, "shutdown": 2, "final": [2, 8], "join": 2, "ssh": 2, "shortcut": 2, "some": [2, 8], "debug": 2, "ani": [2, 4, 8], "manual": 2, "procedur": [2, 3], "configur": 2, "vnc": 2, "server": 2, "local": [2, 7], "access": 2, "displai": 2, "krdc": 2, "compat": 2, "viewer": 2, "info": 2, "port": 2, "after": [2, 3], "releas": 2, "0": [2, 3, 4, 8], "current": [2, 7, 8], "prioriti": 2, "next": [2, 8], "autom": 2, "aarch64": [2, 6], "how": [2, 3, 4, 8], "creat": [2, 3, 8], "real": 2, "world": [2, 3, 7, 8], "librari": [2, 3, 7, 8], "raylib": [2, 4], "sqlite": [2, 3], "libsodium": 2, "illustr": [2, 7, 8], "work": [2, 4], "variou": [1, 2], "plan": 2, "eventu": 2, "necessarili": 2, "order": [2, 3], "optim": [1, 2], "pass": [2, 3, 8], "helper": 2, "add": [2, 8], "parser": [2, 3], "wai": [2, 7, 8], "encod": [2, 8], "decod": 2, "byte": [2, 5, 8], "better": 2, "deal": [2, 3, 8], "caller": 2, "heap": [2, 5], "etc": [2, 3], "powerpc": 2, "power9": 2, "unwind": 2, "cfi": 2, "direct": [2, 8], "experi": 2, "To": 3, "declar": [3, 7, 8], "share": [3, 7, 8], "const": [3, 7, 8], "requir": [3, 6, 7, 8], "lib": [3, 7, 8], "path": [3, 8], "extens": 3, "dll": [3, 7, 8], "dylib": 3, "from": [3, 4, 6, 8], "two": [3, 5, 8], "inspir": 3, "specifi": [3, 8], "its": [3, 8], "mangl": 3, "ellipsi": 3, "last": [3, 8], "printf": [3, 7], "func": [3, 7, 8], "int": [3, 7, 8], "atoi": [3, 4], "tri": 3, "convent": [3, 6, 7], "see": [3, 4, 8], "section": [3, 8], "inform": [3, 4, 8], "subject": 3, "shown": 3, "fmt": 3, "onli": [3, 6, 8], "per": 3, "process": 3, "32": 3, "bit": 3, "form": 3, "descript": [3, 5], "__stdcall": [3, 8], "within": 3, "win32": [3, 7, 8], "fastcal": [3, 6], "__fastcal": 3, "rare": [3, 8], "ecx": 3, "edx": 3, "thiscal": [3, 6], "__thiscal": 3, "safe": 3, "simpli": [3, 8], "find": [3, 4, 7, 8], "show": [3, 7, 8], "user32": [3, 7], "equival": [3, 8], "messageboxa_1": 3, "messageboxa": [3, 7], "void": [1, 3, 7, 8], "uint": [3, 7, 8], "messageboxa_2": 3, "hwnd": 3, "text": 3, "caption": 3, "async": 3, "err": 3, "re": 3, "libc": [3, 7], "6": [3, 7, 8], "str": [3, 8], "1257": 3, "log": [3, 5, 8], "result": [3, 4, 7, 8], "hello": [3, 7, 8], "print": [3, 7, 8], "worker": 3, "your": [3, 4], "respons": 3, "data": [3, 4], "multi": 3, "easili": 3, "style": [3, 4], "promis": 3, "util": 3, "promisifi": 3, "cannot": [3, 8], "must": 3, "addit": [3, 8], "expect": [3, 6, 8], "doubl": [3, 6, 8], "THE": 3, "end": 3, "integ": [1, 3, 8], "s": [3, 8], "On": 3, "forward": [3, 6], "howev": [3, 8], "mani": [3, 8], "simplici": 3, "semant": [3, 8], "primit": [3, 4], "marshal": 3, "out": [3, 8], "timev": [3, 7], "where": [0, 3, 8], "inout": 3, "dual": 3, "same": [3, 5, 8], "msdn": 3, "qualifi": 3, "_out_": [3, 7, 8], "_inout_": [3, 8], "posix": 3, "gettimeofdai": [3, 7], "tv_sec": [3, 7], "unsign": [1, 3, 7, 8], "tv_usec": [3, 7], "timezon": [3, 7], "tz_minuteswest": [3, 7], "tz_dsttime": [3, 7], "tv": [3, 7], "tz": [3, 7], "let": [3, 5, 7, 8], "databas": 3, "sqlite3_db": 3, "copi": [3, 8], "sqlite3_open_v2": 3, "sqlite_open_readwrit": 3, "0x2": 3, "sqlite_open_cr": 3, "0x4": 3, "db": 3, "throw": [3, 8], "sqlite3_close_v2": 3, "With": 3, "noth": 3, "examplecallback": 3, "sum": [3, 8], "adddoublefloat": 3, "f": [3, 8], "them": [3, 8], "part": 3, "h": [3, 8], "transfertoj": 3, "ag": 3, "cb": 3, "buf": 3, "snprintf": 3, "sizeof": [3, 8], "transfercallback": 3, "ret": 3, "niel": 3, "42": [3, 8], "precis": [3, 6], "intepret": 3, "anoth": [3, 8], "undefin": 3, "behavior": [3, 8], "lead": 3, "mess": [3, 8], "fast": 4, "easi": 4, "low": 4, "aggreg": 4, "both": [4, 8], "well": 4, "popular": 4, "os": [4, 6, 8], "combin": [4, 6], "introspect": 4, "variad": [4, 7], "rand": 4, "run": [4, 7], "contribut": 4, "bug": 4, "request": 4, "sourc": [4, 6], "todo": 4, "list": [4, 8], "changelog": 4, "4": 8, "free": [4, 8], "softwar": 4, "redistribut": 4, "modifi": [4, 8], "under": 4, "term": 4, "affero": 4, "gener": [4, 8], "public": 4, "publish": 4, "foundat": 4, "either": [4, 8], "www": 4, "org": 4, "prealloc": 5, "block": 5, "One": 5, "construct": 5, "assign": [5, 8], "mib": 5, "unless": 5, "veri": 5, "page": 5, "extra": 5, "ever": 5, "dure": 5, "config": 5, "obj": 5, "appli": [5, 8], "true": [5, 8], "made": 5, "unus": 5, "resid": 5, "still": 5, "finish": 5, "freed": 5, "resident_async_pool": 5, "left": 5, "sync_stack_s": 5, "sync_heap_s": 5, "async_stack_s": 5, "512": 5, "kib": 5, "async_heap_s": 5, "pool": 5, "moment": 6, "isa": 6, "freebsd": 6, "ia32": 6, "ye": 6, "x86_64": 6, "amd64": 6, "le": [6, 8], "probabl": 6, "fulli": 6, "green": 6, "check": 6, "mark": 6, "mean": [6, 8], "earlier": 6, "nvm": 6, "recent": 6, "distribut": 6, "ms": 6, "hard": 6, "vfp": 6, "coprocessor": 6, "differ": [6, 8], "softfp": 6, "soft": 6, "theori": 6, "lp64f": 6, "prototyp": 7, "languag": 7, "syntax": 7, "time_t": 7, "tm": 7, "tm_sec": 7, "tm_min": 7, "tm_hour": 7, "tm_mdai": 7, "tm_mon": 7, "tm_year": 7, "tm_wdai": 7, "tm_ydai": 7, "tm_isdst": 7, "localtime_r": 7, "format": 7, "02d": 7, "target": 7, "messagebox": 7, "messag": 7, "user": [7, 8], "constant": 7, "mb_iconinform": 7, "0x40": 7, "foobar": 7, "while": 8, "allow": 8, "variat": 8, "enforc": 8, "signed": 8, "valid": 8, "int8": 8, "int8_t": 8, "uint8": 8, "uint8_t": 8, "uchar": 8, "int16": 8, "int16_t": 8, "uint16": 8, "uint16_t": 8, "short": 8, "int32": 8, "int32_t": 8, "uint32": 8, "uint32_t": 8, "int64": 8, "uint64": 8, "longlong": 8, "ulonglong": 8, "float32": 8, "float64": 8, "few": 8, "boolean": 8, "bool": 8, "usual": 8, "ulong": 8, "utf": 8, "string16": 8, "line": 8, "struct1": 8, "dummi": 8, "struct2": 8, "vice": 8, "versa": 8, "unlik": 8, "omit": 8, "anonym": 8, "typedef": 8, "b": 8, "d1": 8, "d2": 8, "rule": 8, "regard": 8, "pad": 8, "latter": 8, "function1": 8, "function2": 8, "differenti": 8, "purpos": 8, "import": 8, "distinguish": 8, "fall": 8, "avoid": 8, "expens": 8, "doe": 8, "sqlite3_stmt": 8, "someth": 8, "stabil": 8, "prevent": 8, "dynam": 8, "termin": 8, "length": 8, "lot": 8, "getcursorpo": 8, "retriev": 8, "cursor": 8, "posit": 8, "kernel32": 8, "x": 8, "y": 8, "po": 8, "kind": 8, "pair": 8, "dedic": 8, "delet": 8, "obviou": 8, "found": 8, "stdio": 8, "fopen": 8, "fclose": 8, "manipul": 8, "fread": 8, "ftell": 8, "manag": 8, "builder": 8, "concaten": 8, "fizzbuzz": 8, "hidden": 8, "behind": 8, "destroi": 8, "concatnew": 8, "concatnewout": 8, "concatfre": 8, "clang": 8, "fpic": 8, "wall": 8, "o2": 8, "stdlib": 8, "stdbool": 8, "errno": 8, "fragment": 8, "size_t": 8, "len": 8, "concat": 8, "malloc": 8, "fprintf": 8, "stderr": 8, "strerror": 8, "concatappend": 8, "frag": 8, "strlen": 8, "memcpi": 8, "concatbuild": 8, "r": 8, "stupid": 8, "try": 8, "failur": 8, "buzz": 8, "fizz": 8, "infer": 8, "itself": 8, "sentinel": 8, "translat": 8, "proper": 8, "notion": 8, "fat": 8, "yourself": 8, "calcul": 8, "stdint": 8, "computetotallength": 8, "ptr": 8, "14n": 8, "just": 8, "findfirstfilew": 8, "findnextfilew": 8, "filetim": 8, "dwlowdatetim": 8, "dwhighdatetim": 8, "win32_find_data": 8, "dwfileattribut": 8, "ftcreationtim": 8, "ftlastaccesstim": 8, "ftlastwritetim": 8, "nfilesizehigh": 8, "nfilesizelow": 8, "dwreserved0": 8, "dwreserved1": 8, "cfilenam": 8, "260": 8, "calternatefilenam": 8, "dwfiletyp": 8, "obsolet": 8, "dwcreatortyp": 8, "wfinderflag": 8, "ushort": 8, "findfirstfil": 8, "findnextfil": 8, "findclos": 8, "getlasterror": 8, "dirnam": 8, "filenam": 8, "error_file_not_found": 8, "error_no_more_fil": 8, "among": 8, "variabl": 8, "invol": 8, "list1": 8, "list2": 8, "thank": 8, "approxim": [0, 8], "singl": 8, "element": 8, "store": 8, "addint": 8, "dest": 8, "36": 8, "degener": 8, "emb": 8, "correct": 8, "uint8arrai": 8, "those": 8, "exactli": 8, "foo1": 8, "foo": 8, "a16": 8, "foo2": 8, "hypothet": 8, "returnfoo1": 8, "returnfoo": 8, "p": 8, "returnfoo2": 8, "int16arrai": 8, "fill": 8, "truncat": 8, "alwai": 8, "nul": 8, "revers": 8, "explicitli": 8, "ask": 8, "explor": 8, "alignof": 8, "pre": 0, "static": 0, "glue": 0, "clone": 2, "git": 2, "As": 2, "said": 2, "monorepositori": 2, "conta": 2, "henc": 2, "misconvers": 1, "empti": 1, "signatur": 1, "unsaf": 1, "improv": 1, "i386": 1}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"benchmark": 0, "rand": 0, "result": 0, "linux": [0, 7], "x86_64": 0, "window": [0, 2, 7], "atoi": 0, "raylib": 0, "run": [0, 2], "changelog": 1, "koffi": [1, 4], "1": [1, 4], "3": [1, 4], "2": 1, "0": 1, "4": [1, 4], "contribut": 2, "bug": 2, "featur": 2, "request": 2, "code": 2, "style": 2, "build": 2, "from": 2, "sourc": 2, "other": 2, "platform": [2, 6], "test": 2, "todo": 2, "list": 2, "function": 3, "call": 3, "definit": 3, "classic": 3, "syntax": 3, "c": [3, 8], "like": 3, "prototyp": 3, "synchron": 3, "asynchron": 3, "variad": 3, "output": 3, "paramet": 3, "struct": [3, 8], "exampl": [3, 7], "opaqu": [3, 8], "handl": [3, 8], "javascript": 3, "callback": 3, "us": 3, "thread": 3, "safeti": 3, "overview": 4, "tabl": 4, "content": 4, "licens": 4, "memori": 5, "usag": 5, "how": 5, "work": 5, "default": 5, "set": 5, "support": 6, "quick": 7, "start": 7, "small": 7, "data": 8, "type": 8, "primit": 8, "pointer": 8, "arrai": 8, "fix": 8, "size": 8, "string": 8, "introspect": 8}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}})
1
+ Search.setIndex({"docnames": ["benchmarks", "changes", "contribute", "functions", "index", "memory", "platforms", "start", "types"], "filenames": ["benchmarks.md", "changes.md", "contribute.md", "functions.md", "index.rst", "memory.md", "platforms.md", "start.md", "types.md"], "titles": ["Benchmarks", "Changelog", "Contributing", "Function calls", "Koffi 1.3.5", "Memory usage", "Supported platforms", "Quick start", "Data types"], "terms": {"here": [0, 2, 3, 4, 8], "quick": [0, 4], "overview": 0, "execut": [0, 3], "time": [0, 2, 5, 7], "koffi": [0, 2, 3, 5, 6, 7, 8], "call": [0, 1, 4, 5, 6, 7, 8], "three": [0, 7, 8], "where": [0, 3, 8], "compar": 0, "theoret": 0, "ideal": 0, "ffi": [0, 3, 4, 7], "implement": [0, 8], "approxim": [0, 8], "pre": 0, "compil": [0, 1, 6], "static": 0, "n": [0, 2, 6, 7, 8], "api": [0, 2, 3, 7, 8], "glue": 0, "code": [0, 1, 3, 4, 5], "The": [0, 1, 2, 3, 5, 6, 7, 8], "first": [0, 2, 3, 7, 8], "base": [0, 3, 4, 8], "second": [0, 3, 7, 8], "third": 0, "These": [0, 2, 3, 8], "ar": [0, 1, 2, 3, 5, 6, 7, 8], "detail": 0, "explain": 0, "below": [0, 1, 2, 3, 7, 8], "node": [0, 2, 3, 4, 6, 7], "napi": 0, "thi": [0, 1, 2, 3, 4, 7, 8], "test": [0, 1, 4, 6], "around": [0, 5, 8], "repeat": 0, "simpl": [0, 2, 3, 8], "standard": [0, 3, 8], "c": [0, 1, 2, 4, 5, 6, 7], "function": [0, 1, 2, 4, 7, 8], "ha": [0, 2, 3, 8], "one": [0, 3, 5, 7, 8], "refer": [0, 4, 8], "through": [0, 3, 8], "an": [0, 3, 5, 8], "modul": [0, 1, 4], "close": [0, 8], "limit": [0, 1], "perfect": 0, "overhead": [0, 4], "js": [0, 1, 2, 3, 4, 6, 8], "us": [0, 1, 2, 3, 4, 5, 6, 7, 8], "offici": [0, 2, 6], "becaus": [0, 2, 3, 8], "pretti": [0, 2], "small": [0, 3, 4], "clearli": 0, "visibl": 0, "were": 0, "measur": 0, "my": [0, 2], "machin": [0, 2], "amd": 0, "ryzen": 0, "7": 0, "4700u": 0, "iter": [0, 8], "total": [0, 8], "rel": 0, "perform": [0, 4], "rand_napi": 0, "20000000": 0, "1": [0, 2, 5, 6, 8], "44": 0, "baselin": 0, "rand_koffi": 0, "2": [0, 4, 5, 6, 8], "60": 0, "x0": 0, "55": 0, "81": [0, 2], "rand_node_ffi": 0, "107": 0, "58": 0, "01": 0, "7400": 0, "intel": 0, "core": 0, "i5": 0, "4460": 0, "10": 0, "3": [0, 2, 6, 8], "87": 0, "54": 0, "84": 0, "02": 0, "4100": 0, "similar": [0, 3], "which": [0, 2, 6, 7], "take": [0, 3, 8], "string": [0, 1, 2, 3, 5, 7], "paramet": [0, 4, 7, 8], "javascript": [0, 4, 8], "v8": [0, 3], "convers": [0, 1, 8], "slow": [0, 2], "heavi": 0, "atoi_napi": 0, "97": 0, "atoi_koffi": 0, "5": [0, 3, 8], "07": 0, "71": 0, "atoi_node_ffi": 0, "693": 0, "16": [0, 8], "005": 0, "23000": 0, "91": 0, "50": 0, "99": 0, "479": 0, "34": 0, "006": 0, "16000": 0, "cpu": 0, "imag": 0, "draw": 0, "much": [0, 2], "heavier": 0, "than": [0, 5], "thu": 0, "reduc": [0, 1], "In": [0, 3, 8], "full": [0, 2, 8], "version": [0, 1, 2, 3, 4, 6, 8], "nativ": [0, 3], "wrapper": [0, 2], "raylib_cc": 0, "100": 0, "9": [0, 1], "31": 0, "x1": 0, "17": 0, "15": [0, 8], "raylib_node_raylib": 0, "90": 0, "raylib_koffi": 0, "12": [0, 2, 6], "86": 0, "18": [0, 8], "raylib_node_ffi": 0, "35": 0, "76": 0, "30": [0, 8], "228": 0, "67": 0, "05": 0, "14": [0, 1, 8], "23": 0, "63": 0, "27": [0, 3], "270": 0, "open": [0, 3, 8], "consol": [0, 3, 5, 8], "go": [0, 2], "cnoke": [0, 2], "befor": [0, 1, 2, 8], "do": [0, 2, 3, 8], "anyth": 0, "els": [0, 8], "cd": [0, 2], "onc": [0, 2, 3, 5, 7, 8], "done": [0, 2, 3, 8], "you": [0, 2, 3, 4, 6, 7, 8], "can": [0, 1, 2, 3, 4, 5, 6, 7, 8], "each": [0, 2, 3, 8], "e": [0, 3, 8], "g": [0, 2, 3, 8], "build": [0, 1, 4, 6, 8], "option": [0, 2, 3, 4, 8], "defin": [0, 8], "custom": 0, "number": [0, 1, 5, 8], "10000000": 0, "main": [1, 3], "fix": [1, 2, 4], "possibl": [1, 2, 8], "openbsd": [1, 6], "i386": 1, "crash": [1, 3], "void": [1, 3, 7, 8], "misconvers": 1, "sign": [1, 8], "integ": [1, 3, 8], "return": [1, 3, 8], "valu": [1, 3, 4, 7, 8], "unsign": [1, 3, 7, 8], "other": [1, 3, 8], "chang": [1, 2, 3, 5, 8], "support": [1, 2, 3, 4, 8], "empti": 1, "signatur": 1, "disabl": [1, 2], "unsaf": 1, "optim": [1, 2], "variou": [1, 2], "document": [1, 8], "improv": 1, "mode": 1, "grace": 1, "degrad": 1, "older": [1, 6], "toolchain": 1, "linux": [1, 2, 4, 6], "debian": [1, 2], "prebuilt": [1, 2, 6], "binari": [1, 2, 6], "when": [1, 2, 3, 5, 8], "instal": [1, 2, 6, 7], "rebuild": 1, "happen": [1, 3, 5, 8], "fail": [1, 2, 3, 8], "load": [1, 3, 7, 8], "major": [1, 2], "expand": 1, "move": 1, "http": [1, 2, 4], "dev": [1, 2], "arrai": [1, 2, 4], "typedarrai": [1, 8], "pointer": [1, 3, 4], "argument": [1, 3, 8], "input": [1, 3, 8], "output": [1, 4, 7, 8], "mix": [1, 2, 8], "convert": [1, 3, 8], "null": [1, 3, 7, 8], "instead": [1, 2, 8], "struct": [1, 2, 4, 5, 7], "member": [1, 3, 8], "callback": [1, 4, 5, 6, 8], "default": [1, 2, 3, 4, 8], "hint": [1, 8], "char": [1, 3, 7, 8], "char16": [1, 8], "char16_t": [1, 8], "definit": [1, 4, 8], "long": [1, 8], "type": [1, 2, 3, 4, 7], "window": [1, 4, 6], "x64": 1, "llp64": [1, 8], "model": 1, "restrict": [1, 2], "automat": [1, 2, 3, 8], "detect": 1, "float": [1, 3, 6, 8], "point": [1, 8], "abi": [1, 2, 6, 8], "arm32": [1, 6], "risc": [1, 6], "v": [1, 6], "forbid": 1, "duplic": 1, "name": [1, 2, 3, 8], "new": [1, 3, 5, 8], "featur": [1, 4], "arm64": [1, 2, 6], "now": [1, 2, 7, 8], "A": [1, 6, 8], "maco": [1, 2, 6], "m1": 1, "includ": [1, 2, 3, 6, 8], "entri": 1, "sinc": [1, 4], "cdecl": [1, 3, 6], "stdcall": [1, 3, 6, 7], "all": [1, 6, 8], "platform": [1, 3, 4, 5, 8], "64": [1, 3, 5, 6, 8], "lp64d": [1, 6], "lp64": [1, 6, 8], "untest": [1, 6], "expos": [1, 8], "set": [1, 4], "memori": [1, 2, 3, 4, 8], "usag": [1, 4], "synchron": [1, 4, 5], "asynchron": [1, 4, 5], "transpar": [1, 8], "between": [1, 3], "buffer": [1, 8], "tent": 1, "excess": 1, "stack": [1, 5], "align": [1, 8], "x86": [1, 3, 6, 7], "potenti": [1, 8], "problem": 1, "big": [1, 3, 5, 8], "int64_t": [1, 7, 8], "uint64_t": [1, 8], "layout": 1, "error": [1, 3, 8], "push": [1, 8], "pop": 1, "issu": [1, 2, 3], "incomplet": 1, "buggi": 1, "hfa": [1, 2], "caus": [1, 3], "miss": [1, 2], "map_stack": 1, "flag": 1, "non": [1, 3, 8], "sens": 1, "intern": [1, 8], "fals": [1, 8], "normal": [1, 5, 8], "make": [1, 2], "sure": [1, 2], "we": [1, 2, 8], "have": [1, 2, 7, 8], "redzon": 1, "architectur": [1, 2, 3, 4, 6, 8], "slower": 1, "alloc": [1, 2, 5, 8], "object": [1, 2, 3, 5, 8], "repositori": 2, "luigi": 2, "monorepo": 2, "contain": [2, 8], "multipl": 2, "project": 2, "idea": 2, "github": 2, "com": 2, "koromix": 2, "provid": [2, 3, 8], "packag": [2, 6], "npm": [2, 6, 7], "archiv": 2, "so": [2, 3, 7, 8], "most": [2, 3, 8], "case": [2, 3, 8], "should": 2, "If": [2, 3, 8], "want": 2, "hack": 2, "specif": [2, 5], "follow": [2, 3, 6, 8], "instruct": [2, 3], "start": [2, 3, 4], "clone": 2, "git": 2, "As": 2, "said": 2, "monorepositori": 2, "conta": 2, "henc": 2, "depend": [2, 3, 8], "met": 2, "desktop": 2, "develop": 2, "workload": 2, "visual": 2, "studio": 2, "2022": 2, "2019": 2, "tool": 2, "compon": 2, "cmake": 2, "meta": 2, "system": [2, 7], "later": [2, 4, 6], "command": 2, "benchmark": [2, 4], "directori": [2, 8], "what": 2, "gcc": 2, "8": [2, 3, 8], "newer": 2, "gnu": [2, 4], "emul": 2, "acceler": 2, "qemu": 2, "need": [2, 3, 8], "even": 2, "gui": 2, "ubuntu": 2, "directli": [2, 8], "licens": 2, "size": [1, 2, 4, 5], "reason": [2, 8], "thei": [2, 3, 8], "avail": [2, 5], "file": [2, 3, 8], "For": [2, 3, 5, 6, 8], "exampl": [2, 4, 8], "wget": 2, "q": 2, "o": [2, 8], "qemu_debian_arm64": 2, "tar": 2, "zst": 2, "zstd": 2, "d": [2, 3, 8], "xv": 2, "sha256sum": 2, "ignor": [2, 3], "registri": 2, "txt": 2, "note": [2, 8], "disk": 2, "content": [2, 8], "mai": [2, 3], "checksum": 2, "been": [2, 3], "least": [2, 5], "And": [2, 7], "sever": [2, 3], "help": 2, "patient": 2, "ccach": 2, "subsequ": [2, 5], "step": 2, "get": [2, 5, 7, 8], "more": [2, 3, 4, 5, 8], "toler": 2, "By": [2, 3, 8], "stop": 2, "But": [2, 8], "ahead": 2, "without": [2, 6], "shut": 2, "down": 2, "again": 2, "everyth": 2, "also": [2, 8], "subset": 2, "cycl": 2, "debian_x64": 2, "debian_i386": 2, "separ": 2, "shutdown": 2, "final": [2, 8], "join": 2, "ssh": 2, "shortcut": 2, "some": [2, 8], "debug": 2, "ani": [2, 4, 8], "manual": 2, "procedur": [2, 3], "configur": [1, 2], "vnc": 2, "server": 2, "local": [2, 7], "access": 2, "displai": 2, "krdc": 2, "compat": 2, "viewer": 2, "info": 2, "port": 2, "after": [2, 3], "releas": 2, "0": [2, 3, 4, 8], "current": [2, 7, 8], "prioriti": 2, "next": [2, 8], "autom": 2, "aarch64": [2, 6], "how": [2, 3, 4, 8], "creat": [2, 3, 8], "real": 2, "world": [2, 3, 7, 8], "librari": [2, 3, 7, 8], "raylib": [2, 4], "sqlite": [2, 3], "libsodium": 2, "illustr": [2, 7, 8], "work": [2, 4], "plan": 2, "eventu": 2, "necessarili": 2, "order": [2, 3], "pass": [2, 3, 8], "helper": 2, "add": [1, 2, 8], "parser": [2, 3], "wai": [2, 7, 8], "encod": [2, 8], "decod": 2, "byte": [2, 5, 8], "union": 2, "better": 2, "deal": [2, 3, 8], "caller": 2, "heap": [1, 2, 5], "etc": [2, 3], "powerpc": 2, "power9": 2, "assembl": [2, 5], "unwind": 2, "cfi": 2, "direct": [2, 8], "experi": 2, "program": [2, 3, 4], "It": [2, 3, 7, 8], "addon": 2, "interact": 2, "person": 2, "prefer": [2, 3], "goe": 2, "rather": 2, "like": [2, 7, 8], "care": 2, "templat": 2, "mainli": 2, "littl": 2, "orient": [2, 8], "i": [2, 8], "strongli": 2, "tag": 2, "over": 2, "inherit": 2, "virtual": 2, "method": 2, "except": [2, 3], "To": 3, "declar": [3, 7, 8], "share": [3, 7, 8], "const": [3, 7, 8], "requir": [3, 6, 7, 8], "lib": [3, 7, 8], "path": [3, 8], "extens": 3, "dll": [3, 7, 8], "dylib": 3, "from": [3, 4, 6, 8], "two": [3, 5, 8], "inspir": 3, "specifi": [3, 8], "its": [3, 8], "mangl": 3, "ellipsi": 3, "last": [3, 8], "printf": [3, 7], "func": [3, 7, 8], "int": [3, 7, 8], "atoi": [3, 4], "tri": 3, "convent": [3, 6, 7], "see": [3, 4, 8], "section": [3, 8], "inform": [3, 4, 8], "subject": 3, "shown": 3, "fmt": 3, "onli": [3, 6, 8], "per": 3, "process": 3, "32": 3, "bit": [3, 8], "form": 3, "descript": [3, 5], "__stdcall": [3, 8], "within": 3, "win32": [3, 7, 8], "fastcal": [3, 6], "__fastcal": 3, "rare": [3, 8], "ecx": 3, "edx": 3, "thiscal": [3, 6], "__thiscal": 3, "safe": 3, "simpli": [3, 8], "find": [3, 4, 7, 8], "show": [3, 7, 8], "user32": [3, 7], "equival": [3, 8], "messageboxa_1": 3, "messageboxa": [3, 7], "uint": [3, 7, 8], "messageboxa_2": 3, "hwnd": 3, "text": 3, "caption": 3, "async": [1, 3], "err": 3, "re": 3, "libc": [3, 7], "6": [3, 7, 8], "str": [3, 8], "1257": 3, "log": [3, 5, 8], "result": [3, 4, 7, 8], "hello": [3, 7, 8], "print": [3, 7, 8], "worker": 3, "your": [3, 4], "respons": 3, "data": [3, 4], "multi": 3, "easili": 3, "style": [3, 4], "promis": 3, "util": 3, "promisifi": 3, "cannot": [3, 5, 8], "must": 3, "addit": [3, 8], "expect": [3, 6, 8], "doubl": [3, 6, 8], "THE": 3, "end": 3, "s": [3, 8], "On": 3, "forward": [3, 6], "howev": [3, 8], "mani": [1, 3, 8], "simplici": [], "semant": [3, 8], "primit": [3, 4], "marshal": 3, "out": [3, 8], "timev": [3, 7], "inout": 3, "dual": 3, "same": [3, 5, 8], "msdn": 3, "qualifi": 3, "_out_": [3, 7, 8], "_inout_": [3, 8], "posix": 3, "gettimeofdai": [3, 7], "tv_sec": [3, 7], "tv_usec": [3, 7], "timezon": [3, 7], "tz_minuteswest": [3, 7], "tz_dsttime": [3, 7], "tv": [3, 7], "tz": [3, 7], "let": [3, 5, 7, 8], "databas": 3, "sqlite3_db": 3, "copi": [3, 8], "sqlite3_open_v2": 3, "sqlite_open_readwrit": 3, "0x2": 3, "sqlite_open_cr": 3, "0x4": 3, "db": 3, "throw": [3, 8], "sqlite3_close_v2": 3, "With": 3, "noth": 3, "examplecallback": 3, "sum": [3, 8], "adddoublefloat": 3, "f": [3, 8], "them": 8, "part": 3, "h": [3, 8], "transfertoj": 3, "ag": 3, "cb": 3, "buf": 3, "snprintf": 3, "sizeof": [3, 8], "transfercallback": 3, "ret": 3, "niel": 3, "42": [3, 8], "run": [1, 3, 4, 5, 7], "precis": [3, 6], "intepret": 3, "anoth": [3, 8], "undefin": [3, 8], "behavior": [3, 8], "lead": 3, "mess": [3, 8], "fast": 4, "easi": 4, "low": 4, "aggreg": 4, "both": [4, 8], "well": 4, "popular": 4, "os": [4, 6, 8], "combin": [4, 6], "introspect": 4, "variad": [4, 7], "thread": 4, "safeti": 4, "rand": 4, "contribut": 4, "bug": 4, "request": 4, "sourc": [4, 6], "todo": 4, "list": [4, 8], "changelog": 4, "free": [4, 8], "softwar": 4, "redistribut": 4, "modifi": [4, 8], "under": 4, "term": 4, "affero": 4, "gener": [4, 8], "public": 4, "publish": 4, "foundat": 4, "either": [4, 8], "www": 4, "org": 4, "prealloc": 5, "block": 5, "One": 5, "construct": 5, "assign": [5, 8], "mib": 5, "unless": 5, "veri": 5, "page": 5, "extra": 5, "ever": 5, "dure": 5, "config": 5, "obj": 5, "appli": [5, 8], "true": [5, 8], "made": 5, "unus": 5, "resid": 5, "still": 5, "finish": 5, "freed": 5, "resident_async_pool": 5, "left": 5, "sync_stack_s": 5, "sync_heap_s": 5, "async_stack_s": 5, "512": 5, "kib": 5, "async_heap_s": 5, "pool": 5, "moment": 6, "isa": 6, "freebsd": 6, "ia32": 6, "ye": 6, "x86_64": 6, "amd64": 6, "le": [6, 8], "probabl": 6, "fulli": 6, "green": 6, "check": 6, "mark": 6, "mean": [6, 8], "earlier": 6, "nvm": 6, "recent": 6, "distribut": 6, "ms": 6, "hard": 6, "vfp": 6, "coprocessor": 6, "differ": [6, 8], "softfp": 6, "soft": 6, "theori": 6, "lp64f": 6, "prototyp": 7, "languag": 7, "syntax": 7, "time_t": 7, "tm": 7, "tm_sec": 7, "tm_min": 7, "tm_hour": 7, "tm_mdai": 7, "tm_mon": 7, "tm_year": 7, "tm_wdai": 7, "tm_ydai": 7, "tm_isdst": 7, "localtime_r": 7, "format": 7, "02d": 7, "target": 7, "messagebox": 7, "messag": 7, "user": [7, 8], "constant": 7, "mb_iconinform": 7, "0x40": 7, "foobar": [], "while": 8, "allow": 8, "variat": 8, "enforc": 8, "signed": 8, "valid": 8, "int8": 8, "int8_t": 8, "uint8": 8, "uint8_t": 8, "uchar": 8, "int16": 8, "int16_t": 8, "uint16": 8, "uint16_t": 8, "short": 8, "int32": 8, "4": [4, 8], "int32_t": 8, "uint32": 8, "uint32_t": 8, "int64": 8, "uint64": 8, "longlong": 8, "ulonglong": 8, "float32": 8, "float64": 8, "accept": 8, "bigint": 8, "exce": 8, "rang": 8, "revers": 8, "few": 8, "boolean": 8, "bool": 8, "usual": 8, "ulong": 8, "utf": 8, "string16": 8, "line": 8, "struct1": 8, "dummi": 8, "struct2": 8, "vice": 8, "versa": 8, "unlik": 8, "omit": 8, "anonym": 8, "typedef": 8, "b": 8, "d1": 8, "d2": 8, "rule": 8, "regard": 8, "pad": 8, "latter": 8, "function1": 8, "function2": 8, "differenti": 8, "purpos": 8, "import": 8, "distinguish": 8, "fall": 8, "avoid": 8, "expens": 8, "doe": 8, "sqlite3_stmt": [], "someth": 8, "stabil": 8, "prevent": 8, "dynam": 8, "termin": 8, "length": 8, "lot": 8, "getcursorpo": 8, "retriev": 8, "cursor": 8, "posit": 8, "kernel32": 8, "x": 8, "y": 8, "po": 8, "kind": 8, "pair": 8, "dedic": 8, "delet": 8, "obviou": 8, "found": 8, "stdio": 8, "fopen": 8, "fclose": 8, "manipul": 8, "fread": 8, "ftell": 8, "manag": 8, "builder": 8, "concaten": 8, "fizzbuzz": 8, "hidden": 8, "behind": 8, "destroi": 8, "concatnew": 8, "concatnewout": 8, "concatfre": 8, "clang": 8, "fpic": 8, "wall": 8, "o2": 8, "stdlib": 8, "stdbool": 8, "errno": 8, "fragment": 8, "size_t": 8, "len": 8, "concat": 8, "malloc": 8, "fprintf": 8, "stderr": 8, "strerror": 8, "concatappend": 8, "frag": 8, "strlen": 8, "memcpi": 8, "concatbuild": 8, "r": 8, "stupid": 8, "try": 8, "failur": 8, "buzz": 8, "fizz": 8, "infer": 8, "itself": 8, "sentinel": 8, "translat": 8, "proper": 8, "notion": 8, "fat": 8, "yourself": 8, "calcul": 8, "stdint": 8, "computetotallength": 8, "ptr": 8, "14n": [], "just": 8, "findfirstfilew": 8, "findnextfilew": 8, "filetim": 8, "dwlowdatetim": 8, "dwhighdatetim": 8, "win32_find_data": 8, "dwfileattribut": 8, "ftcreationtim": 8, "ftlastaccesstim": 8, "ftlastwritetim": 8, "nfilesizehigh": 8, "nfilesizelow": 8, "dwreserved0": 8, "dwreserved1": 8, "cfilenam": 8, "260": 8, "calternatefilenam": 8, "dwfiletyp": 8, "obsolet": 8, "dwcreatortyp": 8, "wfinderflag": 8, "ushort": 8, "findfirstfil": 8, "findnextfil": 8, "findclos": 8, "getlasterror": 8, "dirnam": 8, "filenam": [3, 8], "error_file_not_found": 8, "error_no_more_fil": 8, "among": 8, "variabl": 8, "invol": 8, "list1": 8, "list2": 8, "thank": 8, "singl": 8, "element": 8, "store": 8, "addint": 8, "dest": 8, "36": 8, "degener": 8, "emb": 8, "correct": 8, "uint8arrai": 8, "those": 8, "exactli": 8, "foo1": 8, "foo": 8, "a16": 8, "foo2": 8, "hypothet": 8, "returnfoo1": 8, "returnfoo": 8, "p": 8, "returnfoo2": 8, "int16arrai": 8, "fill": 8, "truncat": 8, "alwai": 8, "nul": 8, "explicitli": 8, "ask": 8, "explor": 8, "alignof": 8, "simplic": 3, "ve": 3, "warn": 3, "regist": 5, "There": 5, "max_async_cal": [1, 5], "maximum": [1, 5], "ongo": 5, "256": 5, "leak": 1}, "objects": {}, "objtypes": {}, "objnames": {}, "titleterms": {"benchmark": 0, "rand": 0, "result": 0, "linux": [0, 7], "x86_64": 0, "window": [0, 2, 7], "atoi": 0, "raylib": 0, "run": [0, 2], "changelog": 1, "koffi": [1, 4], "1": [1, 4], "3": [1, 4], "4": 1, "2": 1, "0": 1, "contribut": 2, "bug": 2, "featur": 2, "request": 2, "build": 2, "from": 2, "sourc": 2, "other": 2, "platform": [2, 6], "test": 2, "todo": 2, "list": 2, "code": 2, "style": 2, "function": 3, "call": 3, "definit": 3, "classic": 3, "syntax": 3, "c": [3, 8], "like": 3, "prototyp": 3, "synchron": 3, "asynchron": 3, "variad": 3, "output": 3, "paramet": 3, "struct": [3, 8], "exampl": [3, 7], "opaqu": [3, 8], "handl": [3, 8], "javascript": 3, "callback": 3, "thread": 3, "safeti": 3, "overview": 4, "tabl": 4, "content": 4, "licens": 4, "memori": 5, "usag": 5, "how": 5, "work": 5, "default": 5, "set": 5, "support": 6, "quick": 7, "start": 7, "small": 7, "data": 8, "type": 8, "primit": 8, "pointer": 8, "arrai": 8, "fix": 8, "size": 8, "string": 8, "introspect": 8, "5": [1, 4]}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}})
@@ -220,7 +220,7 @@
220
220
  </ul>
221
221
  <section id="small-linux-example">
222
222
  <h2>Small Linux example<a class="headerlink" href="#small-linux-example" title="Permalink to this heading">#</a></h2>
223
- <p>This is a small example for Linux systems, which uses <code class="docutils literal notranslate"><span class="pre">gettimeofday()</span></code> and <code class="docutils literal notranslate"><span class="pre">printf()</span></code> to print the current time and the timezone.</p>
223
+ <p>This is a small example for Linux systems, which uses <code class="docutils literal notranslate"><span class="pre">gettimeofday()</span></code>, <code class="docutils literal notranslate"><span class="pre">localtime_r()</span></code> and <code class="docutils literal notranslate"><span class="pre">printf()</span></code> to print the current time.</p>
224
224
  <p>It illustrates the use of output parameters.</p>
225
225
  <div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span><span class="kd">const</span><span class="w"> </span><span class="nx">koffi</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;koffi&#39;</span><span class="p">);</span><span class="w"></span>
226
226
  <span class="linenos"> 2</span>
@@ -268,7 +268,7 @@
268
268
  </section>
269
269
  <section id="small-windows-example">
270
270
  <h2>Small Windows example<a class="headerlink" href="#small-windows-example" title="Permalink to this heading">#</a></h2>
271
- <p>This is a small example targeting the Win32 API, using <code class="docutils literal notranslate"><span class="pre">MessageBox()</span></code> to show a Hello message to the user.</p>
271
+ <p>This is a small example targeting the Win32 API, using <code class="docutils literal notranslate"><span class="pre">MessageBox()</span></code> to show a <em>Hello World!</em> message to the user.</p>
272
272
  <p>It illustrates the use of the x86 stdcall calling convention.</p>
273
273
  <div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span><span class="kd">const</span><span class="w"> </span><span class="nx">koffi</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;koffi&#39;</span><span class="p">);</span><span class="w"></span>
274
274
  <span class="linenos"> 2</span>
@@ -281,7 +281,7 @@
281
281
  <span class="linenos"> 9</span><span class="c1">// Find functions</span><span class="w"></span>
282
282
  <span class="linenos">10</span><span class="kd">const</span><span class="w"> </span><span class="nx">MessageBoxA</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">lib</span><span class="p">.</span><span class="nx">stdcall</span><span class="p">(</span><span class="s1">&#39;MessageBoxA&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;int&#39;</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="s1">&#39;void *&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;string&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;string&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;uint&#39;</span><span class="p">]);</span><span class="w"></span>
283
283
  <span class="linenos">11</span>
284
- <span class="linenos">12</span><span class="nx">MessageBoxA</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Hello&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Foobar&#39;</span><span class="p">,</span><span class="w"> </span><span class="nx">MB_ICONINFORMATION</span><span class="p">);</span><span class="w"></span>
284
+ <span class="linenos">12</span><span class="nx">MessageBoxA</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Hello World!&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Koffi&#39;</span><span class="p">,</span><span class="w"> </span><span class="nx">MB_ICONINFORMATION</span><span class="p">);</span><span class="w"></span>
285
285
  </pre></div>
286
286
  </div>
287
287
  </section>
@@ -432,6 +432,7 @@
432
432
  </tbody>
433
433
  </table>
434
434
  </div>
435
+ <p>Koffi also accepts BigInt values when converting from JS to C integers. If the value exceeds the range of the C type, Koffi will convert the number to an undefined value. In the reverse direction, BigInt values are automatically used when needed for big 64-bit integers.</p>
435
436
  <p>Koffi defines a few more types that can change size depending on the OS and the architecture:</p>
436
437
  <div class="table-wrapper colwidths-auto docutils container">
437
438
  <table class="docutils align-default">
@@ -511,7 +512,7 @@
511
512
  </pre></div>
512
513
  </div>
513
514
  <p>Koffi follows the C and ABI rules regarding struct alignment and padding.</p>
514
- <p>Once a struct is declared, you can use it by name (with a string, like you can do for primitive types) or the through the value returned by the call to <code class="docutils literal notranslate"><span class="pre">koffi.struct()</span></code>. Only the latter is possible when declaring an anonymous struct.</p>
515
+ <p>Once a struct is declared, you can use it by name (with a string, like you can do for primitive types) or through the value returned by the call to <code class="docutils literal notranslate"><span class="pre">koffi.struct()</span></code>. Only the latter is possible when declaring an anonymous struct.</p>
515
516
  <div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="c1">// The following two function declarations are equivalent, and declare a function taking an A value and returning A</span><span class="w"></span>
516
517
  <span class="linenos">2</span><span class="kd">const</span><span class="w"> </span><span class="nx">Function1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">lib</span><span class="p">.</span><span class="nx">func</span><span class="p">(</span><span class="s1">&#39;A Function(A value)&#39;</span><span class="p">);</span><span class="w"></span>
517
518
  <span class="linenos">3</span><span class="kd">const</span><span class="w"> </span><span class="nx">Function2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">lib</span><span class="p">.</span><span class="nx">func</span><span class="p">(</span><span class="s1">&#39;Function&#39;</span><span class="p">,</span><span class="w"> </span><span class="nx">A</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="nx">A</span><span class="p">]);</span><span class="w"></span>
@@ -522,9 +523,9 @@
522
523
  <h2>Pointer types<a class="headerlink" href="#pointer-types" title="Permalink to this heading">#</a></h2>
523
524
  <p>In C, pointer arguments are used for differenty purposes. It is important to distinguish these use cases because Koffi provides different ways to deal with each of them:</p>
524
525
  <ul class="simple">
525
- <li><p><strong>Struct pointers</strong>: Use of struct pointers by C libraries fall in two cases: avoid (potentially) expensive copies, and to let the function change struct contents (output or input/output argument).</p></li>
526
- <li><p><strong>Opaque handles</strong>: the library does not expose the contents of the structs, and only provides you with a pointer to it (e.g. <code class="docutils literal notranslate"><span class="pre">sqlite3_stmt</span></code>). Only the functions provided by the library can do something with this pointer, in Koffi we call this a handle. This is usually done for ABI-stability reason, and to prevent library users from messing directly with library internals.</p></li>
527
- <li><p><strong>Arrays</strong>: in C, you dynamically-sized arrays are usually passed to functions with pointers, either NULL-terminated or with an additional length argument.</p></li>
526
+ <li><p><strong>Struct pointers</strong>: Use of struct pointers by C libraries fall in two cases: avoid (potentially) expensive copies, and to let the function change struct contents (output or input/output arguments).</p></li>
527
+ <li><p><strong>Opaque handles</strong>: the library does not expose the contents of the structs, and only provides you with a pointer to it (e.g. <code class="docutils literal notranslate"><span class="pre">FILE</span> <span class="pre">*</span></code>). Only the functions provided by the library can do something with this pointer, in Koffi we call this a handle. This is usually done for ABI-stability reason, and to prevent library users from messing directly with library internals.</p></li>
528
+ <li><p><strong>Arrays</strong>: in C, you dynamically-sized arrays are usually passed to functions with pointers, either NULL-terminated (or any other sentinel value) or with an additional length argument.</p></li>
528
529
  <li><p><strong>Pointers to primitive types</strong>: This is more rare, and generally used for output or input/output arguments. The Win32 API has a lot of these.</p></li>
529
530
  </ul>
530
531
  <section id="struct-pointers">
@@ -756,7 +757,7 @@
756
757
  <span class="linenos">6</span><span class="kd">let</span><span class="w"> </span><span class="nx">strings</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="s1">&#39;Get&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Total&#39;</span><span class="p">,</span><span class="w"> </span><span class="s1">&#39;Length&#39;</span><span class="p">,</span><span class="w"> </span><span class="kc">null</span><span class="p">];</span><span class="w"></span>
757
758
  <span class="linenos">7</span><span class="kd">let</span><span class="w"> </span><span class="nx">total</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">ComputeTotalLength</span><span class="p">(</span><span class="nx">strings</span><span class="p">);</span><span class="w"></span>
758
759
  <span class="linenos">8</span>
759
- <span class="linenos">9</span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">total</span><span class="p">);</span><span class="w"> </span><span class="c1">// Prints 14n (big int)</span><span class="w"></span>
760
+ <span class="linenos">9</span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">total</span><span class="p">);</span><span class="w"> </span><span class="c1">// Prints 14</span><span class="w"></span>
760
761
  </pre></div>
761
762
  </div>
762
763
  <p>By default, just like for objects, array arguments are copied from JS to C but not vice-versa. You can however change the direction as documented in the section on <a class="reference internal" href="functions#output-parameters"><span class="std std-doc">output parameters</span></a>.</p>
@@ -825,7 +826,7 @@
825
826
  <section id="pointers-to-primitive-types">
826
827
  <h3>Pointers to primitive types<a class="headerlink" href="#pointers-to-primitive-types" title="Permalink to this heading">#</a></h3>
827
828
  <p>In javascript, it is not possible to pass a primitive value by reference to another function. This means that you cannot call a function and expect it to modify the value of one of its number or string parameter.</p>
828
- <p>However, arrays and objects (among others) are reference type values. Assigning an array or an object from one variable to another does not invole any copy. Instead, as the following example illustrates, the new variable references the same list as the first:</p>
829
+ <p>However, arrays and objects (among others) are reference type values. Assigning an array or an object from one variable to another does not invole any copy. Instead, as the following example illustrates, the new variable references the same array as the first:</p>
829
830
  <div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kd">let</span><span class="w"> </span><span class="nx">list1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">1</span><span class="p">,</span><span class="w"> </span><span class="mf">2</span><span class="p">];</span><span class="w"></span>
830
831
  <span class="linenos">2</span><span class="kd">let</span><span class="w"> </span><span class="nx">list2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">list1</span><span class="p">;</span><span class="w"></span>
831
832
  <span class="linenos">3</span>
@@ -835,14 +836,14 @@
835
836
  </pre></div>
836
837
  </div>
837
838
  <p>All of this means that C functions that are expected to modify their primitive output values (such as an <code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">*</span></code> parameter) cannot be used directly. However, thanks to Koffi’s transparent array support, you can use Javascript arrays to approximate reference semantics with single-element arrays.</p>
838
- <p>Below, you can find an example of an addition function where the result is stored in an <code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">*</span></code> output parameter and how to use this function from Koffi.</p>
839
+ <p>Below, you can find an example of an addition function where the result is stored in an <code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">*</span></code> input/output parameter and how to use this function from Koffi.</p>
839
840
  <div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kt">void</span><span class="w"> </span><span class="nf">AddInt</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">dest</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">add</span><span class="p">)</span><span class="w"></span>
840
841
  <span class="linenos">2</span><span class="p">{</span><span class="w"></span>
841
842
  <span class="linenos">3</span><span class="w"> </span><span class="o">*</span><span class="n">dest</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="n">add</span><span class="p">;</span><span class="w"></span>
842
843
  <span class="linenos">4</span><span class="p">}</span><span class="w"></span>
843
844
  </pre></div>
844
845
  </div>
845
- <p>You can simply pass a single-element array as the third argument:</p>
846
+ <p>You can simply pass a single-element array as the first argument:</p>
846
847
  <div class="highlight-js notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="kd">const</span><span class="w"> </span><span class="nx">AddInt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nx">lib</span><span class="p">.</span><span class="nx">func</span><span class="p">(</span><span class="s1">&#39;void AddInt(_Inout_ int *dest, int add)&#39;</span><span class="p">);</span><span class="w"></span>
847
848
  <span class="linenos">2</span>
848
849
  <span class="linenos">3</span><span class="kd">let</span><span class="w"> </span><span class="nx">sum</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">[</span><span class="mf">36</span><span class="p">];</span><span class="w"></span>
package/doc/functions.md CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  ## Function definitions
4
4
 
5
- To declare functions, start by loading the shared library with `koffi.load()`.
5
+ To declare functions, start by loading the shared library with `koffi.load(filename)`.
6
6
 
7
7
  ```js
8
8
  const koffi = require('koffi');
9
9
  const lib = koffi.load('/path/to/shared/library'); // File extension depends on platforms: .so, .dll, .dylib, etc.
10
10
  ```
11
11
 
12
- You can use the returned object to load C functions from the library. Koffi supports two syntaxes:
12
+ You can use the returned object to load C functions from the library. To do so, you can use two syntaxes:
13
13
 
14
- - Classic syntax, inspired by node-ffi
14
+ - The classic syntax, inspired by node-ffi
15
15
  - C-like prototypes
16
16
 
17
17
  ### Classic syntax
@@ -27,18 +27,20 @@ Koffi automatically tries mangled names for non-standard x86 calling conventions
27
27
 
28
28
  ### C-like prototypes
29
29
 
30
- You can declare functions using simple C-like prototype strings, as shown below:
30
+ If you prefer, you can declare functions using simple C-like prototype strings, as shown below:
31
31
 
32
32
  ```js
33
33
  const printf = lib.func('int printf(const char *fmt, ...)');
34
34
  const atoi = lib.func('int atoi(string)'); // The parameter name is not used by Koffi, and optional
35
35
  ```
36
36
 
37
+ You can use `()` or `(void)` for functions that take no argument.
38
+
37
39
  ## Synchronous calls
38
40
 
39
41
  By default, calling a C function happens synchronously.
40
42
 
41
- Most architectures only support one procedure call standard per process. The 32-bit x86 platform is an exception to this, and Koffi support several standards:
43
+ Most architectures only support one procedure call standard per process. The 32-bit x86 platform is an exception to this, and Koffi supports several x86 conventions:
42
44
 
43
45
  Convention | Classic form | Prototype form | Description
44
46
  ------------- | ----------------------------- | -------------- | -------------------------------------------------------------------
@@ -49,7 +51,7 @@ Most architectures only support one procedure call standard per process. The 32-
49
51
 
50
52
  You can safely use these on non-x86 platforms, they are simply ignored.
51
53
 
52
- Below you can find a small example showing how to use a non-default calling convention:
54
+ Below you can find a small example showing how to use a non-default calling convention, with the two syntaxes:
53
55
 
54
56
  ```js
55
57
  const koffi = require('koffi');
@@ -75,7 +77,9 @@ atoi.async('1257', (err, res) => {
75
77
  })
76
78
  console.log('Hello World!');
77
79
 
78
- // This program will print "Hello World!", and then "Result: 1257"
80
+ // This program will print:
81
+ // Hello World!
82
+ // Result: 1257
79
83
  ```
80
84
 
81
85
  These calls are executed by worker threads. It is **your responsibility to deal with data sharing issues** in the native code that may be caused by multi-threading.
@@ -103,7 +107,7 @@ On x86 platforms, only the Cdecl convention can be used for variadic functions.
103
107
 
104
108
  By default, Koffi will only forward arguments from Javascript to C. However, many C functions use pointer arguments for output values, or input/output values.
105
109
 
106
- For simplicy, and because Javascript only has value semantics for primitive types, Koffi can marshal out (or in/out) two types of parameters:
110
+ For simplicity, and because Javascript only has value semantics for primitive types, Koffi can marshal out (or in/out) two types of parameters:
107
111
 
108
112
  - [Structs](types.md#struct-types) (to/from JS objects)
109
113
  - [Opaque handles](types.md#opaque-handles)
@@ -168,8 +172,6 @@ sqlite3_close_v2(db);
168
172
 
169
173
  ## Javascript callbacks
170
174
 
171
- ### Using callbacks
172
-
173
175
  In order to pass a JS function to a C function expecting a callback, you must first create a callback type with the expected return type and parameters. The syntax is similar to the one used to load functions from a shared library.
174
176
 
175
177
  ```js
@@ -182,7 +184,7 @@ const ExampleCallback = koffi.callback('ExampleCallback', 'void', ['int']);
182
184
  const AddDoubleFloat = koffi.callback('double AddDoubleFloat(double d, float f)');
183
185
  ```
184
186
 
185
- Once your callback type is declared, you can use them in struct definitions, or as function parameter and/or return type.
187
+ Once your callback type is declared, you can use it in struct definitions, or as function parameter and/or return type.
186
188
 
187
189
  Here is a small example with the C part and the JS part.
188
190
 
@@ -219,8 +221,8 @@ console.log(ret);
219
221
 
220
222
  On x86 platforms, only Cdecl and Stdcall callbacks are supported.
221
223
 
222
- ### Thread safety
224
+ ## Thread safety
223
225
 
224
- The callback must be called from the main thread, or more precisely from the same thread as the V8 intepreter.
226
+ Asynchronous functions run on worker threads. You need to deal with thread safety issues if you share data between threads.
225
227
 
226
- Calling the callback from another thread is undefined behavior, and will likely lead to a mess.
228
+ Callbacks must be called from the main thread, or more precisely from the same thread as the V8 intepreter. Calling a callback from another thread is undefined behavior, and will likely lead to a crash or a big mess. You've been warned!
package/doc/memory.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  For synchronous/normal calls, Koffi uses two preallocated memory blocks:
6
6
 
7
- - One to construct to assign the C stack, subsequently used by the platform-specific assembly code (1 MiB by default)
7
+ - One to construct the C stack and assign registers, subsequently used by the platform-specific assembly code (1 MiB by default)
8
8
  - One to allocate strings and big objects/structs (2 MiB by default)
9
9
 
10
10
  Unless very big strings or objects (at least more than one page of memory) are used, no extra allocation ever happens during calls or callbacks.
@@ -18,12 +18,15 @@ console.log(config);
18
18
 
19
19
  The same is true for asynchronous calls. When an asynchronous call is made, Koffi will allocate new blocks unless there is an unused (resident) set of blocks still available. Once the asynchronous call is finished, these blocks are freed if there are more than `resident_async_pools` sets of blocks left around.
20
20
 
21
+ There cannot be more than `max_async_calls` running at the same time.
22
+
21
23
  ## Default settings
22
24
 
23
25
  Setting | Default | Description
24
26
  -------------------- | ------- | -----------------------------------------------
25
27
  sync_stack_size | 1 MiB | Stack size for synchronous calls
26
28
  sync_heap_size | 2 MiB | Heap size for synchronous calls
27
- async_stack_size | 512 kiB | Stack size for asynchronous calls
28
- async_heap_size | 1 MiB | Heap size for asynchronous calls
29
+ async_stack_size | 256 kiB | Stack size for asynchronous calls
30
+ async_heap_size | 512 kiB | Heap size for asynchronous calls
29
31
  resident_async_pools | 2 | Number of resident pools for asynchronous calls
32
+ max_async_calls | 64 | Maximum number of ongoing asynchronous calls
package/doc/start.md CHANGED
@@ -19,7 +19,7 @@ Below you can find three examples:
19
19
 
20
20
  ## Small Linux example
21
21
 
22
- This is a small example for Linux systems, which uses `gettimeofday()` and `printf()` to print the current time and the timezone.
22
+ This is a small example for Linux systems, which uses `gettimeofday()`, `localtime_r()` and `printf()` to print the current time.
23
23
 
24
24
  It illustrates the use of output parameters.
25
25
 
@@ -69,7 +69,7 @@ printf('Local time: %02d:%02d:%02d\n', 'int', now.tm_hour, 'int', now.tm_min, 'i
69
69
 
70
70
  ## Small Windows example
71
71
 
72
- This is a small example targeting the Win32 API, using `MessageBox()` to show a Hello message to the user.
72
+ This is a small example targeting the Win32 API, using `MessageBox()` to show a *Hello World!* message to the user.
73
73
 
74
74
  It illustrates the use of the x86 stdcall calling convention.
75
75
 
@@ -85,5 +85,5 @@ const MB_ICONINFORMATION = 0x40;
85
85
  // Find functions
86
86
  const MessageBoxA = lib.stdcall('MessageBoxA', 'int', ['void *', 'string', 'string', 'uint']);
87
87
 
88
- MessageBoxA(null, 'Hello', 'Foobar', MB_ICONINFORMATION);
88
+ MessageBoxA(null, 'Hello World!', 'Koffi', MB_ICONINFORMATION);
89
89
  ```
package/doc/types.md CHANGED
@@ -42,6 +42,8 @@ Number (float) | float64 | 8 | |
42
42
  Number (float) | float | 4 | |
43
43
  Number (float) | double | 8 | |
44
44
 
45
+ Koffi also accepts BigInt values when converting from JS to C integers. If the value exceeds the range of the C type, Koffi will convert the number to an undefined value. In the reverse direction, BigInt values are automatically used when needed for big 64-bit integers.
46
+
45
47
  Koffi defines a few more types that can change size depending on the OS and the architecture:
46
48
 
47
49
  JS type | C type | Signedness | Note
@@ -95,7 +97,7 @@ const A = koffi.struct('A', {
95
97
 
96
98
  Koffi follows the C and ABI rules regarding struct alignment and padding.
97
99
 
98
- Once a struct is declared, you can use it by name (with a string, like you can do for primitive types) or the through the value returned by the call to `koffi.struct()`. Only the latter is possible when declaring an anonymous struct.
100
+ Once a struct is declared, you can use it by name (with a string, like you can do for primitive types) or through the value returned by the call to `koffi.struct()`. Only the latter is possible when declaring an anonymous struct.
99
101
 
100
102
  ```js
101
103
  // The following two function declarations are equivalent, and declare a function taking an A value and returning A
@@ -107,9 +109,9 @@ const Function2 = lib.func('Function', A, [A]);
107
109
 
108
110
  In C, pointer arguments are used for differenty purposes. It is important to distinguish these use cases because Koffi provides different ways to deal with each of them:
109
111
 
110
- - **Struct pointers**: Use of struct pointers by C libraries fall in two cases: avoid (potentially) expensive copies, and to let the function change struct contents (output or input/output argument).
111
- - **Opaque handles**: the library does not expose the contents of the structs, and only provides you with a pointer to it (e.g. `sqlite3_stmt`). Only the functions provided by the library can do something with this pointer, in Koffi we call this a handle. This is usually done for ABI-stability reason, and to prevent library users from messing directly with library internals.
112
- - **Arrays**: in C, you dynamically-sized arrays are usually passed to functions with pointers, either NULL-terminated or with an additional length argument.
112
+ - **Struct pointers**: Use of struct pointers by C libraries fall in two cases: avoid (potentially) expensive copies, and to let the function change struct contents (output or input/output arguments).
113
+ - **Opaque handles**: the library does not expose the contents of the structs, and only provides you with a pointer to it (e.g. `FILE *`). Only the functions provided by the library can do something with this pointer, in Koffi we call this a handle. This is usually done for ABI-stability reason, and to prevent library users from messing directly with library internals.
114
+ - **Arrays**: in C, you dynamically-sized arrays are usually passed to functions with pointers, either NULL-terminated (or any other sentinel value) or with an additional length argument.
113
115
  - **Pointers to primitive types**: This is more rare, and generally used for output or input/output arguments. The Win32 API has a lot of these.
114
116
 
115
117
  ### Struct pointers
@@ -351,7 +353,7 @@ const ComputeTotalLength = lib.func('int64_t ComputeTotalLength(const char **str
351
353
  let strings = ['Get', 'Total', 'Length', null];
352
354
  let total = ComputeTotalLength(strings);
353
355
 
354
- console.log(total); // Prints 14n (big int)
356
+ console.log(total); // Prints 14
355
357
  ```
356
358
 
357
359
  By default, just like for objects, array arguments are copied from JS to C but not vice-versa. You can however change the direction as documented in the section on [output parameters](functions.md#output-parameters).
@@ -423,7 +425,7 @@ console.log(filenames);
423
425
 
424
426
  In javascript, it is not possible to pass a primitive value by reference to another function. This means that you cannot call a function and expect it to modify the value of one of its number or string parameter.
425
427
 
426
- However, arrays and objects (among others) are reference type values. Assigning an array or an object from one variable to another does not invole any copy. Instead, as the following example illustrates, the new variable references the same list as the first:
428
+ However, arrays and objects (among others) are reference type values. Assigning an array or an object from one variable to another does not invole any copy. Instead, as the following example illustrates, the new variable references the same array as the first:
427
429
 
428
430
  ```js
429
431
  let list1 = [1, 2];
@@ -436,7 +438,7 @@ console.log(list1); // Prints [1, 42]
436
438
 
437
439
  All of this means that C functions that are expected to modify their primitive output values (such as an `int *` parameter) cannot be used directly. However, thanks to Koffi's transparent array support, you can use Javascript arrays to approximate reference semantics with single-element arrays.
438
440
 
439
- Below, you can find an example of an addition function where the result is stored in an `int *` output parameter and how to use this function from Koffi.
441
+ Below, you can find an example of an addition function where the result is stored in an `int *` input/output parameter and how to use this function from Koffi.
440
442
 
441
443
  ```c
442
444
  void AddInt(int *dest, int add)
@@ -445,7 +447,7 @@ void AddInt(int *dest, int add)
445
447
  }
446
448
  ```
447
449
 
448
- You can simply pass a single-element array as the third argument:
450
+ You can simply pass a single-element array as the first argument:
449
451
 
450
452
  ```js
451
453
  const AddInt = lib.func('void AddInt(_Inout_ int *dest, int add)');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "license": "AGPL-3.0",
27
27
  "dependencies": {
28
- "cnoke": "^2.0.3"
28
+ "cnoke": "^2.0.4"
29
29
  },
30
30
  "devDependencies": {
31
31
  "chalk": "^4.1.2",
@@ -392,6 +392,12 @@
392
392
  "arch": "x64",
393
393
  "directory": "/Users/macos/luigi",
394
394
  "build": "PATH=/usr/local/bin:/usr/bin:/bin SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk node ../cnoke/cnoke.js"
395
+ },
396
+
397
+ "macOS ARM64": {
398
+ "arch": "arm64",
399
+ "directory": "/Users/macos/luigi_arm64",
400
+ "build": "PATH=/usr/local/bin:/usr/bin:/bin SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk node ../cnoke/cnoke.js --arch arm64"
395
401
  }
396
402
  },
397
403
 
@@ -538,16 +544,5 @@
538
544
  }
539
545
  }
540
546
  }
541
- },
542
-
543
- "macos_arm64": {
544
- "name": "macOS ARM64",
545
- "platform": "darwin",
546
-
547
- "builds": {
548
- "macOS ARM64": {
549
- "arch": "arm64"
550
- }
551
- }
552
547
  }
553
548
  }
package/src/abi_x86.cc CHANGED
@@ -145,11 +145,6 @@ bool AnalyseFunction(Napi::Env env, InstanceData *instance, FunctionInfo *func)
145
145
  } break;
146
146
  }
147
147
 
148
- #ifdef __OpenBSD__
149
- // Make sure the SP points inside the MAP_STACK area, or (void) functions may crash on OpenBSD
150
- func->args_size = std::max(4, func->args_size);
151
- #endif
152
-
153
148
  return true;
154
149
  }
155
150
 
package/src/call.cc CHANGED
@@ -40,8 +40,9 @@ CallData::~CallData()
40
40
  mem->heap = old_heap_mem;
41
41
 
42
42
  instance->free_trampolines |= used_trampolines;
43
+ instance->temporaries -= mem->temporary;
43
44
 
44
- if (--mem->depth && mem->temporary) {
45
+ if (!--mem->depth && mem->temporary) {
45
46
  delete mem;
46
47
  }
47
48
  }