Commit graph

35 commits

Author SHA1 Message Date
Alexander Motzkau
25ab0f48bc Added separate Python types for various closure types
Added LfunClosure, (Simul)EfunClosure, (Unbound/Bound)LambdaClosure and
OperatorClosure types for Python.
2025-07-07 22:14:05 +02:00
Alexander Motzkau
8b3031d3b4 With pragma save_local_names save debugging info for local variables
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.
2025-07-07 22:14:05 +02:00
Alexander Motzkau
15166819ed Implement Python-registered structs
Python can register global struct definitions via ldmud.register_struct().
Also added corresponding namespace ldmud.registered_structs that contains
all registered struct types.
2025-07-07 22:14:05 +02:00
Alexander Motzkau
0142ebbd27 Added abilities to Python integration to trace LPC program execution
Added BEFORE_INSTRUCTION hook to be called for every instruction.
Added call_stack property to query the current stack.
2025-07-07 22:14:05 +02:00
Alexander Motzkau
1db6633aab Implement to_type() efun
to_type() converts a value to a given target type.
If required, does so recursively.
2025-03-21 21:30:30 +01:00
Alexander Motzkau
52dc66d499 Add support for LPC type objects in Python
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.
2022-10-10 23:38:01 +02:00
Alexander Motzkau
9c219db7cf Release Python global interpreter lock when not executing Python code
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.
2022-11-07 22:27:52 +01:00
Alexander Motzkau
73ed64c46b Fix save_value()/save_object() for Python objects
For non-saveable Python objects the delimiter (comma) was printed twice.
2022-09-29 23:11:19 +02:00
Alexander Motzkau
508b6efc82 Add Python statistics to driver_info()
Add driver_info information DI_NUM_LPC_PYTHON_REFS and
DI_NUM_PYTHON_LPC_REFS to get the number of references between
both runtime environments.
2022-06-30 22:17:26 +02:00
Alexander Motzkau
8365fa5ebe Implement usage of Python objects in LPC
Python can register certain types for LPC. Objects of those types
can then be passed between Python and LPC code.
2022-05-25 23:16:58 +02:00
Alexander Motzkau
788cd95871 Do cleanup operations across Python boundary
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).
2022-06-29 23:47:41 +02:00
Alexander Motzkau
8556262748 Implement coroutines
Add a new type and several statements to LPC to implement coroutines.
Coroutines allow a function to suspend its execution and resume it
later.
2022-01-09 21:22:34 +01:00
Alexander Motzkau
0659a4124d Implement lightweight objects
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)
2022-01-09 01:13:21 +01:00
Alexander Motzkau
2fb165ddbd Python: Add possibility to save data in an object
Give LPC objects a Python dictionary, so arbitrary members can be saved
there. So efuns can store a state there.
2022-01-08 22:16:53 +01:00
Alexander Motzkau
e682e553a8 Implement support for lvalues in Python
Add an Lvalue class to represent LPC lvalues.
2020-08-26 22:27:57 +02:00
Alexander Motzkau
f840212a68 Introduce pragma warn_unused_variables
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.
2020-07-05 13:18:57 +02:00
Alexander Motzkau
a828c3616d Make pragma strict_types raise errors again
The last release reimplemented pragma strict_types with warning only,
this release will make that errors again.
2020-07-05 13:18:57 +02:00
Alexander Motzkau
012214967f Corrected checks for Python efun calls with ellipsis.
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.
2020-04-28 22:30:06 +02:00
Alexander Motzkau
987b89bbd8 Python: Added protector for replace_program()
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().
2020-04-28 22:30:06 +02:00
Alexander Motzkau
628a6ee00e Implemented type checks for Python efuns
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.
2019-11-04 22:16:19 +01:00
Alexander Motzkau
9ebe41e5ce Implemented byte sequence support for Python.
Byte sequences are now passed as byte objects to Python and vice versa.
2019-04-28 16:43:50 +02:00
Alexander Motzkau
b3c3da3ffb Fixed a bug in type deduction of python efun calls.
When calling python efuns the expression return type
was left uninitialized, resulting in errors or even
crashs when that type was evaluated.
2018-01-30 23:27:00 +01:00
Alexander Motzkau
fa61acc6b7 Fixed a crash on exceptions with python efun closures.
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.
2018-01-30 23:27:00 +01:00
Alexander Motzkau
4baeda32f3 Corrected test suite to respect the absence of pkg-python.
Omit the --python-script option when running without the python package
compiled in. Also the t-python test will be skipped. (Fixes #851)
2017-09-30 19:27:10 +02:00
Alexander Motzkau
fc5cc09c9a Python: Implemented (un)register_hook 2016-10-12 22:27:47 +02:00
Alexander Motzkau
f116220d85 Python: Implemented unregister_efun 2016-10-12 22:27:47 +02:00
Alexander Motzkau
8958197107 Python: Implemented (un)register_socket and fixed a few bugs. 2016-10-12 22:27:47 +02:00
Alexander Motzkau
0db245e961 Python: Added support for quoted arrays. 2016-10-12 22:27:47 +02:00
Alexander Motzkau
20db434a67 Python: Added support for symbols. 2016-10-12 22:27:47 +02:00
Alexander Motzkau
1915b331c7 Python: Added support for mappings. 2016-10-12 22:27:47 +02:00
Alexander Motzkau
29e4dcc340 Python: Added support for arrays. 2016-10-12 22:27:47 +02:00
Alexander Motzkau
5068d78be7 Python: Added support for closures. 2016-10-12 22:24:54 +02:00
Alexander Motzkau
4363f64c2c Python: Set lvalues to not-implemented status, wait for #546. 2016-10-12 22:21:36 +02:00
Alexander Motzkau
00fcd59306 Added GC support to the python package. 2016-10-12 22:21:29 +02:00
Alexander Motzkau
aff1392ef3 Added testsuite for Python. 2016-10-12 21:42:52 +02:00