Tomasu / LuaGlue

C++11 Lua 5.2 Binding Library
zlib License
79 stars 22 forks source link

const support #10

Closed JMLX42 closed 10 years ago

JMLX42 commented 10 years ago

Hello,

I closed my original "VS2013 support" issue (#1) because my pull request should fix it. Here is an error I get with both VS2013 and GCC 4.8.1 regarding constness:

error: value-initialization of reference type ‘const std::basic_string&’

As you can imagine, not being able to store const types is a big problem. What are our options to make this work? Maybe make our std::tuple to be template not by the types themselves but by the equivalent pointer types (const std::string& would be stored as (const std::string&)*). What do you think?

Thanks again,

JMLX42 commented 10 years ago

Ok so AFAIK this is the only remaining big issue that prevents my code from compiling. How could we fix this? How can I help?

Tomasu commented 10 years ago

I'm a bit busy the next couple days, but I will take a look at this later this week. your suggestion to mangle the types to be pointers has promise I think. We'd just mangle it back to remove the extra pointer when actually doing the calling.

JMLX42 commented 10 years ago

I'm exploring another solution: using a recursive meta function to call std::remove_const on Args... I'll let you know.

JMLX42 commented 10 years ago

I fixed it, I'll do a pull request soon.

JMLX42 commented 10 years ago

Constness is now partially fixed thanks to the changes above.

Another constness issue is still not solved: (member) functions marked as const cannot be bound.

class Foo
{
  public:
    void bar() const;
}
state.Class("Foo").method("bar", &Foo::bar); // does not compile: cv-qualifier mismatch error

I've tried to solve this without success... Any idea?

Tomasu commented 10 years ago

Pushed up a fix for that. It was rather annoying, as it needed a bunch of code to be copy and pasted, with one small change to bits. but it works now.