Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata for Structs #401

Merged
merged 158 commits into from
May 15, 2019
Merged
Show file tree
Hide file tree
Changes from 156 commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
9efb7d5
Initial exploration
kythant Apr 4, 2019
98a4824
Initial update
timr1126 Apr 10, 2019
48b555f
Clean up models
timr1126 Apr 13, 2019
b643b53
Update model method signatures
timr1126 Apr 15, 2019
688baa4
This shit keeps happening
kythant Apr 15, 2019
8fc39d1
Merge branch 'user/kythant/parser' of https://github.com/Microsoft/xl…
kythant Apr 15, 2019
b09c4fb
Merge branch 'timr1126/xmeta-model-update' of https://github.com/Micr…
kythant Apr 15, 2019
9dcd2ae
Add model_ref class and cleanup
timr1126 Apr 15, 2019
366bd3b
checkpoint
kythant Apr 15, 2019
f849420
Add assembly name to base_model
timr1126 Apr 15, 2019
bf694a1
Add accessors to namespace children and bodies
timr1126 Apr 15, 2019
f0ab9bb
Merge branch 'timr1126/xmeta-model-update' of https://github.com/Micr…
kythant Apr 16, 2019
7b469ef
Add more accessors to enums and namespace members
timr1126 Apr 15, 2019
5615b3b
Merge branch 'timr1126/xmeta-model-update' of https://github.com/Micr…
kythant Apr 16, 2019
9709740
Move implementations from cpp to headers
timr1126 Apr 16, 2019
02b5c1a
Merge branch 'timr1126/xmeta-model-update' of https://github.com/Micr…
kythant Apr 16, 2019
84d73c9
checkpoint
kythant Apr 16, 2019
ce342ed
build succeeded
kythant Apr 16, 2019
8d6901b
Merge branch 'user/kythant/parser' of https://github.com/Microsoft/xl…
kythant Apr 16, 2019
8682c72
checkpoint
kythant Apr 16, 2019
d46d79e
chkpt
kythant Apr 16, 2019
9b12ed7
chkpnt
kythant Apr 17, 2019
1ca01ae
chkpt
kythant Apr 17, 2019
920af2a
chkpt
kythant Apr 17, 2019
a3cb53c
chkpt
kythant Apr 17, 2019
4ccd55e
Add parent reference to class and interface in event method and property
kythant Apr 17, 2019
7103e73
Update constructor to set parent
kythant Apr 17, 2019
f33ea6f
merged
kythant Apr 17, 2019
c716024
delete
kythant Apr 17, 2019
239d882
Merge branch 'kythant/modelupdate' of https://github.com/Microsoft/xl…
kythant Apr 17, 2019
09154f0
Walker now only walks through namespace declaration
kythant Apr 18, 2019
72a258d
Using winrt base and updates to xmeta emit
kythant Apr 18, 2019
23a1562
raw ptrs to com ptrs
kythant Apr 18, 2019
6a0366b
Added delegate metadata emit
kythant Apr 18, 2019
84c99f3
updated initialization xmeta_emit
kythant Apr 18, 2019
4026745
Merge branch 'user/kythant/parser' of https://github.com/Microsoft/xl…
kythant Apr 18, 2019
8f27bb3
merge
kythant Apr 18, 2019
c29b961
chkpt
kythant Apr 19, 2019
3aa9a51
check hresults
kythant Apr 19, 2019
7f15b08
chkpt
kythant Apr 19, 2019
d9df5f5
Define return type
kythant Apr 19, 2019
c660d10
chkpt
kythant Apr 19, 2019
5b7cb8b
chkpt: I made a test that spit out metadata with only aseembly name a…
kythant Apr 19, 2019
108c225
polish
kythant Apr 19, 2019
68204fb
Fix R value cstr usage
kythant Apr 20, 2019
ebba287
Merge remote-tracking branch 'origin/user/kythant/parser' into kythan…
DefaultRyan Apr 20, 2019
787878f
Minor CMake cleanup
DefaultRyan Apr 20, 2019
df89522
Merge remote-tracking branch 'origin/user/kythant/parser' into kythan…
DefaultRyan Apr 21, 2019
95f1525
Mark .zip files as binary to avoid corruption
DefaultRyan Apr 21, 2019
dc2bedd
Merge remote-tracking branch 'origin/user/kythant/parser' into kythan…
DefaultRyan Apr 21, 2019
59e24e2
fix break with merge conflict
kythant Apr 21, 2019
fd8995d
merge
kythant Apr 21, 2019
c0aa492
Populate enum fields. Tweak behavior of model_ref with multiple alter…
DefaultRyan Apr 21, 2019
ebfb17e
save_to_memory should return a vector
DefaultRyan Apr 22, 2019
32d00f1
merge
kythant Apr 22, 2019
f9a2635
Merge remote-tracking branch 'origin/user/kythant/parser' into kythan…
DefaultRyan Apr 23, 2019
c00fdf7
Merge remote-tracking branch 'origin/user/kythant/parser' into kythan…
DefaultRyan Apr 23, 2019
10295b5
this shit works and the other branch doesn't
kythant Apr 23, 2019
c4aad90
main
kythant Apr 23, 2019
19e3b33
chkpt
kythant Apr 23, 2019
362e01f
chkpt
kythant Apr 23, 2019
9a649e9
Fix malformed type signature blobs
DefaultRyan Apr 23, 2019
7980206
update test
kythant Apr 23, 2019
d6eb78d
polish
kythant Apr 23, 2019
cedd328
whitespace
kythant Apr 23, 2019
d348456
build changes
kythant Apr 24, 2019
a6717e1
small cmake fix
kythant Apr 24, 2019
3daa760
move initialize stuff to constructor
kythant Apr 24, 2019
196e8e5
testing for enum base type
kythant Apr 24, 2019
9a9b9af
Move xmeta_emit to a different library, win32 settings on cmake
kythant Apr 24, 2019
d850b1d
string view in emit
kythant Apr 24, 2019
692461d
const & in walker
kythant Apr 24, 2019
fd3d835
Code review
kythant Apr 24, 2019
9c9051b
new line eof and test_symbol_table changes
kythant Apr 24, 2019
a551c43
Code review
kythant Apr 24, 2019
b830061
fix mistake in symbol table test
kythant Apr 24, 2019
347aab3
code review
kythant Apr 24, 2019
fdafcf3
Change listener member in walker from shared_ptr to reference
kythant Apr 24, 2019
b65278b
Merge branch 'user/kythant/parser' of https://github.com/Microsoft/xl…
kythant Apr 24, 2019
ced710c
Remove extra flags from enum def
kythant Apr 24, 2019
dbe8a10
Reverting that change
kythant Apr 24, 2019
1b10868
eof
kythant Apr 25, 2019
bf13e13
Modified xlang model listener
kythant Apr 25, 2019
27800b2
tabs to spaces
kythant Apr 25, 2019
f1ca24f
delegate type flag back in for consistency
kythant Apr 25, 2019
822ab6e
Code review
kythant Apr 26, 2019
e92e4bf
Initial delegate metadata
kythant Apr 26, 2019
5ad0f3f
create param
kythant Apr 26, 2019
a76db93
test signature
kythant Apr 26, 2019
50a68de
Fix signature writer bugs
DefaultRyan Apr 26, 2019
6e3bf32
chkpt
kythant Apr 26, 2019
24ef822
merge
kythant Apr 26, 2019
0114927
Added namespaces to enum
kythant Apr 26, 2019
a393d9d
remove header
kythant Apr 26, 2019
7672eaf
merge
kythant Apr 26, 2019
a44d184
RetTypeSig should throw an error if attempting to retrieve a nonexist…
DefaultRyan Apr 26, 2019
d2b679f
chkpt
kythant Apr 27, 2019
d8044db
Merge branch 'kythant/delegateMd' of https://github.com/Microsoft/xla…
kythant Apr 27, 2019
3e0e37c
tests written
kythant Apr 29, 2019
90cef2e
Delegate population
kythant Apr 30, 2019
89b5326
change tabs into spaces
kythant Apr 30, 2019
06e5820
eof
kythant Apr 30, 2019
05c05b3
merge
kythant Apr 30, 2019
4d43166
Merge
kythant Apr 30, 2019
829b7cc
chkpt
kythant Apr 30, 2019
dfaf223
Merge branch 'user/kythant/parser' of https://github.com/Microsoft/xl…
kythant Apr 30, 2019
60305a1
chkpt
kythant Apr 30, 2019
923757b
Merge branch 'kythant/DelegateModelPopulation' of https://github.com/…
kythant Apr 30, 2019
da4084e
Adding struct population
May 1, 2019
33eefb2
revert
kythant May 1, 2019
12205a6
struct merge
kythant May 1, 2019
c062395
resolving class types
kythant May 2, 2019
f0ab443
improved test
kythant May 2, 2019
2f626a1
Redeclaration error
kythant May 2, 2019
ed273a7
struct circular case
kythant May 2, 2019
7a42d35
struct circular test
kythant May 2, 2019
aba645e
merge
kythant May 2, 2019
0d00b07
fixes and spacing
kythant May 2, 2019
efdb409
eof
kythant May 2, 2019
0951453
Initial struct metadata code
kythant May 3, 2019
dad27d9
chkpt
kythant May 3, 2019
e3c6465
add get_fully_qualfied_id() to namespace member model
kythant May 3, 2019
7f4c649
polish
kythant May 3, 2019
18a86bd
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 3, 2019
98a35c5
Making test_emit clearer
kythant May 3, 2019
a712d06
Removing fluff
kythant May 3, 2019
1def64e
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 3, 2019
87b7b85
to simple type or id helper fixed
kythant May 3, 2019
971b755
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 3, 2019
b4c08d9
struct metadata tests
kythant May 3, 2019
1942ffc
test that enum typelayout is auto
kythant May 3, 2019
f0f1a84
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 3, 2019
81b7bfc
rename type with using directive
kythant May 6, 2019
a8a3db1
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 6, 2019
43aab2f
test update with flags
kythant May 7, 2019
650d524
test update
kythant May 7, 2019
ca6ada2
fix merging comments
kythant May 7, 2019
721cbf0
testing for struct field flags
kythant May 7, 2019
f250185
test update
kythant May 7, 2019
0d182a3
small test improvement
kythant May 7, 2019
099164d
method impl
kythant May 7, 2019
a71d608
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 7, 2019
3cec7a0
Major refactoring: Moving out error writers and cur fields
kythant May 7, 2019
49aea89
refactor how getting number of syntax errors work
kythant May 7, 2019
ea8fd47
refactors on resolve and struct circular
kythant May 7, 2019
7abf61e
refactoring out more stuff in idl_reader
kythant May 8, 2019
7a1ea5e
struct member duplication test
kythant May 8, 2019
e15d0c6
refactor walker so the reader doesn't pass itself in
kythant May 8, 2019
2498258
quick fix
kythant May 8, 2019
440cab1
code review
kythant May 8, 2019
7641d84
Merge branch 'kythant/DelegateMetadata' of https://github.com/Microso…
kythant May 8, 2019
7f6d77a
struct circular check bug fix
kythant May 9, 2019
5e0b367
const ref
kythant May 9, 2019
d7eb69f
merge
kythant May 10, 2019
63316c9
whitespace and addressing warnings from xmeta_emit
kythant May 10, 2019
d7c4021
fix variable name
kythant May 10, 2019
20e4434
Merge branch 'user/kythant/parser' of https://github.com/Microsoft/xl…
kythant May 13, 2019
e3a35b6
Code review
kythant May 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/library/impl/meta_reader/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ namespace xlang::meta::reader
return extends_type(*this, "System"sv, "MulticastDelegate"sv);
}

