Skip to content

Commit

Permalink
Merge branch '368preparations' into unitopia
Browse files Browse the repository at this point in the history
  • Loading branch information
amotzkau committed Jan 16, 2024
2 parents 63bd197 + 4b7c7d3 commit c007141
Show file tree
Hide file tree
Showing 76 changed files with 4,504 additions and 1,094 deletions.
17 changes: 16 additions & 1 deletion doc/concepts/python
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,15 @@ LDMUD MODULE

- efuns
This namespace contains all original efuns (without any
registered python efuns or simul-efuns). These can be called
registered Python efuns or simul-efuns). These can be called
as a regular function.

- registered_efuns
Contains all registered Python efuns.

- registered_types
Contains all registered Python types.


There is mapping of LPC values to Python values for the following types:
int <-> int(, bool)
Expand Down Expand Up @@ -420,6 +426,15 @@ PYTHON TYPES
from __save__ as the only argument and will return the
restored object.

__convert__
Used by to_type() to convert the Python object into another
type. Gets the target type object as its first argument and
the to_type_options struct (which may be None) as a second
argument. If the conversion is not supported, can either
return None or an exception. Only if the function does not
exist, __int__, __float__, __str__ or __bytes__ are called
if appropriate.

EXAMPLE
import ldmud

Expand Down
5 changes: 3 additions & 2 deletions doc/efun/bytesp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ HISTORY
Introducted in LDMud 3.6.0.

SEE ALSO
clonep(E), closurep(E), floatp(E), mappingp(E), objectp(E), intp(E),
referencep(E), pointerp(E), stringp(E), structp(E), symbolp(E)
clonep(E), closurep(E), coroutinep(E), floatp(E), intp(E),
lpctypep(E), lwobjectp(E), mappingp(E), objectp(E), pointerp(E),
referencep(E), stringp(E), structp(E), symbolp(E)
7 changes: 4 additions & 3 deletions doc/efun/clonep
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HISTORY
with replaced programs no longer count as clones.

SEE ALSO
load_name(E), clone_object(E), clones(E), bytesp(E), closurep(E),
floatp(E), mappingp(E), objectp(E), intp(E), referencep(E),
pointerp(E), stringp(E), symbolp(E), structp(E)
load_name(E), clone_object(E), clones(E), bytesp(E),
closurep(E), coroutinep(E), floatp(E), intp(E), lpctypep(E),
lwobjectp(E), mappingp(E), objectp(E), pointerp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
5 changes: 3 additions & 2 deletions doc/efun/closurep
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ HISTORY
Introduced in 3.2@70

SEE ALSO
bytesp(E), clonep(E), floatp(E), mappingp(E), objectp(E), intp(E),
referencep(E), pointerp(E), stringp(E), symbolp(E), structp(E)
bytesp(E), clonep(E), coroutinep(E), floatp(E), intp(E), lpctypep(E),
lwobjectp(E), mappingp(E), objectp(E), pointerp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
13 changes: 13 additions & 0 deletions doc/efun/coroutinep
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SYNOPSIS
int coroutinep(mixed arg)

DESCRIPTION
Returns 1 if the argument is a coroutine.

HISTORY
Introduced in LDMud 3.6.5.

SEE ALSO
bytesp(E), clonep(E), closurep(E), floatp(E), intp(E), lpctypep(E),
lwobjectp(E), mappingp(E), objectp(E), pointerp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
5 changes: 3 additions & 2 deletions doc/efun/floatp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ DESCRIPTION
Returns 1 if the arg is a floating point number, 0 else.

SEE ALSO
bytesp(E), clonep(E), closurep(E), mappingp(E), objectp(E), intp(E),
referencep(E), pointerp(E), stringp(E), symbolp(E), structp(E)
bytesp(E), clonep(E), closurep(E), coroutinep(E), intp(E),
lpctypep(E), lwobjectp(E), mappingp(E), objectp(E), pointerp(E),
referencep(E), stringp(E), structp(E), symbolp(E)
5 changes: 3 additions & 2 deletions doc/efun/intp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ DESCRIPTION
Return 1 if arg is an integer number.

SEE ALSO
bytesp(E), clonep(E), closurep(E), floatp(E), mappingp(E), objectp(E),
referencep(E), pointerp(E), stringp(E), symbolp(E), structp(E)
bytesp(E), clonep(E), closurep(E), coroutinep(E), floatp(E),
lpctypep(E), lwobjectp(E), mappingp(E), objectp(E), pointerp(E),
referencep(E), stringp(E), structp(E), symbolp(E)
13 changes: 13 additions & 0 deletions doc/efun/lpctypep
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SYNOPSIS
int lpctypep(mixed arg)

DESCRIPTION
Returns 1 if the argument is an LPC type.

HISTORY
Introduced in LDMud 3.6.7.

SEE ALSO
bytesp(E), clonep(E), closurep(E), coroutinep(E), floatp(E), intp(E),
lwobjectp(E), mappingp(E), objectp(E), pointerp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
6 changes: 3 additions & 3 deletions doc/efun/lwobjectp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ DESCRIPTION
Return 1 if arg is a lightweight object.

