Previously pragma save_local_names was only used to store information of
variables of coroutines to be inspected by Python code. Extend this to
all local variables.
Standard struct definition where not usable in dynamic settings
(e.g. to_type()), as the definition was not registered to the corresponding
struct name and type.
Python can register global struct definitions via ldmud.register_struct().
Also added corresponding namespace ldmud.registered_structs that contains
all registered struct types.
ldmud.registered_efuns contains all registered Python efuns and
ldmud.registered_types provides all registered Python types.
Those are read-only, for manipulation there is (un)register_efun/type().
Fully support the LPC type system in Python, providing representations
for basic types (int, float, string, bytes), named (lightweight) object
types, concrete struct types and union types.
The global interpreter lock is acquired during initialization and never
released. So if any Python modules start additional threads they can
hardly run, because the lock is held by the main thread mostly all of
the time.
Include any LPC data exclusively held by Python code in the cleanup process,
which is to remove any dangling object references (replacing with 0 or
removing from mappings).
At startup the current_object was initialized incorrectly (setting its type
to object, but with a NULL object), resulting in a NULL pointer dereference
later on. (Fixes#902)
Add a new type and data structure to LPC. Lightweight objects combine
properties from structs (small memory footprint, automatic lifetime
management) and objects (capsulation, functions).
(Implements #688)
The Object and Closure types in Python now support evaluation in a
boolean context and return False if the corresponding object was
destructed, True otherwise.
Struct member access is now done via the .members attribute of
structs and lvalues. For Struct objects this will return a member
object with .name, .type and .value attributes. For Lvalue objects
this will return an Lvalue for the given member.
When active the compiler will warn about variables that are not used,
i.e. not read from or not written to. The warning differentiates between
variables that were just declared, variables that were written to or
variables that were only read from. Taking a reference from a variable
is seen as a read/write access, so no warning afterwards.
When checking the number of arguments for calls to Python efuns,
the existence of ellipsis in the argument list were ignored,
resulting in false compile errors.
When lfun or variable objects are created, we need to make sure,
the indices are adjusted if a replace_program() is in progress.
Just like closures we create a protector structure that will be
processed after the replace_program().
In Python the representation of an LPC object offers an attribute
variables, that contains all variables of that object with some
information about it and an attribute to change its value.
In Python the representation of an LPC object offers an attribute
functions, that contains all visible functions of that object
with some information about that function and the call operator.
If Python efuns have type annotations they are evaluated
at compile and runtime. Even without annotations the number
of arguments are checked at compile time.
On a call to python efun closures the funstart entry
in the constrol stack was left uninitialized, resulting
in a crash when it that value was used to generate
the stack trace.