From 0ccce3412e0d3954aa5bc9c9b7f959789f3d6ffa Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 27 Apr 2020 17:08:54 -0500 Subject: [PATCH 01/11] add df-other-vectors-type. --- SYNTAX.rst | 8 ++++++++ StructType.pm | 6 ++++++ data-definition.xsd | 14 ++++++++++++++ df.building-vectors.xml | 4 ++++ df.item-vectors.xml | 3 +++ df.world.xml | 15 ++++++--------- lower-1.xslt | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 74 insertions(+), 9 deletions(-) diff --git a/SYNTAX.rst b/SYNTAX.rst index 45f670215..1b1a4bde8 100644 --- a/SYNTAX.rst +++ b/SYNTAX.rst @@ -541,6 +541,14 @@ These are defined in df-code.lisp: with some extra code to make it easier to interact with. +```` + + Defines a tuple of vectors with the same base type. Individual vectors act as if they were defined as:: + + + + where ``FOO_KEY`` is a key in the ``foo_other_id`` enum. + Class type definition ===================== diff --git a/StructType.pm b/StructType.pm index 1c2e1486f..a32adc2d1 100644 --- a/StructType.pm +++ b/StructType.pm @@ -195,6 +195,8 @@ sub render_struct_type { my $item_type = $tag->getAttribute('item-type'); my $list_link_type = $tag->getAttribute('df-list-link-type'); my $list_link_field = $tag->getAttribute('df-list-link-field'); + my $is_other_vectors = (($tag->getAttribute('ld:subtype') or '') eq 'df-other-vectors-type'); + my $index_enum = $tag->getAttribute('index-enum'); my $custom_methods = is_attr_true($tag, 'custom-methods') || $tag->findnodes('custom-methods/cmethod'); my $has_methods = $is_class || is_attr_true($tag, 'has-methods'); my $inherits = $tag->getAttribute('inherits-from'); @@ -218,6 +220,10 @@ sub render_struct_type { } elsif ($is_linked_list) { register_ref $item_type, 1; $ispec = ' : DfLinkedList<'.$typename.', '.$item_type.'>'; + } elsif ($is_other_vectors) { + register_ref $item_type, 1; + register_ref $index_enum, 1; + $ispec = ' : DfOtherVectors<'.$typename.', '.$index_enum.', '.$item_type.'>'; } if ($list_link_type) { diff --git a/data-definition.xsd b/data-definition.xsd index b66c33873..7ee85475c 100644 --- a/data-definition.xsd +++ b/data-definition.xsd @@ -39,6 +39,7 @@ + @@ -155,6 +156,19 @@ + + + + + + + + + + + + + diff --git a/df.building-vectors.xml b/df.building-vectors.xml index 3bd21eaa9..a4ac604f2 100644 --- a/df.building-vectors.xml +++ b/df.building-vectors.xml @@ -379,6 +379,10 @@ + + + + From 7fb6d10877279ca3fc1f85c53d128d255ca8515f Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 27 Apr 2020 18:30:17 -0500 Subject: [PATCH 02/11] forgot that attributes go last in XSD --- data-definition.xsd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data-definition.xsd b/data-definition.xsd index 7ee85475c..d90fef6be 100644 --- a/data-definition.xsd +++ b/data-definition.xsd @@ -159,13 +159,13 @@ + + + - - - From 68a4cd269238e6d9680e1b6ad58e3eafcc5d7c5b Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 27 Apr 2020 18:56:18 -0500 Subject: [PATCH 03/11] use a weak reference to the vector pointer type --- StructType.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StructType.pm b/StructType.pm index a32adc2d1..b53157e39 100644 --- a/StructType.pm +++ b/StructType.pm @@ -221,7 +221,7 @@ sub render_struct_type { register_ref $item_type, 1; $ispec = ' : DfLinkedList<'.$typename.', '.$item_type.'>'; } elsif ($is_other_vectors) { - register_ref $item_type, 1; + register_ref $item_type, 0; register_ref $index_enum, 1; $ispec = ' : DfOtherVectors<'.$typename.', '.$index_enum.', '.$item_type.'>'; } From 39764b488fbe30e88947406c93546e3508aa4d4a Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Mon, 27 Apr 2020 18:59:18 -0500 Subject: [PATCH 04/11] skip explicitly negative enum items for df-other-vectors-type --- lower-1.xslt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lower-1.xslt b/lower-1.xslt index b657c5d5a..5e9c692d9 100644 --- a/lower-1.xslt +++ b/lower-1.xslt @@ -82,7 +82,7 @@ - + From 20bf25312dde9306c950fe362e0b611bd00c6e0e Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 12:09:48 -0500 Subject: [PATCH 05/11] allow code-helper, comment, and since in df-other-vectors-type --- lower-1.xslt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lower-1.xslt b/lower-1.xslt index 5e9c692d9..4275e8f3a 100644 --- a/lower-1.xslt +++ b/lower-1.xslt @@ -82,6 +82,11 @@ + + + + + From dd855e65b044a1ae5a9123a1da6263982d7705c8 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 12:11:29 -0500 Subject: [PATCH 06/11] allow allow the shared attributes/elements in the xsd for df-other-vectors-type --- data-definition.xsd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data-definition.xsd b/data-definition.xsd index d90fef6be..a192a7e92 100644 --- a/data-definition.xsd +++ b/data-definition.xsd @@ -160,8 +160,10 @@ + + From fa1d3172ab27769e02fd0fbd3c32e39288a090b7 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 12:20:15 -0500 Subject: [PATCH 07/11] fix generated other vectors not having types correctly set --- lower-1.xslt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lower-1.xslt b/lower-1.xslt index 4275e8f3a..feb4e1830 100644 --- a/lower-1.xslt +++ b/lower-1.xslt @@ -98,15 +98,15 @@ - - - + + + - - + + From 46c32860457c8017c20ceb98d504bb4dff630b7c Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 12:27:15 -0500 Subject: [PATCH 08/11] SharedAttributes is already pulled in by TypeDef --- data-definition.xsd | 1 - 1 file changed, 1 deletion(-) diff --git a/data-definition.xsd b/data-definition.xsd index a192a7e92..ffdbb3334 100644 --- a/data-definition.xsd +++ b/data-definition.xsd @@ -163,7 +163,6 @@ - From 3244170f42b22bce571c06311d4e23680fcf0e1b Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 12:46:16 -0500 Subject: [PATCH 09/11] create other_vectors_identity type --- StructFields.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/StructFields.pm b/StructFields.pm index 42b73225f..65ee580de 100644 --- a/StructFields.pm +++ b/StructFields.pm @@ -560,10 +560,17 @@ sub emit_struct_fields($$;%) { &render_struct_field($_) for @fields; my $identity_type = 'struct_identity'; + my $maybe_index_enum = ''; if ($flags{-class}) { $identity_type = 'virtual_identity'; } elsif (is_attr_true($tag, 'is-union')) { $identity_type = 'union_identity'; + } elsif (($tag->getAttribute('ld:subtype') or '') eq 'df-other-vectors-type') { + $identity_type = 'other_vectors_identity'; + my $xe = $tag->getAttribute('index-enum'); + #static_include_type $xe; + my $enum = type_identity_reference($types{$xe}); + $maybe_index_enum = ', '.$enum; } my $full_name = fully_qualified_name($tag, $name, 1); @@ -657,7 +664,7 @@ sub emit_struct_fields($$;%) { type_identity_reference($tag,-parent => 1), ', ', "\"$name\", ", ($inherits ? "&${inherits}::_identity" : 'NULL'), ', ', - "$ftable);"; + "${ftable}${maybe_index_enum});"; } } 'fields-' . $fields_group; } From 944b7f5d6cd1e41b00a0f219ca51678f37b16c89 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 28 Apr 2020 14:59:24 -0500 Subject: [PATCH 10/11] define types of other vectors --- df.building-vectors.xml | 80 ++++++++++++++++++++++++++++++++ df.item-vectors.xml | 100 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) diff --git a/df.building-vectors.xml b/df.building-vectors.xml index a4ac604f2..a1224a7fb 100644 --- a/df.building-vectors.xml +++ b/df.building-vectors.xml @@ -381,7 +381,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/df.item-vectors.xml b/df.item-vectors.xml index a4f259af4..ef38a75eb 100644 --- a/df.item-vectors.xml +++ b/df.item-vectors.xml @@ -791,6 +791,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a2e3a62358e4d89cca6a79f52fde20499a2cf34b Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 30 Apr 2020 17:56:20 -0500 Subject: [PATCH 11/11] add some more error checking to the xslt implementation of df-other-vectors-type --- lower-1.xslt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lower-1.xslt b/lower-1.xslt index feb4e1830..52ab43230 100644 --- a/lower-1.xslt +++ b/lower-1.xslt @@ -81,6 +81,30 @@ + + +Error: df-other-vectors-type may only contain stl-vector fields. () + + + + + + + + + + +Error: field is not a member of enum + + + + +Error: field corresponds to an enum value of + + + + +