-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Is your feature request related to a problem? Please describe.
It seems that CMakePPLang classes support a feature called "extension attributes/methods" in other languages like Kotlin or C#. The feature allows external parties to define additional methods and attributes on a class outside of the cpp_class/cpp_end_class fences. I believe support for this feature is merely a byproduct of how classes were implemented, but nevertheless, I could not find any documentation on it.
Example usage:
cpp_class(MyClass)
cpp_attr(MyClass a 1)
cpp_attr(MyClass b 2)
cpp_end_class()
# Create instance
MyClass(CTOR my_instance)
# In a different file
# Add a new attribute
cpp_attr(MyClass c 4)
# Set attribute as single value, noting that
# the instance we created earlier now has the new attribute
MyClass(SET "${my_instance}" c 3)
# Get the value and ensure it was set correctly
MyClass(GET "${my_instance}" res c)
ct_assert_equal(res 3)Describe the solution you'd like
I think it would be wise to at least document the current ability to use extension attributes/methods, perhaps adding that such usage is unstable and not guaranteed to work in future versions unless we desire to officially support them. Otherwise, it might be a good idea to explicitly disallow them, which can be done by "freezing" a class's definition upon calling cpp_end_class().
This issue is very low priority, mainly I'm just writing it down because I made the observation and wondered if such usage was officially supported or not.