﻿<?xml version="1.0" encoding="utf-8"?>
<!--
// Copyright (c) 2010-2014 SharpGen.Runtime - Alexandre Mutel
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-->
<config id="sharpgen-runtime-com" xmlns="urn:SharpGen.Config">
  <namespace>SharpGen.Runtime</namespace>
  <assembly>SharpGen.Runtime.COM</assembly>

  <sdk name="WindowsSdk" version="10.0.17763.0" />
  <sdk name="StdLib" />

  <include-prolog>
    // Use unicode
    #define UNICODE

    // for SAL annotations
    #define _PREFAST_

    // To force GUID to be declared
    #define INITGUID

    #define _ALLOW_KEYWORD_MACROS

    // Wrap all declspec for code-gen
    #define __declspec(x) __attribute__((annotate(#x)))
  </include-prolog>
  <include file="windows.h" />

  <include file="Unknwnbase.h" namespace="SharpGen.Runtime">
    <attach>IUnknown</attach>
  </include>

  <include file="Objidlbase.h" namespace="SharpGen.Runtime.Win32" output="Win32">
    <attach>STATSTG</attach>
    <attach>tagLOCKTYPE</attach>
    <attach>LOCKTYPE</attach>
    <attach>ISequentialStream</attach>
    <attach>IStream</attach>
  </include>

  <include file="wtypes.h" namespace="SharpGen.Runtime.Win32" output="Win32">
    <attach>tagSTGC</attach>
    <attach>STGC</attach>
    <attach>STATFLAG</attach>
  </include>

  <include file="winerror.h" namespace="SharpGen.Runtime.Win32" output="Win32"/>

  <include file="winstring.h" namespace="SharpGen.Runtime.Win32" output="Win32">
    <attach>WindowsCreateString</attach>
  </include>

  <!-- SharpGen global naming -->
  <naming />

  <!-- SharpGen.Runtime global types -->
  <extension>
    <context>sharpgen-runtime-com-ext</context>
    <context>sharpgen-runtime-com</context>
    <context>winerror</context>
    <create-cpp enum="SHARPGEN_RUNTIME_COM_ERRORCODE" macro="ERROR_(.*)" />
    <context-clear/>

    <define enum="System.IO.SeekOrigin" sizeof="4" underlying="System.UInt32"  />
    <define struct="SharpGen.Runtime.Win32.RawBool" sizeof="4" />

    <define interface="SharpGen.Runtime.ComObject" />

    <define interface="SharpGen.Runtime.Win32.PropertyBag"/>
    <define struct="SharpGen.Runtime.Win32.SecurityAttributes" sizeof="16" />
    <define struct="SharpGen.Runtime.Win32.NativeMessage" sizeof="28" />

    <define struct="SharpGen.Runtime.Win32.Variant" sizeof="16"/>
    <define struct="SharpGen.Runtime.Win32.BitmapInfoHeader" sizeof="40"/>

    <create class="SharpGen.Runtime.Win32.WinRTStrings" visibility="internal static" />

  </extension>

  <!--
    // *****************************************************************
    // Bindings
    // *****************************************************************
    -->
  <bindings>
    <!-- SharpGen.Runtime bindings -->
    <bind from="SHARPGEN_RUNTIME_SEEKORIGIN" to="System.IO.SeekOrigin" />

    <!-- Win32 bindings -->
    <bind from="INT_PTR" to="System.IntPtr" />
    <bind from="UINT_PTR" to="System.UIntPtr" />
    <bind from="LONG_PTR" to="System.IntPtr" />
    <bind from="ULONG_PTR" to="System.UIntPtr" />
    <bind from="HANDLE_PTR" to="System.IntPtr" />

    <bind from="BOOL" to="SharpGen.Runtime.Win32.RawBool"/>
    <bind from="HANDLE" to="System.IntPtr" />
    <bind from="HRESULT" to="SharpGen.Runtime.Result" />
    <bind from="SIZE_T" to="SharpGen.Runtime.PointerSize" />
    <bind from="SSIZE_T" to="SharpGen.Runtime.PointerSize" />
    <bind from="MSG" to="SharpGen.Runtime.Win32.NativeMessage" />
    <bind from="ULARGE_INTEGER" to="System.UInt64" />
    <bind from="LARGE_INTEGER" to="System.Int64" />
    <bind from="FILETIME" to="System.Int64" />
    <bind from="DWORD" to="System.Int32" />
    <bind from="ULONG" to="System.UInt32" />
    <bind from="LONG" to="System.Int32" />

    <bind from="SECURITY_ATTRIBUTES" to="SharpGen.Runtime.Win32.SecurityAttributes"/>

    <bind from="VARIANT" to="SharpGen.Runtime.Win32.Variant"/>
    <bind from="PROPVARIANT" to="SharpGen.Runtime.Win32.Variant"/>

    <!-- Win32 structures -->
    <bind from="DISPPARAMS" to="System.Runtime.InteropServices.ComTypes.DISPPARAMS"/>
    <bind from="EXCEPINFO" to="System.Runtime.InteropServices.ComTypes.EXCEPINFO"/>

    <!-- COM interfaces not directly used -->
    <bind from="ITypeInfo" to="SharpGen.Runtime.ComObject" />
    <bind from="IErrorLog" to="SharpGen.Runtime.ComObject" />
    <bind from="IMoniker" to="SharpGen.Runtime.ComObject" />
    <bind from="IEnumMoniker" to="SharpGen.Runtime.ComObject" />
    <bind from="IBindCtx" to="SharpGen.Runtime.ComObject" />
    <bind from="IRpcStubBuffer" to="SharpGen.Runtime.ComObject"/>
    <bind from="IRpcChannelBuffer" to="SharpGen.Runtime.ComObject"/>
    <bind from="IPropertyStore" to="SharpGen.Runtime.ComObject"/>
    <bind from="IPropertyBag2" to="SharpGen.Runtime.Win32.PropertyBag"/>
    <bind from="IClassFactory" to="SharpGen.Runtime.ComObject"/>
    <bind from="IEnumUnknown" to="SharpGen.Runtime.ComObject"/>
    <bind from="IEnumString" to="SharpGen.Runtime.ComObject"/>
    <bind from="INamedPropertyStore" to="SharpGen.Runtime.ComObject"/>

    <bind from="HSTRING" to="System.IntPtr" />
  </bindings>

  <!-- SharpGen.Runtime global mapping -->
  <mapping>
    <context>sharpgen-runtime-com-ext</context>
    <context>sharpgen-runtime-com</context>
    <context>winerror</context>
    <map enum="SHARPGEN_RUNTIME_COM_ERRORCODE" namespace="SharpGen.Runtime.Win32" name="ErrorCode"/>
    <map enum-item="ERROR_(.*)" name-tmp="$1" naming="noexpand"/>
    <context-clear/>

    <context>Unknwnbase</context>
    <map interface="IUnknown" callback="true" callback-dual="true" callback-name="ComObject" callback-visibility="public" shadow-name="SharpGen.Runtime.ComObjectShadow" vtbl-name="SharpGen.Runtime.ComObjectShadow.ComObjectVtbl" />
    <map method="IUnknown::.*" keep-implement-public="true" />
    <map method="IUnknown::QueryInterface" check="false" />
    <context-clear/>

    <!-- Map IStream -->
    <context>Objidlbase</context>
    <context>wtypes</context>
    <map struct="STATSTG" name="StorageStatistics" />

    <map enum="STGC" name="CommitFlags" flags="true"/>
    <map enum-item="STGC_(.*)" name-tmp="$1"/>
    <map enum-item="STGC_ONLYIFCURRENT" name="OnlyCurrent"/>
    <map enum-item="STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE" name="DangerouslyCommitMerelyToDiskCache"/>

    <map enum="LOCKTYPE" name="LockType" flags="true"/>
    <map enum-item="LOCK_(.*)" name-tmp="$1"/>
    <map enum-item="LOCK_ONLYONCE" name="OnlyOnce"/>

    <map enum="STATFLAG" name="StorageStatisticsFlags"/>
    <map enum-item="STATFLAG_DEFAULT" name="Default"/>
    <map enum-item="STATFLAG_NONAME" name="NoName"/>
    <remove enum-item="STATFLAG_NOOPEN"/>

    <map interface="ISequentialStream" name="IStreamBase" callback-visibility="public" callback="true" callback-dual="true" callback-name="ComStreamBase" autogen-shadow="true" />
    <map param="ISequentialStream::Read::pcbRead" return="true"/>
    <map param="ISequentialStream::Write::pcbWritten" return="true"/>
    <map method="ISequentialStream::.*" keep-implement-public="true"/>

    <map interface="IStream" name="IStream" callback-visibility="public" callback="true" callback-dual="true" callback-name="ComStream" autogen-shadow="true" />
    <map param="IStream::Seek::dwOrigin" type="SHARPGEN_RUNTIME_SEEKORIGIN"/>
    <map param="IStream::Seek::plibNewPosition" return="true"/>
    <map param="IStream::CopyTo::pcbRead" attribute="out" return="true"/>
    <map param="IStream::CopyTo::pcbWritten" attribute="out"/>
    <map param="IStream::Commit::grfCommitFlags" type="STGC"/>
    <map param="IStream::.*::dwLockType" type="LOCKTYPE"/>
    <map method="IStream::Stat" name="GetStatistics" />
    <map param="IStream::Stat::pstatstg" attribute="out" return="true"/>
    <map param="IStream::Stat::grfStatFlag" type="STATFLAG"/>
    <map param="IStream::Clone::ppstm" return="true"/>
    <map method="IStream::.*" keep-implement-public="true" property="false" />

    <context-clear/>

    <context>winstring</context>
    <map function="WindowsCreateString" dll='"api-ms-win-core-winrt-string-l1"' group="SharpGen.Runtime.Win32.WinRTStrings" />
    <context-clear />
  </mapping>
</config>