Skip to content

Commit 0847468

Browse files
committed
New feature CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
Changes `OPERATOR_DEEPCOPY` into a new `OPERATOR_SERIALIZE`. Since `deepcopy` can be implemented in terms of `tp_serialize` (since `CONFIG_EXPERIMENTAL_SERIALIZED_DEEPCOPY`), this feature expands on that idea by starting the process of getting rid of the old `tp_deep_copy` callback, and `operator deepcopy` in user-code. The former has already been replaced with `tp_serialize`, and the later is now available, though its semantics (i.e. the arguments it takes, as well as its intended return value) are yet to-be determined.
1 parent c6f4121 commit 0847468

39 files changed

+365
-28
lines changed

include/deemon/api.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,23 @@ __pragma_GCC_diagnostic_ignored(Walloc_size_larger_than)
420420
/* EXPERIMENTAL/WIP FEATURES */
421421
/************************************************************************/
422422

423+
/* NOTES:
424+
* - All of these features will eventually become mandatory
425+
* - Some features may prevent deemon from compiling when enabled/disabled
426+
* - Deviate from the defaults encoded here at your own risk
427+
*/
428+
429+
#if 0
430+
#if (!defined(CONFIG_EXPERIMENTAL_MY_FEATURE) && \
431+
!defined(CONFIG_NO_EXPERIMENTAL_MY_FEATURE))
432+
#if 1
433+
#define CONFIG_EXPERIMENTAL_MY_FEATURE
434+
#else
435+
#define CONFIG_NO_EXPERIMENTAL_MY_FEATURE
436+
#endif
437+
#endif /* !CONFIG_[NO_]EXPERIMENTAL_MY_FEATURE */
438+
#endif
439+
423440
/* Experimental feature switch: use altered status codes for "boundattr" / "bounditem".
424441
* When enabled, "hasitem"/"hasattr" can be implemented by aliasing "bounditem"/"boundattr" */
425442
#if (!defined(CONFIG_EXPERIMENTAL_ALTERED_BOUND_CONSTANTS) && \
@@ -455,7 +472,7 @@ __pragma_GCC_diagnostic_ignored(Walloc_size_larger_than)
455472

456473
/* Experimental feature switch: ST_ISDIR can be imported as a module, and modules
457474
* whose names match an equally named directory within the same containing directory
458-
* also expose all the symbols from that directory within themselves:
475+
* also expose all the files from that directory as symbols:
459476
* Files:
460477
* - mylib/foo.dee >> global final symbolFromFoo = 42;
461478
* - mylib/foo/bar.dee >> global final symbolFromBar = "Wow!";
@@ -511,6 +528,18 @@ __pragma_GCC_diagnostic_ignored(Walloc_size_larger_than)
511528
#define CONFIG_NO_EXPERIMENTAL_SERIALIZED_DEEPCOPY
512529
#endif
513530
#endif /* !CONFIG_[NO_]EXPERIMENTAL_SERIALIZED_DEEPCOPY */
531+
532+
533+
/* Experimental feature switch: Replace "OPERATOR_DEEPCOPY" with "OPERATOR_SERIALIZE"
534+
* TODO: When this one becomes mandatory, "tp_deep_copy" and "tp_deepload" will be removed! */
535+
#if (!defined(CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR) && \
536+
!defined(CONFIG_NO_EXPERIMENTAL_SERIALIZE_OPERATOR))
537+
#if defined(CONFIG_EXPERIMENTAL_SERIALIZED_DEEPCOPY) && 1
538+
#define CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
539+
#else
540+
#define CONFIG_NO_EXPERIMENTAL_SERIALIZE_OPERATOR
541+
#endif
542+
#endif /* !CONFIG_[NO_]EXPERIMENTAL_SERIALIZE_OPERATOR */
514543
/************************************************************************/
515544

516545

