-
Notifications
You must be signed in to change notification settings - Fork 95
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
call by reference, using a pointer or a non-const reference, does not work #109
Comments
This is an awkward one to fix. However, I would like to fix it. It is tricky because |
Note to self: Value holder policies. external/internal. |
I have a fix to support pointer typed argument nicely. That is all you need if you want a metaclass's function to return something through a function argument with a pointer to a basic type. |
Sure, yes, I’d be interested in seeing it. |
I like to show you in a tested code but it looks like currently the ponder branch is not buildable. |
What seems to be broken? All of the tests appear to be passes in develop and master branches on all platforms. |
I was not able to build on a RedHat platform. On Mac, it built however. Below is the build error.
|
Please note compiler version notes. C++14 required. |
Cmake automatically configured it to use std=gnu++1y on the RedHat platform. |
This must be new since I was able to build just a few days ago. |
Yes. It’s mentioned in the change log and release notes. |
I put a more explicit note about C++14 support in the notes. Sorry if it wasn't clear. |
I upgraded my gcc to version 7.2 and it built fine for me. Please see my pull request for this discussion thread. Thanks. |
Sorry, busy week at work. I have looked at the PR. Hopefully your patch works for now. I had a think on the way to work. My current thinking is to add calling policies and/or argument policies. This would allow customisation of the argument passing. CAMP/Ponder currently converts arguments to |
I made some progress on this. There is a "feature/arg" branch with a working pass-by-ref for pointers. I'm not going to push it out because it doesn't handle references, just pointers. I'm thinking of adding a "non-owned reference" type, which Value would use as a variant type. The basic types convert into their nearest equivalent type, but the reference would have to be identical. This is necessary because non-const references can't be returned otherwise (unless we convert them to UserObject reference holders, which is expensive and requires registering the basic types). Ideally I'd like a "direct call" mechanism as well as a "Value call" mechanism. Direct call could be used for known compile-time function signatures, and "Value call" could be used where we perhaps have runtime data-driven reflection and we don't know the type of anything until we use it. Direct calling means we could bypass some of the inefficiencies of the temporary Value call. The Lua calling mechanism works like this. Sorry if you aren't interested in all these ramblings. Just having a brain dump! |
I experimented with adding a ValueRef type that is a cheaper version of UserObject byRef. This would mean you don't have to declare basic types to use them by reference. |
That sounds promising. Will call by pointer work also? |
Finally checked this into the develop branch. I'm a bit rusty no what I've done! |
Declaring a metaclass function with a pointer or a non-const reference to any basic type as an argument does not compile. The pointer to a basic type can be made compilable if you register this basic type. But if you register this basic type, and property or function returning value of this type becomes ponder::ValueKind::User. This prevents you from converting the property value or the function return value back to the basic type. The conversion would throw an exception. It basically makes this basic value type used as a property value or a function returning value not visible to the client.
The text was updated successfully, but these errors were encountered: