Commit graph

44 commits

Author SHA1 Message Date
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
676eee0601 Fix crash in Python when accessing a swapped object
Python routines did restore the object but forgot to update internal pointers
resulting in dereference of invalid pointers.
2022-09-02 18:17:56 +02:00
Alexander Motzkau
ca6b3b9e9b Fix memory leak in Python ldmud.Mapping.__init__() function
The __init__() of ldmud.Mapping forgot the give up the references
of the dictionary items to transfer.
2022-08-01 19:20:40 +02:00
Alexander Motzkau
2593a95766 Handle uninitialized objects in Python gracefully
Detect uninitialized objects and pass them as zero (or
for arrays/mappings as empty array/mappings) to LPC.
2022-07-19 20:34:52 +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
9a89c72a92 Implement range index operator for wide mappings
Introduce a mapping index operation m[key, index1 .. index2].
(Implements #753)
2021-06-09 16:32:21 +02:00
Alexander Motzkau
c61f92f52d Fix crash when running LPC code on Python startup
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)
2022-01-11 21:52:37 +01:00
Alexander Motzkau
bf44f19753 Save local variable names for inspection in coroutines
With the new pragma save_local_names the names of local variables are
stored in the program so they can be inspected (with Python) later on.
2022-01-09 21:22:34 +01: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
9414a7a046 Preprocessor statements and pragmas must be written in full
It is no more permissible to preprocessor statements in part
(e.g. '#incl <>' or just '# <>'), also pragma names must be written fully.
2021-02-02 20:41:00 +01:00
Alexander Motzkau
325b29fa14 Prevent empty mapping entries after failed assignments
A mapping entry will only be created when the actual assignment
is executed, not when the lvalue is created.
(Fixes #148)
2020-11-11 02:21:16 +01:00
Alexander Motzkau
0c8c25ad36 Implemented bool conversion for objects and closures in Python
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.
2020-10-27 19:40:09 +01:00
Alexander Motzkau
cc1d20ba91 Fix hash and call operator of closures in Python
The call operator crashed on uninitialized closures,
the hash operator did not hash lfun or efun closures correctly.
2020-10-24 13:51:58 +02:00
Alexander Motzkau
07c99b6e16 Implement support for lvalues of struct members in Python
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.
2020-08-26 22:27:57 +02: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
68bc5440c7 Python: Implemented variable list for object representation
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.
2020-04-28 22:30:06 +02:00
Alexander Motzkau
855ee6441a Python: Implemented function list for object representation
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.
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
a34d55ecec Python: Implemented iterators for mappings. 2016-10-12 22:27:48 +02:00
Alexander Motzkau
2e2069da48 Python: Implemented slices for arrays and mappings, and Object.name. 2016-10-12 22:27:47 +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
516293c069 Added get_master/get_simul_efun() to the ldmud module. 2016-10-12 21:42:52 +02:00
Alexander Motzkau
aff1392ef3 Added testsuite for Python. 2016-10-12 21:42:52 +02:00