-
-
Notifications
You must be signed in to change notification settings - Fork 537
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
Overriding base types? #1490
Comments
Cant comment really on overriding base types.
Hmm, I guess you mean that your implementation would be something along the lines of the following? lua.new_usertype<MyType>("MyType",
"actualFunction1", [](std::string s){ actualFunction1(convert(s)) },
"actualFunction2", [](std::string s){ actualFunction2(convert(s)) },
"actualFunction3", [](std::string s){ actualFunction3(convert(s)) },
); I think you can make it transparent in an easier way. See these resources, especially the first code example link: |
@Rochet2 Yep, exactly what I mean. (As an aside, it doesn't appear that Sol plays well with nested STL types like |
@Rochet2 As an alternative to customizing via custom converters, could I just "extend" the existing string type? It would be really cool to be able to do |
But for "replacing" existing types I'll definitely look into what you said -- it would be nice having an arbitrary-precision integer/real type. |
You can do it like this local foo = "A"
function string.foo(s) return s..s end -- dummy example
print(foo:foo())
I dont really have anything for that. You can usually wrap things into structs for example to avoid issues. |
I'd like to override the base types of Lua (e.g. maybe replacing the integer type with an arbitrary-precision integer, or a string with a custom string class). Is this even possible? I mean, I know I could register a usertype called String or something, but then if I used functions in my Lua code that used that custom type I'd have to do:
Or similar. That isn't ideal. I could make conversion transparent, but then if I (say) wanted to expose methods in QString I'd need to write hundreds of lambdas to convert back and forth. Is this just a pipe dream, or is it doable?
The text was updated successfully, but these errors were encountered: