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

JsSetRuntimeMemoryAllocationCallback

関数
ランタイムのメモリ割り当てコールバックを設定する。
DLLchakra.dll呼出規約winapi

シグネチャ

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

JsErrorCode JsSetRuntimeMemoryAllocationCallback(
    void* runtime,
    void* callbackState,   // optional
    JsMemoryAllocationCallback allocationCallback
);

パラメーター

名前方向
runtimevoid*in
callbackStatevoid*inoptional
allocationCallbackJsMemoryAllocationCallbackin

戻り値の型: JsErrorCode

各言語での呼び出し定義

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

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

JsSetRuntimeMemoryAllocationCallback = ctypes.windll.chakra.JsSetRuntimeMemoryAllocationCallback
JsSetRuntimeMemoryAllocationCallback.restype = wintypes.DWORD
JsSetRuntimeMemoryAllocationCallback.argtypes = [
    ctypes.POINTER(None),  # runtime : void*
    ctypes.POINTER(None),  # callbackState : void* optional
    ctypes.c_void_p,  # allocationCallback : JsMemoryAllocationCallback
]
require 'fiddle'
require 'fiddle/import'

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

var (
	chakra = windows.NewLazySystemDLL("chakra.dll")
	procJsSetRuntimeMemoryAllocationCallback = chakra.NewProc("JsSetRuntimeMemoryAllocationCallback")
)

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