winrtgen 0.0.1 copy "winrtgen: ^0.0.1" to clipboard
winrtgen: ^0.0.1 copied to clipboard

discontinued

Provides functionality to generate WinRT APIs from Windows Metadata (WinMD) files.

example/example.dart

// Copyright (c) 2023, Halil Durmus. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

import 'package:dart_style/dart_style.dart';
import 'package:winrtgen/winrtgen.dart';

final formatter = DartFormatter();

String format(Object object) {
  final source = object.toString();
  try {
    return formatter.format(source);
  } catch (_) {
    print('Failed to format ${object.runtimeType}.');
    return source;
  }
}

void printEnum() {
  final enumProjection =
      EnumProjection.fromType('Windows.Foundation.AsyncStatus');
  print(format(enumProjection));
}

void printStruct() {
  final structProjection =
      StructProjection.fromType('Windows.Gaming.Input.GamepadReading');
  print(format(structProjection));
  final nativeStructProjection =
      NativeStructProjection.fromType('Windows.Gaming.Input.GamepadReading');
  print(format(nativeStructProjection));
}

void printMethod() {
  final methodProjection = MethodProjection.fromTypeAndMethodName(
      'Windows.Data.Xml.Dom.IXmlDocument', 'CreateElementNS');
  print(format(methodProjection));
}

void printGetter() {
  final getterProjection = GetterProjection.fromTypeAndMethodName(
      'Windows.Globalization.ICalendar', 'get_Languages');
  print(format(getterProjection));
}

void printSetter() {
  final setterProjection = SetterProjection.fromTypeAndMethodName(
      'Windows.Devices.Geolocation.IGeolocator', 'put_DesiredAccuracy');
  print(format(setterProjection));
}

void printInterface() {
  final interfaceProjection =
      InterfaceProjection.fromType('Windows.Storage.Pickers.IFileOpenPicker');
  print(format(interfaceProjection));
}

void printClass() {
  final classProjection =
      ClassProjection.fromType('Windows.Globalization.Calendar');
  print(format(classProjection));
}

void main() async {
  await WinRTMetadataStore.loadMetadata();

  printEnum();
  printStruct();
  printMethod();
  printGetter();
  printSetter();
  printInterface();
  printClass();

  WinRTMetadataStore.close();
}
0
likes
50
points
0
downloads

Publisher

verified publisherwin32.pub

Weekly Downloads

Provides functionality to generate WinRT APIs from Windows Metadata (WinMD) files.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

args, crypto, dart_style, ffi, html, http, path, pool, win32, winmd

More

Packages that depend on winrtgen