Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WS_UNION_FIELD_DESCRIPTION

WS_UNION_FIELD_DESCRIPTION

構造体
サイズx64: 96 バイト / x86: 52 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
valueINT4+0+0この共用体メンバを選択する判別子(列挙)の値。
fieldWS_FIELD_DESCRIPTION88/48+8+4選択時に使用するフィールドの記述。

各言語での定義

#include <windows.h>

// WS_FIELD_DESCRIPTION  (x64 88 / x86 48 バイト)
typedef struct WS_FIELD_DESCRIPTION {
    WS_FIELD_MAPPING mapping;
    WS_XML_STRING* localName;
    WS_XML_STRING* ns;
    WS_TYPE type;
    void* typeDescription;
    DWORD offset;
    DWORD options;
    WS_DEFAULT_VALUE* defaultValue;
    DWORD countOffset;
    WS_XML_STRING* itemLocalName;
    WS_XML_STRING* itemNs;
    WS_ITEM_RANGE* itemRange;
} WS_FIELD_DESCRIPTION;

// WS_UNION_FIELD_DESCRIPTION  (x64 96 / x86 52 バイト)
typedef struct WS_UNION_FIELD_DESCRIPTION {
    INT value;
    WS_FIELD_DESCRIPTION field;
} WS_UNION_FIELD_DESCRIPTION;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_FIELD_DESCRIPTION
{
    public int mapping;
    public IntPtr localName;
    public IntPtr ns;
    public int type;
    public IntPtr typeDescription;
    public uint offset;
    public uint options;
    public IntPtr defaultValue;
    public uint countOffset;
    public IntPtr itemLocalName;
    public IntPtr itemNs;
    public IntPtr itemRange;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_UNION_FIELD_DESCRIPTION
{
    public int value;
    public WS_FIELD_DESCRIPTION field;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_FIELD_DESCRIPTION
    Public mapping As Integer
    Public localName As IntPtr
    Public ns As IntPtr
    Public type As Integer
    Public typeDescription As IntPtr
    Public offset As UInteger
    Public options As UInteger
    Public defaultValue As IntPtr
    Public countOffset As UInteger
    Public itemLocalName As IntPtr
    Public itemNs As IntPtr
    Public itemRange As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_UNION_FIELD_DESCRIPTION
    Public value As Integer
    Public field As WS_FIELD_DESCRIPTION
End Structure
import ctypes
from ctypes import wintypes

class WS_FIELD_DESCRIPTION(ctypes.Structure):
    _fields_ = [
        ("mapping", ctypes.c_int),
        ("localName", ctypes.c_void_p),
        ("ns", ctypes.c_void_p),
        ("type", ctypes.c_int),
        ("typeDescription", ctypes.c_void_p),
        ("offset", wintypes.DWORD),
        ("options", wintypes.DWORD),
        ("defaultValue", ctypes.c_void_p),
        ("countOffset", wintypes.DWORD),
        ("itemLocalName", ctypes.c_void_p),
        ("itemNs", ctypes.c_void_p),
        ("itemRange", ctypes.c_void_p),
    ]

class WS_UNION_FIELD_DESCRIPTION(ctypes.Structure):
    _fields_ = [
        ("value", ctypes.c_int),
        ("field", WS_FIELD_DESCRIPTION),
    ]
#[repr(C)]
pub struct WS_FIELD_DESCRIPTION {
    pub mapping: i32,
    pub localName: *mut core::ffi::c_void,
    pub ns: *mut core::ffi::c_void,
    pub type: i32,
    pub typeDescription: *mut core::ffi::c_void,
    pub offset: u32,
    pub options: u32,
    pub defaultValue: *mut core::ffi::c_void,
    pub countOffset: u32,
    pub itemLocalName: *mut core::ffi::c_void,
    pub itemNs: *mut core::ffi::c_void,
    pub itemRange: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct WS_UNION_FIELD_DESCRIPTION {
    pub value: i32,
    pub field: WS_FIELD_DESCRIPTION,
}
import "golang.org/x/sys/windows"

type WS_FIELD_DESCRIPTION struct {
	mapping int32
	localName uintptr
	ns uintptr
	type int32
	typeDescription uintptr
	offset uint32
	options uint32
	defaultValue uintptr
	countOffset uint32
	itemLocalName uintptr
	itemNs uintptr
	itemRange uintptr
}

type WS_UNION_FIELD_DESCRIPTION struct {
	value int32
	field WS_FIELD_DESCRIPTION
}
type
  WS_FIELD_DESCRIPTION = record
    mapping: Integer;
    localName: Pointer;
    ns: Pointer;
    type: Integer;
    typeDescription: Pointer;
    offset: DWORD;
    options: DWORD;
    defaultValue: Pointer;
    countOffset: DWORD;
    itemLocalName: Pointer;
    itemNs: Pointer;
    itemRange: Pointer;
  end;

  WS_UNION_FIELD_DESCRIPTION = record
    value: Integer;
    field: WS_FIELD_DESCRIPTION;
  end;
const WS_FIELD_DESCRIPTION = extern struct {
    mapping: i32,
    localName: ?*anyopaque,
    ns: ?*anyopaque,
    type: i32,
    typeDescription: ?*anyopaque,
    offset: u32,
    options: u32,
    defaultValue: ?*anyopaque,
    countOffset: u32,
    itemLocalName: ?*anyopaque,
    itemNs: ?*anyopaque,
    itemRange: ?*anyopaque,
};

const WS_UNION_FIELD_DESCRIPTION = extern struct {
    value: i32,
    field: WS_FIELD_DESCRIPTION,
};
type
  WS_FIELD_DESCRIPTION {.bycopy.} = object
    mapping: int32
    localName: pointer
    ns: pointer
    type: int32
    typeDescription: pointer
    offset: uint32
    options: uint32
    defaultValue: pointer
    countOffset: uint32
    itemLocalName: pointer
    itemNs: pointer
    itemRange: pointer

  WS_UNION_FIELD_DESCRIPTION {.bycopy.} = object
    value: int32
    field: WS_FIELD_DESCRIPTION
struct WS_FIELD_DESCRIPTION
{
    int mapping;
    void* localName;
    void* ns;
    int type;
    void* typeDescription;
    uint offset;
    uint options;
    void* defaultValue;
    uint countOffset;
    void* itemLocalName;
    void* itemNs;
    void* itemRange;
}

struct WS_UNION_FIELD_DESCRIPTION
{
    int value;
    WS_FIELD_DESCRIPTION field;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WS_UNION_FIELD_DESCRIPTION サイズ: 52 バイト(x86)
dim st, 13    ; 4byte整数×13(構造体サイズ 52 / 4 切り上げ)
; value : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; field : WS_FIELD_DESCRIPTION (+4, 48byte)  varptr(st)+4 を基点に操作(48byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WS_UNION_FIELD_DESCRIPTION サイズ: 96 バイト(x64)
dim st, 24    ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; value : INT (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; field : WS_FIELD_DESCRIPTION (+8, 88byte)  varptr(st)+8 を基点に操作(88byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WS_FIELD_DESCRIPTION
    #field int mapping
    #field intptr localName
    #field intptr ns
    #field int type
    #field intptr typeDescription
    #field int offset
    #field int options
    #field intptr defaultValue
    #field int countOffset
    #field intptr itemLocalName
    #field intptr itemNs
    #field intptr itemRange
#endstruct

#defstruct global WS_UNION_FIELD_DESCRIPTION
    #field int value
    #field WS_FIELD_DESCRIPTION field
#endstruct

stdim st, WS_UNION_FIELD_DESCRIPTION        ; NSTRUCT 変数を確保
st->value = 100
mes "value=" + st->value