Re: get/set wrap methods.



What does your _MEMBER_GET() macros look like? You specify the type of the returned C++ value as the 3rd argument to _MEMBER_GET(), and if it's not the same as the C type of the structure member, you add a _CONVERSION() macro.

Kjell

Den 2018-02-22 kl. 17:05, skrev Pavlo Solntsev:
I am trying to wrap a simple structure from libgda package. I followed some examples and documentation and was able to implement all get/set methods via _MEMBER_GET macros. The generated code looks exactly as I would expect for c++ get/set:

const T& get_some()const;
void set_some(const T&);

My question about getter. It looks like I return a reference for the temporary created object, which is not good. Do you think getter should return Glib::RefPtr<>? It is a little uncommon for c++ in my opinion. Does it cause any performance degradation by creating a RefPtr object and returning it? 

As an example, we may consider a simple struct:
struct Person {
char *fname;
char *lname;
};

Thanks,

-Pavlo Solntsev




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]