A list for the developers of CellML tools

Text archives Help


[cellml-dev] CellML wchar sizes


Chronological Thread 
  • From: lpsmith at spod-central.org (Lucian Smith)
  • Subject: [cellml-dev] CellML wchar sizes
  • Date: Fri, 4 Dec 2009 19:21:46 +0000

* Andrew Miller <ak.miller at auckland.ac.nz> [2009-12-04 00:08] writes:
>
>
> nsCOMPtr<cellml_apiICellMLComponentSet> components;
> rv = mod->LocalComponents(getter_AddRefs(components));
> NS_ENSURE_SUCCESS(rv, );

Aha! Thanks!

> I'd suggest reading up on XPCOM - there is a lot of good information on
> the Internet about it.

You would think so, and I've read your links and searched google many
times, but while there are a few sites that at least vaguely explain what
is going on in terms I have heard of before, I haven't found a single one
that will tell me (as they say in acting) "what to do with my hands".
Almost everyone assumes you will be using javascript, where the syntax is
at least slightly more sensible, and the C++ examples are perfunctory and
inadequately explained. I have not found anywhere that will tell me, for
example:

> NS_ENSURE_SUCCESS(a, b) checks if a is a successful code (e.g. NS_OK is
> an example of a successful code, while NS_ERROR_FAILURE is an example of
> a failure code). If it is a failure code, it returns b.

or:

> That's because all XPCOM functions return nsresult, and the return value
> is the second parameter. They also capitalise the first letter.

Searching google for ns_ensure_success, I could only find code examples,
and I just tried searching the mozilla developer site and found
https://developer.mozilla.org/en/NS_ENSURE_SUCCESS but even that has a
broken link for NS_FAILED, so I don't really know what that part means
(well, I wouldn't had you not explained above), and it doesn't tell me
that it attempts to return 'return-value' *from the function it is in*, as
opposed to from a hidden function within the macro itself (i.e. 'nsreturn
= NS_ENSURE_SUCCESS(rv, rv)'), and it doesn't tell me what to do if I'm in
a 'void' function ('NS_ENSURE_SUCCESS(rv, void)', which would have been my
first guess, does not, as you might expect, compile). And had I not known
to look for NS_ENSURE_SUCCESS in the first place from code examples and
from this list, I do not know where I would have found it in the first
place.


Which is to say that were this project not in service of a specific aim on
our grant, I would have given up long ago, and even so, it is only the
helpfulness of the people on this list that have made the project
bearable. So, thank you again! I *hope* that the above tidbits will
allow me to press on through to actual bugs, instead of just getting hung
up on syntax, of all things...

One final question, on memory management. Before I was using XPCOM, I had
figured out (I think) how to add and remove the references from these
pointers. But now there seems to be a new syntax for adding refs (the
getter_AddRefs() bit), and while you have consistently used that function
in your examples, I have seen examples online that do not. What is the
deal there, and when do I need to call AddRefs and when do I not, and when
(if ever) would I need to call a ReleaseRefs() function, which I have not
seen, but which I am postulating the existence of?

-Lucian




Archive powered by MHonArc 2.6.18.

Top of page