inline bool TypeDef::is_struct() const
{
return extends_type(*this, "System"sv, "ValueType"sv);
}

struct EnumDefinition
{
explicit EnumDefinition(TypeDef const& type)
Expand Down
1 change: 1 addition & 0 deletions src/library/impl/meta_reader/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace xlang::meta::reader

bool is_enum() const;
bool is_delegate() const;
bool is_struct() const;
auto get_enum_definition() const;
};

Expand Down
21 changes: 21 additions & 0 deletions src/test/xmeta/example/deprecation_attributes.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//Saving this now to user as a test later
kythant marked this conversation as resolved.
Show resolved Hide resolved

import "RtCopContract.idl";
import "windows.foundation.idl";
namespace Deprecation
{
[contract(RtCop.RtCopContract, 1)]
runtimeclass Muffin
{
UInt32 WeightInGrams { get; };
[deprecated("Muffin is deprecated", deprecate, RtCop.RtCopContract, 2)]
String Flavor { get; };


[deprecated("Muffin is deprecated", deprecate, RtCop.RtCopContract, 2)]
{
void Consume();
Windows.Foundation.IAsyncAction CookAsync();
}
}
}
28 changes: 18 additions & 10 deletions src/test/xmeta/test_lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ TEST_CASE("Namespace Identifier")

xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener) == 0);

reader.read(test_idl, listener);
REQUIRE(reader.get_num_syntax_errors() == 0);
auto& namespaces = listener.namespaces;
REQUIRE(namespaces.find("test") != namespaces.end());
}
Expand All @@ -46,7 +46,8 @@ TEST_CASE("Token identifier with unicode letter character")

xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener) == 0);
reader.read(test_idl, listener);
REQUIRE(reader.get_num_syntax_errors() == 0);
auto& namespaces = listener.namespaces;

REQUIRE(namespaces.find("test1AÆĦdžZ") != namespaces.end()); // LU
Expand All @@ -64,7 +65,8 @@ TEST_CASE("Identifer not starting with letter character")
)" };
xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener, true) != 0);
reader.read(test_idl, listener, true);
REQUIRE(reader.get_num_syntax_errors() != 0);
}

TEST_CASE("Remove comments")
Expand All @@ -76,7 +78,8 @@ TEST_CASE("Remove comments")

xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener) == 0);
reader.read(test_idl, listener);
REQUIRE(reader.get_num_syntax_errors() == 0);
auto& namespaces = listener.namespaces;

REQUIRE(namespaces.find("test") != namespaces.end());
Expand All @@ -93,7 +96,8 @@ TEST_CASE("Spacing")

xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener) == 0);
reader.read(test_idl, listener);
REQUIRE(reader.get_num_syntax_errors() == 0);
auto& namespaces = listener.namespaces;

REQUIRE(namespaces.find("test") != namespaces.end());
Expand All @@ -115,7 +119,8 @@ TEST_CASE("Lexer uuid")

xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener) == 0);
reader.read(test_idl, listener);
REQUIRE(reader.get_num_syntax_errors() == 0);
auto& expressions = listener.expressions;

REQUIRE(expressions.find("b7de5527-4c8f-42dd-84da-5ec493abdb9a") != expressions.end());
Expand Down Expand Up @@ -148,7 +153,8 @@ TEST_CASE("Enum assignments")

xlang_test_listener listener;
xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl, listener) == 0);
reader.read(test_idl, listener);
REQUIRE(reader.get_num_syntax_errors() == 0);
std::set<std::string> &enums = listener.enums;

REQUIRE(enums.find("Color") != enums.end());
Expand Down Expand Up @@ -191,7 +197,9 @@ TEST_CASE("Enum illegal assignments")

xmeta_idl_reader reader{ "" };
xlang_test_listener listener;
REQUIRE(reader.read(test_idl_string_assignment, listener, true) == 1);
reader.read(test_idl_string_assignment, listener, true);
REQUIRE(reader.get_num_syntax_errors() == 1);
kythant marked this conversation as resolved.
Show resolved Hide resolved
listener.reset();
REQUIRE(reader.read(test_idl_float_assignment, listener, true) == 1);
reader.read(test_idl_float_assignment, listener, true);
REQUIRE(reader.get_num_syntax_errors() == 1);
}
106 changes: 85 additions & 21 deletions src/test/xmeta/test_symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ TEST_CASE("Duplicate Namespaces")
)");

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl) == 0);
reader.read(test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down Expand Up @@ -49,7 +50,8 @@ TEST_CASE("Multiple definition error test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl) == 0);
reader.read(test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);
REQUIRE(reader.get_num_semantic_errors() == 3);
}

Expand All @@ -70,7 +72,8 @@ TEST_CASE("Enum test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl) == 0);
reader.read(test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down Expand Up @@ -115,7 +118,8 @@ TEST_CASE("Enum circular implicit dependency")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(implicit_dependency_error_idl) == 0);
reader.read(implicit_dependency_error_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);
REQUIRE(reader.get_num_semantic_errors() == 1);
}

Expand All @@ -133,7 +137,8 @@ TEST_CASE("Enum circular explicit dependency")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(explicit_dependency_error_idl) == 0);
reader.read(explicit_dependency_error_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);
REQUIRE(reader.get_num_semantic_errors() == 1);
}

Expand All @@ -150,7 +155,8 @@ TEST_CASE("Delegate test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl) == 0);
reader.read(test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down Expand Up @@ -204,7 +210,8 @@ TEST_CASE("Struct test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(struct_test_idl) == 0);
reader.read(struct_test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down Expand Up @@ -256,27 +263,81 @@ TEST_CASE("Struct test")

TEST_CASE("Struct circular test")
{
std::istringstream struct_test_idl{ R"(
namespace N
{
struct S1
{
std::istringstream struct_test_idl{ R"(
namespace N
{
S2 field_1;
struct S0
BenJKuhn marked this conversation as resolved.
Show resolved Hide resolved
{
S1 field_1;
}
struct S1
{
S2 field_1;
}
struct S2
{
S3 field_1;
}
struct S3
{
S1 field_1;
}
}
struct S2
)" };

xmeta_idl_reader reader{ "" };
reader.read(struct_test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);
REQUIRE(reader.get_num_semantic_errors() == 4);
kythant marked this conversation as resolved.
Show resolved Hide resolved
}
{
std::istringstream struct_test_idl{ R"(
namespace N
{
S3 field_1;
struct S0
{
S1 field_1;
S2 field_2;
}
struct S1
{
S3 field_1;
}
struct S2
{
S3 field_1;
}
struct S3
{
}
}
struct S3
)" };

xmeta_idl_reader reader{ "" };
reader.read(struct_test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);
REQUIRE(reader.get_num_semantic_errors() == 0);
}
}

TEST_CASE("Struct duplicate member test")
{
std::istringstream struct_test_idl{ R"(
namespace N
{
struct S0
{
S1 field_1;
Int32 field_1;
Int32 field_1;
}
}
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(struct_test_idl) == 0);
REQUIRE(reader.get_num_semantic_errors() == 3);
reader.read(struct_test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);
REQUIRE(reader.get_num_semantic_errors() == 1);
auto namespaces = reader.get_namespaces();
}

Expand All @@ -298,7 +359,8 @@ TEST_CASE("Resolving delegates types test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl) == 0);
reader.read(test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down Expand Up @@ -361,7 +423,8 @@ TEST_CASE("Resolving struct types test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(struct_test_idl) == 0);
reader.read(struct_test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down Expand Up @@ -419,7 +482,8 @@ TEST_CASE("Resolving types across namespaces test")
)" };

xmeta_idl_reader reader{ "" };
REQUIRE(reader.read(test_idl) == 0);
reader.read(test_idl);
REQUIRE(reader.get_num_syntax_errors() == 0);

auto namespaces = reader.get_namespaces();
auto it = namespaces.find("N");
Expand Down
Loading