Win32 API 日本語リファレンス
ホームSystem.Js › JsCreateRuntime

JsCreateRuntime

関数
Chakra JavaScriptランタイムを作成する。
DLLchakra.dll呼出規約winapi

シグネチャ

// chakra.dll
#include <windows.h>

JsErrorCode JsCreateRuntime(
    JsRuntimeAttributes attributes,
    JsRuntimeVersion runtimeVersion,
    JsThreadServiceCallback threadService,   // optional
    void** runtime
);

パラメーター

名前方向
attributesJsRuntimeAttributesin
runtimeVersionJsRuntimeVersionin
threadServiceJsThreadServiceCallbackinoptional
runtimevoid**out

戻り値の型: JsErrorCode

各言語での呼び出し定義

// chakra.dll
#include <windows.h>

JsErrorCode JsCreateRuntime(
    JsRuntimeAttributes attributes,
    JsRuntimeVersion runtimeVersion,
    JsThreadServiceCallback threadService,   // optional
    void** runtime
);
[DllImport("chakra.dll", ExactSpelling = true)]
static extern uint JsCreateRuntime(
    int attributes,   // JsRuntimeAttributes
    int runtimeVersion,   // JsRuntimeVersion
    IntPtr threadService,   // JsThreadServiceCallback optional
    IntPtr runtime   // void** out
);
<DllImport("chakra.dll", ExactSpelling:=True)>
Public Shared Function JsCreateRuntime(
    attributes As Integer,   ' JsRuntimeAttributes
    runtimeVersion As Integer,   ' JsRuntimeVersion
    threadService As IntPtr,   ' JsThreadServiceCallback optional
    runtime As IntPtr   ' void** out
) As UInteger
End Function
' attributes : JsRuntimeAttributes
' runtimeVersion : JsRuntimeVersion
' threadService : JsThreadServiceCallback optional
' runtime : void** out
Declare PtrSafe Function JsCreateRuntime Lib "chakra" ( _
    ByVal attributes As Long, _
    ByVal runtimeVersion As Long, _
    ByVal threadService As LongPtr, _
    ByVal runtime As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

JsCreateRuntime = ctypes.windll.chakra.JsCreateRuntime
JsCreateRuntime.restype = wintypes.DWORD
JsCreateRuntime.argtypes = [
    ctypes.c_int,  # attributes : JsRuntimeAttributes
    ctypes.c_int,  # runtimeVersion : JsRuntimeVersion
    ctypes.c_void_p,  # threadService : JsThreadServiceCallback optional
    ctypes.c_void_p,  # runtime : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('chakra.dll')
JsCreateRuntime = Fiddle::Function.new(
  lib['JsCreateRuntime'],
  [
    Fiddle::TYPE_INT,  # attributes : JsRuntimeAttributes
    Fiddle::TYPE_INT,  # runtimeVersion : JsRuntimeVersion
    Fiddle::TYPE_VOIDP,  # threadService : JsThreadServiceCallback optional
    Fiddle::TYPE_VOIDP,  # runtime : void** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "chakra")]
extern "system" {
    fn JsCreateRuntime(
        attributes: i32,  // JsRuntimeAttributes
        runtimeVersion: i32,  // JsRuntimeVersion
        threadService: *const core::ffi::c_void,  // JsThreadServiceCallback optional
        runtime: *mut *mut ()  // void** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("chakra.dll")]
public static extern uint JsCreateRuntime(int attributes, int runtimeVersion, IntPtr threadService, IntPtr runtime);
"@
$api = Add-Type -MemberDefinition $sig -Name 'chakra_JsCreateRuntime' -Namespace Win32 -PassThru
# $api::JsCreateRuntime(attributes, runtimeVersion, threadService, runtime)
#uselib "chakra.dll"
#func global JsCreateRuntime "JsCreateRuntime" sptr, sptr, sptr, sptr
; JsCreateRuntime attributes, runtimeVersion, threadService, runtime   ; 戻り値は stat
; attributes : JsRuntimeAttributes -> "sptr"
; runtimeVersion : JsRuntimeVersion -> "sptr"
; threadService : JsThreadServiceCallback optional -> "sptr"
; runtime : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "chakra.dll"
#cfunc global JsCreateRuntime "JsCreateRuntime" int, int, sptr, sptr
; res = JsCreateRuntime(attributes, runtimeVersion, threadService, runtime)
; attributes : JsRuntimeAttributes -> "int"
; runtimeVersion : JsRuntimeVersion -> "int"
; threadService : JsThreadServiceCallback optional -> "sptr"
; runtime : void** out -> "sptr"
; JsErrorCode JsCreateRuntime(JsRuntimeAttributes attributes, JsRuntimeVersion runtimeVersion, JsThreadServiceCallback threadService, void** runtime)
#uselib "chakra.dll"
#cfunc global JsCreateRuntime "JsCreateRuntime" int, int, intptr, intptr
; res = JsCreateRuntime(attributes, runtimeVersion, threadService, runtime)
; attributes : JsRuntimeAttributes -> "int"
; runtimeVersion : JsRuntimeVersion -> "int"
; threadService : JsThreadServiceCallback optional -> "intptr"
; runtime : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	chakra = windows.NewLazySystemDLL("chakra.dll")
	procJsCreateRuntime = chakra.NewProc("JsCreateRuntime")
)

// attributes (JsRuntimeAttributes), runtimeVersion (JsRuntimeVersion), threadService (JsThreadServiceCallback optional), runtime (void** out)
r1, _, err := procJsCreateRuntime.Call(
	uintptr(attributes),
	uintptr(runtimeVersion),
	uintptr(threadService),
	uintptr(runtime),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // JsErrorCode
function JsCreateRuntime(
  attributes: Integer;   // JsRuntimeAttributes
  runtimeVersion: Integer;   // JsRuntimeVersion
  threadService: Pointer;   // JsThreadServiceCallback optional
  runtime: Pointer   // void** out
): DWORD; stdcall;
  external 'chakra.dll' name 'JsCreateRuntime';
result := DllCall("chakra\JsCreateRuntime"
    , "Int", attributes   ; JsRuntimeAttributes
    , "Int", runtimeVersion   ; JsRuntimeVersion
    , "Ptr", threadService   ; JsThreadServiceCallback optional
    , "Ptr", runtime   ; void** out
    , "UInt")   ; return: JsErrorCode
●JsCreateRuntime(attributes, runtimeVersion, threadService, runtime) = DLL("chakra.dll", "dword JsCreateRuntime(int, int, void*, void*)")
# 呼び出し: JsCreateRuntime(attributes, runtimeVersion, threadService, runtime)
# attributes : JsRuntimeAttributes -> "int"
# runtimeVersion : JsRuntimeVersion -> "int"
# threadService : JsThreadServiceCallback optional -> "void*"
# runtime : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。