ホーム › Globalization › utrace_vformat
utrace_vformat
関数可変引数リストからICUトレース出力を整形する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT utrace_vformat(
LPSTR outBuf,
INT capacity,
INT indent,
LPCSTR fmt,
CHAR* args
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| outBuf | LPSTR | in |
| capacity | INT | in |
| indent | INT | in |
| fmt | LPCSTR | in |
| args | CHAR* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT utrace_vformat(
LPSTR outBuf,
INT capacity,
INT indent,
LPCSTR fmt,
CHAR* args
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int utrace_vformat(
[MarshalAs(UnmanagedType.LPStr)] string outBuf, // LPSTR
int capacity, // INT
int indent, // INT
[MarshalAs(UnmanagedType.LPStr)] string fmt, // LPCSTR
IntPtr args // CHAR* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function utrace_vformat(
<MarshalAs(UnmanagedType.LPStr)> outBuf As String, ' LPSTR
capacity As Integer, ' INT
indent As Integer, ' INT
<MarshalAs(UnmanagedType.LPStr)> fmt As String, ' LPCSTR
args As IntPtr ' CHAR* in/out
) As Integer
End Function' outBuf : LPSTR
' capacity : INT
' indent : INT
' fmt : LPCSTR
' args : CHAR* in/out
Declare PtrSafe Function utrace_vformat Lib "icuuc" ( _
ByVal outBuf As String, _
ByVal capacity As Long, _
ByVal indent As Long, _
ByVal fmt As String, _
ByVal args As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
utrace_vformat = ctypes.cdll.icuuc.utrace_vformat
utrace_vformat.restype = ctypes.c_int
utrace_vformat.argtypes = [
wintypes.LPCSTR, # outBuf : LPSTR
ctypes.c_int, # capacity : INT
ctypes.c_int, # indent : INT
wintypes.LPCSTR, # fmt : LPCSTR
ctypes.POINTER(ctypes.c_byte), # args : CHAR* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
utrace_vformat = Fiddle::Function.new(
lib['utrace_vformat'],
[
Fiddle::TYPE_VOIDP, # outBuf : LPSTR
Fiddle::TYPE_INT, # capacity : INT
Fiddle::TYPE_INT, # indent : INT
Fiddle::TYPE_VOIDP, # fmt : LPCSTR
Fiddle::TYPE_VOIDP, # args : CHAR* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn utrace_vformat(
outBuf: *mut u8, // LPSTR
capacity: i32, // INT
indent: i32, // INT
fmt: *const u8, // LPCSTR
args: *mut i8 // CHAR* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int utrace_vformat([MarshalAs(UnmanagedType.LPStr)] string outBuf, int capacity, int indent, [MarshalAs(UnmanagedType.LPStr)] string fmt, IntPtr args);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_utrace_vformat' -Namespace Win32 -PassThru
# $api::utrace_vformat(outBuf, capacity, indent, fmt, args)#uselib "icuuc.dll"
#func global utrace_vformat "utrace_vformat" sptr, sptr, sptr, sptr, sptr
; utrace_vformat outBuf, capacity, indent, fmt, varptr(args) ; 戻り値は stat
; outBuf : LPSTR -> "sptr"
; capacity : INT -> "sptr"
; indent : INT -> "sptr"
; fmt : LPCSTR -> "sptr"
; args : CHAR* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global utrace_vformat "utrace_vformat" str, int, int, str, var ; res = utrace_vformat(outBuf, capacity, indent, fmt, args) ; outBuf : LPSTR -> "str" ; capacity : INT -> "int" ; indent : INT -> "int" ; fmt : LPCSTR -> "str" ; args : CHAR* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global utrace_vformat "utrace_vformat" str, int, int, str, sptr ; res = utrace_vformat(outBuf, capacity, indent, fmt, varptr(args)) ; outBuf : LPSTR -> "str" ; capacity : INT -> "int" ; indent : INT -> "int" ; fmt : LPCSTR -> "str" ; args : CHAR* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT utrace_vformat(LPSTR outBuf, INT capacity, INT indent, LPCSTR fmt, CHAR* args) #uselib "icuuc.dll" #cfunc global utrace_vformat "utrace_vformat" str, int, int, str, var ; res = utrace_vformat(outBuf, capacity, indent, fmt, args) ; outBuf : LPSTR -> "str" ; capacity : INT -> "int" ; indent : INT -> "int" ; fmt : LPCSTR -> "str" ; args : CHAR* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT utrace_vformat(LPSTR outBuf, INT capacity, INT indent, LPCSTR fmt, CHAR* args) #uselib "icuuc.dll" #cfunc global utrace_vformat "utrace_vformat" str, int, int, str, intptr ; res = utrace_vformat(outBuf, capacity, indent, fmt, varptr(args)) ; outBuf : LPSTR -> "str" ; capacity : INT -> "int" ; indent : INT -> "int" ; fmt : LPCSTR -> "str" ; args : CHAR* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procutrace_vformat = icuuc.NewProc("utrace_vformat")
)
// outBuf (LPSTR), capacity (INT), indent (INT), fmt (LPCSTR), args (CHAR* in/out)
r1, _, err := procutrace_vformat.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(outBuf))),
uintptr(capacity),
uintptr(indent),
uintptr(unsafe.Pointer(windows.BytePtrFromString(fmt))),
uintptr(args),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction utrace_vformat(
outBuf: PAnsiChar; // LPSTR
capacity: Integer; // INT
indent: Integer; // INT
fmt: PAnsiChar; // LPCSTR
args: Pointer // CHAR* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'utrace_vformat';result := DllCall("icuuc\utrace_vformat"
, "AStr", outBuf ; LPSTR
, "Int", capacity ; INT
, "Int", indent ; INT
, "AStr", fmt ; LPCSTR
, "Ptr", args ; CHAR* in/out
, "Cdecl Int") ; return: INT●utrace_vformat(outBuf, capacity, indent, fmt, args) = DLL("icuuc.dll", "int utrace_vformat(char*, int, int, char*, void*)")
# 呼び出し: utrace_vformat(outBuf, capacity, indent, fmt, args)
# outBuf : LPSTR -> "char*"
# capacity : INT -> "int"
# indent : INT -> "int"
# fmt : LPCSTR -> "char*"
# args : CHAR* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。