summaryrefslogtreecommitdiff
path: root/other/apidsl/README.md
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-08-10 13:46:04 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-08-17 14:57:20 +0100
commitdd8a568141b43546521ca438d861e00c26051f6c (patch)
tree98f3f9a871f164b20693eca89eb0c8bf2ae826ed /other/apidsl/README.md
parentcebf64a588039c202880659a85d070126bcc68da (diff)
Make self_connection_status callback stateless.
**What are we doing?** We are moving towards stateless callbacks. This means that when registering a callback, you no longer pass a user data pointer. Instead, you pass a user data pointer to tox_iterate. This pointer is threaded through the code, passed to each callback. The callback can modify the data pointed at. An extra indirection will be needed if the pointer itself can change. **Why?** Currently, callbacks are registered with a user data pointer. This means the library has N pointers for N different callbacks. These pointers need to be managed by the client code. Managing the lifetime of the pointee can be difficult. In C++, it takes special effort to ensure that the lifetime of user data extends at least beyond the lifetime of the Tox instance. For other languages, the situation is much worse. Java and other garbage collected languages may move objects in memory, so the pointers are not stable. Tox4j goes through a lot of effort to make the Java/Scala user experience a pleasant one by keeping a global array of Tox+userdata on the C++ side, and communicating via protobufs. A Haskell FFI would have to do similarly complex tricks. Stateless callbacks ensure that a user data pointer only needs to live during a single function call. This means that the user code (or language runtime) can move the data around at will, as long as it sets the new location in the callback. **How?** We are doing this change one callback at a time. After each callback, we ensure that everything still works as expected. This means the toxcore change will require 15 Pull Requests.
Diffstat (limited to 'other/apidsl/README.md')
-rw-r--r--other/apidsl/README.md20
1 files changed, 11 insertions, 9 deletions
diff --git a/other/apidsl/README.md b/other/apidsl/README.md
index 3ba44678..99694dca 100644
--- a/other/apidsl/README.md
+++ b/other/apidsl/README.md
@@ -18,14 +18,16 @@ If you want to do it quickly and you don't have time for anything other than cop
18 18
19Command to run from ``toxcore`` directory (quick way, involves using curl): 19Command to run from ``toxcore`` directory (quick way, involves using curl):
20```bash 20```bash
21rm toxcore/tox.h && \ 21# For tox.h:
22( curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl < ./other/apidsl/tox.in.h > ./toxcore/tox.h ) && \ 22curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \
23astyle --options=./other/astyle/astylerc ./toxcore/tox.h 23 < other/apidsl/tox.in.h \
24``` 24 | astyle --options=other/astyle/astylerc \
25 25 > toxcore/tox.h
26When formatting will be complete, you should see output like: 26# For toxav.h:
27``` 27curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \
28Formatted ./toxcore/tox.h 28 < other/apidsl/toxav.in.h \
29 | astyle --options=other/astyle/astylerc \
30 > toxav/toxav.h
29``` 31```
30 32
31You may want to make sure with ``git diff`` that changes made in ``tox.h`` reflect changes in ``tox.in.h``. 33You may want to make sure with ``git diff`` that changes made in ``tox.h`` reflect changes in ``tox.in.h``.
@@ -43,7 +45,7 @@ If you prefer to have more control over what is happening, there are steps below
434. Use ``apidsl`` ``??`` 454. Use ``apidsl`` ``??``
445. Parse generated ``tox.h`` with astyle, minimal command for it would be: 465. Parse generated ``tox.h`` with astyle, minimal command for it would be:
45```bash 47```bash
46astyle --options=./other/astyle/astylerc ./toxcore/tox.h 48astyle --options=other/astyle/astylerc toxcore/tox.h
47``` 49```
48 50
49**Always pass output from ``apidsl`` through astyle.** 51**Always pass output from ``apidsl`` through astyle.**