ホーム › Globalization › udtitvfmt_getContext
udtitvfmt_getContext
関数日付間隔フォーマッタの表示コンテキストを取得する。
シグネチャ
// icu.dll
#include <windows.h>
UDisplayContext udtitvfmt_getContext(
const UDateIntervalFormat* formatter,
UDisplayContextType type,
UErrorCode* status
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| formatter | UDateIntervalFormat* | in | 表示コンテキストを取得する日時間隔書式化器のハンドル。 |
| type | UDisplayContextType | in | 取得する表示コンテキストの種別。 |
| status | UErrorCode* | inout | エラーコードへのポインタ。呼び出し前に初期化する必要がある。 |
戻り値の型: UDisplayContext
各言語での呼び出し定義
// icu.dll
#include <windows.h>
UDisplayContext udtitvfmt_getContext(
const UDateIntervalFormat* formatter,
UDisplayContextType type,
UErrorCode* status
);[DllImport("icu.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int udtitvfmt_getContext(
ref IntPtr formatter, // UDateIntervalFormat*
int type, // UDisplayContextType
ref int status // UErrorCode* in/out
);<DllImport("icu.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function udtitvfmt_getContext(
ByRef formatter As IntPtr, ' UDateIntervalFormat*
type As Integer, ' UDisplayContextType
ByRef status As Integer ' UErrorCode* in/out
) As Integer
End Function' formatter : UDateIntervalFormat*
' type : UDisplayContextType
' status : UErrorCode* in/out
Declare PtrSafe Function udtitvfmt_getContext Lib "icu" ( _
ByRef formatter As LongPtr, _
ByVal type As Long, _
ByRef status As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
udtitvfmt_getContext = ctypes.cdll.icu.udtitvfmt_getContext
udtitvfmt_getContext.restype = ctypes.c_int
udtitvfmt_getContext.argtypes = [
ctypes.c_void_p, # formatter : UDateIntervalFormat*
ctypes.c_int, # type : UDisplayContextType
ctypes.c_void_p, # status : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icu.dll')
udtitvfmt_getContext = Fiddle::Function.new(
lib['udtitvfmt_getContext'],
[
Fiddle::TYPE_VOIDP, # formatter : UDateIntervalFormat*
Fiddle::TYPE_INT, # type : UDisplayContextType
Fiddle::TYPE_VOIDP, # status : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icu")]
extern "C" {
fn udtitvfmt_getContext(
formatter: *const isize, // UDateIntervalFormat*
type: i32, // UDisplayContextType
status: *mut i32 // UErrorCode* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icu.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int udtitvfmt_getContext(ref IntPtr formatter, int type, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icu_udtitvfmt_getContext' -Namespace Win32 -PassThru
# $api::udtitvfmt_getContext(formatter, type, status)#uselib "icu.dll"
#func global udtitvfmt_getContext "udtitvfmt_getContext" sptr, sptr, sptr
; udtitvfmt_getContext varptr(formatter), type, varptr(status) ; 戻り値は stat
; formatter : UDateIntervalFormat* -> "sptr"
; type : UDisplayContextType -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icu.dll" #cfunc global udtitvfmt_getContext "udtitvfmt_getContext" var, int, var ; res = udtitvfmt_getContext(formatter, type, status) ; formatter : UDateIntervalFormat* -> "var" ; type : UDisplayContextType -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icu.dll" #cfunc global udtitvfmt_getContext "udtitvfmt_getContext" sptr, int, sptr ; res = udtitvfmt_getContext(varptr(formatter), type, varptr(status)) ; formatter : UDateIntervalFormat* -> "sptr" ; type : UDisplayContextType -> "int" ; status : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UDisplayContext udtitvfmt_getContext(UDateIntervalFormat* formatter, UDisplayContextType type, UErrorCode* status) #uselib "icu.dll" #cfunc global udtitvfmt_getContext "udtitvfmt_getContext" var, int, var ; res = udtitvfmt_getContext(formatter, type, status) ; formatter : UDateIntervalFormat* -> "var" ; type : UDisplayContextType -> "int" ; status : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UDisplayContext udtitvfmt_getContext(UDateIntervalFormat* formatter, UDisplayContextType type, UErrorCode* status) #uselib "icu.dll" #cfunc global udtitvfmt_getContext "udtitvfmt_getContext" intptr, int, intptr ; res = udtitvfmt_getContext(varptr(formatter), type, varptr(status)) ; formatter : UDateIntervalFormat* -> "intptr" ; type : UDisplayContextType -> "int" ; status : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icu = windows.NewLazySystemDLL("icu.dll")
procudtitvfmt_getContext = icu.NewProc("udtitvfmt_getContext")
)
// formatter (UDateIntervalFormat*), type (UDisplayContextType), status (UErrorCode* in/out)
r1, _, err := procudtitvfmt_getContext.Call(
uintptr(formatter),
uintptr(type),
uintptr(status),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UDisplayContextfunction udtitvfmt_getContext(
formatter: Pointer; // UDateIntervalFormat*
type: Integer; // UDisplayContextType
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icu.dll' name 'udtitvfmt_getContext';result := DllCall("icu\udtitvfmt_getContext"
, "Ptr", formatter ; UDateIntervalFormat*
, "Int", type ; UDisplayContextType
, "Ptr", status ; UErrorCode* in/out
, "Cdecl Int") ; return: UDisplayContext●udtitvfmt_getContext(formatter, type, status) = DLL("icu.dll", "int udtitvfmt_getContext(void*, int, void*)")
# 呼び出し: udtitvfmt_getContext(formatter, type, status)
# formatter : UDateIntervalFormat* -> "void*"
# type : UDisplayContextType -> "int"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icu" fn udtitvfmt_getContext(
formatter: [*c]isize, // UDateIntervalFormat*
type: i32, // UDisplayContextType
status: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc udtitvfmt_getContext(
formatter: ptr int, # UDateIntervalFormat*
`type`: int32, # UDisplayContextType
status: ptr int32 # UErrorCode* in/out
): int32 {.importc: "udtitvfmt_getContext", cdecl, dynlib: "icu.dll".}pragma(lib, "icu");
extern(C)
int udtitvfmt_getContext(
ptrdiff_t* formatter, // UDateIntervalFormat*
int type, // UDisplayContextType
int* status // UErrorCode* in/out
);ccall((:udtitvfmt_getContext, "icu.dll"), Int32,
(Ptr{Int}, Int32, Ptr{Int32}),
formatter, type, status)
# formatter : UDateIntervalFormat* -> Ptr{Int}
# type : UDisplayContextType -> Int32
# status : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t udtitvfmt_getContext(
intptr_t* formatter,
int32_t type,
int32_t* status);
]]
local icu = ffi.load("icu")
-- icu.udtitvfmt_getContext(formatter, type, status)
-- formatter : UDateIntervalFormat*
-- type : UDisplayContextType
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icu.dll');
const udtitvfmt_getContext = lib.func('__cdecl', 'udtitvfmt_getContext', 'int32_t', ['intptr_t *', 'int32_t', 'int32_t *']);
// udtitvfmt_getContext(formatter, type, status)
// formatter : UDateIntervalFormat* -> 'intptr_t *'
// type : UDisplayContextType -> 'int32_t'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icu.dll", {
udtitvfmt_getContext: { parameters: ["pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.udtitvfmt_getContext(formatter, type, status)
// formatter : UDateIntervalFormat* -> "pointer"
// type : UDisplayContextType -> "i32"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t udtitvfmt_getContext(
intptr_t* formatter,
int32_t type,
int32_t* status);
C, "icu.dll");
// $ffi->udtitvfmt_getContext(formatter, type, status);
// formatter : UDateIntervalFormat*
// type : UDisplayContextType
// status : UErrorCode* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icu extends Library {
Icu INSTANCE = Native.load("icu", Icu.class);
int udtitvfmt_getContext(
LongByReference formatter, // UDateIntervalFormat*
int type, // UDisplayContextType
IntByReference status // UErrorCode* in/out
);
}@[Link("icu")]
lib Libicu
fun udtitvfmt_getContext = udtitvfmt_getContext(
formatter : LibC::SSizeT*, # UDateIntervalFormat*
type_ : Int32, # UDisplayContextType
status : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef udtitvfmt_getContextNative = Int32 Function(Pointer<IntPtr>, Int32, Pointer<Int32>);
typedef udtitvfmt_getContextDart = int Function(Pointer<IntPtr>, int, Pointer<Int32>);
final udtitvfmt_getContext = DynamicLibrary.open('icu.dll')
.lookupFunction<udtitvfmt_getContextNative, udtitvfmt_getContextDart>('udtitvfmt_getContext');
// formatter : UDateIntervalFormat* -> Pointer<IntPtr>
// type : UDisplayContextType -> Int32
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function udtitvfmt_getContext(
formatter: Pointer; // UDateIntervalFormat*
type: Integer; // UDisplayContextType
status: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icu.dll' name 'udtitvfmt_getContext';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "udtitvfmt_getContext"
c_udtitvfmt_getContext :: Ptr CIntPtr -> Int32 -> Ptr Int32 -> IO Int32
-- formatter : UDateIntervalFormat* -> Ptr CIntPtr
-- type : UDisplayContextType -> Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let udtitvfmt_getcontext =
foreign "udtitvfmt_getContext"
((ptr intptr_t) @-> int32_t @-> (ptr int32_t) @-> returning int32_t)
(* formatter : UDateIntervalFormat* -> (ptr intptr_t) *)
(* type : UDisplayContextType -> int32_t *)
(* status : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icu (t "icu.dll"))
(cffi:use-foreign-library icu)
(cffi:defcfun ("udtitvfmt_getContext" udtitvfmt-get-context :convention :cdecl) :int32
(formatter :pointer) ; UDateIntervalFormat*
(type :int32) ; UDisplayContextType
(status :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $udtitvfmt_getContext = Win32::API::More->new('icu',
'int udtitvfmt_getContext(LPVOID formatter, int type, LPVOID status)');
# my $ret = $udtitvfmt_getContext->Call($formatter, $type, $status);
# formatter : UDateIntervalFormat* -> LPVOID
# type : UDisplayContextType -> int
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。