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