Accessing member variables from user types #79

Closed
jeaye opened this Issue Feb 24, 2013 · 4 comments

Projects

None yet

2 participants

@jeaye
jeaye commented Feb 24, 2013

It'd be damn sexy to be able to pass a user type to a Chai function and have it be able to access the type's (public) member variables directly, instead of everything being handled via functions (accessor and mutator could be written, but this would be a lovely convenience).

@lefticus
Member

I'm not sure exactly what you have in mind. I just committed an example of access a C++ member from ChaiScript, with no accessor needed. Is this what you had in mind?

@jeaye
jeaye commented Feb 24, 2013

Very sexy, though not very intuitive. Using chaiscript::fun for members does seem a bit misleading; something like chaiscript::member or chaiscript::property would be most straightforward. Though I'm not quite sure if you're clarifying what I was requesting or suggesting a possible (though not yet implemented) solution.

Thanks for the reply.

@lefticus
Member

That code works and is now officially part of the unit tests. The function has been there since the beginning. The concept was to make the interface as simple as possible so "fun" is any type of member or function. "constructor" is special because they are not regular functions. You cannot make a pointer to a constructor.

-Jason

@jeaye
jeaye commented Feb 25, 2013

Ahh, got it. Thanks for the clarification, Jason (and thanks for ChaiScript!). Things are working beautifully now.

Cheers,
Jeaye

@jeaye jeaye closed this Feb 25, 2013
@mgee mgee pushed a commit to mgee/ChaiScript that referenced this issue Jan 2, 2015
@lefticus lefticus Add example of wrapping data members of a class #79 9403c06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment