[Pyobjc-dev] "out" parameters and return values
Brought to you by:
ronaldoussoren
|
From: Mani G. <ma...@tu...> - 2009-02-02 14:59:16
|
Hi all,
>From what I understand of the PyObjc documentation, "out" pointer
variables (such as "NSError **outError") are actually appended to the
list of return values for a bridge function.
For example:
int returnIntWithError: NSError **outError
from Python would be invoked as:
returned_int, returned_error = returnIntWithError_(None)
I hope that my understanding of the above is correct.
Now, my real question is to extend the above concept to the Python
side, when we want to implement an informal protocol. Let's say the
protocol says that I have to implement the returnIntWithError:
function as described above. How do I implement this function? Is the
code below enough?
def returnIntWithError_(self, outError):
myError = NSError.errorWithDomain_code_userInfo_('myDomain', '1', objc.nil)
myReturnVal = 1
return myReturnVal, myError
Note that I am completely ignoring the "outError" parameter. Does this
look kosher?
Thanks in advance for any help!
Cheers,
Mani
|