using System.Xml.Serialization; namespace SharpGen.Config { [XmlType("map")] public class MappingRule : MappingBaseRule { /// /// Default Value for parameters /// [XmlAttribute("assembly")] public string Assembly { get; set; } /// /// Default Value for parameters /// [XmlAttribute("namespace")] public string Namespace { get; set; } /// /// Default Value for parameters /// [XmlAttribute("default")] public string DefaultValue { get; set; } [XmlIgnore] public bool? MethodCheckReturnType { get; set; } = true; [XmlAttribute("check")] public bool _MethodCheckReturnType_ { get => MethodCheckReturnType.Value; set => MethodCheckReturnType = value; } [XmlIgnore] public bool? AlwaysReturnHResult { get; set; } [XmlAttribute("hresult")] public bool _AlwaysReturnHResult_ { get => AlwaysReturnHResult.Value; set => AlwaysReturnHResult = value; } /// /// General visibility for Methods /// [XmlIgnore] public Visibility? Visibility { get; set; } [XmlAttribute("visibility")] public Visibility _Visibility_ { get => Visibility.Value; set => Visibility = value; } /// /// General visibility for DefaultCallback class /// [XmlIgnore] public Visibility? NativeCallbackVisibility { get; set; } [XmlAttribute("callback-visibility")] public Visibility _NativeCallbackVisibility_ { get => NativeCallbackVisibility.Value; set => NativeCallbackVisibility = value; } /// /// General visibility for Shadow class /// [XmlIgnore] public Visibility? ShadowVisibility { get; set; } [XmlAttribute("shadow-visibility")] public Visibility _ShadowVisibility_ { get => ShadowVisibility.Value; set => ShadowVisibility = value; } /// /// General visibility for Vtbl class /// [XmlIgnore] public Visibility? VtblVisibility { get; set; } [XmlAttribute("vtbl-visibility")] public Visibility _VtblVisibility_ { get => VtblVisibility.Value; set => VtblVisibility = value; } [XmlIgnore] public NamingFlags? NamingFlags { get; set; } [XmlAttribute("naming")] public NamingFlags _NamingFlags_ { get => NamingFlags.Value; set => NamingFlags = value; } /// /// Name of a native callback /// [XmlAttribute("callback-name")] public string NativeCallbackName { get; set; } /// /// Used for methods, to force a method to not be translated to a property /// [XmlIgnore] public bool? Property { get; set; } [XmlAttribute("property")] public bool _Property_ { get => Property.Value; set => Property = value; } /// /// Use to output vtbl offsets for methods as private fields that can be modified /// [XmlIgnore] public bool? CustomVtbl { get; set; } [XmlAttribute("custom-vtbl")] public bool _CustomVtbl_ { get => CustomVtbl.Value; set => CustomVtbl = value; } /// /// Used for property zith COM Objects, in order to persist the getter /// [XmlIgnore] public bool? Persist { get; set; } [XmlAttribute("persist")] public bool _Persist_ { get => Persist.Value; set => Persist = value; } /// /// Gets or sets the struct pack alignment. /// /// The struct pack. [XmlIgnore] public int? StructPack { get; set; } [XmlAttribute("pack")] public int _StructPack_ { get => StructPack.Value; set => StructPack = value; } /// /// Mapping name /// [XmlAttribute("name-tmp")] public string MappingName { get; set; } /// /// Mapping name /// [XmlAttribute("name")] public string MappingNameFinal { get => MappingName; set { MappingName = value; IsFinalMappingName = true; } } /// /// True if the MappingName doesn't need any further rename processing /// [XmlIgnore] public bool? IsFinalMappingName { get; set; } = false; /// /// True if a struct should used a native value type marshalling /// [XmlIgnore] public bool? StructHasNativeValueType { get; set; } [XmlAttribute("native")] public bool _StructHasNativeValueType_ { get => StructHasNativeValueType.Value; set => StructHasNativeValueType = value; } /// /// True if a struct should be used as a class instead of struct (imply StructHasNativeValueType) /// [XmlIgnore] public bool? StructToClass { get; set; } [XmlAttribute("struct-to-class")] public bool _StructToClass_ { get => StructToClass.Value; set => StructToClass = value; } /// /// True if a struct is using some Custom Marshal (imply StructHasNativeValueType) /// [XmlIgnore] public bool? StructCustomMarshal { get; set; } [XmlAttribute("marshal")] public bool _StructCustomMarshal_ { get => StructCustomMarshal.Value; set => StructCustomMarshal = value; } /// /// True if a struct is using some Custom Marshal (imply StructHasNativeValueType) /// [XmlIgnore] public bool? IsStaticMarshal { get; set; } [XmlAttribute("static-marshal")] public bool _IsStaticMarshal_ { get => IsStaticMarshal.Value; set => IsStaticMarshal = value; } /// /// True if a struct is using some a Custom New for the Native struct (imply StructHasNativeValueType) /// [XmlIgnore] public bool? StructCustomNew { get; set; } [XmlAttribute("new")] public bool _StructCustomNew_ { get => StructCustomNew.Value; set => StructCustomNew = value; } /// /// Mapping type name /// [XmlAttribute("type")] public string MappingType { get; set; } /// /// Set to true to override the type used to natively represent this member when marshalling with the mapping type /// [XmlIgnore] public bool? OverrideNativeType { get; set; } [XmlAttribute("override-native-type")] public bool _OverrideNativeType_ { get => OverrideNativeType.Value; set => OverrideNativeType = value; } /// /// Pointer to modify the type /// [XmlAttribute("pointer")] public string Pointer { get; set; } /// /// ArrayDimension /// [XmlAttribute("array")] public string TypeArrayDimension { get; set; } /// /// Used for enums, to tag enums that are used as flags /// [XmlIgnore] public bool? EnumHasFlags { get; set; } [XmlAttribute("flags")] public bool _EnumHasFlags_ { get => EnumHasFlags.Value; set => EnumHasFlags = value; } /// /// Used for enums, to tag enums that should have none value (0) /// [XmlIgnore] public bool? EnumHasNone { get; set; } [XmlAttribute("none")] public bool _EnumHasNone_ { get => EnumHasNone.Value; set => EnumHasNone = value; } /// /// Used for interface to mark them as callback interface /// [XmlIgnore] public bool? IsCallbackInterface { get; set; } [XmlAttribute("callback")] public bool _IsCallbackInterface_ { get => IsCallbackInterface.Value; set => IsCallbackInterface = value; } /// /// Used for interface to mark them as dual-callback interface /// [XmlIgnore] public bool? IsDualCallbackInterface { get; set; } [XmlAttribute("callback-dual")] public bool _IsDualCallbackInterface_ { get => IsDualCallbackInterface.Value; set => IsDualCallbackInterface = value; } [XmlIgnore] public bool? AutoGenerateShadow { get; set; } [XmlAttribute("autogen-shadow")] public bool _AutoGenerateShadow_ { get => AutoGenerateShadow.Value; set => AutoGenerateShadow = value; } [XmlIgnore] public bool? AutoGenerateVtbl { get; set; } [XmlAttribute("autogen-vtbl")] public bool _AutoGenerateVtbl_ { get => AutoGenerateVtbl.Value; set => AutoGenerateVtbl = value; } [XmlIgnore] public bool? StaticShadowVtbl { get; set; } [XmlAttribute("vtbl-static")] public bool _StaticShadowVtbl_ { get => StaticShadowVtbl.Value; set => StaticShadowVtbl = value; } [XmlAttribute("shadow-name")] public string ShadowName { get; set; } [XmlAttribute("vtbl-name")] public string VtblName { get; set; } /// /// Used for methods to specify that inheriting methods from interface should be kept public and without any rename. /// [XmlIgnore] public bool? IsKeepImplementPublic { get; set; } [XmlAttribute("keep-implement-public")] public bool _IsKeepImplementPublic_ { get => IsKeepImplementPublic.Value; set => IsKeepImplementPublic = value; } /// /// DLL name attached to a function /// [XmlAttribute("dll")] public string FunctionDllName { get; set; } /// /// Used to duplicate methods taking pointers and generate an additional private method with pure pointer. This method /// is also disabling renaming /// /// true if [raw PTR]; otherwise, false. [XmlIgnore] public bool? RawPtr { get; set; } [XmlAttribute("rawptr")] public bool _RawPtr_ { get => RawPtr.Value; set => RawPtr = value; } /// /// Parameter Attribute /// [XmlIgnore] public ParamAttribute? ParameterAttribute { get; set; } [XmlAttribute("attribute")] public ParamAttribute _ParameterAttribute_ { get => ParameterAttribute.Value; set => ParameterAttribute = value; } /// /// For Method, true means that the return type should be returned in any case. For Parameter is tagged to be used as a /// return type /// [XmlIgnore] public bool? ParameterUsedAsReturnType { get; set; } [XmlAttribute("return")] public bool _ParameterUsedAsReturnType_ { get => ParameterUsedAsReturnType.Value; set => ParameterUsedAsReturnType = value; } /// /// ClassType attached to a function /// [XmlAttribute("group")] public string Group { get; set; } /// /// An integer that can be used to transform the method's vtable offset relative to the value specified by the /// compiler. /// [XmlAttribute("offset-translate")] public int LayoutOffsetTranslate { get; set; } /// /// Specifies how a marshallable element is related to other marshallables. /// [XmlAttribute("relation")] public string Relation { get; set; } /// /// Provides an ability to prevent method generation in an interface /// [XmlIgnore] public bool? Hidden { get; set; } [XmlAttribute("hidden")] public bool _Hidden_ { get => Hidden.Value; set => Hidden = value; } /// /// Best-effort flag for retaining pointers in generated bindings. /// [XmlIgnore] public bool? KeepPointers { get; set; } [XmlAttribute("keep-pointers")] public bool _KeepPointers_ { get => KeepPointers.Value; set => KeepPointers = value; } public bool ShouldSerialize_MethodCheckReturnType_() => MethodCheckReturnType != null; public bool ShouldSerialize_AlwaysReturnHResult_() => AlwaysReturnHResult != null; public bool ShouldSerialize_Visibility_() => Visibility != null; public bool ShouldSerialize_NativeCallbackVisibility_() => NativeCallbackVisibility != null; public bool ShouldSerialize_ShadowVisibility_() => ShadowVisibility != null; public bool ShouldSerialize_VtblVisibility_() => VtblVisibility != null; public bool ShouldSerialize_NamingFlags_() => NamingFlags != null; public bool ShouldSerialize_Property_() => Property != null; public bool ShouldSerialize_CustomVtbl_() => CustomVtbl != null; public bool ShouldSerialize_Persist_() => Persist != null; public bool ShouldSerialize_StructPack_() => StructPack != null; public bool ShouldSerializeMappingName() => IsFinalMappingName.HasValue && !IsFinalMappingName.Value; public bool ShouldSerializeMappingNameFinal() => !IsFinalMappingName.HasValue || IsFinalMappingName.Value; public bool ShouldSerialize_StructHasNativeValueType_() => StructHasNativeValueType != null; public bool ShouldSerialize_StructToClass_() => StructToClass != null; public bool ShouldSerialize_StructCustomMarshal_() => StructCustomMarshal != null; public bool ShouldSerialize_IsStaticMarshal_() => IsStaticMarshal != null; public bool ShouldSerialize_StructCustomNew_() => StructCustomNew != null; public bool ShouldSerialize_OverrideNativeType_() => OverrideNativeType != null; public bool ShouldSerialize_EnumHasFlags_() => EnumHasFlags != null; public bool ShouldSerialize_EnumHasNone_() => EnumHasNone != null; public bool ShouldSerialize_IsCallbackInterface_() => IsCallbackInterface != null; public bool ShouldSerialize_IsDualCallbackInterface_() => IsDualCallbackInterface != null; public bool ShouldSerialize_AutoGenerateShadow_() => AutoGenerateShadow != null; public bool ShouldSerialize_AutoGenerateVtbl_() => AutoGenerateVtbl != null; public bool ShouldSerialize_StaticShadowVtbl_() => StaticShadowVtbl != null; public bool ShouldSerialize_IsKeepImplementPublic_() => IsKeepImplementPublic != null; public bool ShouldSerialize_RawPtr_() => RawPtr != null; public bool ShouldSerialize_ParameterAttribute_() => ParameterAttribute != null; public bool ShouldSerialize_ParameterUsedAsReturnType_() => ParameterUsedAsReturnType != null; public bool ShouldSerialize_Hidden_() => Hidden != null; public bool ShouldSerialize_KeepPointers_() => KeepPointers != null; } }