Skip to content

Any methods to make attribute declarable in C++ as well? #89

@roxk

Description

@roxk

Right now the only (popular) feature of midl that requires non-trivial annotation is attribute. Commonly used attribute include:

  1. Windows repo's contract
  2. Xaml content
  3. bindable

Is it possible to declare these in C++ as well without needing to write [[idlgen::attribute("bindable",)]]? Note that C++ attribute is not extensible.


Idea

struct based

namespace idlgen
{
template <char const* Property = nullptr>
struct attribute
{
};
}

namespace wux
{
struct bindable_attribute : idlgen::attribute<>
{
};
template<char const* Property>
struct content_property_attribute : idlgen::attribute<Property>
{
};
}

const char property_name[] = "Property";
struct ViewModel : ViewModelT<ViewModel>, bindable_attribute, content_property_attribute<property_name>
{
}

SO says it's possible to use const char* as template parameter. Since we need to support C++17 C++20's std::string-in-template-parameter is not something idlgen can enjoy yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions