├── .config └── 1espt │ └── PipelineAutobaseliningConfig.yml ├── .gitattributes ├── .github └── workflows │ └── stale.yml ├── .gitignore ├── .pipelines ├── AbiWinRT-Job.yml ├── Build-Job.yml ├── MidlRT-Job.yml ├── OneBranch.Official.yml ├── OneBranch.PullRequest.yml ├── SyncMirror-Pipeline.yml └── Variables.yml ├── Directory.Packages.props ├── LICENSE ├── README.md ├── design_notes ├── XDN00 - Design Note Process.md ├── XDN01 - A Strategy for Language Interoperability.md ├── XDN02 - Engineering Guidelines.md ├── XDN03 - xlang Type System.md ├── XDN04 - xlang Metadata.md ├── XDN05 - xlang Binary Interface.md ├── XDN06 - xlang Platform Abstraction Layer.md ├── XDN07 - xlang Foundation Types.md ├── XDN10 - Platform Support for Activation Factories.md ├── XDN11 - Error handling.md ├── XDN11_origination_diagram.png └── design note template.md ├── docs ├── security.md ├── winrt │ └── WinRT SxS Components.md └── xplatwinrt │ ├── XSPEC01 - Type System Specification.md │ ├── XSPEC02 - Metadata Representation.md │ ├── XSPEC03 - Platform Abstraction Layer.md │ └── XSPEC04 - Application Binary Interface.md ├── nuget.config ├── samples ├── meta_reader │ ├── CMakeLists.txt │ ├── main.cpp │ ├── pch.cpp │ └── pch.h ├── python │ └── winml_tutorial │ │ ├── .gitignore │ │ ├── complete_winml_tutorial.py │ │ ├── readme.md │ │ └── winml_content │ │ ├── Labels.txt │ │ ├── SqueezeNet.onnx │ │ └── kitten_224.png └── readme.md └── src ├── CMakeLists.txt ├── CMakeSettings.json ├── Directory.Build.Props ├── UndockedRegFreeWinRT ├── Catch │ └── catch.hpp ├── Directory.Build.props ├── EmbeddedManifestManagedTest │ ├── EmbeddedManifestManagedTest.csproj │ ├── EmbeddedManifestManagedTest.manifest │ └── Program.cs ├── EmbeddedManifestTest │ ├── EmbeddedManifestTest.exe.manifest │ ├── EmbeddedManifestTest.vcxproj │ ├── EmbeddedManifestTest.vcxproj.filters │ ├── directory.build.props │ ├── embedded_manifest_test.cpp │ ├── main.cpp │ ├── packages.config │ ├── pch.cpp │ └── pch.h ├── EmbeddedTestComponent │ ├── Class.cpp │ ├── Class.h │ ├── Class.idl │ ├── EmbeddedTestComponent.def │ ├── EmbeddedTestComponent.manifest │ ├── EmbeddedTestComponent.vcxproj │ ├── EmbeddedTestComponent.vcxproj.filters │ ├── PropertySheet.props │ ├── Resource.rc │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── readme.txt │ └── resource.h ├── ManifestParserTest │ ├── ManifestParserTest.cpp │ ├── ManifestParserTest.vcxproj │ ├── ManifestParserTest.vcxproj.filters │ ├── basicParse.largeFile.manifest │ ├── basicParse.negative.blankFileName.manifest │ ├── basicParse.negative.blankName.manifest │ ├── basicParse.negative.duplicateAcid.manifest │ ├── basicParse.negative.invalidThreadingModel.manifest │ ├── basicParse.negative.missingFileName.manifest │ ├── basicParse.negative.missingName.manifest │ ├── basicParse.negative.missingThreadingModel.manifest │ ├── basicParse.positive.manifest │ ├── main.cpp │ ├── packages.config │ ├── pch.h │ └── winrtActivation.dll1.manifest ├── Nuget │ ├── LICENSE │ ├── Microsoft.Windows.UndockedRegFreeWinrt.nuspec │ ├── Microsoft.Windows.UndockedRegFreeWinrt.targets │ ├── SignConfig.xml │ └── readme.txt ├── README.md ├── SignConfig.xml ├── TestComponent │ ├── Class.cpp │ ├── Class.h │ ├── Class.idl │ ├── PropertySheet.props │ ├── TestComponent.def │ ├── TestComponent.vcxproj │ ├── TestComponent.vcxproj.filters │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ └── readme.txt ├── UndockedRegFreeWinRT.sln ├── UndockedRegFreeWinRT │ ├── UndockedRegFreeWinRT.vcxproj │ ├── UndockedRegFreeWinRT.vcxproj.filters │ ├── catalog.cpp │ ├── catalog.h │ ├── cpp.hint │ ├── dllmain.cpp │ ├── extwinrt.h │ ├── packages.config │ ├── typeresolution.cpp │ ├── typeresolution.h │ └── winrtact.def ├── UndockedRegFreeWinRTManagedTest │ ├── Program.cs │ └── UndockedRegFreeWinRTManagedTest.csproj ├── UndockedRegFreeWinRTTest │ ├── UndockedRegFreeWinRTTest.vcxproj │ ├── UndockedRegFreeWinRTTest.vcxproj.filters │ ├── directory.build.props │ ├── main.cpp │ ├── packages.config │ ├── pch.cpp │ ├── pch.h │ ├── test_apartment_activation.cpp │ └── test_files │ │ └── UndockedRegFreeWinRTTest.exe.manifest ├── detours │ ├── creatwth.cpp │ ├── detours.cpp │ ├── detours.h │ ├── detours.vcxproj │ ├── detours.vcxproj.filters │ ├── detver.h │ ├── disasm.cpp │ ├── disolarm.cpp │ ├── disolarm64.cpp │ ├── disolia64.cpp │ ├── disolx64.cpp │ ├── disolx86.cpp │ ├── image.cpp │ ├── modules.cpp │ └── uimports.cpp └── mwinrtact │ ├── mwinrtact.cs │ └── mwinrtact.csproj ├── foundation ├── CMakeLists.txt └── xlang_foundation.il ├── library ├── catch.hpp ├── cmd_reader.h ├── impl │ ├── base.h │ ├── cmd_reader_windows.h │ ├── meta_reader │ │ ├── cache.h │ │ ├── column.h │ │ ├── custom_attribute.h │ │ ├── database.h │ │ ├── enum.h │ │ ├── enum_traits.h │ │ ├── filter.h │ │ ├── flags.h │ │ ├── helpers.h │ │ ├── index.h │ │ ├── key.h │ │ ├── pe.h │ │ ├── schema.h │ │ ├── signature.h │ │ ├── table.h │ │ ├── type_helpers.h │ │ └── view.h │ └── meta_writer │ │ └── pe_writer.h ├── meta_reader.h ├── meta_writer.h ├── task_group.h ├── text_writer.h └── xlang.meta.natvis ├── package ├── CMakeLists.txt ├── abi │ ├── CMakeLists.txt │ ├── LICENSE │ ├── Microsoft.Windows.AbiWinRT.nuspec │ ├── Microsoft.Windows.AbiWinRT.props │ ├── Microsoft.Windows.AbiWinRT.targets │ ├── SignConfig.xml │ └── readme.txt ├── midlrt │ ├── CMakeLists.txt │ ├── LICENSE │ ├── Microsoft.Windows.MidlRT.IdlGen.targets │ ├── Microsoft.Windows.MidlRT.nuspec │ ├── Microsoft.Windows.MidlRT.props │ ├── Microsoft.Windows.MidlRT.targets │ ├── SignConfig.xml │ ├── readme.md │ └── readme.txt └── pywinrt │ ├── CMakeLists.txt │ ├── LICENSE │ ├── projection │ ├── .gitignore │ ├── AzurePipelinesTemplates │ │ ├── job-build-projection.yml │ │ ├── job-build-pywinrt.yml │ │ ├── job-package-projection.yml │ │ ├── job-sign-projection.yml │ │ ├── steps-build-projection.yml │ │ ├── steps-package-projection.yml │ │ ├── steps-sign-projection.yml │ │ └── task-vsdevcmd.yml │ ├── CMakeLists.txt │ ├── build.ps1 │ ├── generate.ps1 │ ├── package.ps1 │ ├── pipeline-internal.yml │ ├── pipeline-public.yml │ ├── readme.md │ ├── setup.py │ └── unity.ps1 │ └── tool │ ├── CMakeLists.txt │ ├── Microsoft.Windows.PyWinRT.nuspec │ ├── readme.md │ └── readme.txt ├── platform ├── CMakeLists.txt ├── activation_abi.cpp ├── cache_string.h ├── common_activation.cpp ├── common_memory.cpp ├── common_string_convert.cpp ├── error_abi.cpp ├── heap_string.h ├── helpers │ ├── atomic_ref_count.h │ ├── pal_error.h │ └── pal_internal.h ├── opaque_string_wrapper.h ├── platform_activation.h ├── published │ └── pal.h ├── string_abi.cpp ├── string_allocate.h ├── string_base.cpp ├── string_base.h ├── string_convert.h ├── string_reference.h ├── string_traits.h ├── win32_activation.cpp ├── win32_memory.cpp ├── win32_pal_internal.h └── win32_string_convert.cpp ├── readme.md ├── scripts ├── genStringLiteralFiles.cmake ├── mdExts.js ├── scorch.cmake ├── ubuntu │ ├── azure-pipelines.yml │ ├── build.sh │ └── configure.sh └── windows │ ├── azure-pipelines.yml │ ├── build.cmd │ └── vsdevcmd-build.cmd ├── test ├── CMakeLists.txt ├── abi_component │ ├── CMakeLists.txt │ ├── iwidget.h │ ├── module.def │ └── widget.cpp ├── cppx │ ├── CMakeLists.txt │ ├── IXlangObject.cpp │ ├── collection_base.cpp │ ├── error.cpp │ ├── hstring.cpp │ ├── main.cpp │ ├── param_iterable.cpp │ ├── param_map.cpp │ ├── param_map_view.cpp │ ├── param_vector.cpp │ ├── param_vector_view.cpp │ ├── pch.cpp │ ├── pch.h │ ├── produce_map.cpp │ ├── produce_vector.cpp │ ├── single_threaded_map.cpp │ └── single_threaded_vector.cpp ├── library │ ├── CMakeLists.txt │ ├── main.cpp │ ├── pch.cpp │ ├── pch.h │ └── text_writer.cpp ├── platform │ ├── CMakeLists.txt │ ├── activation.cpp │ ├── error.cpp │ ├── main.cpp │ ├── memory.cpp │ ├── pch.cpp │ ├── pch.h │ ├── string.cpp │ ├── string_helpers.h │ └── winrt_helpers.h └── python │ ├── CMakeLists.txt │ ├── complete_winml_tutorial.py │ ├── loader_native.py │ ├── ntestdirectx.py │ ├── ntestgeoloc.py │ ├── ntestnumerics.py │ ├── ntesturi.py │ ├── testcollections.py │ ├── testdirectx.py │ ├── testfromfunction.py │ ├── testgeoloc.py │ ├── testjson.py │ ├── testnumerics.py │ ├── testpropertyvalue.py │ └── testuri.py └── tool ├── CMakeLists.txt ├── Directory.Build.Targets ├── abi ├── CMakeLists.txt ├── SignConfig.xml ├── abi.sln ├── abi.vcxproj ├── abi.vcxproj.filters ├── abi_writer.cpp ├── abi_writer.h ├── build.yaml ├── code_writers.h ├── common.h ├── main.cpp ├── metadata_cache.cpp ├── metadata_cache.h ├── namespace_iterator.h ├── pch.cpp ├── pch.h ├── readme.md ├── sha1.h ├── strings │ ├── constexpr_definitions.h │ ├── constexpr_end_definitions.h │ ├── deprecated_header_end.h │ ├── deprecated_header_start.h │ ├── enum_class.h │ ├── file_header.h │ ├── include_guard_end.h │ ├── include_guard_start.h │ ├── ns_prefix_always.h │ ├── ns_prefix_definitions.h │ ├── ns_prefix_never.h │ ├── ns_prefix_optional.h │ ├── optional_ns_prefix_definitions.h │ └── optional_ns_prefix_end_definitions.h ├── type_banners.h ├── type_names.h ├── types.cpp ├── types.h └── versioning.h ├── cppxlang ├── CMakeLists.txt ├── code_writers.h ├── component_writers.h ├── file_writers.h ├── helpers.h ├── main.cpp ├── pch.cpp ├── pch.h ├── settings.h ├── strings │ ├── base_abi.h │ ├── base_activation.h │ ├── base_array.h │ ├── base_async.h │ ├── base_chrono.h │ ├── base_collections.h │ ├── base_collections_base.h │ ├── base_collections_input_iterable.h │ ├── base_collections_input_map.h │ ├── base_collections_input_map_view.h │ ├── base_collections_input_vector.h │ ├── base_collections_input_vector_view.h │ ├── base_collections_map.h │ ├── base_collections_vector.h │ ├── base_com_ptr.h │ ├── base_composable.h │ ├── base_coroutine.h │ ├── base_coroutine_action.h │ ├── base_coroutine_fire_and_forget.h │ ├── base_coroutine_operation.h │ ├── base_coroutine_resume.h │ ├── base_delegate.h │ ├── base_dependencies.h │ ├── base_error.h │ ├── base_events.h │ ├── base_extern.h │ ├── base_handle.h │ ├── base_identity.h │ ├── base_implements.h │ ├── base_macros.h │ ├── base_meta.h │ ├── base_natvis.h │ ├── base_reflect.h │ ├── base_std_hash.h │ ├── base_string.h │ ├── base_string_input.h │ ├── base_string_operators.h │ ├── base_types.h │ ├── base_version.h │ ├── base_weak_ref.h │ └── base_windows.h ├── test_base │ ├── CMakeLists.txt │ └── main.cpp └── type_writers.h └── python ├── CMakeLists.txt ├── code_writers.h ├── file_writers.h ├── helpers.h ├── main.cpp ├── pch.cpp ├── pch.h ├── settings.h ├── strings ├── custom_struct_convert.cpp ├── enter_function.cpp ├── module_methods.cpp ├── ns_module_def.cpp ├── package_init.py ├── pybase.h └── setup.py └── type_writers.h /.config/1espt/PipelineAutobaseliningConfig.yml: -------------------------------------------------------------------------------- 1 | ## DO NOT MODIFY THIS FILE MANUALLY. This is part of auto-baselining from 1ES Pipeline Templates. Go to [https://aka.ms/1espt-autobaselining] for more details. 2 | 3 | pipelines: 4 | 108957: 5 | retail: 6 | source: 7 | credscan: 8 | lastModifiedDate: 2023-10-31 9 | eslint: 10 | lastModifiedDate: 2023-10-31 11 | psscriptanalyzer: 12 | lastModifiedDate: 2023-10-31 13 | armory: 14 | lastModifiedDate: 2023-10-31 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | * text eol=lf 3 | *.png -text 4 | *.onnx -text 5 | *.winmd -text 6 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: '0 0 * * *' 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | permissions: 12 | issues: write 13 | pull-requests: write 14 | 15 | steps: 16 | - uses: actions/stale@v7 17 | with: 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | days-before-stale: 10 20 | days-before-close: 5 21 | stale-issue-message: 'This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.' 22 | stale-pr-message: 'This pull request is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.' 23 | stale-issue-label: 'no-issue-activity' 24 | stale-pr-label: 'no-pr-activity' 25 | -------------------------------------------------------------------------------- /.pipelines/AbiWinRT-Job.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: OfficialBuild 3 | type: boolean 4 | default: false 5 | 6 | jobs: 7 | - job: Build_External_Packages 8 | displayName: Build External Packages (NuGet) 9 | cancelTimeoutInMinutes: 1 10 | dependsOn: Build_ABI_Tool 11 | pool: 12 | type: windows 13 | 14 | variables: 15 | ob_outputDirectory: '$(Build.SourcesDirectory)\out' 16 | ob_nugetPublishing_enabled: ${{ parameters.OfficialBuild }} 17 | PackageVersion: $(Build.BuildNumber) 18 | 19 | steps: 20 | 21 | - task: NuGetToolInstaller@1 22 | displayName: Use NuGet 6.7 23 | continueOnError: True 24 | inputs: 25 | versionSpec: 6.7 26 | 27 | - task: DownloadPipelineArtifact@2 28 | displayName: Download x86 Artifacts 29 | inputs: 30 | artifactName: drop_stage_Build_ABI_Toolrelease_x86 31 | targetPath: $(Build.SourcesDirectory)\x86 32 | 33 | - task: CmdLine@2 34 | displayName: Touch Tools 35 | inputs: 36 | script: > 37 | 38 | rem Signing service stamps binary with a future (GMT) timestamp, breaking build dependencies 39 | 40 | copy /b $(Build.SourcesDirectory)\x86\abi\abi.exe+,, abi.exe 41 | workingDirectory: $(Build.ArtifactStagingDirectory) 42 | failOnStderr: true 43 | 44 | - task: NuGetCommand@2 45 | displayName: Build NuGet 46 | inputs: 47 | command: pack 48 | searchPatternPack: src/package/abi/Microsoft.Windows.AbiWinRT.nuspec 49 | versioningScheme: byBuildNumber 50 | buildProperties: abiwinrt_exe=$(Build.ArtifactStagingDirectory)\abi.exe 51 | packDestination: $(ob_outputDirectory)\packages 52 | 53 | - task: onebranch.pipeline.signing@1 54 | displayName: '🔒 Onebranch Signing for AbiWinRT nuget package' 55 | condition: eq(${{ parameters.OfficialBuild }}, 'true') 56 | inputs: 57 | command: sign 58 | signing_profile: external_distribution 59 | files_to_sign: 'Microsoft.Windows.AbiWinRT.*.nupkg' 60 | search_root: $(ob_outputDirectory)\packages 61 | -------------------------------------------------------------------------------- /.pipelines/Build-Job.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: "BuildConfiguration" 3 | type: string 4 | default: "release" 5 | - name: "BuildPlatform" 6 | type: string 7 | default: "x86" 8 | - name: OfficialBuild 9 | type: boolean 10 | default: false 11 | 12 | jobs: 13 | - job: Build_ABI_Tool 14 | displayName: Build Binaries 15 | pool: 16 | type: windows 17 | 18 | variables: 19 | ob_outputDirectory: '$(Build.SourcesDirectory)\out' 20 | ob_artifactSuffix: ${{ parameters.BuildConfiguration }}_${{ parameters.BuildPlatform }} 21 | StagingFolder: $(ob_outputDirectory) 22 | 23 | ob_sdl_prefast_enabled: true 24 | ob_sdl_prefast_runDuring: 'Build' 25 | ob_sdl_checkCompliantCompilerWarnings: true 26 | 27 | steps: 28 | 29 | - task: NuGetToolInstaller@1 30 | displayName: Use NuGet 6.7 31 | continueOnError: True 32 | inputs: 33 | versionSpec: 6.7 34 | 35 | - task: VSBuild@1 36 | displayName: Build Tools 37 | inputs: 38 | solution: '$(Build.SourcesDirectory)\src\tool\abi\abi.sln' 39 | msbuildArgs: >- 40 | /p:XlangBuildVersion="$(Build.BuildNumber)" 41 | /p:OutDir=$(ob_outputDirectory)\abi\ 42 | /binaryLogger:$(ob_outputDirectory)\abi\abi.binlog 43 | platform: ${{ parameters.BuildPlatform }} 44 | configuration: ${{ parameters.BuildConfiguration }} 45 | clean: true 46 | 47 | - task: onebranch.pipeline.signing@1 48 | displayName: '🔒 Onebranch Signing for abi.exe' 49 | condition: eq(${{ parameters.OfficialBuild }}, 'true') 50 | inputs: 51 | command: sign 52 | signing_profile: external_distribution 53 | files_to_sign: '**/*.dll;**/*.exe' 54 | search_root: $(ob_outputDirectory)\abi 55 | -------------------------------------------------------------------------------- /.pipelines/MidlRT-Job.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: OfficialBuild 3 | type: boolean 4 | default: false 5 | 6 | jobs: 7 | - job: Build_MidlRT_Nuget 8 | displayName: Build MidlRT Package (Nuget) 9 | pool: 10 | type: windows 11 | 12 | variables: 13 | ob_outputDirectory: '$(Build.SourcesDirectory)\out' 14 | ob_nugetPublishing_enabled: ${{ parameters.OfficialBuild }} 15 | PackageVersion: $(Build.BuildNumber) 16 | 17 | steps: 18 | 19 | - task: NuGetToolInstaller@1 20 | displayName: Use NuGet 6.7 21 | continueOnError: True 22 | inputs: 23 | versionSpec: 6.7 24 | 25 | - task: NuGetCommand@2 26 | displayName: Build NuGet 27 | inputs: 28 | command: pack 29 | searchPatternPack: src/package/midlrt/Microsoft.Windows.MidlRT.nuspec 30 | versioningScheme: byBuildNumber 31 | packDestination: $(ob_outputDirectory)\packages 32 | 33 | - task: onebranch.pipeline.signing@1 34 | displayName: '🔒 Onebranch Signing for MidlRT nuget package' 35 | condition: eq(${{ parameters.OfficialBuild }}, 'true') 36 | inputs: 37 | command: sign 38 | signing_profile: external_distribution 39 | files_to_sign: 'Microsoft.Windows.MidlRT.*.nupkg' 40 | search_root: $(ob_outputDirectory)\packages 41 | -------------------------------------------------------------------------------- /.pipelines/OneBranch.PullRequest.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | - name: "BuildConfiguration" 3 | type: string 4 | default: "release" 5 | - name: "BuildPlatform" 6 | type: string 7 | default: "x86" 8 | - name: 'debug' 9 | displayName: 'Enable debug output' 10 | type: boolean 11 | default: false 12 | 13 | variables: 14 | - template: Variables.yml 15 | parameters: 16 | debug: ${{ parameters.debug }} 17 | 18 | trigger: none 19 | 20 | name: $(MajorVersion).$(MinorVersion).$(date:yyMMdd)$(rev:.r)-PR 21 | 22 | resources: 23 | repositories: 24 | - repository: templates 25 | type: git 26 | name: OneBranch.Pipelines/GovernedTemplates 27 | ref: refs/heads/main 28 | 29 | extends: 30 | template: v2/Microsoft.NonOfficial.yml@templates 31 | parameters: 32 | platform: 33 | name: 'windows_undocked' 34 | product: 'build_tools' 35 | 36 | globalSdl: 37 | isNativeCode: true 38 | tsa: 39 | enabled: false 40 | useDynamicRouting: true 41 | sbom: 42 | enabled: true 43 | 44 | stages: 45 | - stage: stage 46 | pool: 47 | type: windows 48 | 49 | jobs: 50 | 51 | - template: .pipelines/Build-Job.yml@self 52 | parameters: 53 | BuildConfiguration: ${{ parameters.BuildConfiguration }} 54 | BuildPlatform: ${{ parameters.BuildPlatform }} 55 | OfficialBuild: false 56 | 57 | - ${{ if and(eq(parameters.BuildPlatform, 'x86'), eq(parameters.BuildConfiguration, 'release')) }}: 58 | - template: .pipelines/AbiWinRT-Job.yml@self 59 | parameters: 60 | OfficialBuild: false 61 | 62 | - template: .pipelines/MidlRT-Job.yml@self 63 | parameters: 64 | OfficialBuild: false -------------------------------------------------------------------------------- /.pipelines/SyncMirror-Pipeline.yml: -------------------------------------------------------------------------------- 1 | # Sync branches in a mirror repository to a base repo by running this pipeline 2 | # from the mirror repo, and supplying the base repo as a parameter 3 | name: $(BuildDefinitionName)_$(date:yyMMdd)$(rev:.r) 4 | 5 | parameters: 6 | - name: "SourceToTargetBranches" 7 | type: object 8 | default: 9 | master: master 10 | - name: "SourceRepository" 11 | type: string 12 | default: "https://github.com/microsoft/xlang.git" 13 | 14 | resources: 15 | repositories: 16 | - repository: 1ESPipelineTemplates 17 | type: git 18 | name: 1ESPipelineTemplates/1ESPipelineTemplates 19 | ref: refs/tags/release 20 | extends: 21 | template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates 22 | parameters: 23 | pool: 24 | name: Azure-Pipelines-1ESPT-ExDShared 25 | image: windows-2022 26 | os: windows 27 | customBuildTags: 28 | - ES365AIMigrationTooling 29 | stages: 30 | - stage: stage 31 | jobs: 32 | - job: SyncMirror 33 | strategy: 34 | matrix: 35 | ${{ each branches in parameters.SourceToTargetBranches }}: 36 | ${{ branches.key }}: 37 | SourceBranch: ${{ branches.key }} 38 | TargetBranch: ${{ branches.value }} 39 | dependsOn: [] 40 | steps: 41 | - checkout: self 42 | persistCredentials: true 43 | 44 | - task: PowerShell@2 45 | inputs: 46 | targetType: 'inline' 47 | script: | 48 | Write-Host "SourceBranch " + "$(SourceBranch)" 49 | Write-Host "TargetBranch " + "$(TargetBranch)" 50 | 51 | $repo = "${{ parameters.SourceRepository }}" 52 | git remote add sourcerepo $repo 53 | git remote 54 | 55 | $target = "$(TargetBranch)" 56 | git fetch origin $target 57 | git checkout $target 58 | git pull origin $target 59 | 60 | $source = "$(SourceBranch)" 61 | git fetch sourcerepo $source 62 | git pull sourcerepo $source 63 | 64 | - task: CmdLine@2 65 | inputs: 66 | script: | 67 | git push 68 | 69 | -------------------------------------------------------------------------------- /.pipelines/Variables.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | MajorVersion: "2" 3 | MinorVersion: "0" 4 | ENABLE_PRS_DELAYSIGN: 1 5 | # Docker image which is used to build the project https://aka.ms/obpipelines/containers 6 | WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2019/vse2022:latest' 7 | system.debug: ${{ parameters.debug }} -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /design_notes/XDN02 - Engineering Guidelines.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: XDN02 3 | title: Engineering Guidelines 4 | author: benkuhn@microsoft.com 5 | status: draft 6 | --- 7 | 8 | # Title: XLDN02 - Engineering Guidelines 9 | 10 | - Ben Kuhn (benkuhn@microsoft.com) 11 | - Status: Draft 12 | 13 | ## Abstract 14 | 15 | The xlang Project involves many components written in a variety of programming languages. This document describes coding guidelines for each language. 16 | 17 | ## Coding Guidelines 18 | 19 | This project adopts industry standard guidelines where one exists. As new language support is added to the project, this list will be expanded to include applicable standards. 20 | 21 | The project references these as guidelines, not laws. Thoughtful deviation is allowed if it aids readability of the specific code in question or is necessary for a technical reason. However, guidelines should not be ignored because of a disagreement with the guideline itself. 22 | 23 | Due to the nature of language interoperability, types expressed using the xlang type system will adhere to naming guidelines in some languages and deviate from others. Naming conventions of the xlang type system take precedence over language-specific guidelines where applicable. 24 | 25 | ### References by language 26 | 27 | - C++ code follows the [C++ core guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md) 28 | 29 | - C# code follows the [C# coding conventions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions) 30 | 31 | - .NET types adhere to the [.NET Framework Design Guidelines](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/inside-a-program/coding-conventions). 32 | 33 | - Python code is [pythonic](https://docs.python-guide.org/writing/style/). 34 | -------------------------------------------------------------------------------- /design_notes/XDN04 - xlang Metadata.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: XDN04 3 | title: xlang Metadata 4 | author: hpierson@microsoft.com 5 | status: draft 6 | --- 7 | 8 | # Title: XDN04 - xlang Metadata 9 | 10 | - Author: Harry Pierson (hpierson@microsoft.com) 11 | - Status: draft 12 | 13 | ## Abstract 14 | 15 | This design note describes the machine-readable format used to encode details about 16 | [xlang types](XDN03%20-%20xlang%20Type%20System.md) implemented by xlang components. The metadata 17 | is used to generate language projections for xlang components automatically using compile time 18 | and/or run time tools. 19 | -------------------------------------------------------------------------------- /design_notes/XDN06 - xlang Platform Abstraction Layer.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: XDN06 3 | title: xlang Platform Abstraction Layer 4 | author: hpierson@microsoft.com 5 | status: draft 6 | --- 7 | 8 | # Title: XDN06 - xlang Platform Abstraction Layer 9 | 10 | - Author: Harry Pierson (hpierson@microsoft.com) 11 | - Status: draft 12 | 13 | ## Abstract 14 | 15 | This design note describes xlang's [platform abstraction layer](https://en.wikipedia.org/wiki/Abstraction_layer) 16 | (or PAL). The PAL contains the core functionality needed by xlang components and language 17 | projections, regardless of the underlying platform. Examples of this functionality include 18 | activating instances of [xlang types](XDN03%20-%20xlang%20Type%20System.md), propagating errors 19 | across binary or language boundaries and managing memory across binary modules. 20 | 21 | ## Activation 22 | 23 | ### Factory Caching 24 | 25 | ## String Manipulation 26 | 27 | ## Memory Management 28 | 29 | ## Error Origination and Propagation 30 | 31 | ## Threading 32 | 33 | ## Numerics -------------------------------------------------------------------------------- /design_notes/XDN07 - xlang Foundation Types.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: XDN07 3 | title: xlang Foundation Types 4 | author: hpierson@microsoft.com 5 | status: draft 6 | --- 7 | 8 | # Title: XDN07 - xlang Foundation Types 9 | 10 | - Author: Harry Pierson (hpierson@microsoft.com) 11 | - Status: draft 12 | 13 | ## Abstract 14 | 15 | This design note describes xlang's foundational types. These types are provided as part of xlang 16 | and are designed to standardize the types used in common language interoperability scenarios like 17 | asynchronous processing and collections. 18 | 19 | ## DateTime and TimeStamp 20 | 21 | ## Asynchronous Operations 22 | 23 | ## Collections 24 | 25 | ## TypedEventHandler 26 | 27 | ## Observables 28 | 29 | ## URI 30 | -------------------------------------------------------------------------------- /design_notes/XDN11_origination_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/xlang/5b209157bf0c2db1ace71a0cf261470536102cf5/design_notes/XDN11_origination_diagram.png -------------------------------------------------------------------------------- /docs/winrt/WinRT SxS Components.md: -------------------------------------------------------------------------------- 1 | ## Placeholder -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/meta_reader/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13") 4 | cmake_policy(SET CMP0076 NEW) 5 | endif() 6 | 7 | project(meta_reader) 8 | 9 | set(XLANG_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../src/library") 10 | 11 | set(CMAKE_CXX_STANDARD 17) 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 13 | 14 | add_executable(meta_reader "") 15 | target_sources(meta_reader PUBLIC main.cpp pch.cpp) 16 | target_include_directories(meta_reader PUBLIC ${XLANG_LIBRARY_PATH}) 17 | 18 | function(ADD_OBJECT_DEPENDS file dependency) 19 | get_source_file_property(cur_obj_depends ${file} OBJECT_DEPENDS) 20 | if (${cur_obj_depends} STREQUAL "NOTFOUND") 21 | set(new_obj_depends "${pch_output_file_name}") 22 | else() 23 | set(new_obj_depends "${cur_obj_depends};${dependency}") 24 | endif() 25 | set_source_files_properties(${file} PROPERTIES OBJECT_DEPENDS ${new_obj_depends}) 26 | endfunction(ADD_OBJECT_DEPENDS) 27 | 28 | function(TARGET_CONFIG_MSVC_PCH target pch_cpp pch_header) 29 | get_target_property(target_name ${target} NAME) 30 | set(pch_output_file_name "${target_name}.pch") 31 | set(pch_output_file "\"${CMAKE_CURRENT_BINARY_DIR}/${pch_output_file_name}\"") 32 | 33 | get_target_property(sources ${target} SOURCES) 34 | foreach(file ${sources}) 35 | if (${file} STREQUAL ${pch_cpp}) 36 | set_source_files_properties(${file} 37 | PROPERTIES 38 | COMPILE_FLAGS " /Yc${pch_header} /Fp${pch_output_file}" 39 | OBJECT_OUTPUTS ${pch_output_file_name}) 40 | else() 41 | set_source_files_properties(${file} PROPERTIES COMPILE_FLAGS " /Yu${pch_header} /Fp${pch_output_file}") 42 | ADD_OBJECT_DEPENDS(${file} ${pch_output_file_name}) 43 | endif() 44 | endforeach() 45 | 46 | set_target_properties(${target} PROPERTIES PCH_OUTPUT_FILE ${pch_output_file}) 47 | set_property(GLOBAL APPEND PROPERTY PCH_OUTPUT_FILES ${pch_output_file}) 48 | endfunction(TARGET_CONFIG_MSVC_PCH) 49 | 50 | if (WIN32) 51 | add_definitions(-DNOMINMAX) 52 | endif() 53 | 54 | if (MSVC) 55 | TARGET_CONFIG_MSVC_PCH(meta_reader pch.cpp pch.h) 56 | target_link_libraries(meta_reader) 57 | else() 58 | target_link_libraries(meta_reader c++ c++abi c++experimental) 59 | target_link_libraries(meta_reader -lpthread) 60 | endif() 61 | -------------------------------------------------------------------------------- /samples/meta_reader/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /samples/meta_reader/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "cmd_reader.h" 6 | #include "meta_reader.h" 7 | #include "task_group.h" 8 | #include "text_writer.h" 9 | -------------------------------------------------------------------------------- /samples/python/winml_tutorial/.gitignore: -------------------------------------------------------------------------------- 1 | /pywinrt_output/build/ 2 | /pywinrt_output/vc140.pdb 3 | /pywinrt_output/_pyrt.*.pyd 4 | /__pycache__/ 5 | -------------------------------------------------------------------------------- /samples/python/winml_tutorial/winml_content/SqueezeNet.onnx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/xlang/5b209157bf0c2db1ace71a0cf261470536102cf5/samples/python/winml_tutorial/winml_content/SqueezeNet.onnx -------------------------------------------------------------------------------- /samples/python/winml_tutorial/winml_content/kitten_224.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/xlang/5b209157bf0c2db1ace71a0cf261470536102cf5/samples/python/winml_tutorial/winml_content/kitten_224.png -------------------------------------------------------------------------------- /samples/readme.md: -------------------------------------------------------------------------------- 1 | # Samples 2 | 3 | ## Folder Structure 4 | 5 | * **/meta_reader** sample metadata reader that generates [MIDL 3](http://docs.microsoft.com/en-us/uwp/midl-3/) files from ECMA-335 metadata. 6 | * **/python/winml_tutorial** a port of the [WinML C++/WinRT tutorial](https://docs.microsoft.com/en-us/windows/ai/get-started-desktop) 7 | to Python -------------------------------------------------------------------------------- /src/CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x86-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ 8 | "msvc_x86" 9 | ], 10 | "buildRoot": "${workspaceRoot}\\_build\\Windows\\x86\\Debug", 11 | "installRoot": "${workspaceRoot}\\_build\\Windows\\x86\\Debug\\Install", 12 | "cmakeCommandArgs": "", 13 | "buildCommandArgs": "-v", 14 | "ctestCommandArgs": "" 15 | }, 16 | { 17 | "name": "x86-Release", 18 | "generator": "Ninja", 19 | "configurationType": "RelWithDebInfo", 20 | "inheritEnvironments": [ 21 | "msvc_x86" 22 | ], 23 | "buildRoot": "${workspaceRoot}\\_build\\Windows\\x86\\Release", 24 | "installRoot": "${workspaceRoot}\\_build\\Windows\\x86\\Release\\Install", 25 | "cmakeCommandArgs": "", 26 | "buildCommandArgs": "-v", 27 | "ctestCommandArgs": "" 28 | }, 29 | { 30 | "name": "x64-Debug", 31 | "generator": "Ninja", 32 | "configurationType": "Debug", 33 | "inheritEnvironments": [ 34 | "msvc_x64_x64" 35 | ], 36 | "buildRoot": "${workspaceRoot}\\_build\\Windows\\x64\\Debug", 37 | "installRoot": "${workspaceRoot}\\_build\\Windows\\x64\\Debug\\Install", 38 | "cmakeCommandArgs": "", 39 | "buildCommandArgs": "-v", 40 | "ctestCommandArgs": "" 41 | }, 42 | { 43 | "name": "x64-Release", 44 | "generator": "Ninja", 45 | "configurationType": "RelWithDebInfo", 46 | "inheritEnvironments": [ 47 | "msvc_x64_x64" 48 | ], 49 | "buildRoot": "${workspaceRoot}\\_build\\Windows\\x64\\Release", 50 | "installRoot": "${workspaceRoot}\\_build\\Windows\\x64\\Release\\Install", 51 | "cmakeCommandArgs": "", 52 | "buildCommandArgs": "-v", 53 | "ctestCommandArgs": "" 54 | } 55 | ] 56 | } -------------------------------------------------------------------------------- /src/Directory.Build.Props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | v143 6 | 10.0 7 | 8 | 9 | 10 | Spectre 11 | 12 | 13 | 14 | 0.0.0 15 | 16 | 17 | 18 | 19 | Level4 20 | true 21 | true 22 | stdcpp17 23 | NOMINMAX;WIN32_LEAN_AND_MEAN;%(PreprocessorDefinitions) 24 | ABIWINRT_VERSION_STRING="$(XlangBuildVersion)";%(PreprocessorDefinitions) 25 | 26 | 27 | 28 | 29 | 30 | MultiThreadedDebug 31 | 32 | 33 | 34 | 35 | 36 | Guard 37 | MultiThreaded 38 | 39 | 40 | true 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 1.0.0.0 4 | $(Platform) 5 | x86 6 | $([System.IO.Path]::GetFullPath('$(SolutionDir)_build\$(BuildPlatform)\$(Configuration)\')) 7 | $(BuildOutDir) 8 | $([System.IO.Path]::GetFullPath('$(SolutionDir)_build\x86\$(Configuration)\')) 9 | $(CsWinRTDir)cswinrt.exe 10 | $(BuildOutDir) 11 | $(OutDir)$(ProjectName)\ 12 | v142 13 | v143 14 | 15 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestManagedTest/EmbeddedManifestManagedTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | x64;x86 7 | 8 | 9 | EmbeddedManifestManagedTest.manifest 10 | 11 | 12 | 13 | true 14 | 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | ..\_build\x86\Debug\TestComponent.winmd 34 | true 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestManagedTest/EmbeddedManifestManagedTest.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | 16 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/EmbeddedManifestTest.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 12 | 16 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/EmbeddedManifestTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/directory.build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | high 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "..\Catch\catch.hpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedManifestTest/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\Catch\catch.hpp" 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/Class.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Class.h" 3 | #include "ClassBoth.g.cpp" 4 | #include "ClassSta.g.cpp" 5 | #include "ClassMta.g.cpp" 6 | 7 | namespace winrt::EmbeddedTestComponent::implementation 8 | { 9 | int32_t ClassBoth::Apartment() 10 | { 11 | APTTYPE aptType; 12 | APTTYPEQUALIFIER aptQualifier; 13 | check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); 14 | return aptType; 15 | } 16 | 17 | void ClassBoth::Apartment(int32_t /* value */) 18 | { 19 | throw hresult_not_implemented(); 20 | } 21 | 22 | int32_t ClassSta::Apartment() 23 | { 24 | APTTYPE aptType; 25 | APTTYPEQUALIFIER aptQualifier; 26 | check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); 27 | return aptType; 28 | } 29 | 30 | void ClassSta::Apartment(int32_t /* value */) 31 | { 32 | throw hresult_not_implemented(); 33 | } 34 | 35 | int32_t ClassMta::Apartment() 36 | { 37 | APTTYPE aptType; 38 | APTTYPEQUALIFIER aptQualifier; 39 | check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); 40 | return aptType; 41 | } 42 | 43 | void ClassMta::Apartment(int32_t /* value */) 44 | { 45 | throw hresult_not_implemented(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/Class.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ClassBoth.g.h" 4 | #include "ClassSta.g.h" 5 | #include "ClassMta.g.h" 6 | 7 | namespace winrt::EmbeddedTestComponent::implementation 8 | { 9 | struct ClassBoth : ClassBothT 10 | { 11 | ClassBoth() = default; 12 | 13 | int32_t Apartment(); 14 | void Apartment(int32_t value); 15 | }; 16 | 17 | struct ClassSta : ClassStaT 18 | { 19 | ClassSta() = default; 20 | 21 | int32_t Apartment(); 22 | void Apartment(int32_t value); 23 | }; 24 | 25 | struct ClassMta : ClassMtaT 26 | { 27 | ClassMta() = default; 28 | 29 | int32_t Apartment(); 30 | void Apartment(int32_t value); 31 | }; 32 | } 33 | 34 | namespace winrt::EmbeddedTestComponent::factory_implementation 35 | { 36 | struct ClassBoth : ClassBothT 37 | { 38 | }; 39 | 40 | struct ClassSta : ClassStaT 41 | { 42 | }; 43 | 44 | struct ClassMta : ClassMtaT 45 | { 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/Class.idl: -------------------------------------------------------------------------------- 1 | namespace EmbeddedTestComponent 2 | { 3 | [default_interface] 4 | runtimeclass ClassBoth 5 | { 6 | ClassBoth(); 7 | Int32 Apartment; 8 | } 9 | 10 | [default_interface] 11 | runtimeclass ClassSta 12 | { 13 | ClassSta(); 14 | Int32 Apartment; 15 | } 16 | 17 | [default_interface] 18 | runtimeclass ClassMta 19 | { 20 | ClassMta(); 21 | Int32 Apartment; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/EmbeddedTestComponent.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/EmbeddedTestComponent.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 13 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/EmbeddedTestComponent.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/Resource.rc: -------------------------------------------------------------------------------- 1 | #define MANIFEST_RESOURCE_ID 2 2 | #define RT_MANIFEST 24 3 | MANIFEST_RESOURCE_ID RT_MANIFEST "EmbeddedTestComponent.manifest" -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | C++/WinRT EmbeddedTestComponent Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the C++/WinRT SDK component 7 | to generate implementation headers from interface (IDL) files. The 8 | generated Windows Runtime component binary and WinMD files should then 9 | be bundled with the Universal Windows Platform (UWP) app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about C++/WinRT here: 22 | http://aka.ms/cppwinrt/ 23 | ======================================================================== 24 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/EmbeddedTestComponent/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/ManifestParserTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.blankFileName.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.blankName.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.duplicateAcid.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 14 | 15 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.invalidThreadingModel.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.missingFileName.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.missingName.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.negative.missingThreadingModel.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/basicParse.positive.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 13 | 17 | 21 | 25 | 26 | 27 | 31 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "..\Catch\catch.hpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\Catch\catch.hpp" 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/ManifestParserTest/winrtActivation.dll1.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 14 | 18 | 22 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/Nuget/LICENSE: -------------------------------------------------------------------------------- 1 | C++ for the Windows Runtime (C++/WinRT) 2 | 3 | Copyright (c) Microsoft Corporation 4 | All rights reserved. 5 | 6 | MIT License 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/Nuget/Microsoft.Windows.UndockedRegFreeWinrt.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Microsoft.Windows.UndockedRegFreeWinrt 5 | 1.0.0.0 6 | Regfree WinRT Build Support 7 | Microsoft 8 | Microsoft 9 | false 10 | Regfree WinRT enables using WinRT types from unpackaged applications, a feature that is available starting on Windows version 1903 and above. This nuget package backfills this functionality to previous Windows versions down to RS2. 11 | 12 | regfree WinRT 13 | © Microsoft Corporation. All rights reserved. 14 | LICENSE 15 | https://github.com/Microsoft/xlang 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/Nuget/SignConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/SignConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/Class.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "Class.h" 3 | #include "ClassBoth.g.cpp" 4 | #include "ClassSta.g.cpp" 5 | #include "ClassMta.g.cpp" 6 | 7 | namespace winrt::TestComponent::implementation 8 | { 9 | int32_t ClassBoth::Apartment() 10 | { 11 | APTTYPE aptType; 12 | APTTYPEQUALIFIER aptQualifier; 13 | check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); 14 | return aptType; 15 | } 16 | 17 | void ClassBoth::Apartment(int32_t /* value */) 18 | { 19 | throw hresult_not_implemented(); 20 | } 21 | 22 | int32_t ClassSta::Apartment() 23 | { 24 | APTTYPE aptType; 25 | APTTYPEQUALIFIER aptQualifier; 26 | check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); 27 | return aptType; 28 | } 29 | 30 | void ClassSta::Apartment(int32_t /* value */) 31 | { 32 | throw hresult_not_implemented(); 33 | } 34 | 35 | int32_t ClassMta::Apartment() 36 | { 37 | APTTYPE aptType; 38 | APTTYPEQUALIFIER aptQualifier; 39 | check_hresult(CoGetApartmentType(&aptType, &aptQualifier)); 40 | return aptType; 41 | } 42 | 43 | void ClassMta::Apartment(int32_t /* value */) 44 | { 45 | throw hresult_not_implemented(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/Class.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ClassBoth.g.h" 4 | #include "ClassSta.g.h" 5 | #include "ClassMta.g.h" 6 | 7 | namespace winrt::TestComponent::implementation 8 | { 9 | struct ClassBoth : ClassBothT 10 | { 11 | ClassBoth() = default; 12 | 13 | int32_t Apartment(); 14 | void Apartment(int32_t value); 15 | }; 16 | 17 | struct ClassSta : ClassStaT 18 | { 19 | ClassSta() = default; 20 | 21 | int32_t Apartment(); 22 | void Apartment(int32_t value); 23 | }; 24 | 25 | struct ClassMta : ClassMtaT 26 | { 27 | ClassMta() = default; 28 | 29 | int32_t Apartment(); 30 | void Apartment(int32_t value); 31 | }; 32 | } 33 | 34 | namespace winrt::TestComponent::factory_implementation 35 | { 36 | struct ClassBoth : ClassBothT 37 | { 38 | }; 39 | 40 | struct ClassSta : ClassStaT 41 | { 42 | }; 43 | 44 | struct ClassMta : ClassMtaT 45 | { 46 | }; 47 | } 48 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/Class.idl: -------------------------------------------------------------------------------- 1 | namespace TestComponent 2 | { 3 | [default_interface] 4 | runtimeclass ClassBoth 5 | { 6 | ClassBoth(); 7 | Int32 Apartment; 8 | } 9 | 10 | [default_interface] 11 | runtimeclass ClassSta 12 | { 13 | ClassSta(); 14 | Int32 Apartment; 15 | } 16 | 17 | [default_interface] 18 | runtimeclass ClassMta 19 | { 20 | ClassMta(); 21 | Int32 Apartment; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/TestComponent.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/TestComponent.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/TestComponent/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | C++/WinRT TestComponent Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the C++/WinRT SDK component 7 | to generate implementation headers from interface (IDL) files. The 8 | generated Windows Runtime component binary and WinMD files should then 9 | be bundled with the Universal Windows Platform (UWP) app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about C++/WinRT here: 22 | http://aka.ms/cppwinrt/ 23 | ======================================================================== 24 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRT/UndockedRegFreeWinRT.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | Source Files 21 | 22 | 23 | 24 | 25 | 26 | Source Files 27 | 28 | 29 | Source Files 30 | 31 | 32 | Header Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRT/catalog.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "wil/result.h" 9 | #include "wil/resource.h" 10 | 11 | HRESULT LoadManifestFromPath(std::wstring path); 12 | 13 | HRESULT LoadFromSxSManifest(PCWSTR path); 14 | 15 | HRESULT LoadFromEmbeddedManifest(PCWSTR path); 16 | 17 | HRESULT WinRTLoadComponentFromFilePath(PCWSTR manifestPath); 18 | 19 | HRESULT WinRTLoadComponentFromString(std::string_view xmlStringValue); 20 | 21 | HRESULT ParseRootManifestFromXmlReaderInput(IUnknown* pInput); 22 | 23 | HRESULT ParseFileTag(Microsoft::WRL::ComPtr xmlReader); 24 | 25 | HRESULT ParseActivatableClassTag(Microsoft::WRL::ComPtr xmlReader, PCWSTR fileName); 26 | 27 | HRESULT WinRTGetThreadingModel( 28 | HSTRING activatableClassId, 29 | ABI::Windows::Foundation::ThreadingType* threading_model); 30 | 31 | HRESULT WinRTGetActivationFactory( 32 | HSTRING activatableClassId, 33 | REFIID iid, 34 | void** factory); 35 | 36 | HRESULT WinRTGetMetadataFile( 37 | const HSTRING name, 38 | IMetaDataDispenserEx* metaDataDispenser, 39 | HSTRING* metaDataFilePath, 40 | IMetaDataImport2** metaDataImport, 41 | mdTypeDef* typeDefToken); -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRT/cpp.hint: -------------------------------------------------------------------------------- 1 | #define UNDOCKEDREGFREEWINRT_API __declspec(dllexport) 2 | #define UNDOCKEDREGFREEWINRT_API __declspec(dllimport) 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRT/extwinrt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | HRESULT WINAPI RegFreeWinRTInitializeForTest(); 4 | HRESULT WINAPI RegFreeWinRTUninitializeForTest(); -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRT/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRT/winrtact.def: -------------------------------------------------------------------------------- 1 | LIBRARY winrtact 2 | 3 | EXPORTS 4 | winrtact_Initialize -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTManagedTest/UndockedRegFreeWinRTManagedTest.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | x64;x86 7 | true 8 | 9 | 10 | 11 | true 12 | 13 | 14 | 15 | true 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | ..\_build\x86\Debug\TestComponent.winmd 31 | true 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/UndockedRegFreeWinRTTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/directory.build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | high 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "..\Catch\catch.hpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\Catch\catch.hpp" 4 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/UndockedRegFreeWinRTTest/test_files/UndockedRegFreeWinRTTest.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 12 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/detours.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 7 | 8 | 9 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/detver.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Common version parameters. 4 | // 5 | // Microsoft Research Detours Package, Version 4.0.1 6 | // 7 | // Copyright (c) Microsoft Corporation. All rights reserved. 8 | // 9 | 10 | #define _USING_V110_SDK71_ 1 11 | #include "winver.h" 12 | #if 0 13 | #include 14 | #include 15 | #else 16 | #ifndef DETOURS_STRINGIFY 17 | #define DETOURS_STRINGIFY(x) DETOURS_STRINGIFY_(x) 18 | #define DETOURS_STRINGIFY_(x) #x 19 | #endif 20 | 21 | #define VER_FILEFLAGSMASK 0x3fL 22 | #define VER_FILEFLAGS 0x0L 23 | #define VER_FILEOS 0x00040004L 24 | #define VER_FILETYPE 0x00000002L 25 | #define VER_FILESUBTYPE 0x00000000L 26 | #endif 27 | #define VER_DETOURS_BITS DETOUR_STRINGIFY(DETOURS_BITS) 28 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/disolarm.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_ARM_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/disolarm64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_ARM64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/disolia64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_IA64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/disolx64.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_X64_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/detours/disolx86.cpp: -------------------------------------------------------------------------------- 1 | #define DETOURS_X86_OFFLINE_LIBRARY 2 | #include "disasm.cpp" 3 | -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/mwinrtact/mwinrtact.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Microsoft.Windows 4 | { 5 | public static class UndockedRegFreeWinrt 6 | { 7 | [DllImport("winrtact.dll")] 8 | static extern void winrtact_Initialize(); 9 | 10 | public static void Initialize() 11 | { 12 | winrtact_Initialize(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/UndockedRegFreeWinRT/mwinrtact/mwinrtact.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/foundation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | if (WIN32) 3 | add_custom_target(foundation_metadata 4 | COMMAND ilasm /DLL /mdv="WindowsRuntime 1.4" /output=${CMAKE_CURRENT_BINARY_DIR}/Foundation.xmeta ${CMAKE_CURRENT_SOURCE_DIR}/xlang_foundation.il 5 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/xlang_foundation.il 6 | BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Foundation.xmeta 7 | ) 8 | set_target_properties(foundation_metadata PROPERTIES 9 | Foundation_xmeta ${CMAKE_CURRENT_BINARY_DIR}/Foundation.xmeta 10 | ) 11 | endif() 12 | -------------------------------------------------------------------------------- /src/library/impl/base.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_WIN32) 4 | #define XLANG_PLATFORM_WINDOWS 1 5 | #else 6 | #define XLANG_PLATFORM_WINDOWS 0 7 | #endif 8 | 9 | #if XLANG_PLATFORM_WINDOWS 10 | #include 11 | #include 12 | #include 13 | #else 14 | #include 15 | #include 16 | #include 17 | #include 18 | #endif 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #if defined(_DEBUG) 38 | #define XLANG_DEBUG 39 | #define XLANG_ASSERT assert 40 | #else 41 | #define XLANG_ASSERT(expression) ((void)0) 42 | #endif 43 | 44 | namespace xlang 45 | { 46 | using namespace std::literals; 47 | 48 | [[noreturn]] inline void throw_invalid(std::string const& message) 49 | { 50 | throw std::invalid_argument(message); 51 | } 52 | 53 | template 54 | [[noreturn]] inline void throw_invalid(std::string message, T const&... args) 55 | { 56 | (message.append(args), ...); 57 | throw std::invalid_argument(message); 58 | } 59 | 60 | template 61 | auto c_str(std::basic_string_view const& view) noexcept 62 | { 63 | if (*(view.data() + view.size())) 64 | { 65 | std::terminate(); 66 | } 67 | 68 | return view.data(); 69 | } 70 | 71 | inline bool starts_with(std::string_view const& value, std::string_view const& match) noexcept 72 | { 73 | return 0 == value.compare(0, match.size(), match); 74 | } 75 | 76 | template struct visit_overload : T... { using T::operator()...; }; 77 | 78 | template 79 | auto call(V&& variant, C&&...call) 80 | { 81 | return std::visit(visit_overload{ std::forward(call)... }, std::forward(variant)); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/library/impl/meta_reader/helpers.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::meta::reader 3 | { 4 | template 5 | bool empty(std::pair const& range) noexcept 6 | { 7 | return range.first == range.second; 8 | } 9 | 10 | template 11 | std::size_t size(std::pair const& range) noexcept 12 | { 13 | return range.second - range.first; 14 | } 15 | 16 | inline auto find(TypeRef const& type) 17 | { 18 | return type.get_database().get_cache().find(type.TypeNamespace(), type.TypeName()); 19 | } 20 | 21 | inline auto find_required(TypeRef const& type) 22 | { 23 | return type.get_database().get_cache().find_required(type.TypeNamespace(), type.TypeName()); 24 | } 25 | 26 | inline TypeDef find_required(coded_index const& type) 27 | { 28 | if (type.type() == TypeDefOrRef::TypeRef) 29 | { 30 | return find_required(type.TypeRef()); 31 | } 32 | else if (type.type() == TypeDefOrRef::TypeDef) 33 | { 34 | return type.TypeDef(); 35 | } 36 | else 37 | { 38 | XLANG_ASSERT(false); 39 | return {}; 40 | } 41 | } 42 | 43 | inline bool is_const(ParamSig const& param) 44 | { 45 | auto is_type_const = [](auto&& type) 46 | { 47 | return type.TypeNamespace() == "System.Runtime.CompilerServices" && type.TypeName() == "IsConst"; 48 | }; 49 | 50 | for (auto const& cmod : param.CustomMod()) 51 | { 52 | auto type = cmod.Type(); 53 | 54 | if (type.type() == TypeDefOrRef::TypeDef) 55 | { 56 | if (is_type_const(type.TypeDef())) 57 | { 58 | return true; 59 | } 60 | } 61 | else if (type.type() == TypeDefOrRef::TypeRef) 62 | { 63 | if (is_type_const(type.TypeRef())) 64 | { 65 | return true; 66 | } 67 | } 68 | } 69 | 70 | return false; 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /src/library/impl/meta_reader/index.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::meta::reader 3 | { 4 | template <> struct typed_index : index_base 5 | { 6 | using index_base::index_base; 7 | 8 | auto MemberRef() const; 9 | auto MethodDef() const; 10 | }; 11 | 12 | template <> struct typed_index : index_base 13 | { 14 | using index_base::index_base; 15 | 16 | auto Field() const; 17 | auto Param() const; 18 | auto Property() const; 19 | }; 20 | 21 | template <> struct typed_index : index_base 22 | { 23 | using index_base::index_base; 24 | 25 | auto Property() const; 26 | auto Event() const; 27 | }; 28 | 29 | template <> struct typed_index : index_base 30 | { 31 | using index_base::index_base; 32 | 33 | auto MethodDef() const; 34 | auto MemberRef() const; 35 | }; 36 | 37 | template <> struct typed_index : index_base 38 | { 39 | using index_base::index_base; 40 | 41 | auto Module() const; 42 | auto ModuleRef() const; 43 | auto AssemblyRef() const; 44 | auto TypeRef() const; 45 | }; 46 | 47 | template <> struct typed_index : index_base 48 | { 49 | using index_base::index_base; 50 | 51 | TypeDef TypeDef() const; 52 | TypeRef TypeRef() const; 53 | TypeSpec TypeSpec() const; 54 | auto CustomAttribute() const; 55 | }; 56 | } 57 | -------------------------------------------------------------------------------- /src/library/impl/meta_reader/type_helpers.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::meta::reader 3 | { 4 | inline std::pair get_type_namespace_and_name(coded_index const& type) 5 | { 6 | if (type.type() == TypeDefOrRef::TypeDef) 7 | { 8 | auto const def = type.TypeDef(); 9 | return { def.TypeNamespace(), def.TypeName() }; 10 | } 11 | else if (type.type() == TypeDefOrRef::TypeRef) 12 | { 13 | auto const ref = type.TypeRef(); 14 | return { ref.TypeNamespace(), ref.TypeName() }; 15 | } 16 | else 17 | { 18 | XLANG_ASSERT(false); 19 | return {}; 20 | } 21 | } 22 | 23 | inline std::pair get_base_class_namespace_and_name(TypeDef const& type) 24 | { 25 | return get_type_namespace_and_name(type.Extends()); 26 | } 27 | 28 | inline auto extends_type(TypeDef type, std::string_view typeNamespace, std::string_view typeName) 29 | { 30 | return get_base_class_namespace_and_name(type) == std::pair(typeNamespace, typeName); 31 | } 32 | 33 | enum class category 34 | { 35 | interface_type, 36 | class_type, 37 | enum_type, 38 | struct_type, 39 | delegate_type 40 | }; 41 | 42 | inline category get_category(TypeDef const& type) 43 | { 44 | if (type.Flags().Semantics() == TypeSemantics::Interface) 45 | { 46 | return category::interface_type; 47 | } 48 | 49 | auto const& [extends_namespace, extends_name] = get_base_class_namespace_and_name(type); 50 | 51 | if (extends_name == "Enum"sv && extends_namespace == "System"sv) 52 | { 53 | return category::enum_type; 54 | } 55 | 56 | if (extends_name == "ValueType"sv && extends_namespace == "System"sv) 57 | { 58 | return category::struct_type; 59 | } 60 | 61 | if (extends_name == "MulticastDelegate"sv && extends_namespace == "System"sv) 62 | { 63 | return category::delegate_type; 64 | } 65 | 66 | return category::class_type; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/library/meta_reader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "impl/base.h" 4 | #include "impl/meta_reader/pe.h" 5 | #include "impl/meta_reader/view.h" 6 | #include "impl/meta_reader/enum.h" 7 | #include "impl/meta_reader/enum_traits.h" 8 | #include "impl/meta_reader/flags.h" 9 | #include "impl/meta_reader/table.h" 10 | #include "impl/meta_reader/index.h" 11 | #include "impl/meta_reader/signature.h" 12 | #include "impl/meta_reader/schema.h" 13 | #include "impl/meta_reader/database.h" 14 | #include "impl/meta_reader/column.h" 15 | #include "impl/meta_reader/type_helpers.h" 16 | #include "impl/meta_reader/key.h" 17 | #include "impl/meta_reader/cache.h" 18 | #include "impl/meta_reader/filter.h" 19 | #include "impl/meta_reader/custom_attribute.h" 20 | #include "impl/meta_reader/helpers.h" 21 | -------------------------------------------------------------------------------- /src/library/meta_writer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "impl/meta_writer/pe_writer.h" 4 | -------------------------------------------------------------------------------- /src/library/task_group.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "impl/base.h" 4 | 5 | namespace xlang 6 | { 7 | struct task_group 8 | { 9 | task_group(task_group const&) = delete; 10 | task_group& operator=(task_group const&) = delete; 11 | 12 | task_group() noexcept = default; 13 | 14 | ~task_group() noexcept 15 | { 16 | for (auto&& task : m_tasks) 17 | { 18 | task.wait(); 19 | } 20 | } 21 | 22 | template 23 | void add(T&& callback) 24 | { 25 | #if defined(XLANG_DEBUG) 26 | callback(); 27 | #else 28 | m_tasks.push_back(std::async(std::forward(callback))); 29 | #endif 30 | } 31 | 32 | void get() 33 | { 34 | auto tasks = std::move(m_tasks); 35 | 36 | for (auto&& task : tasks) 37 | { 38 | task.wait(); 39 | } 40 | 41 | for (auto&& task : tasks) 42 | { 43 | task.get(); 44 | } 45 | } 46 | 47 | private: 48 | 49 | std::vector> m_tasks; 50 | }; 51 | } 52 | -------------------------------------------------------------------------------- /src/package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(abi) 2 | add_subdirectory(pywinrt) 3 | -------------------------------------------------------------------------------- /src/package/abi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | # The Microsoft.Windows.AbiWinRT NuGet package is only targeted at Visual Studio (on Windows) 4 | if (WIN32 AND ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x86")) 5 | 6 | file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/build_tools/nuget.exe" nuget_exe) 7 | file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" abiwinrt_nupkg_dir) 8 | file(TO_NATIVE_PATH "${abiwinrt_nupkg_dir}/Microsoft.Windows.AbiWinRT.${XLANG_BUILD_VERSION}.nupkg" abiwinrt_nupkg) 9 | 10 | get_target_property(abiwinrt_exe abi "abiwinrt_exe") 11 | 12 | file(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${nuget_exe}) 13 | 14 | add_custom_command(OUTPUT ${abiwinrt_nupkg} 15 | COMMAND ${nuget_exe} pack ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.AbiWinRT.nuspec -Properties abiwinrt_exe=${abiwinrt_exe}; -Version ${XLANG_BUILD_VERSION} -OutputDirectory ${CMAKE_CURRENT_BINARY_DIR} -NonInteractive -Verbosity Detailed 16 | DEPENDS ${XLANG_BUILD_VERSION_h} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.AbiWinRT.nuspec 17 | ) 18 | 19 | add_custom_target(make_abiwinrt_nupkg ALL DEPENDS ${abiwinrt_nupkg} abi) 20 | 21 | set_target_properties(make_abiwinrt_nupkg PROPERTIES "abiwinrt_nupkg_dir" ${abiwinrt_nupkg_dir}) 22 | 23 | endif() -------------------------------------------------------------------------------- /src/package/abi/LICENSE: -------------------------------------------------------------------------------- 1 | WinRT ABI Header Generation Tool 2 | 3 | Copyright (c) Microsoft Corporation 4 | All rights reserved. 5 | 6 | MIT License 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /src/package/abi/Microsoft.Windows.AbiWinRT.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft.Windows.AbiWinRT 5 | 1.0.0.0 6 | WinRT ABI Header Build Support 7 | Microsoft 8 | Microsoft 9 | false 10 | Provides the abi.exe tool for generating ABI-level C++ headers for accessing the Windows API. 11 | 12 | native abi winrt nativepackage 13 | © Microsoft Corporation. All rights reserved. 14 | LICENSE 15 | https://github.com/microsoft/xlang/tree/master/src/tool/abi 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/package/abi/Microsoft.Windows.AbiWinRT.props: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 11 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 12 | 13 | true 14 | 15 | -------------------------------------------------------------------------------- /src/package/abi/SignConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/package/abi/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | The Microsoft.Windows.AbiWinRT NuGet package provides the abi.exe tool 3 | for generating ABI-level C++ headers to access Windows Runtime APIs. 4 | 5 | ======================================================================== 6 | For more information, including usage, visit: 7 | https://github.com/microsoft/xlang/tree/master/src/tool/abi 8 | ======================================================================== 9 | -------------------------------------------------------------------------------- /src/package/midlrt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | # The Microsoft.Windows.MidlRT NuGet package is only targeted at Visual Studio (on Windows) 4 | if (WIN32 AND ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x86")) 5 | 6 | file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/build_tools/nuget.exe" nuget_exe) 7 | file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" midlrt_nupkg_dir) 8 | file(TO_NATIVE_PATH "${midlrt_nupkg_dir}/Microsoft.Windows.midlrt.${XLANG_BUILD_VERSION}.nupkg" midlrt_nupkg) 9 | 10 | file(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${nuget_exe}) 11 | 12 | add_custom_command(OUTPUT ${midlrt_nupkg} 13 | COMMAND ${nuget_exe} pack ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.midlrt.nuspec -Properties -Version ${XLANG_BUILD_VERSION} -OutputDirectory ${CMAKE_CURRENT_BINARY_DIR} -NonInteractive -Verbosity Detailed 14 | DEPENDS ${XLANG_BUILD_VERSION_h} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.midlrt.nuspec 15 | ) 16 | 17 | add_custom_target(make_midlrt_nupkg ALL DEPENDS ${midlrt_nupkg} abi) 18 | 19 | set_target_properties(make_midlrt_nupkg PROPERTIES "midlrt_nupkg_dir" ${midlrt_nupkg_dir}) 20 | 21 | endif() -------------------------------------------------------------------------------- /src/package/midlrt/LICENSE: -------------------------------------------------------------------------------- 1 | WinRT Metadata Generation Utility Package 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | MIT License 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | -------------------------------------------------------------------------------- /src/package/midlrt/Microsoft.Windows.MidlRT.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Microsoft.Windows.MidlRT 5 | 1.0.0.0 6 | MidlRT Build Support 7 | Microsoft 8 | Microsoft 9 | false 10 | Provides targets for invoking MidlRT to support projects using MIDL2 and MIDL3 11 | 12 | native midl winrt nativepackage 13 | © Microsoft Corporation. All rights reserved. 14 | LICENSE 15 | https://github.com/microsoft/xlang/tree/master/src/package/midlrt 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/package/midlrt/Microsoft.Windows.MidlRT.props: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 11 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 12 | true 13 | 14 | 15 | 16 | x64 17 | true 18 | 19 | true 20 | 21 | 22 | 23 | 24 | true 25 | $(IntDir)Unmerged\%(Filename).winmd 26 | None 27 | None 28 | false 29 | false 30 | nul 31 | nul 32 | nul 33 | nul 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/package/midlrt/SignConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/package/midlrt/readme.md: -------------------------------------------------------------------------------- 1 | ## The Windows Runtime (WinRT) API Generation tool 2 | 3 | The Microsoft.Windows.MidlRT package provides targets for running the midlrt.exe tool that ships in the Windows SDK. This enables you to build WinRT APIs that generate a .winmd file using either the MIDL2.0 or MIDL3.0 syntax. 4 | 5 | - Nuget Package: https://www.nuget.org/packages/Microsoft.Windows.MidlRT/ 6 | 7 | For more information on MIDL3.0 and all the benefits it brings, including improved compilation times, see the official documentation: https://docs.microsoft.com/en-us/uwp/midl-3/ 8 | 9 | ## Migrating from MIDL2.0 to MIDL3 10 | 11 | See the official documentation for how to migrate from MIDL2.0 syntax to MIDL3.0: https://docs.microsoft.com/en-us/uwp/midl-3/from-midlrt 12 | 13 | ## Usage 14 | 15 | The MidlRT package is **production only**, which means it enables you to generate your own .winmd file. If you are producing a .winmd, it's likely that you'll need to consume other WinRT API's as well, which can be done through the consumption technology of your choice: 16 | 17 | - Microsoft.Windows.CppWinRT: https://www.nuget.org/packages/Microsoft.Windows.CppWinRT/ 18 | - Microsoft.Windows.AbiWinRT: https://www.nuget.org/packages/Microsoft.Windows.AbiWinRT/ 19 | - **Note: Microsoft.Windows.AbiWinRT is only intended for legacy code bases,** 20 | **and doesn't provide support for the latest C++ language features that Microsoft.Windows.CppWinRT does.** 21 | 22 | If you are using `Microsoft.Windows.CppWinRT` there is no need to reference this Nuget directly. 23 | 24 | | Property | Description | 25 | |-----------|---------------| 26 | | `ModernMidlRT` | Uses MIDL3.0. Defaults to `true`. | 27 | -------------------------------------------------------------------------------- /src/package/midlrt/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | The Microsoft.Windows.MidlRT NuGet package provides targets 3 | for producing Windows Runtime APIs. 4 | 5 | ======================================================================== 6 | For more information, including usage, visit: 7 | https://github.com/microsoft/xlang/tree/master/src/package/midlrt 8 | ======================================================================== 9 | -------------------------------------------------------------------------------- /src/package/pywinrt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(tool) 2 | -------------------------------------------------------------------------------- /src/package/pywinrt/LICENSE: -------------------------------------------------------------------------------- 1 | Python for the Windows Runtime (Py/WinRT) 2 | 3 | Copyright (c) Microsoft Corporation 4 | All rights reserved. 5 | 6 | MIT License 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/.gitignore: -------------------------------------------------------------------------------- 1 | /cppwinrt/ 2 | /pywinrt/ -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/job-build-projection.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - job: build_projection 3 | dependsOn: build_pywinrt 4 | pool: 5 | vmImage: 'windows-2019' 6 | timeoutInMinutes: 120 7 | strategy: 8 | maxParallel: 10 9 | matrix: 10 | Release_x86_py37: 11 | buildArchitecture: 'x86' 12 | buildConfiguration: 'Release' 13 | pythonVersion: '3.7' 14 | pythonArchitecture: 'x86' 15 | Release_x64_py37: 16 | buildArchitecture: 'amd64' 17 | buildConfiguration: 'Release' 18 | pythonVersion: '3.7' 19 | pythonArchitecture: 'x64' 20 | Release_x86_py38: 21 | buildArchitecture: 'x86' 22 | buildConfiguration: 'Release' 23 | pythonVersion: '3.8' 24 | pythonArchitecture: 'x86' 25 | Release_x64_py38: 26 | buildArchitecture: 'amd64' 27 | buildConfiguration: 'Release' 28 | pythonVersion: '3.8' 29 | pythonArchitecture: 'x64' 30 | Release_x86_py39: 31 | buildArchitecture: 'x86' 32 | buildConfiguration: 'Release' 33 | pythonVersion: '3.9' 34 | pythonArchitecture: 'x86' 35 | Release_x64_py39: 36 | buildArchitecture: 'amd64' 37 | buildConfiguration: 'Release' 38 | pythonVersion: '3.9' 39 | pythonArchitecture: 'x64' 40 | steps: 41 | - template: steps-build-projection.yml 42 | parameters: 43 | architecture: $(buildArchitecture) 44 | pythonVersionSpec: $(pythonVersion) 45 | projectionType: $(ProjectionType) 46 | pythonArchSpec: $(pythonArchitecture) 47 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/job-build-pywinrt.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - job: build_pywinrt 3 | pool: 4 | vmImage: 'windows-2019' 5 | 6 | steps: 7 | - script: | 8 | @echo off 9 | @echo Build.BuildNumber $(Build.BuildNumber) 10 | @echo buildFullProjection $(buildFullProjection) 11 | 12 | - template: task-vsdevcmd.yml 13 | parameters: 14 | buildArchitecture: 'x86' 15 | hostArchitecture: 'x86' 16 | 17 | # Extract the build revision information from Build.BuildNumber. This is needed to pass to various build steps. 18 | # This relies on the format of the pipeline name being of the format: .$(Date:yy).$(Date:MMdd).$(DayOfYear).$(Rev:r) 19 | # We can't use those variables here (they only work in the *name* of the top level Yaml), so 20 | # pull them out here and set the variables for use later build steps 21 | - powershell: | 22 | $a = $env:BUILD_BUILDNUMBER.split('.') 23 | $yy = $a[1] 24 | $mmdd = $a[2] 25 | $rev = $a[4] 26 | $pywinrtVersion = "0.9.$yy$mmdd.$rev" 27 | Write-Host "##vso[task.setvariable variable=pywinrtVersion]$pywinrtVersion" 28 | Write-Host pywinrtVersion=$pywinrtVersion 29 | displayName: 'Get pywinrt version number from build number' 30 | 31 | - task: CMake@1 32 | displayName: 'Generate xlang build files via cmake' 33 | inputs: 34 | cwd: '.' 35 | cmakeArgs: -S src -B_build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DXLANG_BUILD_VERSION=$(pywinrtVersion) 36 | 37 | - task: CMake@1 38 | displayName: 'build pywinrt' 39 | inputs: 40 | cwd: '.' 41 | cmakeArgs: --build .\_build -- -v pywinrt 42 | 43 | - task: CopyFiles@2 44 | inputs: 45 | sourceFolder: _build\tool\python\ 46 | contents: pywinrt.exe 47 | targetFolder: '$(Build.ArtifactStagingDirectory)' 48 | 49 | - task: PublishBuildArtifacts@1 50 | displayName: 'Publish artifact: pywinrt' 51 | inputs: 52 | PathtoPublish: '$(Build.ArtifactStagingDirectory)' 53 | artifactName: 'pywinrt' -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/job-package-projection.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | dependsOn: build_projection 3 | 4 | jobs: 5 | - job: package_projection 6 | dependsOn: ${{ parameters.dependsOn }} 7 | pool: 8 | vmImage: 'windows-2019' 9 | strategy: 10 | maxParallel: 10 11 | matrix: 12 | Release_37_py: 13 | PyMajorVer: '3' 14 | PyMinorVer: '7' 15 | Release_38_py: 16 | PyMajorVer: '3' 17 | PyMinorVer: '8' 18 | Release_39_py: 19 | PyMajorVer: '3' 20 | PyMinorVer: '9' 21 | 22 | steps: 23 | 24 | - task: DownloadBuildArtifacts@0 25 | inputs: 26 | buildType: 'current' 27 | downloadType: single 28 | artifactName: projection 29 | downloadPath: '$(Build.ArtifactStagingDirectory)' 30 | 31 | - task: UsePythonVersion@0 32 | inputs: 33 | versionSpec: '$(PyMajorVer).$(PyMinorVer).x' 34 | addToPath: true 35 | 36 | - script: pip install wheel 37 | displayName: pip install wheel 38 | 39 | - template: steps-package-projection.yml 40 | parameters: 41 | architecture: x86 42 | pythonVersionSpec: '$(PyMajorVer).$(PyMinorVer).x' 43 | 44 | - template: steps-package-projection.yml 45 | parameters: 46 | architecture: amd64 47 | pythonVersionSpec: '$(PyMajorVer).$(PyMinorVer).x' 48 | 49 | - task: PublishBuildArtifacts@1 50 | displayName: 'Publish artifact: wheel' 51 | inputs: 52 | PathtoPublish: $(Build.ArtifactStagingDirectory)/wheel 53 | artifactName: wheel 54 | 55 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/job-sign-projection.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | dependsOn: build_projection 3 | 4 | jobs: 5 | 6 | - job: sign_projection 7 | dependsOn: ${{ parameters.dependsOn }} 8 | pool: 9 | name: Package ES Lab E 10 | steps: 11 | - task: DownloadBuildArtifacts@0 12 | displayName: 'Download artifact: projection' 13 | inputs: 14 | buildType: 'current' 15 | downloadType: single 16 | artifactName: projection 17 | downloadPath: '$(Build.ArtifactStagingDirectory)' 18 | 19 | - template: steps-sign-projection.yml 20 | 21 | - task: PublishBuildArtifacts@1 22 | displayName: 'Publish artifact: projection' 23 | inputs: 24 | pathToPublish: $(Build.ArtifactStagingDirectory)/projection 25 | artifactName: projection 26 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/steps-package-projection.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | architecture: 'amd64' 3 | pythonVersionSpec: '3.9.x' 4 | 5 | steps: 6 | 7 | - ${{ if eq(parameters.architecture, 'amd64') }}: 8 | - script: | 9 | @echo off 10 | @echo ##vso[task.setvariable variable=platname]win-amd64 11 | displayName: 'set platname to win-amd64' 12 | 13 | - ${{ if eq(parameters.architecture, 'x86') }}: 14 | - script: | 15 | @echo off 16 | @echo ##vso[task.setvariable variable=platname]win32 17 | displayName: 'set platname to win32' 18 | 19 | - task: CopyFiles@2 20 | inputs: 21 | sourceFolder: src/package/pywinrt/ 22 | contents: 'LICENSE' 23 | targetFolder: $(Build.ArtifactStagingDirectory)/projection/${{ parameters.pythonVersionSpec}}/${{ parameters.architecture }} 24 | 25 | - script: python $(Build.SourcesDirectory)/src/package/pywinrt/projection/setup.py bdist_wheel --python-tag cp$(PyMajorVer)$(PyMinorVer) --plat-name $(platname) 26 | workingDirectory: $(Build.ArtifactStagingDirectory)/projection/${{ parameters.pythonVersionSpec}}/${{ parameters.architecture }} 27 | displayName: python setup.py bdist_wheel (${{ parameters.architecture }}) 28 | 29 | - task: CopyFiles@2 30 | inputs: 31 | sourceFolder: $(Build.ArtifactStagingDirectory)/projection/${{ parameters.pythonVersionSpec}}/${{ parameters.architecture }}/dist 32 | contents: '*' 33 | targetFolder: $(Build.ArtifactStagingDirectory)/wheel/ 34 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/steps-sign-projection.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | 3 | - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 4 | displayName: 'Component Governance Detection' 5 | inputs: 6 | scanType: 'Register' 7 | failOnAlert: true 8 | 9 | - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 10 | displayName: 'ESRP CodeSigning' 11 | inputs: 12 | ConnectedServiceName: 'Xlang Code Signing' 13 | FolderPath: '$(Build.ArtifactStagingDirectory)/projection' 14 | signConfigType: inlineSignParams 15 | Pattern: '*.dll,*.exe,*.pyd' 16 | inlineOperation: | 17 | [ 18 | { 19 | "keyCode": "CP-230012", 20 | "operationSetCode": "SigntoolSign", 21 | "parameters": [ 22 | { 23 | "parameterName": "OpusName", 24 | "parameterValue": "Microsoft" 25 | }, 26 | { 27 | "parameterName": "OpusInfo", 28 | "parameterValue": "http://www.microsoft.com" 29 | }, 30 | { 31 | "parameterName": "PageHash", 32 | "parameterValue": "/NPH" 33 | }, 34 | { 35 | "parameterName": "FileDigest", 36 | "parameterValue": "/fd sha256" 37 | }, 38 | { 39 | "parameterName": "TimeStamp", 40 | "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" 41 | } 42 | ], 43 | "toolName": "signtool.exe", 44 | "toolVersion": "6.2.9304.0" 45 | } 46 | ] 47 | 48 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/AzurePipelinesTemplates/task-vsdevcmd.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | buildArchitecture: 'x86' # defaults for any parameters that aren't specified 3 | hostArchitecture: 'x86' 4 | 5 | steps: 6 | - script: | 7 | @echo off 8 | 9 | set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 10 | for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do ( 11 | set vslatest="%%i" 12 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( 13 | set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat" 14 | ) 15 | ) 16 | 17 | @echo vslatest %vslatest% 18 | @echo vsdevcmd %vsdevcmd% 19 | 20 | @echo ##vso[task.setvariable variable=vslatest]%vslatest% 21 | @echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd% 22 | displayName: 'locate vsdevcmd via vswhere' 23 | 24 | - task: BatchScript@1 25 | displayName: 'Configure environment with VSDevCmd (build arch ${{ parameters.buildArchitecture }}/host arch ${{ parameters.hostArchitecture }})' 26 | inputs: 27 | filename: $(vsdevcmd) 28 | arguments: -host_arch=${{ parameters.hostArchitecture }} -arch=${{ parameters.buildArchitecture }} 29 | modifyEnvironment: true 30 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/build.ps1: -------------------------------------------------------------------------------- 1 | $buildType = "Release" 2 | 3 | $repoRootPath = (get-item $PSScriptRoot).parent.Parent.parent.Parent.FullName.Replace('\', '/') 4 | $sourcePath = $PSScriptRoot.Replace('\', '/') 5 | $buildPath = "$repoRootPath/_build/py-projection/$env:VSCMD_ARG_TGT_ARCH-$buildType" 6 | 7 | cmake -S $sourcePath "-B$buildPath" -GNinja "-DCMAKE_BUILD_TYPE=$buildType" -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl 8 | cmake --build $buildPath -- -v 9 | 10 | copy-item $buildPath/*.pyd "$sourcePath/pywinrt/winrt" 11 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/generate.ps1: -------------------------------------------------------------------------------- 1 | param ([switch]$clean, [switch]$fullProjection) 2 | 3 | $windows_sdk = '10.0.18362.0' 4 | $repoRootPath = (get-item $PSScriptRoot).parent.Parent.parent.Parent.FullName 5 | $projectionPath = "$PSScriptRoot" 6 | 7 | if ($clean) { 8 | write-host "removing generated projection files" 9 | remove-item "$repoRootPath/_build/py-projection/" -rec -for -ErrorAction SilentlyContinue 10 | exit 11 | } 12 | 13 | $pywinrt_exe = Get-ChildItem $repoRootPath\_build\Windows\*\*\tool\python\pywinrt.exe | 14 | Sort-Object -Descending | Select-Object -first 1 15 | 16 | if (-not $pywinrt_exe) { 17 | Write-Error "pywinrt not avaliable" 18 | exit 19 | } 20 | 21 | nuget install Microsoft.Windows.CppWinRT -ExcludeVersion -OutputDirectory "$repoRootPath/_build/tools" 22 | 23 | $cppwinrt_exe = "$repoRootPath/_build/tools/Microsoft.Windows.CppWinRT\bin\cppwinrt.exe" 24 | 25 | & $cppwinrt_exe -input $windows_sdk -output $projectionPath/cppwinrt -verbose 26 | 27 | $pywinrt_path = "$projectionPath/pywinrt" 28 | 29 | remove-item $pywinrt_path -Recurse -Force -ErrorAction SilentlyContinue 30 | 31 | if ($fullProjection) { 32 | $pyinclude = @("Windows.") 33 | } 34 | else { 35 | $pyinclude = "Windows.Data.Json", "Windows.Devices.Geolocation", "Windows.Foundation", "Windows.Graphics.DirectX" 36 | } 37 | $pyexclude = "Windows.UI.Composition", "Windows.UI.Xaml" 38 | $pyin = $pyinclude | ForEach-Object { "-include", "$_" } 39 | $pyout = $pyexclude | ForEach-Object { "-exclude", "$_" } 40 | 41 | $pyparams = ("-input", $windows_sdk, "-output", $pywinrt_path, "-verbose") + $pyin + $pyout 42 | 43 | & $pywinrt_exe $pyparams 44 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/package.ps1: -------------------------------------------------------------------------------- 1 | param([switch]$clean) 2 | 3 | $pythonTag = "cp37" 4 | 5 | if ($env:VSCMD_ARG_TGT_ARCH -eq "x64") { 6 | $platformTag = "win_amd64" 7 | } 8 | elseif ($env:VSCMD_ARG_TGT_ARCH -eq "x86") { 9 | $platformTag = "win32" 10 | } 11 | else { 12 | Write-Error "VSCMD_ARG_TGT_ARCH not set to an expected value (x86 or x64)" 13 | exit 14 | } 15 | 16 | Push-Location $PSScriptRoot/pywinrt 17 | 18 | if ($clean) { 19 | Remove-Item build -Recurse 20 | Remove-Item dist -Recurse 21 | Remove-Item *.egg-info -Recurse 22 | } 23 | else { 24 | py ..\setup.py bdist_wheel --python-tag $pythonTag --plat-name $platformTag 25 | } 26 | 27 | Pop-Location -------------------------------------------------------------------------------- /src/package/pywinrt/projection/pipeline-internal.yml: -------------------------------------------------------------------------------- 1 | name: $(System.TeamProject)_$(BuildID).$(Date:yy).$(Date:MMdd).$(DayOfYear).$(Rev:r) 2 | jobs: 3 | - template: AzurePipelinesTemplates/job-build-pywinrt.yml 4 | 5 | - template: AzurePipelinesTemplates/job-build-projection.yml 6 | 7 | - template: AzurePipelinesTemplates/job-sign-projection.yml 8 | parameters: 9 | dependsOn: 'build_projection' 10 | 11 | - template: AzurePipelinesTemplates/job-package-projection.yml 12 | parameters: 13 | dependsOn: sign_projection 14 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/pipeline-public.yml: -------------------------------------------------------------------------------- 1 | name: $(System.TeamProject)_$(BuildID).$(Date:yy).$(Date:MMdd).$(DayOfYear).$(Rev:r) 2 | jobs: 3 | - template: AzurePipelinesTemplates/job-build-pywinrt.yml 4 | 5 | - template: AzurePipelinesTemplates/job-build-projection.yml 6 | 7 | - template: AzurePipelinesTemplates/job-package-projection.yml 8 | parameters: 9 | dependsOn: build_projection 10 | -------------------------------------------------------------------------------- /src/package/pywinrt/projection/unity.ps1: -------------------------------------------------------------------------------- 1 | $pywinrt_src_path = "$PSScriptRoot/pywinrt/winrt/src" 2 | $pywinrt_unity_path = "$PSScriptRoot/pywinrt/winrt/unity" 3 | 4 | remove-item $pywinrt_unity_path -Recurse -Force -ErrorAction SilentlyContinue 5 | mkdir $pywinrt_unity_path | Out-Null 6 | 7 | $coreFiles = Get-ChildItem $pywinrt_src_path\*.cpp | 8 | Where-Object {-not $_.Name.StartsWith("py.")} 9 | 10 | $unityGroups = Get-ChildItem $pywinrt_src_path\*.cpp | 11 | Where-Object {$_.Name.StartsWith("py.")} | 12 | Group-Object -Property { ($_.name.split('.') | Select-Object -first 1 -skip 2)} 13 | 14 | foreach ($g in $unityGroups) 15 | { 16 | Write-Output "Unity: $($g.Name)" 17 | $cppIncludes = $g.group | ForEach-Object{"#include `"$($_.fullname)`""} 18 | "#include `"pch.h`"`n" | Set-Content -Path "$pywinrt_unity_path/$($g.Name).cpp" 19 | $cppIncludes -join "`n" | add-Content -Path "$pywinrt_unity_path/$($g.Name).cpp" 20 | } 21 | 22 | foreach ($f in $coreFiles) 23 | { 24 | Write-Output "Core: $($f.Name)" 25 | Copy-Item $f $pywinrt_unity_path 26 | } -------------------------------------------------------------------------------- /src/package/pywinrt/tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | 3 | # The Microsoft.Windows.CppWinRT NuGet package is only targeted at Visual Studio (on Windows) 4 | if (WIN32 AND ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x86")) 5 | 6 | file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/build_tools/nuget.exe" nuget_exe) 7 | file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" pywinrt_nupkg_dir) 8 | file(TO_NATIVE_PATH "${pywinrt_nupkg_dir}/Microsoft.Windows.PyWinRT.${XLANG_BUILD_VERSION}.nupkg" pywinrt_nupkg) 9 | 10 | get_target_property(pywinrt_exe pywinrt "pywinrt_exe") 11 | 12 | file(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${nuget_exe}) 13 | 14 | add_custom_command(OUTPUT ${pywinrt_nupkg} 15 | COMMAND ${nuget_exe} pack ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.PyWinRT.nuspec -Properties pywinrt_exe=${pywinrt_exe}; -Version ${XLANG_BUILD_VERSION} -OutputDirectory ${CMAKE_CURRENT_BINARY_DIR} -NonInteractive -Verbosity Detailed 16 | DEPENDS ${XLANG_BUILD_VERSION_h} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.PyWinRT.nuspec 17 | ) 18 | 19 | add_custom_target(make_pywinrt_nupkg ALL DEPENDS ${pywinrt_nupkg} pywinrt) 20 | 21 | set_target_properties(make_pywinrt_nupkg PROPERTIES "pywinrt_nupkg_dir" ${pywinrt_nupkg_dir}) 22 | 23 | endif() -------------------------------------------------------------------------------- /src/package/pywinrt/tool/Microsoft.Windows.PyWinRT.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Microsoft.Windows.PyWinRT 5 | 1.0.0.0 6 | Py/WinRT tool 7 | Microsoft 8 | Microsoft 9 | false 10 | Py/WinRT is a tool for generating a Python projection of any Windows Runtime library. Py/WinRT is designed to provide Python developers with first-class access to the modern Windows API. 11 | 12 | Python, WinRT 13 | © Microsoft Corporation. All rights reserved. 14 | LICENSE 15 | https://github.com/Microsoft/xlang/tree/master/src/package/pywinrt/tool 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/package/pywinrt/tool/readme.md: -------------------------------------------------------------------------------- 1 | # Py/WinRT 2 | 3 | Py/WinRT is a tool for generating a Python projection of any Windows Runtime library. Py/WinRT is 4 | designed to provide Python developers with first-class access to the modern Windows API. 5 | 6 | Python developers looking to access in-box WinRT APIs can simply install the Python/WinRT package 7 | from https://test.pypi.org/project/winrt/. Py/WinRT is the tool that generated the code for the 8 | Python/WinRT package. -------------------------------------------------------------------------------- /src/package/pywinrt/tool/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | For more information, visit: 3 | https://github.com/Microsoft/xlang/src/package/pywinrt/tool 4 | ======================================================================== 5 | -------------------------------------------------------------------------------- /src/platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(pal) 2 | 3 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 4 | set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) 5 | 6 | set(sources string_abi.cpp string_base.cpp activation_abi.cpp error_abi.cpp) 7 | 8 | if (WIN32) 9 | set(sources ${sources} win32_memory.cpp win32_string_convert.cpp win32_activation.cpp) 10 | else() 11 | set(sources ${sources} common_memory.cpp common_string_convert.cpp common_activation.cpp) 12 | endif() 13 | 14 | add_definitions(-DXLANG_PAL_EXPORTS) 15 | add_library(pal SHARED ${sources}) 16 | target_include_directories(pal PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/helpers ${CMAKE_CURRENT_BINARY_DIR}) 17 | target_include_directories(pal PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/published) 18 | set_target_properties(pal PROPERTIES OUTPUT_NAME "xlangpal") 19 | RPATH_ORIGIN(pal) 20 | 21 | if (NOT WIN32) 22 | target_link_libraries(pal -ldl) 23 | target_link_libraries(pal c++ c++abi) 24 | target_link_libraries(pal -lpthread) 25 | endif() 26 | 27 | install(TARGETS pal DESTINATION "test/platform") 28 | if (WIN32) 29 | install(FILES $ DESTINATION "test/platform" OPTIONAL) 30 | endif () 31 | 32 | add_custom_target(pal_cppx_base_projection 33 | COMMAND cppxlang -base -out "${CMAKE_CURRENT_BINARY_DIR}") 34 | 35 | add_dependencies(pal pal_cppx_base_projection) 36 | -------------------------------------------------------------------------------- /src/platform/activation_abi.cpp: -------------------------------------------------------------------------------- 1 | #include "pal_internal.h" 2 | #include "opaque_string_wrapper.h" 3 | #include "platform_activation.h" 4 | #include "pal_error.h" 5 | 6 | namespace xlang::impl 7 | { 8 | template 9 | xlang_error_info* get_activation_factory( 10 | xlang_string class_name, 11 | xlang_guid const& iid, 12 | void** factory) 13 | { 14 | for (auto current_namespace = enclosing_namespace(to_string_view(class_name)); 15 | !current_namespace.empty(); 16 | current_namespace = enclosing_namespace(current_namespace)) 17 | { 18 | xlang_pfn_lib_get_activation_factory pfn = try_get_activation_func(current_namespace); 19 | if (pfn) 20 | { 21 | xlang_result result = (*pfn)(class_name, iid, factory); 22 | if (result == xlang_result::success) 23 | { 24 | return nullptr; 25 | } 26 | else if (result != xlang_result::type_load) 27 | { 28 | throw_result(result); 29 | } 30 | } 31 | } 32 | return xlang_originate_error(xlang_result::type_load); 33 | } 34 | } 35 | 36 | using namespace xlang::impl; 37 | 38 | XLANG_PAL_EXPORT xlang_error_info* XLANG_CALL xlang_get_activation_factory( 39 | xlang_string class_name, 40 | xlang_guid const& iid, 41 | void** factory 42 | ) noexcept 43 | try 44 | { 45 | if (!class_name) 46 | { 47 | xlang::throw_result(xlang_result::invalid_arg); 48 | } 49 | 50 | auto const encoding = xlang_get_string_encoding(class_name); 51 | if (encoding == (xlang_string_encoding::utf8 | xlang_string_encoding::utf16)) 52 | { 53 | return get_activation_factory(class_name, iid, factory); 54 | } 55 | 56 | if (encoding == xlang_string_encoding::utf8) 57 | { 58 | return get_activation_factory(class_name, iid, factory); 59 | } 60 | 61 | return get_activation_factory(class_name, iid, factory); 62 | 63 | } 64 | catch (...) 65 | { 66 | *factory = nullptr; 67 | return xlang::to_result(); 68 | } -------------------------------------------------------------------------------- /src/platform/common_activation.cpp: -------------------------------------------------------------------------------- 1 | #include "pal_internal.h" 2 | #include "platform_activation.h" 3 | #include "string_convert.h" 4 | #include "pal_error.h" 5 | #include 6 | #include 7 | 8 | namespace xlang::impl 9 | { 10 | xlang_pfn_lib_get_activation_factory try_get_activation_func( 11 | std::basic_string_view module_namespace) 12 | { 13 | auto const length = get_converted_length(module_namespace); 14 | auto converted_name = std::make_unique(length); 15 | uint32_t converted_length = convert_string(module_namespace, converted_name.get(), length); 16 | 17 | // Note: common convert_string is incorrectly return zero on success. Using length as a 18 | // temporary workaround. Tracked by GitHub issue #180 19 | return try_get_activation_func({ converted_name.get(), length }); 20 | } 21 | 22 | xlang_pfn_lib_get_activation_factory try_get_activation_func( 23 | std::basic_string_view module_namespace) 24 | { 25 | void* module{}; 26 | 27 | std::string module_name{}; 28 | module_name.reserve(module_namespace.size() + 6); // 6 == len("lib") + len(".so") 29 | module_name += "lib"; 30 | module_name += module_namespace; 31 | module_name += ".so"; 32 | 33 | module = dlopen(module_name.c_str(), RTLD_LAZY); 34 | 35 | if (module) 36 | { 37 | return reinterpret_cast(dlsym(module, activation_fn_name.data())); 38 | } 39 | 40 | return nullptr; 41 | } 42 | } -------------------------------------------------------------------------------- /src/platform/common_memory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pal.h" 3 | 4 | #ifdef _WIN32 5 | #error "This file is for targeting platforms other than Windows" 6 | #endif 7 | 8 | extern "C" 9 | { 10 | void* XLANG_CALL xlang_mem_alloc(size_t count) noexcept 11 | { 12 | if (count == 0) 13 | { 14 | count = 1; 15 | } 16 | return ::malloc(count); 17 | } 18 | 19 | void XLANG_CALL xlang_mem_free(void* ptr) noexcept 20 | { 21 | ::free(ptr); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/platform/helpers/atomic_ref_count.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "pal_internal.h" 6 | 7 | namespace xlang::impl 8 | { 9 | struct atomic_ref_count 10 | { 11 | int32_t operator++() noexcept; 12 | int32_t operator--() noexcept; 13 | 14 | int32_t get_count() const noexcept; 15 | 16 | private: 17 | std::atomic count{ 1 }; 18 | }; 19 | 20 | inline int32_t atomic_ref_count::operator++() noexcept 21 | { 22 | // Safe to increment relaxed. New references can only be formed from an existing reference. 23 | // Passing an existing reference from one thread to another, must already provide synchronization. 24 | auto result = count.fetch_add(1, std::memory_order_relaxed) + 1; 25 | XLANG_ASSERT(result > 1); 26 | return result; 27 | } 28 | 29 | inline int32_t atomic_ref_count::operator--() noexcept 30 | { 31 | // This could be std::memory_order_acq_rel, but would result in an unneeded "aquire" 32 | // operations when the counter has not yet reached zero. This case is protected via the 33 | // fence later. 34 | // memory_order_release on decrement forces all other writes on the current thread to 35 | // be visible before the decremented refcount is stored 36 | auto result = count.fetch_sub(1, std::memory_order_release) - 1; 37 | XLANG_ASSERT(result >= 0); 38 | if (result == 0) 39 | { 40 | // This acquire fence ensures that all relaxed/nonatomic stores preceding the release in other threads 41 | // will happen before anything after the fence in this thread. And at this point, we should be the only 42 | // thread with a reference to the object, so it is now safe to delete. 43 | std::atomic_thread_fence(std::memory_order_acquire); 44 | } 45 | return result; 46 | } 47 | 48 | inline int32_t atomic_ref_count::get_count() const noexcept 49 | { 50 | return count.load(std::memory_order_acquire); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/platform/helpers/pal_error.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pal_internal.h" 4 | #include 5 | 6 | namespace xlang 7 | { 8 | [[noreturn]] inline void throw_result(xlang_result result, xlang_char8 const* const message = nullptr) 9 | { 10 | hstring error_message = to_hstring(message); 11 | throw xlang_originate_error(result, get_abi(error_message)); 12 | } 13 | 14 | [[noreturn]] inline void throw_result(xlang_error_info* result) 15 | { 16 | throw result; 17 | } 18 | 19 | // TODO(defaultryan) Replace with xlang projection methods 20 | inline xlang_error_info* to_result() noexcept 21 | { 22 | try 23 | { 24 | throw; 25 | } 26 | catch (xlang_error_info* e) 27 | { 28 | return e; 29 | } 30 | catch (std::bad_alloc const&) 31 | { 32 | return xlang_originate_error(xlang_result::out_of_memory); 33 | } 34 | catch (...) 35 | { 36 | std::terminate(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/platform/helpers/pal_internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef _DEBUG 8 | 9 | #if XLANG_COMPILER_MSVC 10 | #define XLANG_ASSERT _ASSERTE 11 | #else 12 | #include 13 | #define XLANG_ASSERT assert 14 | #endif 15 | #define XLANG_VERIFY XLANG_ASSERT 16 | #define XLANG_VERIFY_(result, expression) XLANG_ASSERT(result == expression) 17 | 18 | #else 19 | 20 | #define XLANG_ASSERT(expression) ((void)0) 21 | #define XLANG_VERIFY(expression) (void)(expression) 22 | #define XLANG_VERIFY_(result, expression) (void)(expression) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/platform/opaque_string_wrapper.h: -------------------------------------------------------------------------------- 1 | #include "pal_internal.h" 2 | #include "heap_string.h" 3 | 4 | namespace xlang::impl 5 | { 6 | // Provide conversions between opaque string types and xlang_string. 7 | // Put another way, insulate opaque_string.h from the public opaque handle types like xlang_string. 8 | inline string_base* from_handle(xlang_string handle) noexcept 9 | { 10 | return reinterpret_cast(handle); 11 | } 12 | 13 | inline heap_string* from_handle(xlang_string_buffer handle) noexcept 14 | { 15 | return reinterpret_cast(handle); 16 | } 17 | 18 | inline xlang_string to_handle(string_base* str) noexcept 19 | { 20 | return reinterpret_cast(str); 21 | } 22 | 23 | inline xlang_string_buffer to_buffer_handle(heap_string* str) noexcept 24 | { 25 | return reinterpret_cast(str); 26 | } 27 | 28 | template 29 | inline std::basic_string_view to_string_view(xlang_string handle) 30 | { 31 | return from_handle(handle)->ensure_buffer(); 32 | } 33 | } -------------------------------------------------------------------------------- /src/platform/platform_activation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pal.h" 4 | #include 5 | 6 | namespace xlang::impl 7 | { 8 | #if XLANG_PLATFORM_WINDOWS 9 | using filesystem_char_type = char16_t; 10 | #else 11 | using filesystem_char_type = char; 12 | #endif 13 | 14 | inline constexpr std::string_view activation_fn_name{ "xlang_lib_get_activation_factory" }; 15 | 16 | xlang_pfn_lib_get_activation_factory try_get_activation_func( 17 | std::basic_string_view module_namespace); 18 | 19 | xlang_pfn_lib_get_activation_factory try_get_activation_func( 20 | std::basic_string_view module_namespace); 21 | 22 | template 23 | inline constexpr std::basic_string_view enclosing_namespace(std::basic_string_view str) noexcept 24 | { 25 | auto pos = str.rfind('.'); 26 | if (pos == str.npos) 27 | { 28 | return {}; 29 | } 30 | return str.substr(0, pos); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/platform/string_allocate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pal_error.h" 4 | 5 | namespace xlang::impl 6 | { 7 | // packed_buffer_size and get_packed_buffer_ptr perform calculations 8 | // that allow allocating a string control type and a backing character buffer 9 | // into a single block. 10 | template 11 | inline uint32_t packed_buffer_size(uint32_t string_length) 12 | { 13 | constexpr auto max_size = std::numeric_limits::max(); 14 | if (max_size / sizeof(char_type) < string_length) 15 | { 16 | throw_result(xlang_result::invalid_arg, "Insufficient buffer size"); 17 | } 18 | uint32_t count = sizeof(char_type) * string_length; 19 | 20 | if (max_size - (sizeof(class_type) + sizeof(char_type)) < count) 21 | { 22 | throw_result(xlang_result::invalid_arg, "Insufficient buffer size"); 23 | } 24 | count += (sizeof(class_type) + sizeof(char_type)); 25 | return count; 26 | } 27 | 28 | template 29 | inline char_type* get_packed_buffer_ptr(class_type* ptr) 30 | { 31 | return reinterpret_cast(ptr + 1); 32 | } 33 | 34 | template 35 | inline char_type const* get_packed_buffer_ptr(class_type const* ptr) 36 | { 37 | return reinterpret_cast(ptr + 1); 38 | } 39 | } -------------------------------------------------------------------------------- /src/platform/string_base.cpp: -------------------------------------------------------------------------------- 1 | #include "string_base.h" 2 | #include "string_reference.h" 3 | #include "heap_string.h" 4 | 5 | namespace xlang::impl 6 | { 7 | void string_base::release_base() noexcept 8 | { 9 | if (this->is_reference()) 10 | { 11 | static_cast(this)->release(); 12 | } 13 | else 14 | { 15 | static_cast(this)->release(); 16 | } 17 | } 18 | 19 | string_base* string_base::duplicate_base() 20 | { 21 | if (this->is_reference()) 22 | { 23 | auto str = static_cast(this); 24 | // This is a string reference. Create a ref counted string and return it. 25 | if (is_utf8()) 26 | { 27 | return heap_string::create(str->get_buffer(), str->get_length(), str->get_alternate()); 28 | } 29 | else 30 | { 31 | return heap_string::create(str->get_buffer(), str->get_length(), str->get_alternate()); 32 | } 33 | } 34 | else 35 | { 36 | static_cast(this)->addref(); 37 | return this; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/platform/string_convert.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "pal.h" 4 | #include 5 | #include 6 | #include 7 | 8 | namespace xlang::impl 9 | { 10 | uint32_t get_converted_length(std::basic_string_view input_str); 11 | uint32_t get_converted_length(std::basic_string_view input_str); 12 | 13 | uint32_t convert_string( 14 | std::basic_string_view input_str, 15 | xlang_char8* output_buffer, 16 | uint32_t buffer_size); 17 | 18 | uint32_t convert_string( 19 | std::basic_string_view input_str, 20 | char16_t* output_buffer, 21 | uint32_t buffer_size); 22 | } -------------------------------------------------------------------------------- /src/platform/string_traits.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace xlang::impl 6 | { 7 | template 8 | struct alternate_string_type; 9 | 10 | template <> 11 | struct alternate_string_type 12 | { 13 | using type = char16_t; 14 | }; 15 | 16 | template <> 17 | struct alternate_string_type 18 | { 19 | using type = xlang_char8; 20 | }; 21 | 22 | template 23 | using alternate_string_type_t = typename alternate_string_type::type; 24 | } 25 | -------------------------------------------------------------------------------- /src/platform/win32_memory.cpp: -------------------------------------------------------------------------------- 1 | #include "pal.h" 2 | #include 3 | 4 | #if !XLANG_PLATFORM_WINDOWS 5 | #error "This file is only for targeting Windows" 6 | #endif 7 | 8 | extern "C" 9 | { 10 | void* XLANG_CALL xlang_mem_alloc(size_t count) XLANG_NOEXCEPT 11 | { 12 | return ::CoTaskMemAlloc(count); 13 | } 14 | 15 | void XLANG_CALL xlang_mem_free(void* ptr) XLANG_NOEXCEPT 16 | { 17 | return ::CoTaskMemFree(ptr); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/platform/win32_pal_internal.h: -------------------------------------------------------------------------------- 1 | #include "pal_internal.h" 2 | #include "pal_error.h" 3 | 4 | #if !XLANG_PLATFORM_WINDOWS 5 | #error "This file is only for targeting Windows" 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | namespace xlang::impl 12 | { 13 | [[noreturn]] inline void throw_originated_last_error() 14 | { 15 | throw_result(xlang_result_from_hresult(HRESULT_FROM_WIN32(::GetLastError()))); 16 | } 17 | 18 | template 19 | void check_bool(T result) 20 | { 21 | if (!result) 22 | { 23 | throw_originated_last_error(); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/scripts/genStringLiteralFiles.cmake: -------------------------------------------------------------------------------- 1 | # Script variables: 2 | # out_h - path to output header file 3 | # out_cpp - path to output implementation file 4 | # namespace - namespace to put declarations in 5 | # glob_expression - glob expression for files to include in the output files 6 | 7 | foreach(outfile ${out_h} ${out_cpp}) 8 | file(WRITE ${outfile} "// This file was generated by CMake\n\n") 9 | endforeach() 10 | 11 | file(APPEND ${out_h} "#pragma once\n\n") 12 | file(APPEND ${out_cpp} "#include \"pch.h\"\n\n") 13 | 14 | foreach(outfile ${out_h} ${out_cpp}) 15 | file(APPEND ${outfile} "namespace ${namespace} {\n\n") 16 | endforeach() 17 | 18 | file(GLOB GLOB_FILES "${glob_expression}") 19 | set(max_string_len 16000) # should this be configurable? 20 | foreach(globfile ${GLOB_FILES}) 21 | get_filename_component(globfile_name ${globfile} NAME_WE) 22 | file(READ ${globfile} globfile_content) 23 | string(LENGTH "${globfile_content}" globfile_size) 24 | 25 | MATH(EXPR array_len "${globfile_size} + 1") # account for null terminator 26 | file(APPEND ${out_h} "extern char const ${globfile_name}[${array_len}];\n\n") 27 | 28 | set(globfile_content_pos 0) 29 | file(APPEND ${out_cpp} "extern char const ${globfile_name}[] = ") 30 | 31 | while(globfile_content_pos LESS_EQUAL ${globfile_size}) 32 | string(SUBSTRING "${globfile_content}" ${globfile_content_pos} ${max_string_len} globfile_content_substring) 33 | file(APPEND ${out_cpp} "R\"xyz(${globfile_content_substring})xyz\" ") 34 | math(EXPR globfile_content_pos "${globfile_content_pos} + ${max_string_len}") 35 | endwhile() 36 | 37 | file(APPEND ${out_cpp} ";\n\n") 38 | endforeach() 39 | 40 | foreach(outfile ${out_h} ${out_cpp}) 41 | file(APPEND ${outfile} "}\n\n") 42 | endforeach() 43 | -------------------------------------------------------------------------------- /src/scripts/scorch.cmake: -------------------------------------------------------------------------------- 1 | set(EXTENSIONS_TO_SCORCH cpp dll exe exp h ilk lib obj pch pdb py winmd) 2 | 3 | foreach(EXTENSION in ${EXTENSIONS_TO_SCORCH}) 4 | file(GLOB_RECURSE FILES_TO_DELETE "${folder}/*.${EXTENSION}") 5 | 6 | foreach (FILE_TO_DELETE in ${FILES_TO_DELETE}) 7 | file(REMOVE ${FILE_TO_DELETE}) 8 | endforeach() 9 | endforeach() 10 | 11 | -------------------------------------------------------------------------------- /src/scripts/ubuntu/azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | resources: 2 | containers: 3 | - container: build_container 4 | image: msftxlangbuild.azurecr.io/xlang-ubuntu-build 5 | endpoint: msftxlangbuild 6 | 7 | pool: 8 | vmImage: 'ubuntu-16.04' 9 | 10 | container: build_container 11 | 12 | steps: 13 | - script: cmake ./src -B_build -GNinja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_INSTALL_PREFIX=install 14 | displayName: 'CMake' 15 | - script: ninja -C _build install -v 16 | displayName: 'Ninja' 17 | - script: ./install/test/library/test_library -r junit -o TEST-test_library.xml 18 | displayName: 'test_library' 19 | continueOnError: true 20 | - script: ./install/test/platform/test_platform -r junit -o TEST-test_platform.xml 21 | displayName: 'test_platform' 22 | continueOnError: true 23 | - task: PublishTestResults@2 24 | inputs: 25 | testResultsFormat: 'JUnit' 26 | testResultsFiles: '**/TEST-*.xml' 27 | 28 | -------------------------------------------------------------------------------- /src/scripts/ubuntu/configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # run this in script to configure Ubuntu 18.04 with the tools needed to build xlang 4 | 5 | # update APT packages 6 | sudo apt update 7 | sudo apt upgrade -y 8 | sudo apt autoremove -y 9 | 10 | # install clang, cmake, ninja and libc++ via APT 11 | sudo apt install clang cmake ninja-build libc++-dev libc++abi-dev -y -------------------------------------------------------------------------------- /src/scripts/windows/azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | pool: 2 | vmImage: 'windows-2019' 3 | 4 | # TODO: reuse src\package\pywinrt\projection\AzurePipelinesTemplates\task-vsdevcmd.yml instead of copying the next two 5 | # steps from that YML file into this pipeline. 6 | 7 | steps: 8 | - script: | 9 | @echo off 10 | 11 | set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 12 | for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do ( 13 | set vslatest="%%i" 14 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( 15 | set vsdevcmd="%%i\Common7\Tools\vsdevcmd.bat" 16 | ) 17 | ) 18 | 19 | @echo vslatest %vslatest% 20 | @echo vsdevcmd %vsdevcmd% 21 | 22 | @echo ##vso[task.setvariable variable=vslatest]%vslatest% 23 | @echo ##vso[task.setvariable variable=vsdevcmd]%vsdevcmd% 24 | displayName: 'locate vsdevcmd via vswhere' 25 | - task: BatchScript@1 26 | displayName: 'Configure environment with VSDevCmd' 27 | inputs: 28 | filename: $(vsdevcmd) 29 | modifyEnvironment: true 30 | 31 | - task: CMake@1 32 | displayName: 'Generate xlang build files via cmake' 33 | inputs: 34 | cwd: '.' 35 | cmakeArgs: -S src -B_build\Windows\x86\Release -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_PREFIX=install 36 | - task: CMake@1 37 | displayName: 'build xlang' 38 | inputs: 39 | cwd: '.' 40 | cmakeArgs: --build .\_build\Windows\x86\Release -- -v install 41 | - script: .\install\test\library\test_library.exe -r junit -o TEST-test_library.xml 42 | displayName: 'test_library' 43 | continueOnError: true 44 | - script: .\install\test\platform\test_platform.exe -r junit -o TEST-test_platform.xml 45 | displayName: 'test_platform' 46 | continueOnError: true 47 | - task: PublishTestResults@2 48 | inputs: 49 | testResultsFormat: 'JUnit' 50 | testResultsFiles: '**/TEST-*.xml' 51 | -------------------------------------------------------------------------------- /src/scripts/windows/vsdevcmd-build.cmd: -------------------------------------------------------------------------------- 1 | set vswherepath="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" 2 | for /f "usebackq delims=" %%i in (`%vswherepath% -latest -property installationPath`) do ( 3 | if exist "%%i\Common7\Tools\vsdevcmd.bat" ( 4 | call "%%i\Common7\Tools\vsdevcmd.bat" 5 | build.cmd %* 6 | ) 7 | ) 8 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(XLANG_TEST_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/inc") 2 | 3 | add_subdirectory(platform) 4 | add_subdirectory(abi_component) 5 | add_subdirectory(library) 6 | 7 | if (WIN32) 8 | add_subdirectory(python) 9 | endif() 10 | 11 | -------------------------------------------------------------------------------- /src/test/abi_component/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(abi_test_component MODULE widget.cpp module.def) 2 | target_include_directories(abi_test_component PRIVATE 3 | ${CMAKE_CURRENT_SOURCE_DIR} 4 | "${CMAKE_SOURCE_DIR}/platform/helpers") 5 | CONSUME_PAL(abi_test_component) 6 | set_target_properties(abi_test_component PROPERTIES OUTPUT_NAME "AbiComponent") 7 | 8 | install(TARGETS abi_test_component DESTINATION "test/platform") 9 | if (WIN32) 10 | install(FILES $ DESTINATION "test/platform" OPTIONAL) 11 | endif () 12 | -------------------------------------------------------------------------------- /src/test/abi_component/iwidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | inline constexpr xlang_guid iwidget_guid{ 0xbd6f821f, 0x66, 0x440c, { 0xb1, 0x15, 0xeb, 0x4, 0x5a, 0xfe, 0xfa, 0x4e } }; 6 | 7 | struct XLANG_NOVTABLE iwidget : xlang_unknown 8 | { 9 | virtual xlang_error_info* get_answer(int32_t* answer) noexcept = 0; 10 | }; 11 | 12 | inline constexpr xlang_guid iwidget_factory_guid{0x4419ea1c, 0xf721, 0x4aa2, { 0x82, 0xdd, 0xb2, 0xf5, 0xd2, 0xcf, 0xc6, 0x3a } }; 13 | 14 | struct XLANG_NOVTABLE iwidget_factory : xlang_unknown 15 | { 16 | virtual xlang_error_info* activate_widget(iwidget** widget) noexcept = 0; 17 | }; 18 | -------------------------------------------------------------------------------- /src/test/abi_component/module.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | xlang_lib_get_activation_factory PRIVATE 3 | -------------------------------------------------------------------------------- /src/test/cppx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_cppx) 2 | 3 | add_executable(test_cppx "") 4 | target_sources(test_cppx 5 | PRIVATE pch.cpp 6 | hstring.cpp 7 | ) 8 | 9 | if (WIN32) 10 | target_sources(test_cppx 11 | PRIVATE 12 | collection_base.cpp 13 | error.cpp 14 | # param_iterable.cpp 15 | # param_map.cpp 16 | # param_map_view.cpp 17 | # param_vector.cpp 18 | # param_vector_view.cpp 19 | # produce_map.cpp 20 | # produce_vector.cpp 21 | # single_threaded_map.cpp 22 | # single_threaded_vector.cpp 23 | ) 24 | endif () 25 | 26 | target_include_directories(test_cppx 27 | PRIVATE ${XLANG_LIBRARY_PATH} ${XLANG_TEST_INC_PATH} ${CMAKE_CURRENT_BINARY_DIR}) 28 | 29 | target_link_libraries(test_cppx pal) 30 | RPATH_ORIGIN(test_cppx) 31 | 32 | if (MSVC) 33 | TARGET_CONFIG_MSVC_PCH(test_cppx pch.cpp pch.h) 34 | target_link_libraries(test_cppx windowsapp ole32) 35 | endif() 36 | 37 | target_sources(test_cppx PUBLIC 38 | main.cpp 39 | IXlangObject.cpp 40 | ) 41 | 42 | install(TARGETS test_cppx DESTINATION "test/platform") 43 | if (WIN32) 44 | install(FILES $ DESTINATION "test/platform" OPTIONAL) 45 | endif () 46 | 47 | if (WIN32) 48 | get_target_property(xmeta_path foundation_metadata Foundation_xmeta) 49 | add_custom_target(test_cppx_base_projection 50 | COMMAND cppxlang -base -in ${xmeta_path} -out ${CMAKE_CURRENT_BINARY_DIR} 51 | DEPENDS ${foundation_metadata} 52 | BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/xlang/base.h 53 | ) 54 | add_dependencies(test_cppx_base_projection foundation_metadata) 55 | else () 56 | add_custom_target(test_cppx_base_projection 57 | COMMAND cppxlang -base -out ${CMAKE_CURRENT_BINARY_DIR} 58 | BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/xlang/base.h 59 | ) 60 | endif () 61 | 62 | add_dependencies(test_cppx test_cppx_base_projection) 63 | -------------------------------------------------------------------------------- /src/test/cppx/IXlangObject.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | using namespace xlang; 4 | 5 | TEST_CASE("IXlangObject") 6 | { 7 | struct Object : implements 8 | { 9 | 10 | }; 11 | 12 | auto obj = make(); 13 | REQUIRE(get_TypeName(obj) == "Object"); 14 | REQUIRE(get_StringRepresentation(obj) == "Object"); 15 | REQUIRE(get_ObjectSize(obj) == sizeof(Object)); 16 | 17 | { 18 | auto obj2 = obj; 19 | REQUIRE(get_HashCode(obj) == get_HashCode(obj2)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/cppx/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch.hpp" 3 | -------------------------------------------------------------------------------- /src/test/cppx/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/test/cppx/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "catch.hpp" 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | -------------------------------------------------------------------------------- /src/test/library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_library) 2 | 3 | add_executable(test_library "") 4 | target_sources(test_library 5 | PUBLIC pch.cpp text_writer.cpp) 6 | 7 | target_include_directories(test_library 8 | PUBLIC ${XLANG_LIBRARY_PATH} ${XLANG_TEST_INC_PATH}) 9 | 10 | RPATH_ORIGIN(test_library) 11 | 12 | if (MSVC) 13 | TARGET_CONFIG_MSVC_PCH(test_library pch.cpp pch.h) 14 | target_link_libraries(test_library windowsapp ole32) 15 | else() 16 | target_link_libraries(test_library c++ c++abi c++experimental) 17 | target_link_libraries(test_library -lpthread) 18 | endif() 19 | 20 | target_sources(test_library PUBLIC main.cpp) 21 | 22 | install(TARGETS test_library DESTINATION "test/library") 23 | -------------------------------------------------------------------------------- /src/test/library/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch.hpp" 3 | -------------------------------------------------------------------------------- /src/test/library/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/test/library/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "catch.hpp" 4 | -------------------------------------------------------------------------------- /src/test/library/text_writer.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "meta_reader.h" 3 | #include "text_writer.h" 4 | 5 | namespace 6 | { 7 | struct writer : xlang::text::writer_base 8 | { 9 | }; 10 | } 11 | 12 | TEST_CASE("writer") 13 | { 14 | writer w; 15 | w.write(" % ^% % post", 123, "String"); 16 | w.swap(); 17 | w.write("pre"); 18 | 19 | REQUIRE(w.flush_to_string() == "pre 123 % String post"); 20 | } 21 | -------------------------------------------------------------------------------- /src/test/platform/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(test_platform) 2 | 3 | add_executable(test_platform "") 4 | target_sources(test_platform 5 | PUBLIC pch.cpp memory.cpp string.cpp activation.cpp error.cpp) 6 | 7 | target_include_directories(test_platform 8 | PUBLIC ${XLANG_LIBRARY_PATH} ${XLANG_TEST_INC_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../output/component/source 9 | PRIVATE "${CMAKE_SOURCE_DIR}/platform/helpers") 10 | 11 | target_link_libraries(test_platform pal) 12 | RPATH_ORIGIN(test_platform) 13 | 14 | if (MSVC) 15 | TARGET_CONFIG_MSVC_PCH(test_platform pch.cpp pch.h) 16 | target_link_libraries(test_platform windowsapp ole32) 17 | endif() 18 | 19 | target_sources(test_platform PUBLIC main.cpp) 20 | add_dependencies(test_platform abi_test_component) 21 | 22 | install(TARGETS test_platform DESTINATION "test/platform") 23 | if (WIN32) 24 | install(FILES $ DESTINATION "test/platform" OPTIONAL) 25 | endif () 26 | -------------------------------------------------------------------------------- /src/test/platform/activation.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | TEST_CASE("Simple activation") 4 | { 5 | xlang_error_info* result{}; 6 | 7 | // TODO: Update cpp projection to emit char16_t names 8 | std::u16string_view class_name{ u"AbiComponent.Widget" }; 9 | xlang_string_header str_header{}; 10 | xlang_string str{}; 11 | 12 | result = xlang_create_string_reference_utf16(class_name.data(), static_cast(class_name.size()), &str_header, &str); 13 | REQUIRE(result == nullptr); 14 | 15 | // TODO: use xplat com_ptr when available (GitHub issue #185) 16 | xlang_unknown* factory{}; 17 | result = xlang_get_activation_factory(str, xlang_unknown_guid, reinterpret_cast(&factory)); 18 | REQUIRE(result == nullptr); 19 | 20 | // TODO: Actually call an activation method once we've converged our type system. 21 | // For now, simply check that we got a valid object back. 22 | REQUIRE(factory != nullptr); 23 | 24 | if (factory) 25 | { 26 | factory->Release(); 27 | factory = nullptr; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/platform/main.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_MAIN 2 | #include "catch.hpp" 3 | -------------------------------------------------------------------------------- /src/test/platform/memory.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | struct MemGuard 4 | { 5 | MemGuard(void* ptr) 6 | : m_ptr{ ptr } 7 | {} 8 | 9 | ~MemGuard() 10 | { 11 | xlang_mem_free(m_ptr); 12 | } 13 | 14 | void* m_ptr{}; 15 | }; 16 | 17 | TEST_CASE("Mem alloc") 18 | { 19 | SECTION("0 byte allocations") 20 | { 21 | MemGuard ptr1{ xlang_mem_alloc(0) }; 22 | MemGuard ptr2{ xlang_mem_alloc(0) }; 23 | 24 | REQUIRE(ptr1.m_ptr != nullptr); 25 | REQUIRE(ptr2.m_ptr != nullptr); 26 | REQUIRE(ptr1.m_ptr != ptr2.m_ptr); 27 | } 28 | SECTION("1 byte allocations") 29 | { 30 | MemGuard ptr1{ xlang_mem_alloc(1) }; 31 | MemGuard ptr2{ xlang_mem_alloc(1) }; 32 | 33 | REQUIRE(ptr1.m_ptr != nullptr); 34 | REQUIRE(ptr2.m_ptr != nullptr); 35 | REQUIRE(ptr1.m_ptr != ptr2.m_ptr); 36 | 37 | // Ensure I can write to those locations 38 | *static_cast(ptr1.m_ptr) = 'a'; 39 | *static_cast(ptr2.m_ptr) = 'b'; 40 | } 41 | SECTION("1 MB allocation") 42 | { 43 | // 1 MB is small enough that it should be essentially guaranteed to succeed 44 | // in this setting, but big enough that a misconfigured heap might fail. 45 | constexpr size_t size = 0x100000; 46 | MemGuard ptr{ xlang_mem_alloc(size) }; 47 | REQUIRE(ptr.m_ptr != nullptr); 48 | char* begin = static_cast(ptr.m_ptr); 49 | std::fill(begin, begin + size, 'a'); 50 | } 51 | SECTION("Impossibly huge allocation") 52 | { 53 | // This is waaaay too much memory, requiring the entire address space. 54 | // Any implementation that claims success is lying. :) 55 | MemGuard ptr{ xlang_mem_alloc(std::numeric_limits::max()) }; 56 | REQUIRE(ptr.m_ptr == nullptr); 57 | // This will also check xlang_mem_free with null 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/platform/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/test/platform/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "catch.hpp" 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #if XLANG_PLATFORM_WINDOWS 12 | #include 13 | #endif 14 | -------------------------------------------------------------------------------- /src/test/platform/string_helpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // template helpers to genericize test code 4 | 5 | template 6 | auto xlang_create_string(char_type const* source, uint32_t length, xlang_string* str) 7 | { 8 | static_assert(std::disjunction_v, std::is_same>); 9 | if constexpr (std::is_same_v) 10 | { 11 | return xlang_create_string_utf8(source, length, str); 12 | } 13 | else 14 | { 15 | return xlang_create_string_utf16(source, length, str); 16 | } 17 | } 18 | 19 | template 20 | auto xlang_create_string_reference(char_type const* source, uint32_t length, xlang_string_header* header, xlang_string* str) 21 | { 22 | static_assert(std::disjunction_v, std::is_same>); 23 | if constexpr (std::is_same_v) 24 | { 25 | return xlang_create_string_reference_utf8(source, length, header, str); 26 | } 27 | else 28 | { 29 | return xlang_create_string_reference_utf16(source, length, header, str); 30 | } 31 | } 32 | 33 | template 34 | auto xlang_get_string_raw_buffer(xlang_string str, char_type const* * buffer, uint32_t* length) 35 | { 36 | static_assert(std::disjunction_v, std::is_same>); 37 | if constexpr (std::is_same_v) 38 | { 39 | return xlang_get_string_raw_buffer_utf8(str, buffer, length); 40 | } 41 | else 42 | { 43 | return xlang_get_string_raw_buffer_utf16(str, buffer, length); 44 | } 45 | } 46 | 47 | template 48 | auto xlang_preallocate_string_buffer(uint32_t length, char_type** char_buffer, xlang_string_buffer* buffer_handle) 49 | { 50 | static_assert(std::disjunction_v, std::is_same>); 51 | if constexpr (std::is_same_v) 52 | { 53 | return xlang_preallocate_string_buffer_utf8(length, char_buffer, buffer_handle); 54 | } 55 | else 56 | { 57 | return xlang_preallocate_string_buffer_utf16(length, char_buffer, buffer_handle); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/test/platform/winrt_helpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // TODO: Unify C++/WinRT guid and xlang guid 7 | inline xlang_guid to_guid(winrt::guid const& iid) noexcept 8 | { 9 | static_assert(sizeof(xlang_guid) == sizeof(winrt::guid)); 10 | xlang_guid result; 11 | std::memcpy(&result, &iid, sizeof(xlang_guid)); 12 | return result; 13 | } -------------------------------------------------------------------------------- /src/test/python/loader_native.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("./generated") 3 | 4 | import _winrt 5 | _winrt.init_apartment() 6 | 7 | def import_ns(ns): 8 | import importlib.machinery 9 | import importlib.util 10 | module_name = "_winrt_" + ns.replace('.', '_') 11 | loader = importlib.machinery.ExtensionFileLoader(module_name, _winrt.__file__) 12 | spec = importlib.util.spec_from_loader(module_name, loader) 13 | module = importlib.util.module_from_spec(spec) 14 | loader.exec_module(module) 15 | return module 16 | -------------------------------------------------------------------------------- /src/test/python/ntestdirectx.py: -------------------------------------------------------------------------------- 1 | import loader_native, unittest 2 | 3 | wgd = loader_native.import_ns("Windows.Graphics.DirectX") 4 | wgdd = loader_native.import_ns("Windows.Graphics.DirectX.Direct3D11") 5 | 6 | class TestDirectX(unittest.TestCase): 7 | 8 | def test_struct_containing_enum_pos(self): 9 | msd = wgdd.Direct3DMultisampleDescription(1, 2) 10 | sd = wgdd.Direct3DSurfaceDescription(4, 8, 10, msd) # 10 = DirectXPixelFormat.R16G16B16A16Float 11 | 12 | self.assertEqual(sd.width, 4) 13 | self.assertEqual(sd.height, 8) 14 | self.assertEqual(sd.format, 10) 15 | 16 | msd2 = sd.multisample_description 17 | self.assertEqual(msd.count, 1) 18 | self.assertEqual(msd.quality, 2) 19 | 20 | def test_struct_containing_enum_kwd(self): 21 | msd = wgdd.Direct3DMultisampleDescription(1, 2) 22 | sd = wgdd.Direct3DSurfaceDescription(format=10, width=4, multisample_description=msd, height=8) 23 | 24 | self.assertEqual(sd.width, 4) 25 | self.assertEqual(sd.height, 8) 26 | self.assertEqual(sd.format, 10) 27 | 28 | msd2 = sd.multisample_description 29 | self.assertEqual(msd.count, 1) 30 | self.assertEqual(msd.quality, 2) 31 | 32 | if __name__ == '__main__': 33 | unittest.main() 34 | -------------------------------------------------------------------------------- /src/test/python/ntestnumerics.py: -------------------------------------------------------------------------------- 1 | import loader_native, unittest 2 | 3 | wfn = loader_native.import_ns("Windows.Foundation.Numerics") 4 | 5 | class TestNumerics(unittest.TestCase): 6 | def test_struct_ctor_pos(self): 7 | r = wfn.Rational(2, 4) 8 | 9 | self.assertEqual(r.numerator, 2) 10 | self.assertEqual(r.denominator, 4) 11 | 12 | def test_struct_ctor_kwd(self): 13 | r = wfn.Rational(denominator=2, numerator=4) 14 | 15 | self.assertEqual(r.numerator, 4) 16 | self.assertEqual(r.denominator, 2) 17 | 18 | def test_struct_ctor_mix(self): 19 | r = wfn.Rational(3, denominator=6) 20 | 21 | self.assertEqual(r.numerator, 3) 22 | self.assertEqual(r.denominator, 6) 23 | 24 | def test_struct_ctor_dict(self): 25 | r = wfn.Rational({"denominator":2, "numerator":4}) 26 | 27 | self.assertEqual(r.numerator, 4) 28 | self.assertEqual(r.denominator, 2) 29 | 30 | def test_vec3(self): 31 | v = wfn.Vector3(1.0, 2.0, 3.0) 32 | 33 | self.assertEqual(v.x, 1.0) 34 | self.assertEqual(v.y, 2.0) 35 | self.assertEqual(v.z, 3.0) 36 | 37 | def test_plane(self): 38 | v = wfn.Vector3(1.0, 2.0, 3.0) 39 | p = wfn.Plane(v, 4.0) 40 | n = p.normal 41 | 42 | self.assertEqual(n.x, 1.0) 43 | self.assertEqual(n.y, 2.0) 44 | self.assertEqual(n.z, 3.0) 45 | self.assertEqual(p.d, 4.0) 46 | 47 | def test_plane_dict(self): 48 | p = wfn.Plane({"x":1.0, "y":2.0, "z":3.0}, 4.0) 49 | n = p.normal 50 | 51 | self.assertEqual(n.x, 1.0) 52 | self.assertEqual(n.y, 2.0) 53 | self.assertEqual(n.z, 3.0) 54 | self.assertEqual(p.d, 4.0) 55 | 56 | if __name__ == '__main__': 57 | unittest.main() 58 | -------------------------------------------------------------------------------- /src/test/python/testcollections.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("./generated") 3 | 4 | import unittest 5 | import asyncio 6 | 7 | import winrt.windows.foundation.collections as wfc 8 | 9 | class TestCollections(unittest.TestCase): 10 | 11 | def test_stringmap(self): 12 | m = wfc.StringMap() 13 | m.insert("hello", "world") 14 | 15 | self.assertTrue(m.has_key("hello")) 16 | self.assertFalse(m.has_key("world")) 17 | self.assertEqual(m.size, 1) 18 | self.assertEqual(m.lookup("hello"), "world") 19 | 20 | 21 | def test_stringmap_changed_event(self): 22 | loop = asyncio.new_event_loop() 23 | asyncio.set_event_loop(None) 24 | 25 | async def async_test(): 26 | future = loop.create_future() 27 | 28 | def onMapChanged(sender, args): 29 | self.assertEqual(args.collection_change, wfc.CollectionChange.ITEM_INSERTED) 30 | self.assertEqual(args.key, "dr") 31 | 32 | self.assertEqual(sender.size, 2) 33 | self.assertTrue(sender.has_key("dr")) 34 | self.assertTrue(sender.has_key("hello")) 35 | 36 | loop.call_soon_threadsafe(asyncio.Future.set_result, future, True) 37 | 38 | m = wfc.StringMap() 39 | m.insert("hello", "world") 40 | token = m.add_map_changed(onMapChanged) 41 | m.insert("dr", "who") 42 | m.remove_map_changed(token) 43 | 44 | called = await future 45 | self.assertTrue(called) 46 | 47 | loop.run_until_complete(async_test()) 48 | loop.close() 49 | 50 | 51 | if __name__ == '__main__': 52 | unittest.main() 53 | -------------------------------------------------------------------------------- /src/test/python/testdirectx.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("./generated") 3 | 4 | import unittest 5 | 6 | import winrt.windows.graphics.directx as wgd 7 | import winrt.windows.graphics.directx.direct3d11 as wgdd 8 | 9 | class TestDirectX(unittest.TestCase): 10 | 11 | def test_struct_containing_enum_pos(self): 12 | msd = wgdd.Direct3DMultisampleDescription(1, 2) 13 | sd = wgdd.Direct3DSurfaceDescription(4, 8, wgd.DirectXPixelFormat.R16_G16_B16_A16_FLOAT, msd) 14 | 15 | self.assertEqual(sd.width, 4) 16 | self.assertEqual(sd.height, 8) 17 | self.assertEqual(sd.format, wgd.DirectXPixelFormat.R16_G16_B16_A16_FLOAT) 18 | 19 | msd2 = sd.multisample_description 20 | self.assertEqual(msd.count, 1) 21 | self.assertEqual(msd.quality, 2) 22 | 23 | def test_struct_containing_enum_kwd(self): 24 | msd = wgdd.Direct3DMultisampleDescription(1, 2) 25 | sd = wgdd.Direct3DSurfaceDescription(format=wgd.DirectXPixelFormat.R16_G16_B16_A16_FLOAT, width=4, multisample_description=msd, height=8) 26 | 27 | self.assertEqual(sd.width, 4) 28 | self.assertEqual(sd.height, 8) 29 | self.assertEqual(sd.format, wgd.DirectXPixelFormat.R16_G16_B16_A16_FLOAT) 30 | 31 | msd2 = sd.multisample_description 32 | self.assertEqual(msd.count, 1) 33 | self.assertEqual(msd.quality, 2) 34 | 35 | if __name__ == '__main__': 36 | unittest.main() 37 | -------------------------------------------------------------------------------- /src/test/python/testfromfunction.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("./generated") 3 | 4 | import unittest 5 | 6 | import winrt.windows.foundation.collections as wfc 7 | 8 | class TestQueryInterface(unittest.TestCase): 9 | def test_as_function(self): 10 | propset = wfc.PropertySet() 11 | propset.insert("strmap", wfc.StringMap()) 12 | self.assertTrue(propset.has_key("strmap")) 13 | o = propset.lookup("strmap") 14 | strmap = wfc.StringMap._from(o) 15 | self.assertEqual(type(strmap), wfc.StringMap) 16 | 17 | if __name__ == '__main__': 18 | unittest.main() 19 | -------------------------------------------------------------------------------- /src/test/python/testnumerics.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.append("./generated") 3 | 4 | import unittest 5 | 6 | import winrt.windows.foundation.numerics as wfn 7 | 8 | class TestNumerics(unittest.TestCase): 9 | def test_struct_ctor_pos(self): 10 | r = wfn.Rational(2, 4) 11 | 12 | self.assertEqual(r.numerator, 2) 13 | self.assertEqual(r.denominator, 4) 14 | 15 | def test_struct_ctor_kwd(self): 16 | r = wfn.Rational(denominator=2, numerator=4) 17 | 18 | self.assertEqual(r.numerator, 4) 19 | self.assertEqual(r.denominator, 2) 20 | 21 | def test_struct_ctor_mix(self): 22 | r = wfn.Rational(3, denominator=6) 23 | 24 | self.assertEqual(r.numerator, 3) 25 | self.assertEqual(r.denominator, 6) 26 | 27 | def test_struct_ctor_dict(self): 28 | r = wfn.Rational({"denominator":2, "numerator":4}) 29 | 30 | self.assertEqual(r.numerator, 4) 31 | self.assertEqual(r.denominator, 2) 32 | 33 | def test_vec3(self): 34 | v = wfn.Vector3(1.0, 2.0, 3.0) 35 | 36 | self.assertEqual(v.x, 1.0) 37 | self.assertEqual(v.y, 2.0) 38 | self.assertEqual(v.z, 3.0) 39 | 40 | def test_plane(self): 41 | v = wfn.Vector3(1.0, 2.0, 3.0) 42 | p = wfn.Plane(v, 4.0) 43 | n = p.normal 44 | 45 | self.assertEqual(n.x, 1.0) 46 | self.assertEqual(n.y, 2.0) 47 | self.assertEqual(n.z, 3.0) 48 | self.assertEqual(p.d, 4.0) 49 | 50 | def test_plane_dict(self): 51 | p = wfn.Plane({"x":1.0, "y":2.0, "z":3.0}, 4.0) 52 | n = p.normal 53 | 54 | self.assertEqual(n.x, 1.0) 55 | self.assertEqual(n.y, 2.0) 56 | self.assertEqual(n.z, 3.0) 57 | self.assertEqual(p.d, 4.0) 58 | 59 | if __name__ == '__main__': 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /src/tool/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(abi) 2 | add_subdirectory(python) 3 | add_subdirectory(cppxlang) 4 | -------------------------------------------------------------------------------- /src/tool/abi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(abi) 2 | 3 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 4 | add_compile_options(-Wno-missing-field-initializers) 5 | endif() 6 | 7 | add_executable(abi "") 8 | target_sources(abi PUBLIC 9 | abi_writer.cpp 10 | main.cpp 11 | metadata_cache.cpp 12 | pch.cpp 13 | types.cpp 14 | "${PROJECT_BINARY_DIR}/strings.cpp") 15 | target_include_directories(abi PUBLIC ${XLANG_LIBRARY_PATH} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) 16 | target_compile_definitions(abi PUBLIC "ABIWINRT_VERSION_STRING=\"${XLANG_BUILD_VERSION}\"") 17 | 18 | GENERATE_STRING_LITERAL_FILES("${PROJECT_SOURCE_DIR}/strings/*.h" "strings" "xlang::strings" abi) 19 | 20 | if (WIN32) 21 | TARGET_CONFIG_MSVC_PCH(abi pch.cpp pch.h) 22 | target_link_libraries(abi windowsapp ole32 shlwapi) 23 | else() 24 | target_link_libraries(abi c++ c++abi c++experimental) 25 | target_link_libraries(abi -lpthread) 26 | endif() 27 | 28 | if (MSVC) 29 | target_compile_options(abi PUBLIC /guard:cf /Qspectre /sdl) 30 | target_link_options(abi PUBLIC /guard:cf /DYNAMICBASE /CETCOMPAT /debugtype:cv,fixup) 31 | endif() 32 | 33 | file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/abi.exe" abiwinrt_exe) 34 | set_target_properties(abi PROPERTIES "abiwinrt_exe" ${abiwinrt_exe}) -------------------------------------------------------------------------------- /src/tool/abi/SignConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/tool/abi/abi.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.13.35913.81 d17.13 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "abi", "abi.vcxproj", "{F025D704-CA01-4C93-9097-D0C7BF9CCA07}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Debug|x64.ActiveCfg = Debug|x64 17 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Debug|x64.Build.0 = Debug|x64 18 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Debug|x86.ActiveCfg = Debug|Win32 19 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Debug|x86.Build.0 = Debug|Win32 20 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Release|x64.ActiveCfg = Release|x64 21 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Release|x64.Build.0 = Release|x64 22 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Release|x86.ActiveCfg = Release|Win32 23 | {F025D704-CA01-4C93-9097-D0C7BF9CCA07}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {8D5AC3F4-11A9-461A-B4D3-B19A6C7DD36A} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /src/tool/abi/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/tool/abi/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "cmd_reader.h" 6 | #include "meta_reader.h" 7 | #include "task_group.h" 8 | #include "text_writer.h" 9 | -------------------------------------------------------------------------------- /src/tool/abi/readme.md: -------------------------------------------------------------------------------- 1 | ## The ABI/WinRT language projection 2 | 3 | The Application Binary Interface (ABI) projection generates header files for consuming WinRT APIs that are similar to headers generated from COM .idl files. 4 | 5 | **Note: This tool is for legacy codebases and not recommended for new development. C++ developers should instead use https://github.com/microsoft/cppwinrt, which supports standard C++ and the latest C++ language features.** 6 | 7 | - Nuget Package: https://www.nuget.org/packages/Microsoft.Windows.AbiWinRT/ 8 | 9 | ## Usage 10 | 11 | Similar to the `Microsoft.Windows.CppWinRT`nuget package, you can add a reference to `Microsoft.Windows.AbiWinRT` and the tool will generate the projection headers for your project to consume. 12 | 13 | | Property | Description | 14 | |-----------|---------------| 15 | | `AbiWinRTAddAbiNamespacePrefix` | Adds the `ABI::` prefix to all generated headers. Defaults to `true`. | 16 | | `AbiWinRTEnsureSDKHeaderCompat` | Passes the `-lowercase-include-guard` switch to `abi.exe` to enable compat with SDK headers. Defaults to `false`. | 17 | -------------------------------------------------------------------------------- /src/tool/abi/strings/constexpr_definitions.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma push_macro("MIDL_CONST_ID") 3 | #undef MIDL_CONST_ID 4 | #define MIDL_CONST_ID const __declspec(selectany) 5 | 6 | -------------------------------------------------------------------------------- /src/tool/abi/strings/constexpr_end_definitions.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma pop_macro("MIDL_CONST_ID") -------------------------------------------------------------------------------- /src/tool/abi/strings/deprecated_header_end.h: -------------------------------------------------------------------------------- 1 | 2 | // Restore the original value of the 'DEPRECATED' macro 3 | #pragma pop_macro("DEPRECATED") 4 | 5 | #ifdef __clang__ 6 | #pragma clang diagnostic pop // deprecated-declarations 7 | #else 8 | #pragma warning(pop) 9 | #endif -------------------------------------------------------------------------------- /src/tool/abi/strings/deprecated_header_start.h: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // Deprecated attribute support 4 | // 5 | 6 | #pragma push_macro("DEPRECATED") 7 | #undef DEPRECATED 8 | 9 | #if !defined(DISABLE_WINRT_DEPRECATION) 10 | #if defined(__cplusplus) 11 | #if __cplusplus >= 201402 12 | #define DEPRECATED(x) [[deprecated(x)]] 13 | #define DEPRECATEDENUMERATOR(x) [[deprecated(x)]] 14 | #elif defined(_MSC_VER) 15 | #if _MSC_VER >= 1900 16 | #define DEPRECATED(x) [[deprecated(x)]] 17 | #define DEPRECATEDENUMERATOR(x) [[deprecated(x)]] 18 | #else 19 | #define DEPRECATED(x) __declspec(deprecated(x)) 20 | #define DEPRECATEDENUMERATOR(x) 21 | #endif // _MSC_VER >= 1900 22 | #else // Not Standard C++ or MSVC, ignore the construct. 23 | #define DEPRECATED(x) 24 | #define DEPRECATEDENUMERATOR(x) 25 | #endif // C++ deprecation 26 | #else // C - disable deprecation 27 | #define DEPRECATED(x) 28 | #define DEPRECATEDENUMERATOR(x) 29 | #endif 30 | #else // Deprecation is disabled 31 | #define DEPRECATED(x) 32 | #define DEPRECATEDENUMERATOR(x) 33 | #endif /* DEPRECATED */ 34 | 35 | // Disable Deprecation for this header, MIDL verifies that cross-type access is acceptable 36 | #ifdef __clang__ 37 | #pragma clang diagnostic push 38 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 39 | #else 40 | #pragma warning(push) 41 | #pragma warning(disable: 4996) 42 | #endif 43 | -------------------------------------------------------------------------------- /src/tool/abi/strings/enum_class.h: -------------------------------------------------------------------------------- 1 | #if defined(__MIDL_USE_C_ENUM) 2 | #define MIDL_ENUM enum 3 | #else 4 | #define MIDL_ENUM enum class 5 | #endif 6 | -------------------------------------------------------------------------------- /src/tool/abi/strings/file_header.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma warning( disable: 4049 ) /* more than 64k source lines */ 3 | 4 | /* verify that the version is high enough to compile this file*/ 5 | #ifndef __REQUIRED_RPCNDR_H_VERSION__ 6 | #define __REQUIRED_RPCNDR_H_VERSION__ 500 7 | #endif 8 | 9 | /* verify that the version is high enough to compile this file*/ 10 | #ifndef __REQUIRED_RPCSAL_H_VERSION__ 11 | #define __REQUIRED_RPCSAL_H_VERSION__ 100 12 | #endif 13 | 14 | #include 15 | #include 16 | 17 | #ifndef __RPCNDR_H_VERSION__ 18 | #error this stub requires an updated version of 19 | #endif /* __RPCNDR_H_VERSION__ */ 20 | 21 | #ifndef COM_NO_WINDOWS_H 22 | #include 23 | #include 24 | #endif /*COM_NO_WINDOWS_H*/ 25 | -------------------------------------------------------------------------------- /src/tool/abi/strings/include_guard_end.h: -------------------------------------------------------------------------------- 1 | 2 | #endif // __%_p_h__ 3 | 4 | #endif // __%_h__ 5 | -------------------------------------------------------------------------------- /src/tool/abi/strings/include_guard_start.h: -------------------------------------------------------------------------------- 1 | #ifndef __%_h__ 2 | #define __%_h__ 3 | #ifndef __%_p_h__ 4 | #define __%_p_h__ 5 | 6 | 7 | #pragma once 8 | -------------------------------------------------------------------------------- /src/tool/abi/strings/ns_prefix_always.h: -------------------------------------------------------------------------------- 1 | #define CHECK_NS_PREFIX_STATE "always" -------------------------------------------------------------------------------- /src/tool/abi/strings/ns_prefix_definitions.h: -------------------------------------------------------------------------------- 1 | 2 | // Ensure that the setting of the /ns_prefix command line switch is consistent for all headers. 3 | // If you get an error from the compiler indicating "warning C4005: 'CHECK_NS_PREFIX_STATE': macro redefinition", this 4 | // indicates that you have included two different headers with different settings for the /ns_prefix MIDL command line switch 5 | #if !defined(DISABLE_NS_PREFIX_CHECKS) 6 | % 7 | #endif // !defined(DISABLE_NS_PREFIX_CHECKS) 8 | 9 | -------------------------------------------------------------------------------- /src/tool/abi/strings/ns_prefix_never.h: -------------------------------------------------------------------------------- 1 | #define CHECK_NS_PREFIX_STATE "never" -------------------------------------------------------------------------------- /src/tool/abi/strings/ns_prefix_optional.h: -------------------------------------------------------------------------------- 1 | #if defined(MIDL_NS_PREFIX) 2 | #define CHECK_NS_PREFIX_STATE "always" 3 | #else 4 | #define CHECK_NS_PREFIX_STATE "never" 5 | #endif // MIDL_NS_PREFIX -------------------------------------------------------------------------------- /src/tool/abi/strings/optional_ns_prefix_definitions.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma push_macro("ABI_CONCAT") 3 | #pragma push_macro("ABI_PARAMETER") 4 | #pragma push_macro("ABI_NAMESPACE_BEGIN") 5 | #pragma push_macro("ABI_NAMESPACE_END") 6 | #pragma push_macro("C_IID") 7 | #undef ABI_CONCAT 8 | #undef ABI_PARAMETER 9 | #undef ABI_NAMESPACE_BEGIN 10 | #undef ABI_NAMESPACE_END 11 | #undef C_IID 12 | #define ABI_CONCAT(x,y) x##y 13 | 14 | // /ns_prefix optional state 15 | #if defined(MIDL_NS_PREFIX) 16 | #if defined(__cplusplus) 17 | #define ABI_PARAMETER(x) ABI::x 18 | #define ABI_NAMESPACE_BEGIN namespace ABI { 19 | #define ABI_NAMESPACE_END } 20 | #else // !defined(__cplusplus) 21 | #define C_ABI_PARAMETER(x) ABI_CONCAT(__x_ABI_C, x) 22 | #endif // !defined(__cplusplus) 23 | #define C_IID(x) ABI_CONCAT(IID___x_ABI_C, x) 24 | #else 25 | #if defined(__cplusplus) 26 | #define ABI_PARAMETER(x) x 27 | #define ABI_NAMESPACE_BEGIN 28 | #define ABI_NAMESPACE_END 29 | #else // !defined(__cplusplus) 30 | #define C_ABI_PARAMETER(x) ABI_CONCAT(__x_, x) 31 | #endif // !defined(__cplusplus) 32 | #define C_IID(x) ABI_CONCAT(IID___x_, x) 33 | #endif // defined(MIDL_NS_PREFIX) 34 | -------------------------------------------------------------------------------- /src/tool/abi/strings/optional_ns_prefix_end_definitions.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma pop_macro("C_IID") 3 | #pragma pop_macro("ABI_CONCAT") 4 | #pragma pop_macro("ABI_PARAMETER") 5 | #pragma pop_macro("ABI_NAMESPACE_BEGIN") 6 | #pragma pop_macro("ABI_NAMESPACE_END") 7 | 8 | -------------------------------------------------------------------------------- /src/tool/cppxlang/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cppxlang) 2 | 3 | add_executable(cppxlang "") 4 | target_sources(cppxlang PUBLIC main.cpp pch.cpp "${PROJECT_BINARY_DIR}/strings.cpp") 5 | target_include_directories(cppxlang PUBLIC ${XLANG_LIBRARY_PATH} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) 6 | target_compile_definitions(cppxlang PUBLIC "XLANG_VERSION_STRING=\"${XLANG_BUILD_VERSION}\"") 7 | 8 | GENERATE_STRING_LITERAL_FILES("${PROJECT_SOURCE_DIR}/strings/*" "strings" "xlang::strings" cppxlang) 9 | 10 | if (WIN32) 11 | TARGET_CONFIG_MSVC_PCH(cppxlang pch.cpp pch.h) 12 | target_compile_options(cppxlang PUBLIC /await) 13 | target_link_libraries(cppxlang windowsapp ole32 shlwapi) 14 | else() 15 | target_link_libraries(cppxlang c++ c++abi c++experimental) 16 | target_link_libraries(cppxlang -lpthread) 17 | endif() 18 | 19 | add_subdirectory(test_base) 20 | -------------------------------------------------------------------------------- /src/tool/cppxlang/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/tool/cppxlang/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cmd_reader.h" 4 | #include "meta_reader.h" 5 | #include "task_group.h" 6 | #include "text_writer.h" 7 | -------------------------------------------------------------------------------- /src/tool/cppxlang/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace xlang 4 | { 5 | struct settings_type 6 | { 7 | std::set input; 8 | std::set reference; 9 | 10 | std::string output_folder; 11 | bool base{}; 12 | bool license{}; 13 | bool brackets{}; 14 | 15 | bool component{}; 16 | std::string component_folder; 17 | std::string component_name; 18 | std::string component_pch; 19 | bool component_prefix{}; 20 | bool component_overwrite{}; 21 | std::string component_lib; 22 | bool component_opt{}; 23 | 24 | bool verbose{}; 25 | 26 | std::set include; 27 | std::set exclude; 28 | 29 | meta::reader::filter projection_filter; 30 | meta::reader::filter component_filter; 31 | }; 32 | 33 | extern settings_type settings; 34 | } 35 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_abi.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::impl 3 | { 4 | template <> struct abi 5 | { 6 | using type = ::xlang_unknown; 7 | }; 8 | template <> struct guid_storage 9 | { 10 | static constexpr guid value{ 0x00000000,0x0000,0x0000,{ 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } }; 11 | }; 12 | using unknown_abi = abi_t; 13 | 14 | template <> struct abi 15 | { 16 | using type = ::IXlangObject; 17 | }; 18 | template <> struct guid_storage 19 | { 20 | static constexpr guid value{ ::IXlangObject_guid }; 21 | }; 22 | template <> struct name 23 | { 24 | static constexpr auto & value{ u8"Object" }; 25 | static constexpr auto & data{ u8"cinterface(IXlangObject)" }; 26 | }; 27 | template <> struct category 28 | { 29 | using type = basic_category; 30 | }; 31 | using xlang_object_abi = abi_t; 32 | 33 | struct XLANG_NOVTABLE IAgileObject : unknown_abi 34 | { 35 | }; 36 | template <> struct guid_storage 37 | { 38 | static constexpr guid value{ 0x94EA2B94,0xE9CC,0x49E0,{ 0xC0,0xFF,0xEE,0x64,0xCA,0x8F,0x5B,0x90 } }; 39 | }; 40 | 41 | struct XLANG_NOVTABLE IWeakReference : unknown_abi 42 | { 43 | virtual com_interop_result XLANG_CALL Resolve(guid const& iid, void** objectReference) noexcept = 0; 44 | }; 45 | template <> struct guid_storage 46 | { 47 | static constexpr guid value{ 0x00000037,0x0000,0x0000,{ 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } }; 48 | }; 49 | 50 | struct XLANG_NOVTABLE IWeakReferenceSource : unknown_abi 51 | { 52 | virtual com_interop_result XLANG_CALL GetWeakReference(IWeakReference** weakReference) noexcept = 0; 53 | }; 54 | template <> struct guid_storage 55 | { 56 | static constexpr guid value{ 0x00000038,0x0000,0x0000,{ 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } }; 57 | }; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_async.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::impl 3 | { 4 | template 5 | void blocking_suspend(Async const& async) 6 | { 7 | std::mutex m; 8 | std::condition_variable cv; 9 | bool completed = false; 10 | async.Completed([&](auto && ...) 11 | { 12 | { 13 | std::lock_guard const guard(m); 14 | completed = true; 15 | } 16 | cv.notify_one(); 17 | }); 18 | 19 | std::unique_lock guard(m); 20 | cv.wait(m, [&] { return completed; }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_collections_map.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang 3 | { 4 | template , typename Allocator = std::allocator>> 5 | Foundation::Collections::IMap single_threaded_map() 6 | { 7 | return make>>(std::map{}); 8 | } 9 | 10 | template , typename Allocator = std::allocator>> 11 | Foundation::Collections::IMap single_threaded_map(std::map&& values) 12 | { 13 | return make>>(std::move(values)); 14 | } 15 | 16 | template , typename KeyEqual = std::equal_to, typename Allocator = std::allocator>> 17 | Foundation::Collections::IMap single_threaded_map(std::unordered_map&& values) 18 | { 19 | return make>>(std::move(values)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_collections_vector.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang 3 | { 4 | template > 5 | Foundation::Collections::IVector single_threaded_vector(std::vector&& values = {}) 6 | { 7 | return make>>(std::move(values)); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_coroutine_action.h: -------------------------------------------------------------------------------- 1 | 2 | namespace std::experimental 3 | { 4 | template 5 | struct coroutine_traits 6 | { 7 | struct promise_type final : xlang::impl::promise_base 10 | { 11 | void return_void() const noexcept 12 | { 13 | } 14 | }; 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_coroutine_fire_and_forget.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang 3 | { 4 | struct fire_and_forget {}; 5 | } 6 | 7 | namespace std::experimental 8 | { 9 | template 10 | struct coroutine_traits 11 | { 12 | struct promise_type 13 | { 14 | xlang::fire_and_forget get_return_object() const noexcept 15 | { 16 | return{}; 17 | } 18 | 19 | void return_void() const noexcept 20 | { 21 | } 22 | 23 | suspend_never initial_suspend() const noexcept 24 | { 25 | return{}; 26 | } 27 | 28 | suspend_never final_suspend() const noexcept 29 | { 30 | return{}; 31 | } 32 | 33 | void unhandled_exception() const noexcept 34 | { 35 | std::terminate(); 36 | } 37 | }; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_coroutine_operation.h: -------------------------------------------------------------------------------- 1 | 2 | namespace std::experimental 3 | { 4 | template 5 | struct coroutine_traits, Args...> 6 | { 7 | struct promise_type final : xlang::impl::promise_base, 9 | xlang::Foundation::AsyncOperationCompletedHandler> 10 | { 11 | TResult get_return_value() noexcept 12 | { 13 | return std::move(m_result); 14 | } 15 | 16 | void return_value(TResult&& value) noexcept 17 | { 18 | m_result = std::move(value); 19 | } 20 | 21 | void return_value(TResult const& value) noexcept 22 | { 23 | m_result = value; 24 | } 25 | 26 | TResult m_result{ xlang::impl::empty_value() }; 27 | }; 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_dependencies.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #ifdef _WIN32 30 | #include 31 | #endif 32 | 33 | #include 34 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_extern.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef _WIN32 3 | 4 | extern "C" 5 | { 6 | int32_t XLANG_CALL XLANG_IIDFromString(wchar_t const* string, xlang::guid* iid) noexcept; 7 | void XLANG_CALL XLANG_GetCurrentThreadStackLimits(uintptr_t* low_limit, uintptr_t* high_limit) noexcept; 8 | uint32_t XLANG_CALL XLANG_GetLastError() noexcept; 9 | int32_t XLANG_CALL XLANG_CoGetObjectContext(xlang::guid const& iid, void** object) noexcept; 10 | 11 | uint32_t XLANG_CALL XLANG_WaitForSingleObject(void* handle, uint32_t milliseconds) noexcept; 12 | int32_t XLANG_CALL XLANG_TrySubmitThreadpoolCallback(void(XLANG_CALL *callback)(void*, void* context), void* context, void*) noexcept; 13 | xlang::impl::ptp_timer XLANG_CALL XLANG_CreateThreadpoolTimer(void(XLANG_CALL *callback)(void*, void* context, void*), void* context, void*) noexcept; 14 | void XLANG_CALL XLANG_SetThreadpoolTimer(xlang::impl::ptp_timer timer, void* time, uint32_t period, uint32_t window) noexcept; 15 | void XLANG_CALL XLANG_CloseThreadpoolTimer(xlang::impl::ptp_timer timer) noexcept; 16 | xlang::impl::ptp_wait XLANG_CALL XLANG_CreateThreadpoolWait(void(XLANG_CALL *callback)(void*, void* context, void*, uint32_t result), void* context, void*) noexcept; 17 | void XLANG_CALL XLANG_SetThreadpoolWait(xlang::impl::ptp_wait wait, void* handle, void* timeout) noexcept; 18 | void XLANG_CALL XLANG_CloseThreadpoolWait(xlang::impl::ptp_wait wait) noexcept; 19 | } 20 | 21 | XLANG_LINK(IIDFromString, 8) 22 | XLANG_LINK(GetCurrentThreadStackLimits, 8) 23 | XLANG_LINK(GetLastError, 0) 24 | XLANG_LINK(CoGetObjectContext, 8) 25 | 26 | XLANG_LINK(WaitForSingleObject, 8) 27 | XLANG_LINK(TrySubmitThreadpoolCallback, 12) 28 | XLANG_LINK(CreateThreadpoolTimer, 12) 29 | XLANG_LINK(SetThreadpoolTimer, 16) 30 | XLANG_LINK(CloseThreadpoolTimer, 4) 31 | XLANG_LINK(CreateThreadpoolWait, 12) 32 | XLANG_LINK(SetThreadpoolWait, 12) 33 | XLANG_LINK(CloseThreadpoolWait, 4) 34 | 35 | #endif 36 | 37 | extern "C" 38 | { 39 | int32_t XLANG_CALL XLANG_GetActivationFactory(void* classId, void** factory) noexcept; 40 | } 41 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_handle.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang 3 | { 4 | template 5 | struct handle_type 6 | { 7 | using type = typename T::type; 8 | 9 | handle_type() noexcept = default; 10 | 11 | explicit handle_type(type value) noexcept : m_value(value) 12 | { 13 | } 14 | 15 | handle_type(handle_type&& other) noexcept : m_value(other.detach()) 16 | { 17 | } 18 | 19 | handle_type& operator=(handle_type&& other) noexcept 20 | { 21 | if (this != &other) 22 | { 23 | attach(other.detach()); 24 | } 25 | 26 | return*this; 27 | } 28 | 29 | ~handle_type() noexcept 30 | { 31 | close(); 32 | } 33 | 34 | void close() noexcept 35 | { 36 | if (*this) 37 | { 38 | T::close(m_value); 39 | m_value = T::invalid(); 40 | } 41 | } 42 | 43 | explicit operator bool() const noexcept 44 | { 45 | return T::invalid() != m_value; 46 | } 47 | 48 | type get() const noexcept 49 | { 50 | return m_value; 51 | } 52 | 53 | type* put() noexcept 54 | { 55 | XLANG_ASSERT(m_value == T::invalid()); 56 | return &m_value; 57 | } 58 | 59 | void attach(type value) noexcept 60 | { 61 | close(); 62 | *put() = value; 63 | } 64 | 65 | type detach() noexcept 66 | { 67 | type value = m_value; 68 | m_value = T::invalid(); 69 | return value; 70 | } 71 | 72 | friend void swap(handle_type& left, handle_type& right) noexcept 73 | { 74 | std::swap(left.m_value, right.m_value); 75 | } 76 | 77 | private: 78 | 79 | type m_value = T::invalid(); 80 | }; 81 | } 82 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_macros.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef _DEBUG 3 | 4 | #define XLANG_ASSERT assert 5 | #define XLANG_VERIFY XLANG_ASSERT 6 | #define XLANG_VERIFY_(result, expression) XLANG_ASSERT(result == expression) 7 | 8 | #else 9 | 10 | #define XLANG_ASSERT(expression) ((void)0) 11 | #define XLANG_VERIFY(expression) (void)(expression) 12 | #define XLANG_VERIFY_(result, expression) (void)(expression) 13 | 14 | #endif 15 | 16 | #if defined(_MSC_VER) 17 | #define XLANG_EBO __declspec(empty_bases) 18 | #define XLANG_NOVTABLE __declspec(novtable) 19 | #define XLANG_CALL __stdcall 20 | #define XLANG_NOINLINE __declspec(noinline) 21 | #else 22 | #define XLANG_EBO 23 | #define XLANG_NOVTABLE 24 | #define XLANG_CALL 25 | #define XLANG_NOINLINE 26 | #endif 27 | 28 | #define XLANG_SHIM(...) (*(abi_t<__VA_ARGS__>**)&static_cast<__VA_ARGS__ const&>(static_cast(*this))) 29 | 30 | #ifndef XLANG_EXTERNAL_CATCH_CLAUSE 31 | #define XLANG_EXTERNAL_CATCH_CLAUSE 32 | #endif 33 | 34 | #if defined(_MSC_VER) 35 | #ifdef _M_HYBRID 36 | #define XLANG_LINK(function, count) __pragma(comment(linker, "/alternatename:#XLANG_" #function "@" #count "=#" #function "@" #count)) 37 | #elif _M_IX86 38 | #define XLANG_LINK(function, count) __pragma(comment(linker, "/alternatename:_XLANG_" #function "@" #count "=_" #function "@" #count)) 39 | #else 40 | #define XLANG_LINK(function, count) __pragma(comment(linker, "/alternatename:XLANG_" #function "=" #function)) 41 | #endif 42 | #else 43 | #define XLANG_LINK(function, count) 44 | #endif 45 | 46 | // Note: this is a workaround for a false-positive warning produced by the Visual C++ 15.9 compiler. 47 | #pragma warning(disable : 5046) 48 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_std_hash.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::impl 3 | { 4 | inline size_t hash_data(void const* ptr, size_t const bytes) noexcept 5 | { 6 | #ifdef _WIN64 7 | constexpr size_t fnv_offset_basis = 14695981039346656037ULL; 8 | constexpr size_t fnv_prime = 1099511628211ULL; 9 | #else 10 | constexpr size_t fnv_offset_basis = 2166136261U; 11 | constexpr size_t fnv_prime = 16777619U; 12 | #endif 13 | size_t result = fnv_offset_basis; 14 | uint8_t const* const buffer = static_cast(ptr); 15 | 16 | for (size_t next = 0; next < bytes; ++next) 17 | { 18 | result ^= buffer[next]; 19 | result *= fnv_prime; 20 | } 21 | 22 | return result; 23 | } 24 | 25 | inline size_t hash_unknown(Windows::Foundation::IUnknown const& value) noexcept 26 | { 27 | void* const abi_value = get_abi(value.try_as()); 28 | return std::hash{}(abi_value); 29 | } 30 | 31 | template 32 | struct hash_base 33 | { 34 | size_t operator()(T const& value) const noexcept 35 | { 36 | return hash_unknown(value); 37 | } 38 | }; 39 | } 40 | 41 | namespace std 42 | { 43 | template<> struct hash 44 | { 45 | size_t operator()(xlang::hstring const& value) const noexcept 46 | { 47 | std::basic_string_view view = value; 48 | return xlang::impl::hash_data(view.data(), view.size() * sizeof(xlang_char8)); 49 | } 50 | }; 51 | 52 | template<> struct hash : xlang::impl::hash_base {}; 53 | template<> struct hash : xlang::impl::hash_base {}; 54 | template<> struct hash : xlang::impl::hash_base {}; 55 | } 56 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_types.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang::impl 3 | { 4 | #ifdef __IUnknown_INTERFACE_DEFINED__ 5 | #define XLANG_WINDOWS_ABI 6 | using ref_count_type = unsigned long; 7 | #else 8 | using ref_count_type = uint32_t; 9 | #endif 10 | 11 | using ptp_io = struct tp_io*; 12 | using ptp_timer = struct tp_timer*; 13 | using ptp_wait = struct tp_wait*; 14 | using bstr = wchar_t*; 15 | } 16 | 17 | namespace xlang 18 | { 19 | using guid = xlang_guid; 20 | } 21 | 22 | namespace xlang::Windows::Foundation 23 | { 24 | enum class TrustLevel : int32_t 25 | { 26 | BaseTrust, 27 | PartialTrust, 28 | FullTrust 29 | }; 30 | 31 | struct IUnknown; 32 | struct IXlangObject; 33 | struct IActivationFactory; 34 | } 35 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_version.h: -------------------------------------------------------------------------------- 1 | 2 | #define CPPXLANG_VERSION "%" 3 | 4 | // XLANG_version is used by Microsoft to analyze cppxlang library adoption and inform future product decisions. 5 | #ifdef _WIN32 6 | extern "C" 7 | __declspec(selectany) char const * const XLANG_version = "cppxlang version:" CPPXLANG_VERSION; 8 | #else 9 | extern "C" 10 | inline char const * const XLANG_version = "cppxlang version:" CPPXLANG_VERSION; 11 | #endif 12 | 13 | #ifdef _M_IX86 14 | #pragma comment(linker, "/include:_XLANG_version") 15 | #else 16 | #pragma comment(linker, "/include:XLANG_version") 17 | #endif 18 | 19 | namespace xlang 20 | { 21 | template 22 | constexpr bool check_version(char const(&base)[BaseSize], char const(&component)[ComponentSize]) noexcept 23 | { 24 | if constexpr (BaseSize != ComponentSize) 25 | { 26 | return false; 27 | } 28 | 29 | for (size_t i = 0; i != BaseSize - 1; ++i) 30 | { 31 | if (base[i] != component[i]) 32 | { 33 | return false; 34 | } 35 | } 36 | 37 | return true; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/tool/cppxlang/strings/base_weak_ref.h: -------------------------------------------------------------------------------- 1 | 2 | namespace xlang 3 | { 4 | template 5 | struct weak_ref 6 | { 7 | weak_ref(std::nullptr_t = nullptr) noexcept {} 8 | 9 | weak_ref(impl::com_ref const& object) 10 | { 11 | if (object) 12 | { 13 | if constexpr(impl::is_implements_v) 14 | { 15 | m_ref = std::move(object->get_weak().m_ref); 16 | } 17 | else 18 | { 19 | check_com_interop_error(object.template as()->GetWeakReference(m_ref.put())); 20 | } 21 | } 22 | } 23 | 24 | impl::com_ref get() const noexcept 25 | { 26 | if (!m_ref) 27 | { 28 | return nullptr; 29 | } 30 | 31 | if constexpr(impl::is_implements_v) 32 | { 33 | impl::com_ref> temp; 34 | m_ref->Resolve(guid_of(), put_abi(temp)); 35 | void* result = get_self(temp); 36 | detach_abi(temp); 37 | return { result, take_ownership_from_abi }; 38 | } 39 | else 40 | { 41 | void* result{}; 42 | m_ref->Resolve(guid_of(), &result); 43 | return { result, take_ownership_from_abi }; 44 | } 45 | } 46 | 47 | auto put() noexcept 48 | { 49 | return m_ref.put(); 50 | } 51 | 52 | explicit operator bool() const noexcept 53 | { 54 | return static_cast(m_ref); 55 | } 56 | 57 | private: 58 | 59 | com_ptr m_ref; 60 | }; 61 | 62 | template 63 | weak_ref> make_weak(T const& object) 64 | { 65 | return object; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/tool/cppxlang/test_base/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(cppx_base) 2 | 3 | add_executable(cppx_base "") 4 | target_sources(cppx_base PUBLIC main.cpp) 5 | target_include_directories(cppx_base PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") 6 | target_link_libraries(cppx_base pal) 7 | 8 | if (WIN32) 9 | target_compile_options(cppx_base PUBLIC /await /permissive-) 10 | target_link_libraries(cppx_base windowsapp ole32 shlwapi) 11 | else() 12 | target_link_libraries(cppx_base c++ c++abi c++experimental) 13 | target_link_libraries(cppx_base -lpthread) 14 | endif() 15 | 16 | add_custom_target(cppx_base_h 17 | COMMAND cppxlang -base -out "${CMAKE_CURRENT_BINARY_DIR}") 18 | 19 | add_dependencies(cppx_base cppx_base_h) 20 | -------------------------------------------------------------------------------- /src/tool/cppxlang/test_base/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | xlang::get_activation_factory(u8"Foo"); 6 | } 7 | -------------------------------------------------------------------------------- /src/tool/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(pywinrt) 2 | 3 | add_executable(pywinrt "") 4 | target_sources(pywinrt PUBLIC main.cpp pch.cpp "${PROJECT_BINARY_DIR}/strings.cpp") 5 | target_include_directories(pywinrt PUBLIC ${XLANG_LIBRARY_PATH} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}) 6 | target_compile_definitions(pywinrt PUBLIC "XLANG_VERSION_STRING=\"${XLANG_BUILD_VERSION}\"") 7 | 8 | GENERATE_STRING_LITERAL_FILES("${PROJECT_SOURCE_DIR}/strings/*" "strings" "pywinrt::strings" pywinrt) 9 | 10 | if (WIN32) 11 | TARGET_CONFIG_MSVC_PCH(pywinrt pch.cpp pch.h) 12 | target_compile_options(pywinrt PUBLIC /await) 13 | target_link_libraries(pywinrt windowsapp ole32 shlwapi) 14 | else() 15 | target_link_libraries(pywinrt c++ c++abi c++experimental) 16 | target_link_libraries(pywinrt -lpthread) 17 | endif() 18 | 19 | file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/pywinrt.exe" pywinrt_exe) 20 | set_target_properties(pywinrt PROPERTIES "pywinrt_exe" ${pywinrt_exe}) 21 | -------------------------------------------------------------------------------- /src/tool/python/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /src/tool/python/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cmd_reader.h" 4 | #include "meta_reader.h" 5 | #include "task_group.h" 6 | #include "text_writer.h" 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /src/tool/python/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace pywinrt 4 | { 5 | struct settings_type 6 | { 7 | std::set input; 8 | 9 | std::filesystem::path output_folder; 10 | std::string module{ "pyrt" }; 11 | bool verbose{}; 12 | 13 | std::set include; 14 | std::set exclude; 15 | xlang::meta::reader::filter filter; 16 | }; 17 | 18 | extern settings_type settings; 19 | } 20 | -------------------------------------------------------------------------------- /src/tool/python/strings/custom_struct_convert.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | static int64_t custom_get(winrt::Windows::Foundation::DateTime const& instance) 4 | { 5 | return instance.time_since_epoch().count(); 6 | } 7 | 8 | static void custom_set(winrt::Windows::Foundation::DateTime& instance, int64_t value) 9 | { 10 | instance = winrt::Windows::Foundation::DateTime{ winrt::Windows::Foundation::TimeSpan{ value } }; 11 | } 12 | 13 | static int64_t custom_get(winrt::Windows::Foundation::TimeSpan const& instance) 14 | { 15 | return instance.count(); 16 | } 17 | 18 | static void custom_set(winrt::Windows::Foundation::TimeSpan& instance, int64_t value) 19 | { 20 | instance = winrt::Windows::Foundation::TimeSpan{ value }; 21 | } 22 | 23 | static int64_t custom_get(winrt::event_token const& instance) 24 | { 25 | return instance.value; 26 | } 27 | 28 | static void custom_set(winrt::event_token& instance, int64_t value) 29 | { 30 | instance.value = value; 31 | } 32 | 33 | static int32_t custom_get(winrt::hresult const& instance) 34 | { 35 | return instance; 36 | } 37 | 38 | static void custom_set(winrt::hresult& instance, int32_t value) 39 | { 40 | instance = value; 41 | } -------------------------------------------------------------------------------- /src/tool/python/strings/enter_function.cpp: -------------------------------------------------------------------------------- 1 | 2 | static PyObject* _enter_@(%* self) noexcept 3 | { 4 | Py_INCREF(self); 5 | return (PyObject*)self; 6 | } 7 | -------------------------------------------------------------------------------- /src/tool/python/strings/ns_module_def.cpp: -------------------------------------------------------------------------------- 1 | 2 | static PyModuleDef_Slot module_slots[] = { 3 | {Py_mod_exec, module_exec}, 4 | {0, nullptr} 5 | }; 6 | 7 | PyDoc_STRVAR(module_doc, "%"); 8 | 9 | static PyModuleDef module_def = { 10 | PyModuleDef_HEAD_INIT, 11 | "%", 12 | module_doc, 13 | 0, 14 | nullptr, 15 | module_slots, 16 | nullptr, 17 | nullptr, 18 | nullptr 19 | }; 20 | -------------------------------------------------------------------------------- /src/tool/python/strings/package_init.py: -------------------------------------------------------------------------------- 1 | from . import _% 2 | _%.init_apartment() 3 | 4 | def _import_ns_module(ns): 5 | import importlib.machinery 6 | import importlib.util 7 | 8 | try: 9 | module_name = "_%_" + ns.replace('.', '_') 10 | 11 | loader = importlib.machinery.ExtensionFileLoader(module_name, _%.__file__) 12 | spec = importlib.util.spec_from_loader(module_name, loader) 13 | module = importlib.util.module_from_spec(spec) 14 | loader.exec_module(module) 15 | return module 16 | except: 17 | return None 18 | -------------------------------------------------------------------------------- /src/tool/python/strings/setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | setuptools.setup( 4 | name = "%", 5 | version = "1.0a0", 6 | description="Generated Python/WinRT package", 7 | license="MIT", 8 | url="http://github.com/Microsoft/xlang", 9 | package_data={ "%":["_%.pyd"] }, 10 | packages = setuptools.find_namespace_packages(where='.', include=("%*"))) 11 | --------------------------------------------------------------------------------