-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add documentation, especially ownership & const information to public interfaces #9
Add documentation, especially ownership & const information to public interfaces #9
Conversation
Thanks for cool documentation ✨ |
Thanks! 😄 You might be interested in publishing the documentation of the master branch via gh-pages, I just managed to enable that for alaCarte. See https://alacarte-maps.github.io/alacarte/ for the result and |
In other news: I'll need to remove the pointer part of the opaqua struct typedefs and instead add it in all signatures, because otherwise one can't define arguments taking them as pointers to const data. See http://stackoverflow.com/questions/8504411/typedef-pointer-const-weirdnesst for more reasoning. Like it is said there, I also think it's a good idea not to hide the fact that those are pointers from the parameter definitions of libqmlbind's functions, but my main argument is, if we start to add const, it should be used consistently. 😉 |
@seanchas116 I just tried to think of good coments for |
Because a PR says more than thousend words: What I mean is this: #11. |
Sorry for confusing naming, |
Now that I understood that, I have two remaining questions:
|
I haven't tested but I think both are possible. |
I re-checked again, I really think both variants should work currently. I just pushed documentation for interface and exporter including my new understanding of how things work. Regarding the possible API change, I really think merging
kind of fashion is possible from the public API standpoint, but let's discuss this later as soon as I finnished my journey through the code and unterstand what's going on. 😉 New questions:
|
Thanks for advancing documentation!
I think it's nice change too 👍 To answer questions:
|
@seanchas116 I'm not quite sure on ownership handling of Could you comment on that? Is ownership transfered in all mentioned places, or is there some copying involved? e.g. what happens if a signal is connected to multiple slots? |
If my memory is correct, ownership of all
I took a look how Qt metacall are done in slots by seeing moc output: // slot signature
QJSValue foo(const QJSValue &value) const;
// in qt_static_metacall
switch (_id) {
case 0: { QJSValue _r = _t->foo((*reinterpret_cast< const QJSValue(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< QJSValue*>(_a[0]) = _r; } break;
default: ;
} Values are copied so we don't have to pass ownership. |
Thanks for the explanation, just integrated that. Following what you said, I now think that
is the correct signature, meaning that the Do you think that's right, or does the implementation of |
|
Now I see. Could you please re-check Another thing I stumbled over: I don't understand what you're doing in the signal emitter at https://github.com/florianjacob/libqmlbind/blob/doc_ownership_const/qmlbind/src/signalemitter.cpp#L31. I added a comment above it with what I thought what's going on there yesterday, but today I think this is not what's happening there anymore. 😆 I don't get why this works, why don't you need to reserve a new array with an additional element at the front for the return value? |
* \brief executes the `name` method defined on the `objRef` C object, with `argc` parameters in `argv`, and returns | ||
* the result. | ||
* | ||
* This method must take ownership of the `qmlbind_values` in the `argv` array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As talked in comments, this method does not take ownership of argv values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault, I updated the code but forgot to update the comments. 😆 Good that you found it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 😄
I thought signals are methods with no return value so the front element (used for return values) is not needed... |
Now I understand. 😄 It would be a nice solution if the front element really was not used, but I think this is not the case. Signals actually can have return values. It's undocumented behaviour, but they have the return value of the slot that was called last. Obviously, no sane person uses that behaviour, but this will result in an arbitrary write to a few bytes before the array if the signal is connected to a slot or method with a return value. Especially if a signal is connected to a method, the method could have a return value that we like to ignore if it's called via the signal, but still gets written to the front element. A source I found to back this up: http://stackoverflow.com/questions/5842124/can-qt-signals-return-a-value/5903082 I'll prepare a PR for fixing this in a moment. ⌚ |
the steps are epxlained in the readme file.
in the readme file
removing the ptr-part is necessary to be able to annotate the underlying types as const. arguments where renamed to self where appropriate to match the new ownership conventions.
namely adding const and making pointers explicit.
because big parts are copied from Qt's documentation (which is under FDL) and just adapted for libqmlbind.
Just finished the last bits & bobs and then rewrote history (I love to say that ⏳ ) to make it more understandable. Notable changes since my last comment: I added a hello world example for window creation, added code to automatically publish the documentation via travis to github pages as https://seanchas116.github.io/libqmlbind, and extended license.txt to set the documentation under GNU FDL. As big portions are mainly copied from Qt's documentation (which is under FDL), I think we have to do that somehow (as FDL is a copyleft license), I hope I did that correctly. @seanchas116 The only thing to do for you to activate documentation publishing would be to add a GH_TOKEN of yours as hidden travis environment variable, as explained in the publish script. The PR is now in the state I want it to be and ready for final proof-reading and polishing. ✨ @rainbyte, as an outsider and initiator of #3, could you please fire up doxygen and see whether everything is understandable and fullfills your needs? @tpickett66, as you already had a look at libqmlbind, maybe you can review the docs, too, in case you can find the time? |
@florianjacob, first, thanks for your work in this again New documentation is great, my only remarks are already known (issue #15). In order to close issue #3, I think some usage examples are needed. |
@florianjacob, I've updated the issue accordingly I'll try to write the examples using this docs. |
@florianjacob Thanks a lot for your work again! I'll merge this pull request and start publishing documentation. |
Documentations is successfully published! http://seanchas116.github.io/libqmlbind/ |
Awesome! Kudos for the project! :) |
@seanchas116 There's an http:/ link left in the project description which could be changed to https://, too. 🔒 |
@seanchas116 and excuse all the fiddling that was still necessary to get travis to work. 😆 |
Thanks! Fixed now. |
I just updated libqmlbind to latest in ruby-qml. The const information helps finding some leaks and I was able to fix them 😄 |
That's nice to hear! 🔩 😄 |
This is a work in progress, only
application.h
is documented for now.Please review if everything is correct & comment on the style. I'll continue to add commits with comments for other classes to this PR soon.