Obj-C Exceptions In Gecko: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 20: Line 20:


* For wrapping calls that are not expressions, do not return values (at least not ones we care about)
* For wrapping calls that are not expressions, do not return values (at least not ones we care about)
** <code>NS_OBJC_TRY_IGNORE</code>
** <code>NS_OBJC_TRY_IGNORE();</code>
** <code>NS_OBJC_TRY_ABORT</code>
** <code>NS_OBJC_TRY_ABORT();</code>


* For wrapping expressions that return a value
* For wrapping expressions that return a value
** <code>NS_OBJC_TRY_EXPR_NULL</code>
** <code>NS_OBJC_TRY_EXPR_NULL();</code>
** <code>NS_OBJC_TRY_EXPR_ABORT</code>
** <code>NS_OBJC_TRY_EXPR_ABORT();</code>


An example of non-EXPR macro usage:
An example of non-EXPR macro usage:
Line 40: Line 40:


* Basic wrapping, use anywhere
* Basic wrapping, use anywhere
** <code>NS_OBJC_BEGIN_TRY_ABORT_BLOCK</code>
** <code>NS_OBJC_BEGIN_TRY_ABORT_BLOCK;</code>
** <code>NS_OBJC_END_TRY_ABORT_BLOCK</code>
** <code>NS_OBJC_END_TRY_ABORT_BLOCK;</code>


* Use to wrap an entire method that returns an Obj-C pointer
* Use to wrap an entire method that returns an Obj-C pointer
** <code>NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL</code>
** <code>NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;</code>
** <code>NS_OBJC_END_TRY_ABORT_BLOCK_NIL</code>
** <code>NS_OBJC_END_TRY_ABORT_BLOCK_NIL;</code>


* Used to wrap an entire method that returns an xpcom result code (<code>nsresult</code>)
* Used to wrap an entire method that returns an xpcom result code (<code>nsresult</code>)
** <code>NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT</code>
** <code>NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;</code>
** <code>NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT</code>
** <code>NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;</code>


We will probably add another block type that returns nsnull, for use with methods that return xpcom objects, we might add others as the need arises. For any other place where you would like to wrap an entire method, you'll have to use the first basic block macros and refactor code to correctly to place the return statement after the end macro. This means you'll also have to scope any variables used in the return statement correctly.
We will probably add another block type that returns nsnull, for use with methods that return xpcom objects, we might add others as the need arises. For any other place where you would like to wrap an entire method, you'll have to use the first basic block macros and refactor code to correctly to place the return statement after the end macro. This means you'll also have to scope any variables used in the return statement correctly.
Confirmed users, Bureaucrats and Sysops emeriti
1,680

edits