class WinMD::Ecma335Importer

Overview

Converts the Ecma335::ApiModel of a parsed .winmd into the win32json document shape that WinMD::File already consumes, one document per namespace. Keeping the JSON contract as the boundary means every template, override and alias mechanism of the JSON pipeline applies unchanged, and the intermediate documents can be dumped for diffing against real win32json.

Defined in:

winmd/ecma335_importer.cr

Constant Summary

ARCHITECTURES = {1 => "X86", 2 => "X64", 4 => "Arm64"}

Windows.Win32.Foundation.Metadata.Architecture flag bits.

CONSTANT_VALUE_TYPES = {"bool" => "Boolean", "char" => "Char", "int8" => "SByte", "uint8" => "Byte", "int16" => "Int16", "uint16" => "UInt16", "int32" => "Int32", "uint32" => "UInt32", "int64" => "Int64", "uint64" => "UInt64", "float32" => "Single", "float64" => "Double", "string" => "String"}

Constant element types (from the Constant table) to win32json ValueType.

PRIMITIVES = {"void" => "Void", "bool" => "Boolean", "char" => "Char", "int8" => "SByte", "uint8" => "Byte", "int16" => "Int16", "uint16" => "UInt16", "int32" => "Int32", "uint32" => "UInt32", "int64" => "Int64", "uint64" => "UInt64", "float32" => "Single", "float64" => "Double", "nativeint" => "IntPtr", "nativeuint" => "UIntPtr"}

ECMA-335 primitive element names to the .NET names win32json uses.

UNLINKABLE_MODULES = {"forceinline", "ntdllk"}

Import modules that no user-mode program can link against: FORCEINLINE marks header-only inline functions with no export anywhere, and ntdllk is the kernel-mode ntdll. Emitting these would add unresolvable @[Link] libraries.

WIN32_PREFIX = "Windows.Win32."

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(parsed : Ecma335::ParsedAssembly) #

[View source]

Class Method Detail

def self.api_name(namespace : String) : String #

win32json file/API name: the namespace without the Windows.Win32 prefix.


[View source]

Instance Method Detail

def associated_enums=(associated_enums : Bool) #

When true, integer parameters and fields that carry an AssociatedEnum attribute are typed as that enum, the way older metadata declared them.


[View source]
def associated_enums? : Bool #

When true, integer parameters and fields that carry an AssociatedEnum attribute are typed as that enum, the way older metadata declared them.


[View source]
def dump(dir : Path) : Nil #

Writes one <Api>.json document per namespace into dir.


[View source]
def files : Array(WinMD::File) #

[View source]
def import : Array(WinMD::File) #

[View source]
def namespace_json(namespace : String, pretty : Bool = false) : String #

[View source]
def namespaces : Array(String) #

Namespaces that produce an output file, sorted. The namespace holding the metadata attribute definitions themselves is not part of the API surface.


[View source]