SEE ALSO
bytesp(E), clonep(E), closurep(E), floatp(E), intp(E), mappingp(E),
objectp(E), pointerp(E), referencep(E), stringp(E), structp(E),
symbolp(E)
bytesp(E), clonep(E), closurep(E), coroutinep(E), floatp(E), intp(E),
lpctypep(E), mappingp(E), objectp(E), pointerp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
5 changes: 3 additions & 2 deletions doc/efun/mappingp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ DESCRIPTION
SEE ALSO
mkmapping(E), m_indices(E), m_values(E), m_add(E), m_delete(E),
sizeof(E), widthof(E), bytesp(E), clonep(E), closurep(E),
floatp(E), objectp(E), intp(E), referencep(E), pointerp(E),
stringp(E), symbolp(E), structp(E)
coroutinep(E), floatp(E), intp(E), lpctypep(E), lwobjectp(E),
objectp(E), pointerp(E), referencep(E), stringp(E), structp(E),
symbolp(E)
6 changes: 3 additions & 3 deletions doc/efun/objectp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ DESCRIPTION
Return 1 if arg is an object.

SEE ALSO
bytesp(E), clonep(E), closurep(E), floatp(E), intp(E), lwobjectp(E),
mappingp(E), pointerp(E), referencep(E), stringp(E), structp(E),
symbolp(E)
bytesp(E), clonep(E), closurep(E), coroutinep(E), floatp(E), intp(E),
lpctypep(E), lwobjectp(E), mappingp(E), pointerp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
5 changes: 3 additions & 2 deletions doc/efun/pointerp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ DESCRIPTION
Return 1 if arg is a pointer, i.e. an array.

SEE ALSO
bytesp(E), clonep(E), closurep(E), floatp(E), mappingp(E), objectp(E),
intp(E), referencep(E), stringp(E), symbolp(E), structp(E)
bytesp(E), clonep(E), closurep(E), coroutinep(E), floatp(E), intp(E),
lpctypep(E), lwobjectp(E), mappingp(E), objectp(E), referencep(E),
stringp(E), structp(E), symbolp(E)
6 changes: 3 additions & 3 deletions doc/efun/referencep
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ DESCRIPTION
a.g. referencep(&x).

SEE ALSO
references(LPC), bytesp(E), clonep(E), closurep(E), floatp(E),
mappingp(E), objectp(E), intp(E), pointerp(E), stringp(E),
symbolp(E), structp(E)
references(LPC), bytesp(E), clonep(E), closurep(E), coroutinep(E),
floatp(E), intp(E), lpctypep(E), lwobjectp(E), mappingp(E),
objectp(E), pointerp(E), stringp(E), structp(E), symbolp(E)
5 changes: 3 additions & 2 deletions doc/efun/stringp
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ DESCRIPTION
Return 1 if arg is a string.

SEE ALSO
bytesp(E), clonep(E), closurep(E), floatp(E), mappingp(E), objectp(E),
intp(E), referencep(E), pointerp(E), symbolp(E), structp(E)
bytesp(E), clonep(E), closurep(E), coroutinep(E), floatp(E), intp(E),
lpctypep(E), lwobjectp(E), mappingp(E), objectp(E), pointerp(E),
referencep(E), structp(E), symbolp(E)
6 changes: 3 additions & 3 deletions doc/efun/structp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ HISTORY
Introducted in LDMud 3.3.273.

SEE ALSO
baseof(E), bytesp(E), clonep(E), closurep(E), floatp(E),
mappingp(E), objectp(E), intp(E), referencep(E), pointerp(E),
stringp(E), symbolp(E)
baseof(E), bytesp(E), clonep(E), closurep(E), coroutinep(E),
floatp(E), intp(E), lpctypep(E), lwobjectp(E), mappingp(E),
objectp(E), pointerp(E), referencep(E), stringp(E), symbolp(E)
6 changes: 3 additions & 3 deletions doc/efun/symbolp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ HISTORY
Introduced in 3.2@70

SEE ALSO
quote(E), bytesp(E), clonep(E), closurep(E), floatp(E),
mappingp(E), objectp(E), intp(E), referencep(E), pointerp(E),
stringp(E), structp(E)
quote(E), bytesp(E), clonep(E), closurep(E), coroutinep(E),
floatp(E), intp(E), lpctypep(E), lwobjectp(E), mappingp(E),
objectp(E), pointerp(E), referencep(E), stringp(E), structp(E)
58 changes: 58 additions & 0 deletions doc/efun/to_type
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
SYNOPSIS
mixed to_type(mixed value, lpctype type)
mixed to_type(mixed value, lpctype type, struct to_type_options options)

DESCRIPTION
Converts <value> to <type>. This efun will apply any type conversions
recursively to make <value> conform to <type>. The following
conversions are available:

source type target types
------------- ----------------------------------------
array (int) string, bytes
array (mixed) quoted array, struct, mapping
bytes string, int*
closure object, lwobject, int, string
coroutine string
int float, string
float int, string
lpctype lpctype*, mapping, string
lwobject string
mapping struct, mixed*
object string
quoted array mixed*
string symbol, int, float, lpctype, object, bytes, int*
struct struct, mapping, mixed*, string
symbol string, int*

