Open Genhis opened 4 years ago
Duplicate of krpc/krpc#63
I agree this would be a good addition. I will draw up a design for this.
if a base class have KRPCClass annotation, all classes derived from it should be exported and create a correct hierarchy.
I think we should require explicit KRPCClass annotations on all classes that you want to be exposed to clients. That way you have complete control over what's exposed. For example, you might have base class A, and classes B, C and D that derive from it. You might want to expose A, B and C to the client but not D.
What we need to implement is:
Open questions:
It's been a long time since I wrote this request, so I don't remember all details about how I imagined certain things to function.
KRPCClass
annotations can also be required for derived classes.I agree we should just try and follow C# rules. I think this will be fine for most clients that support OOP.
The interesting one would be the Cnano client. I think it'll be doable though. I'll have a go at a proof of concept implementation.
In my service, I have classes which share common functionality, so I set up an inheritance hierarchy. However, this hierarchy is not preserved when I generate client code. Instead, the common functionality is duplicated for each derived class annotated with
KRPCClass
which prevents me from using benefits of inheritance on the client side, such as creating a list of objects with the same base class. Although not all languages may support inheritance, it would be nice to have it at least in languages which support it.After doing some research, I believe the following parts would need changing to support this feature:
KRPCClass
To conclude my examples below, if a base class have
KRPCClass
annotation, all classes derived from it should be exported and create a correct hierarchy. The derived classes do not need to haveKRPCClass
annotation. This is just my opinion on how I would use the API, and I welcome further discussion.I would love to help with the implementation but currently I am having issues with making this project compile on Windows. I think I am missing some dependencies but I don't know which ones exactly.
Examples:
How I would use it in Java: