aboutsummaryrefslogtreecommitdiff
path: root/files/ja/mozilla/tech/xpcom/reference/ns_ensure_true/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ja/mozilla/tech/xpcom/reference/ns_ensure_true/index.html')
-rw-r--r--files/ja/mozilla/tech/xpcom/reference/ns_ensure_true/index.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/files/ja/mozilla/tech/xpcom/reference/ns_ensure_true/index.html b/files/ja/mozilla/tech/xpcom/reference/ns_ensure_true/index.html
new file mode 100644
index 0000000000..cf931e4a21
--- /dev/null
+++ b/files/ja/mozilla/tech/xpcom/reference/ns_ensure_true/index.html
@@ -0,0 +1,49 @@
+---
+title: NS ENSURE TRUE
+slug: Mozilla/Tech/XPCOM/Reference/NS_ENSURE_TRUE
+tags:
+ - XPCOM
+ - XPCOM_Macros
+translation_of: Mozilla/Tech/XPCOM/Reference/NS_ENSURE_TRUE
+---
+<h3 id="Summary" name="Summary">概要</h3>
+
+<p><strong>マクロ</strong></p>
+
+<p><em>expr</em> の評価値が <strong>false</strong> の場合に <em>return-value </em>を返す。</p>
+
+<h3 id="Syntax" name="Syntax">構文</h3>
+
+<pre>NS_ENSURE_TRUE( expr, return-value );
+</pre>
+
+<p> </p>
+
+<h3 id="Usage" name="Usage">使い方</h3>
+
+<pre>nsresult mozMyClass::MozStringMucking()
+{
+ char *foo = new char[123];
+ NS_ENSURE_TRUE(foo, NS_ERROR_OUT_OF_MEMORY);
+
+ // This is equivalent to doing:
+ // これは以下の式と同等です。
+ if (!foo)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ // Thou shalt not return NS_ERROR_FAILURE..
+ // これは、NS_ERROR_FAILURE を返さない。。
+ int i = 3;
+ NS_ENSURE_TRUE(i == 3, NS_ERROR_FAILURE);
+
+ return NS_OK;
+}
+
+char* mozMyClass::DoStuff()
+{
+ char* bar = new char[321];
+ NS_ENSURE_TRUE(bar, nsnull);
+
+ return bar;
+}
+</pre>