ホーム › Globalization › ubidi_openSized
ubidi_openSized
関数事前にサイズを確保したUBiDiオブジェクトを生成する。
シグネチャ
// icuuc.dll
#include <windows.h>
UBiDi* ubidi_openSized(
INT maxLength,
INT maxRunCount,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| maxLength | INT | in | 処理予定テキストの最大長(UChar単位)。事前にメモリを確保する。 |
| maxRunCount | INT | in | 想定する最大実行数(run数)。不明なら0を指定できる。 |
| pErrorCode | UErrorCode* | inout | ICUのエラーコードを受け渡すポインタ。呼び出し前にU_ZERO_ERRORで初期化する。 |
戻り値の型: UBiDi*
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
UBiDi* ubidi_openSized(
INT maxLength,
INT maxRunCount,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ubidi_openSized(
int maxLength, // INT
int maxRunCount, // INT
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ubidi_openSized(
maxLength As Integer, ' INT
maxRunCount As Integer, ' INT
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As IntPtr
End Function' maxLength : INT
' maxRunCount : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function ubidi_openSized Lib "icuuc" ( _
ByVal maxLength As Long, _
ByVal maxRunCount As Long, _
ByRef pErrorCode As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ubidi_openSized = ctypes.cdll.icuuc.ubidi_openSized
ubidi_openSized.restype = ctypes.c_void_p
ubidi_openSized.argtypes = [
ctypes.c_int, # maxLength : INT
ctypes.c_int, # maxRunCount : INT
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ubidi_openSized = Fiddle::Function.new(
lib['ubidi_openSized'],
[
Fiddle::TYPE_INT, # maxLength : INT
Fiddle::TYPE_INT, # maxRunCount : INT
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ubidi_openSized(
maxLength: i32, // INT
maxRunCount: i32, // INT
pErrorCode: *mut i32 // UErrorCode* in/out
) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ubidi_openSized(int maxLength, int maxRunCount, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ubidi_openSized' -Namespace Win32 -PassThru
# $api::ubidi_openSized(maxLength, maxRunCount, pErrorCode)#uselib "icuuc.dll"
#func global ubidi_openSized "ubidi_openSized" sptr, sptr, sptr
; ubidi_openSized maxLength, maxRunCount, varptr(pErrorCode) ; 戻り値は stat
; maxLength : INT -> "sptr"
; maxRunCount : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global ubidi_openSized "ubidi_openSized" int, int, var ; res = ubidi_openSized(maxLength, maxRunCount, pErrorCode) ; maxLength : INT -> "int" ; maxRunCount : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global ubidi_openSized "ubidi_openSized" int, int, sptr ; res = ubidi_openSized(maxLength, maxRunCount, varptr(pErrorCode)) ; maxLength : INT -> "int" ; maxRunCount : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; UBiDi* ubidi_openSized(INT maxLength, INT maxRunCount, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global ubidi_openSized "ubidi_openSized" int, int, var ; res = ubidi_openSized(maxLength, maxRunCount, pErrorCode) ; maxLength : INT -> "int" ; maxRunCount : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; UBiDi* ubidi_openSized(INT maxLength, INT maxRunCount, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global ubidi_openSized "ubidi_openSized" int, int, intptr ; res = ubidi_openSized(maxLength, maxRunCount, varptr(pErrorCode)) ; maxLength : INT -> "int" ; maxRunCount : INT -> "int" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procubidi_openSized = icuuc.NewProc("ubidi_openSized")
)
// maxLength (INT), maxRunCount (INT), pErrorCode (UErrorCode* in/out)
r1, _, err := procubidi_openSized.Call(
uintptr(maxLength),
uintptr(maxRunCount),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UBiDi*function ubidi_openSized(
maxLength: Integer; // INT
maxRunCount: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ubidi_openSized';result := DllCall("icuuc\ubidi_openSized"
, "Int", maxLength ; INT
, "Int", maxRunCount ; INT
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Ptr") ; return: UBiDi*●ubidi_openSized(maxLength, maxRunCount, pErrorCode) = DLL("icuuc.dll", "void* ubidi_openSized(int, int, void*)")
# 呼び出し: ubidi_openSized(maxLength, maxRunCount, pErrorCode)
# maxLength : INT -> "int"
# maxRunCount : INT -> "int"
# pErrorCode : 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 "icuuc" fn ubidi_openSized(
maxLength: i32, // INT
maxRunCount: i32, // INT
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;proc ubidi_openSized(
maxLength: int32, # INT
maxRunCount: int32, # INT
pErrorCode: ptr int32 # UErrorCode* in/out
): ptr int {.importc: "ubidi_openSized", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
ptrdiff_t* ubidi_openSized(
int maxLength, // INT
int maxRunCount, // INT
int* pErrorCode // UErrorCode* in/out
);ccall((:ubidi_openSized, "icuuc.dll"), Ptr{Int},
(Int32, Int32, Ptr{Int32}),
maxLength, maxRunCount, pErrorCode)
# maxLength : INT -> Int32
# maxRunCount : INT -> Int32
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
intptr_t* ubidi_openSized(
int32_t maxLength,
int32_t maxRunCount,
int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ubidi_openSized(maxLength, maxRunCount, pErrorCode)
-- maxLength : INT
-- maxRunCount : INT
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ubidi_openSized = lib.func('__cdecl', 'ubidi_openSized', 'intptr_t *', ['int32_t', 'int32_t', 'int32_t *']);
// ubidi_openSized(maxLength, maxRunCount, pErrorCode)
// maxLength : INT -> 'int32_t'
// maxRunCount : INT -> 'int32_t'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
ubidi_openSized: { parameters: ["i32", "i32", "pointer"], result: "pointer" },
});
// lib.symbols.ubidi_openSized(maxLength, maxRunCount, pErrorCode)
// maxLength : INT -> "i32"
// maxRunCount : INT -> "i32"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
intptr_t* ubidi_openSized(
int32_t maxLength,
int32_t maxRunCount,
int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->ubidi_openSized(maxLength, maxRunCount, pErrorCode);
// maxLength : INT
// maxRunCount : INT
// pErrorCode : 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 Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
Pointer ubidi_openSized(
int maxLength, // INT
int maxRunCount, // INT
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun ubidi_openSized = ubidi_openSized(
maxLength : Int32, # INT
maxRunCount : Int32, # INT
pErrorCode : Int32* # UErrorCode* in/out
) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ubidi_openSizedNative = Pointer<IntPtr> Function(Int32, Int32, Pointer<Int32>);
typedef ubidi_openSizedDart = Pointer<IntPtr> Function(int, int, Pointer<Int32>);
final ubidi_openSized = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ubidi_openSizedNative, ubidi_openSizedDart>('ubidi_openSized');
// maxLength : INT -> Int32
// maxRunCount : INT -> Int32
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ubidi_openSized(
maxLength: Integer; // INT
maxRunCount: Integer; // INT
pErrorCode: Pointer // UErrorCode* in/out
): Pointer; cdecl;
external 'icuuc.dll' name 'ubidi_openSized';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ubidi_openSized"
c_ubidi_openSized :: Int32 -> Int32 -> Ptr Int32 -> IO (Ptr CIntPtr)
-- maxLength : INT -> Int32
-- maxRunCount : INT -> Int32
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ubidi_opensized =
foreign "ubidi_openSized"
(int32_t @-> int32_t @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* maxLength : INT -> int32_t *)
(* maxRunCount : INT -> int32_t *)
(* pErrorCode : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("ubidi_openSized" ubidi-open-sized :convention :cdecl) :pointer
(max-length :int32) ; INT
(max-run-count :int32) ; INT
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ubidi_openSized = Win32::API::More->new('icuuc',
'LPVOID ubidi_openSized(int maxLength, int maxRunCount, LPVOID pErrorCode)');
# my $ret = $ubidi_openSized->Call($maxLength, $maxRunCount, $pErrorCode);
# maxLength : INT -> int
# maxRunCount : INT -> int
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型