From a065e04d529da1d847b5062a12c46d916408bf32 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 21:46:22 -0500 Subject: update based on https://github.com/mdn/yari/issues/2028 --- .../jsapi_reference/js_newcontext/index.html | 93 ---------------------- 1 file changed, 93 deletions(-) delete mode 100644 files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html (limited to 'files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext') diff --git a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html b/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html deleted file mode 100644 index ab77638f70..0000000000 --- a/files/ja/mozilla/projects/spidermonkey/jsapi_reference/js_newcontext/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: JS NewContext -slug: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewContext -tags: - - JSAPI Reference - - SpiderMonkey -translation_of: Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_NewContext ---- -

- -

- -

- -

新たなJavaScriptコンテキストを生成します。 Creates a new JavaScript context.

- -

構文

- -

= Syntax =

- -
JSContext * JS_NewContext(JSRuntime *rt, size_t stackchunksize);
-
- - - - - - - - - - - - - - - - - - - -
NameTypeDescription
rtJSRuntime *コンテキストの親となるランタイムを指定します。JavaScriptのオブジェクト、関数、文字列、数値はJSRuntime内のコンテキスト内で共有されますが、JSRuntimeをまたぐことはありません。 -

Parent runtime for the new context. JavaScript objects, functions, strings, and numbers may be shared among the contexts in a <code>JSRuntime</code>, but they cannot be shared across <code>JSRuntime</code>s.

-
stackchunksizesize_t -

各スタック領域のサイズをバイトで指定します。標準的には8192が適切な値であり、大抵の場合において調節すべきでないパラメータです。 The size, in bytes, of each "stack chunk". This is a memory management tuning parameter which most users should not adjust. <code>8192</code> is a good default value.

-
- -

説明

- -

= Description = スクリプトの実行および値の保持に利用するコンテキストを新規に生成する関数です。各スクリプトは独自のコンテキスト上で実行され、各コンテキストは特定のJSRuntimeオブジェクトrtと関連づけられています。 Creates a new JavaScript context for executing scripts and examining JavaScript values. Each script runs in its own context, and each context must be associated with a specified <code>JSRuntime</code>, <code>rt</code>.

- -

JS_NewContextは、成功したとき新たなコンテキストへのポインタを返します。失敗したときはNULLを返します。 On success, <code>JS_NewContext</code> returns a pointer to the new context. Otherwise it returns <code>NULL</code>.

- -

この関数の呼び元は、コンテキストを使い終わったらJS_DestroyContextを実行しなければなりません。JSRuntimeを解放する前に、そのJSContextをすべて解放する必要があります。 The caller must call <code>JS_DestroyContext</code> when it is done using the context. Before a <code>JSRuntime</code> may be destroyed, all the <code>JSContext</code>s associated with it must be destroyed.

- -

JS_THREADSAFEを有効にしたビルドでは、あるJSContextを同時にアクセスできるスレッドは一つだけです。新規のJSContextは、初期状態で呼び元のスレッドと関連付けられます。コンテキストがあるスレッドと関連付けられている間は、他のスレッドからそれを利用したり解放することはできません。JSContextを別のスレッドに移動する場合は、JS_ClearContextThreadJS_SetContextThreadを利用してください。 In a <code>JS_THREADSAFE</code> build, only one thread may use a <code>JSContext</code> at a time. The new <code>JSContext</code> is initially associated with the calling thread. As long as it stays associated with that thread, no other thread may use it or destroy it. A <code>JSContext</code> may be transferred from one thread to another by calling <code>JS_ClearContextThread</code> and <code>JS_SetContextThread</code>.

- -

新たに生成したJSContextは、初期状態においてグローバルオブジェクトを持ちません。 The new <code>JSContext</code> initially has no global object.

- -

注記

- -

== Notes == 一度生成されたコンテキストは異なるスクリプトやJSAPI呼び出しのために複数回利用される可能性があります。具体的には、Webブラウザが各HTMLに対応する独立したコンテキストを生成したときに、ページ内のすべてのスクリプトは同じコンテキストを用いて実行されるといったシナリオが考えられます。 Once created, a context can be used any number of times for different scripts or JSAPI queries. For example, a browser would create a separate context for each HTML page; every script in the page would use the same context.

- -

新規コンテキストは、ObjectDateArrayといった標準的なグローバルオブジェクトを一切保持していません。それらを利用するには、JS_InitStandardClassesを呼び出す必要があります。JSAPIを利用するアプリケーションで独自の関数やクラスを提供したい場合には、JS_GetGlobalObjectを使ってそのコンテキストのグローバルオブジェクトを取得し、JS_DefineFunctionsおよびJS_InitClassをそれに適用することで独自のグローバル関数やクラスをコンテキストに追加できます。 The new context initially does not contain any globals, even standard globals such as <code>Object</code>, <code>Date</code>, and <code>Array</code>. To create them, call <code>JS_InitStandardClasses</code>. A JSAPI application typically also provides some custom functions and classes. Use <code>JS_GetGlobalObject</code> to get a context's global object. Use <code></code> and <code>JS_InitClass</code> to add custom global functions and classes to the context.

- -

stackchunksizeは、JavaScriptのスタックサイズを調節するものではありません(JSAPIでは、スタック長を調節するインタフェースを提供していません)。stackchunksizeに大きい値を設定するのは誤った方法です。DEBUGビルドにおいて、stackchunksizeを大きくすると性能が著しく劣化します。一般的には8192が推奨されます。 The <code>stackchunksize</code> parameter does not control the JavaScript stack size. (The JSAPI does not provide a way to adjust the stack depth limit.) Passing a large number for <code>stackchunksize</code> is a mistake. In a <code>DEBUG</code> build, large chunk sizes can degrade performance dramatically. The usual value of <code>8192</code> is recommended.

- -

関連項目

- -

= See Also =

- - - - - - - - - - - - - - - - -
GroupsFunctions
Documents{{ LXRSearch("ident", "i", "JS_NewContext", "LXR ID Search") }}
EntriesJS_ContextIterator, -

JS_DestroyContext, JS_SetContextCallback

-
- -

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

-- cgit v1.2.3-54-g00ecf