Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__eq in metatable for C++ objects? #31

Open
ahupowerdns opened this issue Dec 21, 2015 · 4 comments
Open

__eq in metatable for C++ objects? #31

ahupowerdns opened this issue Dec 21, 2015 · 4 comments
Labels

Comments

@ahupowerdns
Copy link
Contributor

Our (PowerDNS) love for luawrapper continues to be grandiose! We've built most of dnsdist on it, and now also the Lua integration in the upcoming Recursor 4.x release, thanks!

To make things really shine, we'd like users to be able to compare two DNSName objects in Lua like this:
if(nameA == nameB) then .. stuff .. end
Where nameA are created with newDN() which returns a DNSName.

I've tried:
d_lw->registerFunction("__eq", &DNSName::operator==);

Which would of course be grand. When I explicitly call it (nameA:__eq(nameB)), it works too. But it is not in the metatable, so nameA==nameB does not call operator==. Unsure what it does call, btw! (perhaps it compares exact object identity?).

I see that I could do it with writeVariable to a specific named Lua-side object, but I don't think I could do this from my (C++ based) newDN() function, since my object need not even have a name yet.

Naively, it looks like registerFunction needs a variant for writing to metatables, but I could be wrong.

Help! :-)

@tomaka
Copy link
Owner

tomaka commented Dec 21, 2015

Unfortunately I stopped using Lua a while ago, so I really don't remember much about all this.

@ahupowerdns
Copy link
Contributor Author

Ok, thank you for all your great work! As PowerDNS we are pondering taking
over maintenance of a public fork of LuaWrapper, if we do so, would you
consider doing a commit to your README pointing people to our work?

Thanks again!

On Mon, Dec 21, 2015 at 12:39:27PM -0800, tomaka wrote:

Unfortunately I stopped using Lua a while ago, so I really don't remember much about all this.


Reply to this email directly or view it on GitHub:
#31 (comment)

@tomaka
Copy link
Owner

tomaka commented Dec 21, 2015

Sure!

I haven't touched any C++ code for the past year or so, and have no plan to go back to this language, so it's not me who is going to maintain this library.

@Habbie
Copy link

Habbie commented Dec 22, 2015

Hello @tomaka, I am working with @ahupowerdns on PowerDNS. Would you be open to handing over the whole repository (what Github calls 'Transfer ownership' in the repo settings' 'Danger Zone') so the issues and open pulls also become our problem?

Habbie added a commit to PowerDNS/luawrapper that referenced this issue Mar 24, 2017
Upstream from PowerDNS: don't shadow variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants