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

Remove FieldTemplate<> from field reflection type #374

Closed
wants to merge 8 commits into from
Closed

Remove FieldTemplate<> from field reflection type #374

wants to merge 8 commits into from

Conversation

veselinp
Copy link
Contributor

  • FieldTemplate<> params are part of field relfection type, this unnecessary increases generated symbol names.

@msftclas
Copy link

@veselinp,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

Copy link
Member

@chwarr chwarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Clang build is failing with this change. Can you look into what's wrong?

CHANGELOG.md Outdated
### C++ & `gbc` ###

* Remove FieldTemplate details from field reflection type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: there's a gbc section right below where this would make more sense. Consider also duplicating the entry in the C++ section as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

CHANGELOG.md Outdated
@@ -19,6 +19,10 @@ different versioning scheme, following the Haskell community's
* C# NuGet version: TBD (minor bump needed)
* C# Comm NuGet version: TBD (minor bump needed)

### C++ & `gbc` ###

* Remove FieldTemplate details from field reflection type.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: can you expand on this and say why we're making the change (to shorten the symbol names)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@veselinp
Copy link
Contributor Author

I've pushed a fixup, clang should be happy now.

@chadwalters
Copy link
Contributor

clang build is happy. Looks like VC12 is still broken though.

@veselinp
Copy link
Contributor Author

vc12 doesn't understand constexpr :)

@veselinp
Copy link
Contributor Author

now, clang is broken, I'm looking again

ordered_non_unique_field<SimpleStructView::Schema::var::m_str>,
ordered_non_unique_field<SimpleStructView::Schema::var::m_uint64>
ordered_non_unique_field<SimpleStructView::Schema::var::m_str, get_field_template<SimpleStructView::Schema::var::m_str>::type>,
ordered_non_unique_field<SimpleStructView::Schema::var::m_uint64, get_field_template<SimpleStructView::Schema::var::m_uint64>::type>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this part of the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified this, and moved all logic into ordered_non_unique_field<>, please check cpp/test/core/multi_index.h

vc12 doesn't support constexp - ordered_non_unique_field requires member field address in compile time, which can be resolved via FieldTemplate.

CHANGELOG.md Outdated
@@ -21,6 +21,9 @@ different versioning scheme, following the Haskell community's

### `gbc` and Bond compiler library ###

* C++ codegen generates field reflection, that uses an explicit type
derrived from reflection::FieldTemplate. This hides FieldTemplate
details and, as result, shortens symbol names.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Change to "C++ codegen hides FieldTemplate details, shortening symbol names."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@chwarr
Copy link
Member

chwarr commented Apr 10, 2017

I will look again later today.

@@ -101,24 +101,21 @@ struct FieldTemplate
/// @brief Static data member describing field metadata
static const Metadata& metadata;

/// @brief Static data member representing the field pointer
static const field_pointer field;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a breaking change (removal of public member of public interface). Is it intentional? If so, what's motivating making this breaking change?

It appears that the replacement for this functionality is &theFieldType.GetVariable(someStruct).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, let me revisit this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this materially reduces the lib and PDB size, then it's something we can consider. The next release for C++ will have some other breaking changes (albeit minor ones) like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it back for now, we may want to handle vc12 explicitly to remove this symbol from generated .obj files.

@@ -26,14 +26,14 @@ class def_readwrite_property
: c(c)
{}

template <typename Field>
void operator()(const Field&) const
template <uint16_t field_id, typename ModifierTag, typename Struct, typename FieldType, FieldType Struct::*field_ptr, const bond::Metadata* metadata_ptr>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change required to get this to build?

  • If so, then the introduction of the anonymous struct is not working as I'd expect it to (the anonymous struct should have an is a relationship with FieldTemplate), and is a large breaking change.
  • If this was just done to clean up the code, that's fine, but I need to get confirmation from you.

Copy link
Contributor Author

@veselinp veselinp Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is related to FieldTemplate<>::field change. I will revert this file for now.

Copy link
Member

@chwarr chwarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this in now. By the way, I needed to fix up the changelog section. That merge didn't go well.

CI failure is MSVC 2013 timeout...

@chwarr chwarr closed this in 906272b Apr 25, 2017
@veselinp veselinp deleted the hide_field_template_details_from_reflection branch May 1, 2017 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants