react-native-xaml/package/Codegen/EventArgsTypeProperties.tt

70 строки
2.5 KiB
Plaintext

<#@ template language="C#" linePragmas="false" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
#pragma once
#include "pch.h"
#include "XamlMetadata.h"
#include "Crc32Str.h"
/*************************************************************
THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT MODIFY MANUALLY
SOURCE WINMDS USED:
<#
foreach (var winmd in WinMDs) {
#>
- <#= winmd #>
<#
}
#>
**************************************************************/
<# foreach (var ns in Properties.Select(p => p.DeclaringType.GetNamespace()).Distinct()) { #>
#include <winrt/<#= ns #>.h>
<# } #>
struct EventArgsProperty {
const char* const name;
using isType_t = bool (*) (const winrt::Windows::Foundation::IInspectable& ea);
const isType_t isType;
using getter_t = winrt::Windows::Foundation::IInspectable (*) (const winrt::Windows::Foundation::IInspectable& ea);
const getter_t getter;
};
const EventArgsProperty eventArgsProperties[] = {
<# foreach (var prop in Properties) {
if (prop.Property != null) { #>
{ "<#= Util.ToJsName(prop.Name) #>", IsType<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>(); return <#= Util.MaybeBox("ea", prop.Property) #>; } },
<# } else { #>
{ "<#= Util.ToJsName(prop.Name) #>", IsType<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>, [](const winrt::Windows::Foundation::IInspectable& obj) { auto ea = obj.as<<#= Util.GetCppWinRTType(prop.DeclaringType) #>>(); return Get<#= prop.Name #>_<#= prop.DeclaringType.GetName() #>(); },
<#} #>
<# } #>
};
struct EventArgsMethod {
const char* const name;
using isType_t = bool (*) (const winrt::Windows::Foundation::IInspectable& ea);
const isType_t isType;
using getter_t = facebook::jsi::Value(*) (facebook::jsi::Runtime& rt, std::shared_ptr<XamlObject> thisVal, const facebook::jsi::Value* args, size_t count);
const getter_t getter;
};
<# foreach (var t in Util.eventArgsMethods) {
foreach (var m in t.Value) {
#>
facebook::jsi::Value <#= t.Key.Replace(".", "_") #>_<#= m #>(facebook::jsi::Runtime& rt, std::shared_ptr<XamlObject> thisVal, const facebook::jsi::Value* args, size_t count);
<# } } #>
const EventArgsMethod eventArgsMethods[] = {
<# foreach (var t in Util.eventArgsMethods) {
foreach (var m in t.Value) {
#>
{ "<#= m #>", IsType<<#= Util.GetCppWinRTType(t.Key) #>>, <#= t.Key.Replace(".", "_") #>_<#= m #> },
<# } } #>
};