From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../jsapi_reference/js_defineobject/index.html | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html (limited to 'files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject') diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html new file mode 100644 index 0000000000..782201ccc5 --- /dev/null +++ b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_defineobject/index.html @@ -0,0 +1,126 @@ +--- +title: JS_DefineObject +slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DefineObject +tags: + - JSAPI Reference + - SpiderMonkey +translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_DefineObject +--- +

+

+

+ +

あるオブジェクトのプロパティとなるオブジェクトを生成する関数です。 Create an object that is a property of another object. {{ 英語版章題("Syntax") }}

+ +

構文

+ +
JSObject * JS_DefineObject(JSContext *cx, JSObject *obj,
+    const char *name, JSClass *clasp, JSObject *proto,
+    uintN flags);
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
cxJSContext *エラー報告に用いるランタイム環境から派生したコンテキストへのポインタPointer to a JS context from which to derive runtime information for error reporting. {{ Jsapi-requires-request() }}
objJSObject *生成したオブジェクトをプロパティとして持つオブジェクトへのポインタObject to which this new object belongs as a property.
nameconst char *objでのプロパティ名Name of the property that encapsulates the new object in <code>obj</code>.
claspJSClass *オブジェクト生成に用いるクラスClass to use for the new object.
protoJSObject *オブジェクト生成に用いるプロトタイプPrototype object to use for the new object.
flagsuintN生成したオブジェクトの属性を指定するフラグProperty flags for the new object.
+ +

{{ 英語版章題("Description") }}

+ +

説明

+ +

JS_DefineObjectは、オブジェクトのインスタンスを生成し、それを引数objで指定した既存オブジェクトのプロパティとして設定する関数です。引数nameで、objでのプロパティ名を指定し、flagsでそのプロパティの属性を指定します。以下の表で設定可能なflagsの値を示します。これらの値は単一、あるいは複数の値の論理和として引数に与えることができます。 <code>JS_DefineObject</code> instantiates and names a new object for an existing object, <code>obj</code>. <code>name</code> is the property name to assign to <code>obj</code> to hold the new object, and <code>flags</code> contains the property flags to set for the newly created property. The following table lists possible values you can pass in <code>flags</code>, either singly, or <code>OR</code>'d together:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FlagPurpose
JSPROP_ENUMERATEforinループを使ったアクセス(Core JavaScript 1.5 Guide:Object Manipulation Statements)を可能にします。Property is visible to <code>for</code> and <code>in</code> loops.
JSPROP_READONLYプロパティの値を読み取り専用にします。Property is read only.
JSPROP_PERMANENTプロパティの削除を不可能にします。Property cannot be deleted.
JSPROP_EXPORTEDProperty can be imported by other objects.
JSPROP_INDEXProperty is actually an index into an array of properties, and is cast to a const char *.
+ +

引数claspはオブジェクトの生成時に用いる基底クラスへのポインタ、引数protoはプロトタイプへのポインタをそれぞれとります。protoNULLを指定した場合、JavaScriptは自分自身をプロトタイプとします。引数objはオブジェクトの親オブジェクトになります。 <code>clasp</code> is a pointer to the base class to use when creating the new object, and <code>proto</code> is an pointer to the prototype upon which to base the new object. If you set <code>proto</code> to <code>NULL</code>, JS sets the prototype object for you. The parent object for the new object is set to <code>obj</code>.

+ +

JS_DefineObjectが成功したとき、返値は新たに生成したプロパティオブジェクトへのポインタになります。もしすでにプロパティが設定されていた場合、オブジェクトは生成されず、返り値はNULLになります。 <code>JS_DefineObject</code> returns a pointer to the newly created property object if successful. If the property already exists, or cannot be created, <code>JS_DefineObject</code> returns <code>NULL</code>. {{ 英語版章題("See Also") }}

+ +

参照

+ + + + + + + + + + + + + + + + +
GroupsFunctions
Documents{{ LXRSearch("ident", "i", "JS_DefineObject", "LXR ID Search") }}
Entries +

JSClass, JS_DefineConstDoubles, JS_DefineElement, JS_DefineFunction, JS_DefineFunctions, JS_DefineProperties, JS_DefineProperty, JS_DefinePropertyWithTinyId, JS_NewObject, JS_ValueToObject

+
+ +
 
+ +

{{ languages( { "en": "en/JS_DefineObject" } ) }}

-- cgit v1.2.3-54-g00ecf