include/deemon/class.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,22 +937,24 @@ INTDEF WUNUSED NONNULL((1)) int DCALL instance_builtin_inherited_initkw(DeeObjec
937937
/* Builtin (pre-defined) hooks that are used when the user-class doesn't override these operators. */
938938
INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL instance_builtin_tcopy(DeeTypeObject *tp_self, DeeObject *__restrict self, DeeObject *other);
939939
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_builtin_copy(DeeObject *__restrict self, DeeObject *__restrict other);
940+
#ifndef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
940941
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_builtin_tdeepload(DeeTypeObject *tp_self, DeeObject *__restrict self);
941942
INTDEF WUNUSED NONNULL((1)) int DCALL instance_builtin_deepload(DeeObject *__restrict self);
943+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
942944
#ifdef CONFIG_NOBASE_OPTIMIZED_CLASS_OPERATORS
943945
INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL instance_builtin_nobase_tcopy(DeeTypeObject *tp_self, DeeObject *__restrict self, DeeObject *other);
944946
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_builtin_nobase_copy(DeeObject *__restrict self, DeeObject *__restrict other);
947+
#ifndef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
945948
INTDEF WUNUSED NONNULL((1)) int DCALL instance_builtin_nobase_deepload(DeeObject *__restrict self);
949+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
946950
#endif /* CONFIG_NOBASE_OPTIMIZED_CLASS_OPERATORS */
947951
INTDEF NONNULL((1)) void DCALL instance_builtin_destructor(DeeObject *__restrict self); /* No t-variant, because types are unwound automatically during destruction. */
948952
INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL instance_builtin_tassign(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other);
949953
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_builtin_assign(DeeObject *self, DeeObject *other);
950954
INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL instance_builtin_tmoveassign(DeeTypeObject *tp_self, DeeObject *self, DeeObject *other);
951955
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_builtin_moveassign(DeeObject *self, DeeObject *other);
952-
#if 0
953956
struct Dee_serial;
954957
INTDEF WUNUSED NONNULL((1)) int DCALL instance_builtin_serialize(DeeObject *__restrict self, struct Dee_serial *__restrict writer, Dee_seraddr_t addr);
955-
#endif
956958

957959
#ifdef Dee_TP_FCLASS_AUTOINIT
958960
/* No predefined construction operators (with `Dee_TP_FCLASS_AUTOINIT'). */
@@ -990,8 +992,10 @@ INTDEF WUNUSED NONNULL((1, 2)) Dee_ssize_t DCALL instance_builtin_auto_printrepr
990992
/* Hooks when the user-class overrides the associated operator. */
991993
INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL instance_tcopy(DeeTypeObject *tp_self, DeeObject *__restrict self, DeeObject *other);
992994
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_copy(DeeObject *__restrict self, DeeObject *__restrict other);
995+
#ifndef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
993996
INTDEF WUNUSED NONNULL((1, 2, 3)) int DCALL instance_tdeepcopy(DeeTypeObject *tp_self, DeeObject *__restrict self, DeeObject *other);
994997
INTDEF WUNUSED NONNULL((1, 2)) int DCALL instance_deepcopy(DeeObject *__restrict self, DeeObject *__restrict other);
998+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
995999
INTDEF NONNULL((1)) void DCALL instance_destructor(DeeObject *__restrict self); /* No t-variant, because types are unwound automatically during destruction. */
9961000

9971001
/* GC support for class objects. */

include/deemon/compiler/ast.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,18 @@ struct ast {
405405
* >> --sym_read;
406406
* >> ++sym_write;
407407
* This way, symbols can track how often they are written to, or read from. */
408-
# define AST_FACTION_ASSERT 0x1013 /* `assert <act0>' - Assert that <act0> evaluates to true at runtime. */
409-
# define AST_FACTION_ASSERT_M 0x2014 /* `assert <act0>, <act1>' - Assert that <act0> evaluates to true at runtime,
410-
* <act1> is a message that is evaluated and added
411-
* to the error message when the assertion fails. */
408+
# define AST_FACTION_ASSERT 0x1013 /* `assert <act0>' - Assert that <act0> evaluates to true at runtime. */
409+
# define AST_FACTION_ASSERT_M 0x2014 /* `assert <act0>, <act1>' - Assert that <act0> evaluates to true at runtime,
410+
* <act1> is a message that is evaluated and added
411+
* to the error message when the assertion fails. */
412412
# define AST_FACTION_BOUNDATTR 0x2015/* `<act0>.operator . (<act1>) is bound' - Check if the attribute `<act1>' of `<act0>' is currently bound. */
413413
# define AST_FACTION_BOUNDITEM 0x2016/* `<act0>.operator [] (<act1>) is bound' - Check if the item `<act1>' of `<act0>' is currently bound. */
414-
# define AST_FACTION_SAMEOBJ 0x2017 /* `<act0> === <act1>' - Check if <act0> and <act1> are the same object */
415-
# define AST_FACTION_DIFFOBJ 0x2018 /* `<act0> !== <act1>' - Check if <act0> and <act1> are the different objects */
414+
# define AST_FACTION_SAMEOBJ 0x2017 /* `<act0> === <act1>' - Check if <act0> and <act1> are the same object */
415+
# define AST_FACTION_DIFFOBJ 0x2018 /* `<act0> !== <act1>' - Check if <act0> and <act1> are the different objects */
416416
# define AST_FACTION_CALL_KW 0x3019 /* `<act0>(<act1>..., **<act2>)' - Call `act0' with `act1', while also passing keywords from `act2' */
417+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
418+
# define AST_FACTION_DEEPCOPY 0x101a /* `deepcopy <act0>' - Create a deep copy of `act0' */
419+
#endif /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
417420
struct {
418421
DREF struct ast *a_act0; /* [0..1] Primary action operand or NULL when not used. */
419422
DREF struct ast *a_act1; /* [0..1] Secondary action operand or NULL when not used. */
@@ -628,10 +631,16 @@ struct ast {
628631

629632
/* Automatically generate moveassign operations when the
630633
* right-hand-size has been modulated using a copy/deepcopy operator. */
634+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
635+
#define AST_SHOULD_MOVEASSIGN(x) \
636+
(((x)->a_type == AST_OPERATOR && (x)->a_flag == OPERATOR_COPY) || \
637+
((x)->a_type == AST_ACTION && (x)->a_flag == AST_FACTION_DEEPCOPY))
638+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
631639
#define AST_SHOULD_MOVEASSIGN(x) \
632640
((x)->a_type == AST_OPERATOR && \
633641
((x)->a_flag == OPERATOR_COPY || \
634642
(x)->a_flag == OPERATOR_DEEPCOPY))
643+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
635644
#define AST_ISNONE(x) ((x)->a_type == AST_CONSTEXPR && DeeNone_Check((x)->a_constexpr))
636645
#define AST_HASDDI(x) ((x)->ast_ddi.l_file != NULL)
637646

include/deemon/compiler/lexer.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ DEF_M_IF(__POSIX__, HAS(EXT_SYSTEM_MACROS)) /* DEPRECATED! */
207207
DEF_M_IF(__unix__, HAS(EXT_SYSTEM_MACROS))
208208
#endif /* CONFIG_HOST_UNIX */
209209

210+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
211+
#undef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
212+
/* Don't use this macro in user-code -- only here for compat
213+
* in standard library until this feature becomes mandatory! */
214+
DEF_M(CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR)
215+
#define CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
216+
#endif /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
217+
210218

211219
WGROUP(WG_SYMBOL, "symbol", WSTATE_FATAL)
212220
WGROUP(WG_IMPLICIT, "implicit", WSTATE_FATAL)

include/deemon/object.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,11 @@ struct Dee_type_constructor {
17711771
struct {
17721772
WUNUSED_T NONNULL_T((1)) int (DCALL *tp_ctor)(DeeObject *__restrict self);
17731773
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_copy_ctor)(DeeObject *__restrict self, DeeObject *__restrict other);
1774+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
1775+
Dee_funptr_t _unused_tp_deep_ctor;
1776+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
17741777
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_deep_ctor)(DeeObject *__restrict self, DeeObject *__restrict other);
1778+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
17751779
WUNUSED_T NONNULL_T((1)) ATTR_INS_T(3, 2) int (DCALL *tp_any_ctor)(DeeObject *__restrict self, size_t argc, DeeObject *const *argv);
17761780

17771781
/* WARNING: `tp_any_ctor_kw' may be invoked with `argc == 0 && kw == NULL',
@@ -1830,7 +1834,11 @@ struct Dee_type_constructor {
18301834
*/
18311835
WUNUSED_T DREF DeeObject *(DCALL *tp_ctor)(void);
18321836
WUNUSED_T NONNULL_T((1)) DREF DeeObject *(DCALL *tp_copy_ctor)(DeeObject *__restrict other);
1837+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
1838+
Dee_funptr_t _unused_tp_deep_ctor;
1839+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
18331840
WUNUSED_T NONNULL_T((1)) DREF DeeObject *(DCALL *tp_deep_ctor)(DeeObject *__restrict other);
1841+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
18341842
WUNUSED_T ATTR_INS_T(2, 1) DREF DeeObject *(DCALL *tp_any_ctor)(size_t argc, DeeObject *const *argv);
18351843
/* WARNING: `tp_any_ctor_kw' may be invoked with `argc == 0 && kw == NULL',
18361844
* even when `tp_ctor' or `tp_any_ctor' has been defined as non-NULL! */
@@ -1866,6 +1874,9 @@ struct Dee_type_constructor {
18661874
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_assign)(DeeObject *self, DeeObject *some_object);
18671875
WUNUSED_T NONNULL_T((1, 2)) int (DCALL *tp_move_assign)(DeeObject *self, DeeObject *other);
18681876

1877+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
1878+
WUNUSED_T NONNULL_T((1)) int (DCALL *_unused_tp_deepload)(DeeObject *__restrict self);
1879+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
18691880
/* Following a previously successful construction using the `tp_deep_ctor' operator,
18701881
* go through all member objects of the type and replace them with deep copies.
18711882
* This operator is required to provide a safe way for GC objects to be
@@ -1915,6 +1926,7 @@ struct Dee_type_constructor {
19151926
* @return: == 0: Success
19161927
* @return: != 0: Error was thrown */
19171928
WUNUSED_T NONNULL_T((1)) int (DCALL *tp_deepload)(DeeObject *__restrict self);
1929+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
19181930

19191931
/* Callback for `DeeObject_Destroy()' (usually auto-assigned by
19201932
* `DeeType_RequireDestroy()', but can be overwritten with a
@@ -3255,7 +3267,9 @@ template<class _TSelf> Dee_boundmethod_t _Dee_RequiresBoundMethod(WUNUSED_T NONN
32553267
#define Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTSTR 0x00000200 /* >> (for (local x: thisarg) IS_CONSTEXPR(x.operator str)) && ...; */
32563268
#define Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTREPR 0x00000300 /* >> (for (local x: thisarg) IS_CONSTEXPR(x.operator repr)) && ...; */
32573269
#define Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTHASH 0x00000400 /* >> (for (local x: thisarg) IS_CONSTEXPR(x.operator hash)) && ...; */
3270+
#ifndef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
32583271
#define Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTDEEP 0x00000500 /* >> (for (local x: thisarg) IS_CONSTEXPR(x.operator deepcopy)) && ...; */
3272+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
32593273
#define Dee_METHOD_FCONSTCALL_IF_SEQ_CONSTCMPEQ 0x00000600 /* >> (for (local arg: ...) IS_CONSTEXPR(arg.operator iter) && (for (local a, b: zip(thisarg, arg)) IS_CONSTEXPR(a == b, a != b, [a.operator hash(), b.operator hash()]))) && ...; */
32603274
#define Dee_METHOD_FCONSTCALL_IF_SEQ_CONSTCMP 0x00000700 /* >> (for (local arg: ...) IS_CONSTEXPR(arg.operator iter) && (for (local a, b: zip(thisarg, arg)) IS_CONSTEXPR(a == b, a != b, a < b, a > b, a <= b, a >= b))) && ...; */
32613275
#define Dee_METHOD_FCONSTCALL_IF_SEQ_CONSTCONTAINS 0x00000800 /* >> (for (local arg: ...) for (local elem: thisarg) IS_CONSTEXPR(elem == arg)) && ...; */
@@ -3288,7 +3302,9 @@ template<class _TSelf> Dee_boundmethod_t _Dee_RequiresBoundMethod(WUNUSED_T NONN
32883302
#define METHOD_FCONSTCALL_IF_THISELEM_CONSTSTR Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTSTR
32893303
#define METHOD_FCONSTCALL_IF_THISELEM_CONSTREPR Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTREPR
32903304
#define METHOD_FCONSTCALL_IF_THISELEM_CONSTHASH Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTHASH
3305+
#ifndef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
32913306
#define METHOD_FCONSTCALL_IF_THISELEM_CONSTDEEP Dee_METHOD_FCONSTCALL_IF_THISELEM_CONSTDEEP
3307+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
32923308
#define METHOD_FCONSTCALL_IF_SEQ_CONSTCMPEQ Dee_METHOD_FCONSTCALL_IF_SEQ_CONSTCMPEQ
32933309
#define METHOD_FCONSTCALL_IF_SEQ_CONSTCMP Dee_METHOD_FCONSTCALL_IF_SEQ_CONSTCMP
32943310
#define METHOD_FCONSTCALL_IF_SEQ_CONSTCONTAINS Dee_METHOD_FCONSTCALL_IF_SEQ_CONSTCONTAINS
@@ -3767,7 +3783,11 @@ typedef uint16_t Dee_operator_t;
37673783
/* Universal operator codes. */
37683784
#define OPERATOR_CONSTRUCTOR 0x0000 /* `operator this(args...)' - `__constructor__' - `tp_any_ctor'. */
37693785
#define OPERATOR_COPY 0x0001 /* `operator copy(other: type(this))' - `__copy__' - `tp_copy_ctor'. */
3786+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
3787+
#define OPERATOR_SERIALIZE 0x0002 /* `operator serialize(TODO)' - `__serialize__' - `tp_serialize'. */
3788+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
37703789
#define OPERATOR_DEEPCOPY 0x0002 /* `operator deepcopy(other: type(this))' - `__deepcopy__' - `tp_deep_ctor'. */
3790+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
37713791
#define OPERATOR_DESTRUCTOR 0x0003 /* `operator ~this()' - `__destructor__' - `tp_dtor'. */
37723792
#define OPERATOR_ASSIGN 0x0004 /* `operator := (other: Object)' - `__assign__' - `tp_assign'. */
37733793
#define OPERATOR_MOVEASSIGN 0x0005 /* `operator move := (other: type(this))' - `__moveassign__' - `tp_move_assign'. */
@@ -3864,7 +3884,11 @@ typedef uint16_t Dee_operator_t;
38643884
* a lexicographical line sort. */
38653885
#define OPERATOR_0000_CONSTRUCTOR OPERATOR_CONSTRUCTOR
38663886
#define OPERATOR_0001_COPY OPERATOR_COPY
3887+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
3888+
#define OPERATOR_0002_SERIALIZE OPERATOR_SERIALIZE
3889+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
38673890
#define OPERATOR_0002_DEEPCOPY OPERATOR_DEEPCOPY
3891+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
38683892
#define OPERATOR_0003_DESTRUCTOR OPERATOR_DESTRUCTOR
38693893
#define OPERATOR_0004_ASSIGN OPERATOR_ASSIGN
38703894
#define OPERATOR_0005_MOVEASSIGN OPERATOR_MOVEASSIGN
@@ -4346,7 +4370,11 @@ struct Dee_type_object {
43464370
#define DeeType_IsNoArgConstructible(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_init.tp_alloc.tp_ctor != NULL)
43474371
#define DeeType_IsVarArgConstructible(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_init.tp_alloc.tp_any_ctor != NULL || ((DeeTypeObject const *)(x))->tp_init.tp_alloc.tp_any_ctor_kw != NULL)
43484372
#define DeeType_IsConstructible(x) (DeeType_IsSuperConstructible(x) || DeeType_IsNoArgConstructible(x) || DeeType_IsVarArgConstructible(x))
4349-
#define DeeType_IsCopyable(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_init.tp_alloc.tp_copy_ctor != NULL || ((DeeTypeObject const *)(x))->tp_init.tp_alloc.tp_deep_ctor != NULL)
4373+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
4374+
#define DeeType_IsCopyable(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_init.tp_alloc.tp_copy_ctor != NULL) /* TODO: What about inherited copyability? (Dee_TP_FINHERITCTOR) */
4375+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
4376+
#define DeeType_IsCopyable(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_init.tp_alloc.tp_copy_ctor != NULL || ((DeeTypeObject const *)(x))->tp_init.tp_alloc.tp_deep_ctor != NULL) /* TODO: What about inherited copyability? (Dee_TP_FINHERITCTOR) */
4377+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
43504378
#define DeeType_IsNamespace(x) ((Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_flags & (Dee_TP_FFINAL | Dee_TP_FABSTRACT)) == (Dee_TP_FFINAL | Dee_TP_FABSTRACT) && (((DeeTypeObject const *)(x))->tp_features & Dee_TF_SINGLETON))
43514379
#define DeeType_Base(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_base)
43524380
#define DeeType_GCPriority(x) (Dee_REQUIRES_OBJECT(DeeTypeObject const, x)->tp_gc ? ((DeeTypeObject const *)(x))->tp_gc->tp_gcprio : Dee_GC_PRIORITY_LATE)

lib/operators.dee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ function bind(tp: Type, operator_function: Callable): Callable {
5858
* still something they're allowed to do. */
5959
varying function constructor(self, args...): none -> self.operator constructor(args...);
6060
varying function copy(self) -> copy self;
61+
#ifdef CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR
62+
varying function serialize(self, args...) -> self.operator serialize(args...);
63+
#else /* CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
6164
varying function deepcopy(self) -> deepcopy self;
65+
#endif /* !CONFIG_EXPERIMENTAL_SERIALIZE_OPERATOR */
6266
varying function destructor(self): none -> self.operator destructor();
6367
varying function assign(self, other) -> self := other;
6468
varying function moveassign(self, other) -> self.operator move := (other);

0 commit comments

Comments
 (0)