If multiple conversions are possible (e.g. to_type("10", <int|int*>)
the conversion will be selected in order as given in the table above.
If multiple array or struct types are given, the order is undefined.
Conversions, where elements (e.g. from an array, mapping or struct)
need to be discarded, are not considered.

Optionally the function accepts a struct with additional options.
All entries in this struct are optional. These are the members:

source_encoding:
The encoding (given as string) for conversion from bytes to
string. If not given, such a conversion will not be performed.

target_encoding:
The encoding (given as string) for conversion from string to
bytes. If not given, such a conversion will not be performed.

keep_zero:
If set (integer != 0) a zero will not be converted. If unset,
a zero will be converted to string or float if requested,
for all other types it will stay zero.

EXAMPLES
to_type(({ "10", "20" }), [int*]) -> ({ 10, 20 })

HISTORY
Introduced in LDMud 3.6.8.

SEE ALSO
to_array(E), to_bytes(E), to_float(E), to_int(E), to_lpctype(E),
to_object(E), to_string(E), to_struct(E), to_text(E)
6 changes: 4 additions & 2 deletions doc/efun/typeof
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ HISTORY
Introduced in 3.2@63.

SEE ALSO
get_type_info(E), intp(E), objectp(E), floatp(E), pointerp(E),
closurep(E), symbolp(E), stringp(E), mappingp(E), bytesp(E)
get_type_info(E), bytesp(E), clonep(E), closurep(E), coroutinep(E),
floatp(E), intp(E), lpctypep(E), lwobjectp(E), mappingp(E),
objectp(E), pointerp(E), referencep(E), stringp(E), structp(E),
symbolp(E)
2 changes: 2 additions & 0 deletions doc/structs/compile_string_options
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ DEFINITION
int compile_expression;
int compile_block;
int as_async;

int detect_end;
};

DESCRIPTION
Expand Down
17 changes: 17 additions & 0 deletions doc/structs/to_type_options
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NAME
to_type_options

DEFINITION
struct to_type_options
{
string source_encoding;
string target_encoding;

int keep_zero;
};

DESCRIPTION
This struct is used for passing options to the to_type() efun.

SEE ALSO
to_type(E)
11 changes: 11 additions & 0 deletions mudlib/deprecated/allocate_mapping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* This sefun is to provide a replacement for the efun allocate_mapping().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/
#if ! __EFUN_DEFINED__(allocate_mapping)

mapping allocate_mapping(int size, int width = 1)
{
return m_allocate(size, width);
}

#endif
12 changes: 12 additions & 0 deletions mudlib/deprecated/copy_mapping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This sefun is to provide a replacement for the efun copy_mapping().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(copy_mapping)

mapping copy_mapping(mapping m)
{
return copy(m);
}

#endif
12 changes: 12 additions & 0 deletions mudlib/deprecated/extract.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This sefun is to provide a replacement for the efun extract().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(extract)

string extract(string str, int from, int to = -1)
{
return str[>from..>to];
}

#endif
12 changes: 12 additions & 0 deletions mudlib/deprecated/file_name.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* This sefun is to provide a replacement for the efun file_name().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(file_name)

string file_name(object ob = previous_object())
{
return object_name(ob);
}

#endif
15 changes: 15 additions & 0 deletions mudlib/deprecated/filter_array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This sefun is to provide a replacement for the efun filter_array().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(filter_array)

mixed* filter_array(mixed *arr, string|closure|mapping f, varargs mixed* args)
{
if (efun::extern_call())
efun::set_this_object(efun::previous_object());

return filter(arr, f, args...);
}

#endif
15 changes: 15 additions & 0 deletions mudlib/deprecated/filter_mapping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This sefun is to provide a replacement for the efun filter_mapping().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(filter_mapping)

mapping filter_mapping(mapping m, string|closure|mapping f, varargs mixed* args)
{
if (efun::extern_call())
efun::set_this_object(efun::previous_object());

return filter_indices(m, f, args...);
}

#endif
15 changes: 15 additions & 0 deletions mudlib/deprecated/map_array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This sefun is to provide a replacement for the efun map_array().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(map_array)

mixed* map_array(mixed *arr, string|closure|mapping f, varargs mixed* args)
{
if (efun::extern_call())
efun::set_this_object(efun::previous_object());

return map(arr, f, args...);
}

#endif
15 changes: 15 additions & 0 deletions mudlib/deprecated/map_mapping.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This sefun is to provide a replacement for the efun map_mapping().
* Feel free to add it to your mudlibs, if you have much code relying on that.
*/

#if ! __EFUN_DEFINED__(map_mapping)

mapping map_mapping(mapping m, string|closure|mapping f, varargs mixed* args)
{
if (efun::extern_call())
efun::set_this_object(efun::previous_object());

return map_indices(m, f, args...);
}

#endif
Loading

0 comments on commit c007141

Please sign in to comment.