module documentation

Bindings for the official nwn script compiler.

The compiler depends on a native library. This package ships with precompiled binaries for MacOS, Windows and Linux both on X64 and ARM64 architectures.

This module or the underlying library is currently NOT threadsafe.

Example

>>> from nwn.nwscript.comp import Compiler
...
... def resolver(filename: str) -> bytes | None:
...     # Load the file from disk, or return None if not found.
...     # You can also service from memory, or anywhere else.
...     with open(filename, "rb") as f:
...         return f.read()
... comp = Compiler(resolver)
>>> ncs, ndb = comp.compile("myscript.nss")
>>> print(ncs)  # The compiled bytecode
>>> print(ndb)  # The debug information
Class Compiler A class to compile NWScript using the NWScript compiler.
Class Optimization Undocumented
Exception CompilationError Exception raised for errors in the compilation process.
Class _NativeCompileResult Undocumented
Constant _CB_LOAD Undocumented
Constant _CB_WRITE Undocumented
_CB_LOAD = (source)

Undocumented

Value
ct.CFUNCTYPE(ct.c_char_p, ct.c_char_p, ct.c_uint16)
_CB_WRITE = (source)

Undocumented

Value
ct.CFUNCTYPE(ct.c_int32, ct.c_char_p, ct.c_uint16, ct.c_void_p, ct.c_size_t, ct.c_bool
)