ホーム › Networking.WindowsWebServices › WsReadXmlBufferFromBytes
WsReadXmlBufferFromBytes
関数バイト列からXMLバッファを読み込む。
シグネチャ
// webservices.dll
#include <windows.h>
HRESULT WsReadXmlBufferFromBytes(
WS_XML_READER* reader,
const WS_XML_READER_ENCODING* encoding, // optional
const WS_XML_READER_PROPERTY* properties, // optional
DWORD propertyCount,
const void* bytes,
DWORD byteCount,
WS_HEAP* heap,
WS_XML_BUFFER** xmlBuffer,
WS_ERROR* error // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| reader | WS_XML_READER* | in | デシリアライズに用いるXMLリーダー。 |
| encoding | WS_XML_READER_ENCODING* | inoptional | 入力バイト列のエンコーディング指定。NULL可。 |
| properties | WS_XML_READER_PROPERTY* | inoptional | リーダーの構成プロパティ配列。NULL可。 |
| propertyCount | DWORD | in | properties配列の要素数。 |
| bytes | void* | in | 解析する入力バイト列へのポインタ。 |
| byteCount | DWORD | in | bytesのバイト数。 |
| heap | WS_HEAP* | in | 生成バッファの確保に使うWS_HEAPヒープ。 |
| xmlBuffer | WS_XML_BUFFER** | out | 生成されたXMLバッファを受け取る出力ポインタ。 |
| error | WS_ERROR* | inoptional | 失敗時の追加エラー情報を格納するWS_ERRORオブジェクト。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// webservices.dll
#include <windows.h>
HRESULT WsReadXmlBufferFromBytes(
WS_XML_READER* reader,
const WS_XML_READER_ENCODING* encoding, // optional
const WS_XML_READER_PROPERTY* properties, // optional
DWORD propertyCount,
const void* bytes,
DWORD byteCount,
WS_HEAP* heap,
WS_XML_BUFFER** xmlBuffer,
WS_ERROR* error // optional
);[DllImport("webservices.dll", ExactSpelling = true)]
static extern int WsReadXmlBufferFromBytes(
ref IntPtr reader, // WS_XML_READER*
IntPtr encoding, // WS_XML_READER_ENCODING* optional
IntPtr properties, // WS_XML_READER_PROPERTY* optional
uint propertyCount, // DWORD
IntPtr bytes, // void*
uint byteCount, // DWORD
ref IntPtr heap, // WS_HEAP*
IntPtr xmlBuffer, // WS_XML_BUFFER** out
IntPtr error // WS_ERROR* optional
);<DllImport("webservices.dll", ExactSpelling:=True)>
Public Shared Function WsReadXmlBufferFromBytes(
ByRef reader As IntPtr, ' WS_XML_READER*
encoding As IntPtr, ' WS_XML_READER_ENCODING* optional
properties As IntPtr, ' WS_XML_READER_PROPERTY* optional
propertyCount As UInteger, ' DWORD
bytes As IntPtr, ' void*
byteCount As UInteger, ' DWORD
ByRef heap As IntPtr, ' WS_HEAP*
xmlBuffer As IntPtr, ' WS_XML_BUFFER** out
[error] As IntPtr ' WS_ERROR* optional
) As Integer
End Function' reader : WS_XML_READER*
' encoding : WS_XML_READER_ENCODING* optional
' properties : WS_XML_READER_PROPERTY* optional
' propertyCount : DWORD
' bytes : void*
' byteCount : DWORD
' heap : WS_HEAP*
' xmlBuffer : WS_XML_BUFFER** out
' error : WS_ERROR* optional
Declare PtrSafe Function WsReadXmlBufferFromBytes Lib "webservices" ( _
ByRef reader As LongPtr, _
ByVal encoding As LongPtr, _
ByVal properties As LongPtr, _
ByVal propertyCount As Long, _
ByVal bytes As LongPtr, _
ByVal byteCount As Long, _
ByRef heap As LongPtr, _
ByVal xmlBuffer As LongPtr, _
ByVal error As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WsReadXmlBufferFromBytes = ctypes.windll.webservices.WsReadXmlBufferFromBytes
WsReadXmlBufferFromBytes.restype = ctypes.c_int
WsReadXmlBufferFromBytes.argtypes = [
ctypes.c_void_p, # reader : WS_XML_READER*
ctypes.c_void_p, # encoding : WS_XML_READER_ENCODING* optional
ctypes.c_void_p, # properties : WS_XML_READER_PROPERTY* optional
wintypes.DWORD, # propertyCount : DWORD
ctypes.POINTER(None), # bytes : void*
wintypes.DWORD, # byteCount : DWORD
ctypes.c_void_p, # heap : WS_HEAP*
ctypes.c_void_p, # xmlBuffer : WS_XML_BUFFER** out
ctypes.c_void_p, # error : WS_ERROR* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('webservices.dll')
WsReadXmlBufferFromBytes = Fiddle::Function.new(
lib['WsReadXmlBufferFromBytes'],
[
Fiddle::TYPE_VOIDP, # reader : WS_XML_READER*
Fiddle::TYPE_VOIDP, # encoding : WS_XML_READER_ENCODING* optional
Fiddle::TYPE_VOIDP, # properties : WS_XML_READER_PROPERTY* optional
-Fiddle::TYPE_INT, # propertyCount : DWORD
Fiddle::TYPE_VOIDP, # bytes : void*
-Fiddle::TYPE_INT, # byteCount : DWORD
Fiddle::TYPE_VOIDP, # heap : WS_HEAP*
Fiddle::TYPE_VOIDP, # xmlBuffer : WS_XML_BUFFER** out
Fiddle::TYPE_VOIDP, # error : WS_ERROR* optional
],
Fiddle::TYPE_INT)#[link(name = "webservices")]
extern "system" {
fn WsReadXmlBufferFromBytes(
reader: *mut isize, // WS_XML_READER*
encoding: *const WS_XML_READER_ENCODING, // WS_XML_READER_ENCODING* optional
properties: *const WS_XML_READER_PROPERTY, // WS_XML_READER_PROPERTY* optional
propertyCount: u32, // DWORD
bytes: *const (), // void*
byteCount: u32, // DWORD
heap: *mut isize, // WS_HEAP*
xmlBuffer: *mut *mut isize, // WS_XML_BUFFER** out
error: *mut isize // WS_ERROR* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("webservices.dll")]
public static extern int WsReadXmlBufferFromBytes(ref IntPtr reader, IntPtr encoding, IntPtr properties, uint propertyCount, IntPtr bytes, uint byteCount, ref IntPtr heap, IntPtr xmlBuffer, IntPtr error);
"@
$api = Add-Type -MemberDefinition $sig -Name 'webservices_WsReadXmlBufferFromBytes' -Namespace Win32 -PassThru
# $api::WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error)#uselib "webservices.dll"
#func global WsReadXmlBufferFromBytes "WsReadXmlBufferFromBytes" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; WsReadXmlBufferFromBytes varptr(reader), varptr(encoding), varptr(properties), propertyCount, bytes, byteCount, varptr(heap), varptr(xmlBuffer), varptr(error) ; 戻り値は stat
; reader : WS_XML_READER* -> "sptr"
; encoding : WS_XML_READER_ENCODING* optional -> "sptr"
; properties : WS_XML_READER_PROPERTY* optional -> "sptr"
; propertyCount : DWORD -> "sptr"
; bytes : void* -> "sptr"
; byteCount : DWORD -> "sptr"
; heap : WS_HEAP* -> "sptr"
; xmlBuffer : WS_XML_BUFFER** out -> "sptr"
; error : WS_ERROR* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "webservices.dll" #cfunc global WsReadXmlBufferFromBytes "WsReadXmlBufferFromBytes" var, var, var, int, sptr, int, var, var, var ; res = WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error) ; reader : WS_XML_READER* -> "var" ; encoding : WS_XML_READER_ENCODING* optional -> "var" ; properties : WS_XML_READER_PROPERTY* optional -> "var" ; propertyCount : DWORD -> "int" ; bytes : void* -> "sptr" ; byteCount : DWORD -> "int" ; heap : WS_HEAP* -> "var" ; xmlBuffer : WS_XML_BUFFER** out -> "var" ; error : WS_ERROR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "webservices.dll" #cfunc global WsReadXmlBufferFromBytes "WsReadXmlBufferFromBytes" sptr, sptr, sptr, int, sptr, int, sptr, sptr, sptr ; res = WsReadXmlBufferFromBytes(varptr(reader), varptr(encoding), varptr(properties), propertyCount, bytes, byteCount, varptr(heap), varptr(xmlBuffer), varptr(error)) ; reader : WS_XML_READER* -> "sptr" ; encoding : WS_XML_READER_ENCODING* optional -> "sptr" ; properties : WS_XML_READER_PROPERTY* optional -> "sptr" ; propertyCount : DWORD -> "int" ; bytes : void* -> "sptr" ; byteCount : DWORD -> "int" ; heap : WS_HEAP* -> "sptr" ; xmlBuffer : WS_XML_BUFFER** out -> "sptr" ; error : WS_ERROR* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WsReadXmlBufferFromBytes(WS_XML_READER* reader, WS_XML_READER_ENCODING* encoding, WS_XML_READER_PROPERTY* properties, DWORD propertyCount, void* bytes, DWORD byteCount, WS_HEAP* heap, WS_XML_BUFFER** xmlBuffer, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsReadXmlBufferFromBytes "WsReadXmlBufferFromBytes" var, var, var, int, intptr, int, var, var, var ; res = WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error) ; reader : WS_XML_READER* -> "var" ; encoding : WS_XML_READER_ENCODING* optional -> "var" ; properties : WS_XML_READER_PROPERTY* optional -> "var" ; propertyCount : DWORD -> "int" ; bytes : void* -> "intptr" ; byteCount : DWORD -> "int" ; heap : WS_HEAP* -> "var" ; xmlBuffer : WS_XML_BUFFER** out -> "var" ; error : WS_ERROR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WsReadXmlBufferFromBytes(WS_XML_READER* reader, WS_XML_READER_ENCODING* encoding, WS_XML_READER_PROPERTY* properties, DWORD propertyCount, void* bytes, DWORD byteCount, WS_HEAP* heap, WS_XML_BUFFER** xmlBuffer, WS_ERROR* error) #uselib "webservices.dll" #cfunc global WsReadXmlBufferFromBytes "WsReadXmlBufferFromBytes" intptr, intptr, intptr, int, intptr, int, intptr, intptr, intptr ; res = WsReadXmlBufferFromBytes(varptr(reader), varptr(encoding), varptr(properties), propertyCount, bytes, byteCount, varptr(heap), varptr(xmlBuffer), varptr(error)) ; reader : WS_XML_READER* -> "intptr" ; encoding : WS_XML_READER_ENCODING* optional -> "intptr" ; properties : WS_XML_READER_PROPERTY* optional -> "intptr" ; propertyCount : DWORD -> "int" ; bytes : void* -> "intptr" ; byteCount : DWORD -> "int" ; heap : WS_HEAP* -> "intptr" ; xmlBuffer : WS_XML_BUFFER** out -> "intptr" ; error : WS_ERROR* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
webservices = windows.NewLazySystemDLL("webservices.dll")
procWsReadXmlBufferFromBytes = webservices.NewProc("WsReadXmlBufferFromBytes")
)
// reader (WS_XML_READER*), encoding (WS_XML_READER_ENCODING* optional), properties (WS_XML_READER_PROPERTY* optional), propertyCount (DWORD), bytes (void*), byteCount (DWORD), heap (WS_HEAP*), xmlBuffer (WS_XML_BUFFER** out), error (WS_ERROR* optional)
r1, _, err := procWsReadXmlBufferFromBytes.Call(
uintptr(reader),
uintptr(encoding),
uintptr(properties),
uintptr(propertyCount),
uintptr(bytes),
uintptr(byteCount),
uintptr(heap),
uintptr(xmlBuffer),
uintptr(error),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WsReadXmlBufferFromBytes(
reader: Pointer; // WS_XML_READER*
encoding: Pointer; // WS_XML_READER_ENCODING* optional
properties: Pointer; // WS_XML_READER_PROPERTY* optional
propertyCount: DWORD; // DWORD
bytes: Pointer; // void*
byteCount: DWORD; // DWORD
heap: Pointer; // WS_HEAP*
xmlBuffer: Pointer; // WS_XML_BUFFER** out
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsReadXmlBufferFromBytes';result := DllCall("webservices\WsReadXmlBufferFromBytes"
, "Ptr", reader ; WS_XML_READER*
, "Ptr", encoding ; WS_XML_READER_ENCODING* optional
, "Ptr", properties ; WS_XML_READER_PROPERTY* optional
, "UInt", propertyCount ; DWORD
, "Ptr", bytes ; void*
, "UInt", byteCount ; DWORD
, "Ptr", heap ; WS_HEAP*
, "Ptr", xmlBuffer ; WS_XML_BUFFER** out
, "Ptr", error ; WS_ERROR* optional
, "Int") ; return: HRESULT●WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error) = DLL("webservices.dll", "int WsReadXmlBufferFromBytes(void*, void*, void*, dword, void*, dword, void*, void*, void*)")
# 呼び出し: WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error)
# reader : WS_XML_READER* -> "void*"
# encoding : WS_XML_READER_ENCODING* optional -> "void*"
# properties : WS_XML_READER_PROPERTY* optional -> "void*"
# propertyCount : DWORD -> "dword"
# bytes : void* -> "void*"
# byteCount : DWORD -> "dword"
# heap : WS_HEAP* -> "void*"
# xmlBuffer : WS_XML_BUFFER** out -> "void*"
# error : WS_ERROR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "webservices" fn WsReadXmlBufferFromBytes(
reader: [*c]isize, // WS_XML_READER*
encoding: [*c]WS_XML_READER_ENCODING, // WS_XML_READER_ENCODING* optional
properties: [*c]WS_XML_READER_PROPERTY, // WS_XML_READER_PROPERTY* optional
propertyCount: u32, // DWORD
bytes: ?*anyopaque, // void*
byteCount: u32, // DWORD
heap: [*c]isize, // WS_HEAP*
xmlBuffer: [*c][*c]isize, // WS_XML_BUFFER** out
error: [*c]isize // WS_ERROR* optional
) callconv(std.os.windows.WINAPI) i32;proc WsReadXmlBufferFromBytes(
reader: ptr int, # WS_XML_READER*
encoding: ptr WS_XML_READER_ENCODING, # WS_XML_READER_ENCODING* optional
properties: ptr WS_XML_READER_PROPERTY, # WS_XML_READER_PROPERTY* optional
propertyCount: uint32, # DWORD
bytes: pointer, # void*
byteCount: uint32, # DWORD
heap: ptr int, # WS_HEAP*
xmlBuffer: ptr int, # WS_XML_BUFFER** out
error: ptr int # WS_ERROR* optional
): int32 {.importc: "WsReadXmlBufferFromBytes", stdcall, dynlib: "webservices.dll".}pragma(lib, "webservices");
extern(Windows)
int WsReadXmlBufferFromBytes(
ptrdiff_t* reader, // WS_XML_READER*
WS_XML_READER_ENCODING* encoding, // WS_XML_READER_ENCODING* optional
WS_XML_READER_PROPERTY* properties, // WS_XML_READER_PROPERTY* optional
uint propertyCount, // DWORD
void* bytes, // void*
uint byteCount, // DWORD
ptrdiff_t* heap, // WS_HEAP*
ptrdiff_t** xmlBuffer, // WS_XML_BUFFER** out
ptrdiff_t* error // WS_ERROR* optional
);ccall((:WsReadXmlBufferFromBytes, "webservices.dll"), stdcall, Int32,
(Ptr{Int}, Ptr{WS_XML_READER_ENCODING}, Ptr{WS_XML_READER_PROPERTY}, UInt32, Ptr{Cvoid}, UInt32, Ptr{Int}, Ptr{Int}, Ptr{Int}),
reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error)
# reader : WS_XML_READER* -> Ptr{Int}
# encoding : WS_XML_READER_ENCODING* optional -> Ptr{WS_XML_READER_ENCODING}
# properties : WS_XML_READER_PROPERTY* optional -> Ptr{WS_XML_READER_PROPERTY}
# propertyCount : DWORD -> UInt32
# bytes : void* -> Ptr{Cvoid}
# byteCount : DWORD -> UInt32
# heap : WS_HEAP* -> Ptr{Int}
# xmlBuffer : WS_XML_BUFFER** out -> Ptr{Int}
# error : WS_ERROR* optional -> Ptr{Int}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WsReadXmlBufferFromBytes(
intptr_t* reader,
void* encoding,
void* properties,
uint32_t propertyCount,
void* bytes,
uint32_t byteCount,
intptr_t* heap,
intptr_t** xmlBuffer,
intptr_t* error);
]]
local webservices = ffi.load("webservices")
-- webservices.WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error)
-- reader : WS_XML_READER*
-- encoding : WS_XML_READER_ENCODING* optional
-- properties : WS_XML_READER_PROPERTY* optional
-- propertyCount : DWORD
-- bytes : void*
-- byteCount : DWORD
-- heap : WS_HEAP*
-- xmlBuffer : WS_XML_BUFFER** out
-- error : WS_ERROR* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('webservices.dll');
const WsReadXmlBufferFromBytes = lib.func('__stdcall', 'WsReadXmlBufferFromBytes', 'int32_t', ['intptr_t *', 'void *', 'void *', 'uint32_t', 'void *', 'uint32_t', 'intptr_t *', 'intptr_t *', 'intptr_t *']);
// WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error)
// reader : WS_XML_READER* -> 'intptr_t *'
// encoding : WS_XML_READER_ENCODING* optional -> 'void *'
// properties : WS_XML_READER_PROPERTY* optional -> 'void *'
// propertyCount : DWORD -> 'uint32_t'
// bytes : void* -> 'void *'
// byteCount : DWORD -> 'uint32_t'
// heap : WS_HEAP* -> 'intptr_t *'
// xmlBuffer : WS_XML_BUFFER** out -> 'intptr_t *'
// error : WS_ERROR* optional -> 'intptr_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("webservices.dll", {
WsReadXmlBufferFromBytes: { parameters: ["pointer", "pointer", "pointer", "u32", "pointer", "u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error)
// reader : WS_XML_READER* -> "pointer"
// encoding : WS_XML_READER_ENCODING* optional -> "pointer"
// properties : WS_XML_READER_PROPERTY* optional -> "pointer"
// propertyCount : DWORD -> "u32"
// bytes : void* -> "pointer"
// byteCount : DWORD -> "u32"
// heap : WS_HEAP* -> "pointer"
// xmlBuffer : WS_XML_BUFFER** out -> "pointer"
// error : WS_ERROR* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WsReadXmlBufferFromBytes(
intptr_t* reader,
void* encoding,
void* properties,
uint32_t propertyCount,
void* bytes,
uint32_t byteCount,
intptr_t* heap,
intptr_t** xmlBuffer,
intptr_t* error);
C, "webservices.dll");
// $ffi->WsReadXmlBufferFromBytes(reader, encoding, properties, propertyCount, bytes, byteCount, heap, xmlBuffer, error);
// reader : WS_XML_READER*
// encoding : WS_XML_READER_ENCODING* optional
// properties : WS_XML_READER_PROPERTY* optional
// propertyCount : DWORD
// bytes : void*
// byteCount : DWORD
// heap : WS_HEAP*
// xmlBuffer : WS_XML_BUFFER** out
// error : WS_ERROR* optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Webservices extends StdCallLibrary {
Webservices INSTANCE = Native.load("webservices", Webservices.class);
int WsReadXmlBufferFromBytes(
LongByReference reader, // WS_XML_READER*
Pointer encoding, // WS_XML_READER_ENCODING* optional
Pointer properties, // WS_XML_READER_PROPERTY* optional
int propertyCount, // DWORD
Pointer bytes, // void*
int byteCount, // DWORD
LongByReference heap, // WS_HEAP*
Pointer xmlBuffer, // WS_XML_BUFFER** out
LongByReference error // WS_ERROR* optional
);
}@[Link("webservices")]
lib Libwebservices
fun WsReadXmlBufferFromBytes = WsReadXmlBufferFromBytes(
reader : LibC::SSizeT*, # WS_XML_READER*
encoding : WS_XML_READER_ENCODING*, # WS_XML_READER_ENCODING* optional
properties : WS_XML_READER_PROPERTY*, # WS_XML_READER_PROPERTY* optional
propertyCount : UInt32, # DWORD
bytes : Void*, # void*
byteCount : UInt32, # DWORD
heap : LibC::SSizeT*, # WS_HEAP*
xmlBuffer : LibC::SSizeT**, # WS_XML_BUFFER** out
error : LibC::SSizeT* # WS_ERROR* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WsReadXmlBufferFromBytesNative = Int32 Function(Pointer<IntPtr>, Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>, Uint32, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<IntPtr>);
typedef WsReadXmlBufferFromBytesDart = int Function(Pointer<IntPtr>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>, int, Pointer<IntPtr>, Pointer<IntPtr>, Pointer<IntPtr>);
final WsReadXmlBufferFromBytes = DynamicLibrary.open('webservices.dll')
.lookupFunction<WsReadXmlBufferFromBytesNative, WsReadXmlBufferFromBytesDart>('WsReadXmlBufferFromBytes');
// reader : WS_XML_READER* -> Pointer<IntPtr>
// encoding : WS_XML_READER_ENCODING* optional -> Pointer<Void>
// properties : WS_XML_READER_PROPERTY* optional -> Pointer<Void>
// propertyCount : DWORD -> Uint32
// bytes : void* -> Pointer<Void>
// byteCount : DWORD -> Uint32
// heap : WS_HEAP* -> Pointer<IntPtr>
// xmlBuffer : WS_XML_BUFFER** out -> Pointer<IntPtr>
// error : WS_ERROR* optional -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WsReadXmlBufferFromBytes(
reader: Pointer; // WS_XML_READER*
encoding: Pointer; // WS_XML_READER_ENCODING* optional
properties: Pointer; // WS_XML_READER_PROPERTY* optional
propertyCount: DWORD; // DWORD
bytes: Pointer; // void*
byteCount: DWORD; // DWORD
heap: Pointer; // WS_HEAP*
xmlBuffer: Pointer; // WS_XML_BUFFER** out
error: Pointer // WS_ERROR* optional
): Integer; stdcall;
external 'webservices.dll' name 'WsReadXmlBufferFromBytes';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WsReadXmlBufferFromBytes"
c_WsReadXmlBufferFromBytes :: Ptr CIntPtr -> Ptr () -> Ptr () -> Word32 -> Ptr () -> Word32 -> Ptr CIntPtr -> Ptr CIntPtr -> Ptr CIntPtr -> IO Int32
-- reader : WS_XML_READER* -> Ptr CIntPtr
-- encoding : WS_XML_READER_ENCODING* optional -> Ptr ()
-- properties : WS_XML_READER_PROPERTY* optional -> Ptr ()
-- propertyCount : DWORD -> Word32
-- bytes : void* -> Ptr ()
-- byteCount : DWORD -> Word32
-- heap : WS_HEAP* -> Ptr CIntPtr
-- xmlBuffer : WS_XML_BUFFER** out -> Ptr CIntPtr
-- error : WS_ERROR* optional -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsreadxmlbufferfrombytes =
foreign "WsReadXmlBufferFromBytes"
((ptr intptr_t) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> uint32_t @-> (ptr intptr_t) @-> (ptr intptr_t) @-> (ptr intptr_t) @-> returning int32_t)
(* reader : WS_XML_READER* -> (ptr intptr_t) *)
(* encoding : WS_XML_READER_ENCODING* optional -> (ptr void) *)
(* properties : WS_XML_READER_PROPERTY* optional -> (ptr void) *)
(* propertyCount : DWORD -> uint32_t *)
(* bytes : void* -> (ptr void) *)
(* byteCount : DWORD -> uint32_t *)
(* heap : WS_HEAP* -> (ptr intptr_t) *)
(* xmlBuffer : WS_XML_BUFFER** out -> (ptr intptr_t) *)
(* error : WS_ERROR* optional -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library webservices (t "webservices.dll"))
(cffi:use-foreign-library webservices)
(cffi:defcfun ("WsReadXmlBufferFromBytes" ws-read-xml-buffer-from-bytes :convention :stdcall) :int32
(reader :pointer) ; WS_XML_READER*
(encoding :pointer) ; WS_XML_READER_ENCODING* optional
(properties :pointer) ; WS_XML_READER_PROPERTY* optional
(property-count :uint32) ; DWORD
(bytes :pointer) ; void*
(byte-count :uint32) ; DWORD
(heap :pointer) ; WS_HEAP*
(xml-buffer :pointer) ; WS_XML_BUFFER** out
(error :pointer)) ; WS_ERROR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WsReadXmlBufferFromBytes = Win32::API::More->new('webservices',
'int WsReadXmlBufferFromBytes(LPVOID reader, LPVOID encoding, LPVOID properties, DWORD propertyCount, LPVOID bytes, DWORD byteCount, LPVOID heap, LPVOID xmlBuffer, LPVOID error)');
# my $ret = $WsReadXmlBufferFromBytes->Call($reader, $encoding, $properties, $propertyCount, $bytes, $byteCount, $heap, $xmlBuffer, $error);
# reader : WS_XML_READER* -> LPVOID
# encoding : WS_XML_READER_ENCODING* optional -> LPVOID
# properties : WS_XML_READER_PROPERTY* optional -> LPVOID
# propertyCount : DWORD -> DWORD
# bytes : void* -> LPVOID
# byteCount : DWORD -> DWORD
# heap : WS_HEAP* -> LPVOID
# xmlBuffer : WS_XML_BUFFER** out -> LPVOID
# error : WS_ERROR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。