├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── Samples ├── Calc │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── Calc │ │ │ ├── generated │ │ │ ├── Microsoft.UI.Composition.swift │ │ │ ├── Microsoft.UI.Dispatching.swift │ │ │ ├── Microsoft.UI.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Automation.Peers.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.Primitives.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.swift │ │ │ ├── Microsoft.UI.Xaml.Data.swift │ │ │ ├── Microsoft.UI.Xaml.Documents.swift │ │ │ ├── Microsoft.UI.Xaml.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Markup.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Media3D.swift │ │ │ ├── Microsoft.UI.Xaml.Media.swift │ │ │ ├── Microsoft.UI.Xaml.swift │ │ │ ├── Microsoft.UI.swift │ │ │ ├── Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── Windows.Foundation.Collections.swift │ │ │ ├── Windows.Foundation.Numerics.swift │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.System.swift │ │ │ ├── Windows.UI.Core.swift │ │ │ ├── Windows.UI.Text.swift │ │ │ ├── Windows.UI.Xaml.Interop.swift │ │ │ ├── Windows.UI.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Controls.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Data.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Documents.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Input.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.swift │ │ │ ├── cg_Microsoft.UI.Xaml.swift │ │ │ ├── cg_Swift.swift │ │ │ ├── cg_Windows.ApplicationModel.DataTransfer.swift │ │ │ └── cg_Windows.Foundation.swift │ │ │ └── lib.swift │ ├── gen.sh │ └── winrt.json ├── Canvas │ ├── Microsoft.Graphics.Canvas.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── Canvas │ │ │ ├── generated │ │ │ ├── Microsoft.Graphics.Canvas.Brushes.swift │ │ │ ├── Microsoft.Graphics.Canvas.Effects.swift │ │ │ ├── Microsoft.Graphics.Canvas.Geometry.swift │ │ │ ├── Microsoft.Graphics.Canvas.Printing.swift │ │ │ ├── Microsoft.Graphics.Canvas.Svg.swift │ │ │ ├── Microsoft.Graphics.Canvas.Text.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.Composition.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.Xaml.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.swift │ │ │ ├── Microsoft.Graphics.Canvas.swift │ │ │ ├── Microsoft.UI.Composition.swift │ │ │ ├── Microsoft.UI.Dispatching.swift │ │ │ ├── Microsoft.UI.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Automation.Peers.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.Primitives.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.swift │ │ │ ├── Microsoft.UI.Xaml.Data.swift │ │ │ ├── Microsoft.UI.Xaml.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Markup.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Imaging.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Media3D.swift │ │ │ ├── Microsoft.UI.Xaml.Media.swift │ │ │ ├── Microsoft.UI.Xaml.swift │ │ │ ├── Microsoft.UI.swift │ │ │ ├── Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── Windows.Foundation.Numerics.swift │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.Graphics.DirectX.Direct3D11.swift │ │ │ ├── Windows.Graphics.DirectX.swift │ │ │ ├── Windows.Graphics.Effects.swift │ │ │ ├── Windows.Graphics.Imaging.swift │ │ │ ├── Windows.Graphics.Printing.swift │ │ │ ├── Windows.Storage.Streams.swift │ │ │ ├── Windows.UI.Core.swift │ │ │ ├── Windows.UI.Text.swift │ │ │ ├── Windows.UI.Xaml.Interop.swift │ │ │ ├── Windows.UI.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Effects.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Printing.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Svg.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Text.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.UI.Xaml.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.UI.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Controls.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Input.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.swift │ │ │ ├── cg_Microsoft.UI.Xaml.swift │ │ │ ├── cg_Swift.swift │ │ │ ├── cg_Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── cg_Windows.Foundation.swift │ │ │ └── cg_Windows.Graphics.Effects.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── DispatcherQueue │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── DispatcherQueue │ │ │ ├── generated │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.System.swift │ │ │ └── __ns.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── HttpClient │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── HttpClient │ │ │ ├── generated │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.Storage.Streams.swift │ │ │ ├── Windows.Web.Http.Filters.swift │ │ │ ├── Windows.Web.Http.Headers.swift │ │ │ ├── Windows.Web.Http.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Swift.swift │ │ │ ├── cg_Windows.Storage.Streams.swift │ │ │ └── cg_Windows.Web.Http.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── MazeGame │ ├── Microsoft.Graphics.Canvas.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── MazeGame │ │ │ ├── Assets │ │ │ ├── dino.png │ │ │ ├── gamegrid.png │ │ │ └── ninjacat.png │ │ │ ├── AsyncAction.swift │ │ │ ├── Baddie.swift │ │ │ ├── Maze.swift │ │ │ ├── Player.swift │ │ │ ├── generated │ │ │ ├── Microsoft.Graphics.Canvas.Brushes.swift │ │ │ ├── Microsoft.Graphics.Canvas.Effects.swift │ │ │ ├── Microsoft.Graphics.Canvas.Geometry.swift │ │ │ ├── Microsoft.Graphics.Canvas.Printing.swift │ │ │ ├── Microsoft.Graphics.Canvas.Svg.swift │ │ │ ├── Microsoft.Graphics.Canvas.Text.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.Composition.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.Xaml.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.swift │ │ │ ├── Microsoft.Graphics.Canvas.swift │ │ │ ├── Microsoft.UI.Composition.swift │ │ │ ├── Microsoft.UI.Dispatching.swift │ │ │ ├── Microsoft.UI.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Automation.Peers.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.Primitives.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.swift │ │ │ ├── Microsoft.UI.Xaml.Data.swift │ │ │ ├── Microsoft.UI.Xaml.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Markup.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Imaging.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Media3D.swift │ │ │ ├── Microsoft.UI.Xaml.Media.swift │ │ │ ├── Microsoft.UI.Xaml.swift │ │ │ ├── Microsoft.UI.swift │ │ │ ├── Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── Windows.Foundation.Numerics.swift │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.Graphics.DirectX.Direct3D11.swift │ │ │ ├── Windows.Graphics.DirectX.swift │ │ │ ├── Windows.Graphics.Effects.swift │ │ │ ├── Windows.Graphics.Imaging.swift │ │ │ ├── Windows.Graphics.Printing.swift │ │ │ ├── Windows.Storage.Streams.swift │ │ │ ├── Windows.System.swift │ │ │ ├── Windows.UI.Core.swift │ │ │ ├── Windows.UI.Text.swift │ │ │ ├── Windows.UI.Xaml.Interop.swift │ │ │ ├── Windows.UI.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Effects.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Printing.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Svg.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Text.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.UI.Xaml.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.UI.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Controls.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Input.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.swift │ │ │ ├── cg_Microsoft.UI.Xaml.swift │ │ │ ├── cg_Swift.swift │ │ │ ├── cg_Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── cg_Windows.Foundation.swift │ │ │ └── cg_Windows.Graphics.Effects.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── Physics │ ├── Microsoft.Graphics.Canvas.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ ├── Chipmunk2D │ │ │ ├── CMakeLists.txt │ │ │ ├── chipmunk.c │ │ │ ├── cpArbiter.c │ │ │ ├── cpArray.c │ │ │ ├── cpBBTree.c │ │ │ ├── cpBody.c │ │ │ ├── cpCollision.c │ │ │ ├── cpConstraint.c │ │ │ ├── cpDampedRotarySpring.c │ │ │ ├── cpDampedSpring.c │ │ │ ├── cpGearJoint.c │ │ │ ├── cpGrooveJoint.c │ │ │ ├── cpHashSet.c │ │ │ ├── cpHastySpace.c │ │ │ ├── cpMarch.c │ │ │ ├── cpPinJoint.c │ │ │ ├── cpPivotJoint.c │ │ │ ├── cpPolyShape.c │ │ │ ├── cpPolyline.c │ │ │ ├── cpRatchetJoint.c │ │ │ ├── cpRobust.c │ │ │ ├── cpRotaryLimitJoint.c │ │ │ ├── cpShape.c │ │ │ ├── cpSimpleMotor.c │ │ │ ├── cpSlideJoint.c │ │ │ ├── cpSpace.c │ │ │ ├── cpSpaceComponent.c │ │ │ ├── cpSpaceDebug.c │ │ │ ├── cpSpaceHash.c │ │ │ ├── cpSpaceQuery.c │ │ │ ├── cpSpaceStep.c │ │ │ ├── cpSpatialIndex.c │ │ │ ├── cpSweep1D.c │ │ │ ├── include │ │ │ │ └── chipmunk │ │ │ │ │ ├── chipmunk.h │ │ │ │ │ ├── chipmunk_ffi.h │ │ │ │ │ ├── chipmunk_private.h │ │ │ │ │ ├── chipmunk_structs.h │ │ │ │ │ ├── chipmunk_types.h │ │ │ │ │ ├── chipmunk_unsafe.h │ │ │ │ │ ├── cpArbiter.h │ │ │ │ │ ├── cpBB.h │ │ │ │ │ ├── cpBody.h │ │ │ │ │ ├── cpConstraint.h │ │ │ │ │ ├── cpDampedRotarySpring.h │ │ │ │ │ ├── cpDampedSpring.h │ │ │ │ │ ├── cpGearJoint.h │ │ │ │ │ ├── cpGrooveJoint.h │ │ │ │ │ ├── cpHastySpace.h │ │ │ │ │ ├── cpMarch.h │ │ │ │ │ ├── cpPinJoint.h │ │ │ │ │ ├── cpPivotJoint.h │ │ │ │ │ ├── cpPolyShape.h │ │ │ │ │ ├── cpPolyline.h │ │ │ │ │ ├── cpRatchetJoint.h │ │ │ │ │ ├── cpRobust.h │ │ │ │ │ ├── cpRotaryLimitJoint.h │ │ │ │ │ ├── cpShape.h │ │ │ │ │ ├── cpSimpleMotor.h │ │ │ │ │ ├── cpSlideJoint.h │ │ │ │ │ ├── cpSpace.h │ │ │ │ │ ├── cpSpatialIndex.h │ │ │ │ │ ├── cpTransform.h │ │ │ │ │ └── cpVect.h │ │ │ └── prime.h │ │ └── Physics │ │ │ ├── generated │ │ │ ├── Microsoft.Graphics.Canvas.Brushes.swift │ │ │ ├── Microsoft.Graphics.Canvas.Effects.swift │ │ │ ├── Microsoft.Graphics.Canvas.Geometry.swift │ │ │ ├── Microsoft.Graphics.Canvas.Printing.swift │ │ │ ├── Microsoft.Graphics.Canvas.Svg.swift │ │ │ ├── Microsoft.Graphics.Canvas.Text.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.Composition.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.Xaml.swift │ │ │ ├── Microsoft.Graphics.Canvas.UI.swift │ │ │ ├── Microsoft.Graphics.Canvas.swift │ │ │ ├── Microsoft.UI.Composition.swift │ │ │ ├── Microsoft.UI.Dispatching.swift │ │ │ ├── Microsoft.UI.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Automation.Peers.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.Primitives.swift │ │ │ ├── Microsoft.UI.Xaml.Controls.swift │ │ │ ├── Microsoft.UI.Xaml.Data.swift │ │ │ ├── Microsoft.UI.Xaml.Input.swift │ │ │ ├── Microsoft.UI.Xaml.Markup.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Imaging.swift │ │ │ ├── Microsoft.UI.Xaml.Media.Media3D.swift │ │ │ ├── Microsoft.UI.Xaml.Media.swift │ │ │ ├── Microsoft.UI.Xaml.swift │ │ │ ├── Microsoft.UI.swift │ │ │ ├── Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── Windows.Foundation.Numerics.swift │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.Graphics.DirectX.Direct3D11.swift │ │ │ ├── Windows.Graphics.DirectX.swift │ │ │ ├── Windows.Graphics.Effects.swift │ │ │ ├── Windows.Graphics.Imaging.swift │ │ │ ├── Windows.Graphics.Printing.swift │ │ │ ├── Windows.Storage.Streams.swift │ │ │ ├── Windows.UI.Core.swift │ │ │ ├── Windows.UI.Text.swift │ │ │ ├── Windows.UI.Xaml.Interop.swift │ │ │ ├── Windows.UI.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Effects.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Printing.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Svg.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.Text.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.UI.Xaml.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.UI.swift │ │ │ ├── cg_Microsoft.Graphics.Canvas.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Controls.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Input.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.Animation.swift │ │ │ ├── cg_Microsoft.UI.Xaml.Media.swift │ │ │ ├── cg_Microsoft.UI.Xaml.swift │ │ │ ├── cg_Swift.swift │ │ │ ├── cg_Windows.ApplicationModel.DataTransfer.swift │ │ │ ├── cg_Windows.Foundation.swift │ │ │ └── cg_Windows.Graphics.Effects.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── Power │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── Power │ │ │ ├── generated │ │ │ ├── Microsoft.Windows.System.Power.swift │ │ │ ├── Windows.Foundation.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Microsoft.Windows.System.Power.swift │ │ │ └── cg_Swift.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── SystemIdentification │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── SystemIdentification │ │ │ ├── generated │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.Security.Cryptography.swift │ │ │ ├── Windows.Storage.Streams.swift │ │ │ ├── Windows.System.Profile.swift │ │ │ ├── Windows.System.swift │ │ │ └── __ns.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json ├── Toast │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ │ ├── C │ │ │ ├── include │ │ │ │ ├── C.h │ │ │ │ └── generated.h │ │ │ └── shim.c │ │ └── Toast │ │ │ ├── generated │ │ │ ├── Windows.Data.Xml.Dom.swift │ │ │ ├── Windows.Foundation.swift │ │ │ ├── Windows.Storage.Streams.swift │ │ │ ├── Windows.Storage.swift │ │ │ ├── Windows.System.swift │ │ │ ├── Windows.UI.Notifications.swift │ │ │ ├── __ns.swift │ │ │ ├── cg_Swift.swift │ │ │ ├── cg_Windows.Data.Xml.Dom.swift │ │ │ ├── cg_Windows.Foundation.swift │ │ │ └── cg_Windows.UI.Notifications.swift │ │ │ └── main.swift │ ├── gen.sh │ └── winrt.json └── XamlApp │ ├── Microsoft.WindowsAppRuntime.Bootstrap.dll │ ├── Microsoft.WindowsAppRuntime.Bootstrap.lib │ ├── Package.swift │ ├── Sources │ ├── C │ │ ├── include │ │ │ ├── C.h │ │ │ └── generated.h │ │ └── shim.c │ └── XamlApp │ │ ├── generated │ │ ├── Microsoft.UI.Composition.swift │ │ ├── Microsoft.UI.Dispatching.swift │ │ ├── Microsoft.UI.Input.swift │ │ ├── Microsoft.UI.Xaml.Automation.Peers.swift │ │ ├── Microsoft.UI.Xaml.Controls.Primitives.swift │ │ ├── Microsoft.UI.Xaml.Controls.swift │ │ ├── Microsoft.UI.Xaml.Data.swift │ │ ├── Microsoft.UI.Xaml.Documents.swift │ │ ├── Microsoft.UI.Xaml.Input.swift │ │ ├── Microsoft.UI.Xaml.Markup.swift │ │ ├── Microsoft.UI.Xaml.Media.Animation.swift │ │ ├── Microsoft.UI.Xaml.Media.Media3D.swift │ │ ├── Microsoft.UI.Xaml.Media.swift │ │ ├── Microsoft.UI.Xaml.swift │ │ ├── Microsoft.UI.swift │ │ ├── Windows.ApplicationModel.DataTransfer.swift │ │ ├── Windows.Foundation.Numerics.swift │ │ ├── Windows.Foundation.swift │ │ ├── Windows.UI.Core.swift │ │ ├── Windows.UI.Text.swift │ │ ├── Windows.UI.Xaml.Interop.swift │ │ ├── Windows.UI.swift │ │ ├── __ns.swift │ │ ├── cg_Microsoft.UI.Xaml.Controls.swift │ │ ├── cg_Microsoft.UI.Xaml.Documents.swift │ │ ├── cg_Microsoft.UI.Xaml.Input.swift │ │ ├── cg_Microsoft.UI.Xaml.Media.Animation.swift │ │ ├── cg_Microsoft.UI.Xaml.Media.swift │ │ ├── cg_Microsoft.UI.Xaml.swift │ │ ├── cg_Swift.swift │ │ ├── cg_Windows.ApplicationModel.DataTransfer.swift │ │ └── cg_Windows.Foundation.swift │ │ └── lib.swift │ ├── gen.sh │ └── winrt.json └── WinRT ├── Package.swift └── Sources ├── CWinRT ├── include │ └── CWinRT.h └── shim.c └── WinRT ├── COM ├── IUnknown+Swift.swift ├── IUnknown.swift └── IUnknownRef.swift ├── Future.swift ├── HString.swift ├── HStringStorage.swift ├── IInspectable+Swift.swift ├── IInspectable.swift ├── Object.swift ├── Runtime+Swift.swift ├── Setup.swift ├── Support ├── COM+Extensions.swift ├── Error.swift ├── ErrorHandling.swift ├── RawTyped.swift ├── Swift+Extensions.swift └── WinSDK+Extensions.swift └── TrustLevel+Swift.swift /.gitattributes: -------------------------------------------------------------------------------- 1 | *.swift text eol=lf 2 | *.md text eol=lf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # git ls-files --others --exclude-from=.git/info/exclude 2 | # Lines that start with '#' are comments. 3 | # For a project mostly in C, the following would be a good set of 4 | # exclude patterns (uncomment them if you want to use them): 5 | 6 | .*.sw[nop] 7 | *~ 8 | 9 | /build/ 10 | 11 | /package.resolved 12 | /Packages/ 13 | .build/ 14 | 15 | .vscode/ 16 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, Saleem Abdulrasool 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Notes on this fork 3 | ----------- 4 | 5 | This fork of compnerd/SwiftWinRT contains some work 6 | I've been doing toward automatic generation of the 7 | Swift bindings for WinRT. It has changed very 8 | significantly from the original repo. 9 | 10 | There are five SwiftPM packages here: 11 | 12 | - WinRT contains the core definitions for supporting 13 | IInspectable and such. It is largely similar to 14 | the original repo. 15 | 16 | - WindowsSdk contains automatically generated bindings 17 | for a bunch of WinRT things in the Windows SDK. 18 | 19 | - WindowsApp contains automatically generated bindings 20 | for a bunch of WinRT things in the Windows App SDK. 21 | 22 | - Win2D contains automatically generated bindings 23 | for Win2D. 24 | 25 | - Samples contains several sample apps. 26 | 27 | ---- 28 | 29 | None of the generated bindings are complete. Generally 30 | speaking, I can generate bindings for any of the 31 | WinRT types in Windows SDK, Windows App SDK, or Win2D, 32 | and the resulting Swift code will compile. However, 33 | the size of the result is so large it causes the Windows 34 | linker to fail because of the 65,536 symbols limit. 35 | I'm still investigating ways around this. 36 | 37 | The two original samples are still here and have been 38 | modified a little bit to build with the new bindings. 39 | 40 | A new toast notification sample has been added. 41 | 42 | The most complete sample is MazeGame, a Swift port 43 | of the Win2DMazeGame sample from Microsoft. It 44 | uses WinUI3 for a simple GUI shell and Win2D for 45 | the game itself. 46 | 47 | I'm using Swift 5.6.1, and I have not tested with 48 | any other version. 49 | 50 | -------------------------------------------------------------------------------- /Samples/Calc/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Calc/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/Calc/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Calc/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/Calc/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .library(name: "Calc", type: .dynamic, targets: ["Calc"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .target(name: "Calc", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Microsoft.UI.Dispatching.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Dispatching { 10 | // type: Microsoft.UI.Dispatching.DispatcherQueue 11 | // runtime class 12 | public class DispatcherQueue 13 | : 14 | WinRT.Object 15 | { 16 | private var _self : Microsoft.UI.Dispatching.IDispatcherQueue; 17 | public init(plok: Microsoft.UI.Dispatching.IDispatcherQueue?) throws { 18 | _self = plok! 19 | try super.init(plok: _self.QueryInterface()) 20 | } 21 | public func Interface() -> Microsoft.UI.Dispatching.IDispatcherQueue { return _self; } 22 | // static interface not needed: Microsoft.UI.Dispatching.IDispatcherQueueStatics 23 | // method not needed: CreateTimer 24 | // method not needed: TryEnqueue 25 | // method not needed: TryEnqueue 26 | // method not needed: add_ShutdownStarting 27 | // method not needed: remove_ShutdownStarting 28 | // method not needed: add_ShutdownCompleted 29 | // method not needed: remove_ShutdownCompleted 30 | // instance interface not needed: Microsoft.UI.Dispatching.IDispatcherQueue2 31 | } 32 | 33 | // type: Microsoft.UI.Dispatching.IDispatcherQueue 34 | // interface type 35 | open class IDispatcherQueue 36 | : 37 | WinRT.IInspectable 38 | { 39 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xf6ebf8fa, Data2: 0xbe1c, Data3 : 0x5bf6, Data4 : (0xa4, 0x67, 0x73, 0xda, 0x28, 0x73, 0x8a, 0xe8)) } 40 | // method not needed: CreateTimer 41 | // method not needed: TryEnqueue 42 | // method not needed: TryEnqueueWithPriority 43 | // method not needed: add_ShutdownStarting 44 | // method not needed: remove_ShutdownStarting 45 | // method not needed: add_ShutdownCompleted 46 | // method not needed: remove_ShutdownCompleted 47 | } // IDispatcherQueue 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Microsoft.UI.Input.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Input { 10 | // type: Microsoft.UI.Input.IInputCursor 11 | // interface type 12 | open class IInputCursor 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x359b15f9, Data2: 0x19c2, Data3 : 0x5714, Data4 : (0x84, 0x32, 0x75, 0x17, 0x68, 0x26, 0x40, 0x6b)) } 17 | } // IInputCursor 18 | 19 | 20 | // type: Microsoft.UI.Input.IPointerPoint 21 | // interface type 22 | open class IPointerPoint 23 | : 24 | WinRT.IInspectable 25 | { 26 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x0d430ee6, Data2: 0x252c, Data3 : 0x59a4, Data4 : (0xb2, 0xa2, 0xd4, 0x42, 0x64, 0xdc, 0x6a, 0x40)) } 27 | // method not needed: get_FrameId 28 | // method not needed: get_IsInContact 29 | // method not needed: get_PointerDeviceType 30 | // method not needed: get_PointerId 31 | // method not needed: get_Position 32 | // method not needed: get_Properties 33 | // method not needed: get_Timestamp 34 | // method not needed: GetTransformedPoint 35 | } // IPointerPoint 36 | 37 | 38 | // type: Microsoft.UI.Input.InputCursor 39 | // runtime class 40 | open class InputCursor 41 | : 42 | WinRT.Object 43 | { 44 | private var _self : Microsoft.UI.Input.IInputCursor; 45 | public init(plok: Microsoft.UI.Input.IInputCursor?) throws { 46 | _self = plok! 47 | try super.init(plok: _self.QueryInterface()) 48 | } 49 | public func Interface() -> Microsoft.UI.Input.IInputCursor { return _self; } 50 | // COMPOSABLE: Microsoft.UI.Input.IInputCursorFactory 51 | // composable interface not needed: Microsoft.UI.Input.IInputCursorFactory 52 | // static interface not needed: Microsoft.UI.Input.IInputCursorStatics 53 | // instance interface not needed: Windows.Foundation.IClosable 54 | } 55 | 56 | // type: Microsoft.UI.Input.PointerPoint 57 | // runtime class 58 | public class PointerPoint 59 | : 60 | WinRT.Object 61 | { 62 | private var _self : Microsoft.UI.Input.IPointerPoint; 63 | public init(plok: Microsoft.UI.Input.IPointerPoint?) throws { 64 | _self = plok! 65 | try super.init(plok: _self.QueryInterface()) 66 | } 67 | public func Interface() -> Microsoft.UI.Input.IPointerPoint { return _self; } 68 | // method not needed: get_FrameId 69 | // method not needed: get_IsInContact 70 | // method not needed: get_PointerDeviceType 71 | // method not needed: get_PointerId 72 | // method not needed: get_Position 73 | // method not needed: get_Properties 74 | // method not needed: get_Timestamp 75 | // method not needed: GetTransformedPoint 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Windows.ApplicationModel.DataTransfer.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.ApplicationModel.DataTransfer { 10 | // type: Windows.ApplicationModel.DataTransfer.DataPackageOperation 11 | // enum type 12 | public typealias DataPackageOperation = _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation; 13 | 14 | } 15 | extension Windows.ApplicationModel.DataTransfer.DataPackageOperation { 16 | public static var None : Self { 17 | get { 18 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_None; 19 | } 20 | } 21 | public static var Copy : Self { 22 | get { 23 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Copy; 24 | } 25 | } 26 | public static var Move : Self { 27 | get { 28 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Move; 29 | } 30 | } 31 | public static var Link : Self { 32 | get { 33 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Link; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Windows.Foundation.Collections.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Foundation.Collections { 10 | // type: Windows.Foundation.Collections.IVectorChangedEventArgs 11 | // interface type 12 | open class IVectorChangedEventArgs 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x575933df, Data2: 0x34fe, Data3 : 0x4480, Data4 : (0xaf, 0x15, 0x07, 0x69, 0x1f, 0x3d, 0x5d, 0x9b)) } 17 | // method not needed: get_CollectionChange 18 | // method not needed: get_Index 19 | } // IVectorChangedEventArgs 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Windows.Foundation.Numerics.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Foundation.Numerics { 10 | // type: Windows.Foundation.Numerics.Matrix4x4 11 | // struct type 12 | public typealias Matrix4x4 = _q_CWindows_CFoundation_CNumerics_CMatrix4x4; 13 | 14 | // type: Windows.Foundation.Numerics.Vector2 15 | // struct type 16 | public typealias Vector2 = _q_CWindows_CFoundation_CNumerics_CVector2; 17 | 18 | // type: Windows.Foundation.Numerics.Vector3 19 | // struct type 20 | public typealias Vector3 = _q_CWindows_CFoundation_CNumerics_CVector3; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Windows.UI.Xaml.Interop.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Xaml.Interop { 10 | // type: Windows.UI.Xaml.Interop.TypeKind 11 | // enum type 12 | public typealias TypeKind = _q_CWindows_CUI_CXaml_CInterop_CTypeKind; 13 | 14 | // type: Windows.UI.Xaml.Interop.TypeName 15 | // struct type 16 | public typealias TypeName = _q_CWindows_CUI_CXaml_CInterop_CTypeName; 17 | 18 | } 19 | extension Windows.UI.Xaml.Interop.TypeKind { 20 | public static var Primitive : Self { 21 | get { 22 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Primitive; 23 | } 24 | } 25 | public static var Metadata : Self { 26 | get { 27 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Metadata; 28 | } 29 | } 30 | public static var Custom : Self { 31 | get { 32 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Custom; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/Windows.UI.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI { 10 | // type: Windows.UI.Color 11 | // struct type 12 | public typealias Color = _q_CWindows_CUI_CColor; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Microsoft { } 6 | extension Microsoft { public struct UI { } } 7 | extension Microsoft.UI { public struct Composition { } } 8 | extension Microsoft.UI { public struct Dispatching { } } 9 | extension Microsoft.UI { public struct Input { } } 10 | extension Microsoft.UI { public struct Xaml { } } 11 | extension Microsoft.UI.Xaml { public struct Automation { } } 12 | extension Microsoft.UI.Xaml.Automation { public struct Peers { } } 13 | extension Microsoft.UI.Xaml { public struct Controls { } } 14 | extension Microsoft.UI.Xaml.Controls { public struct Primitives { } } 15 | extension Microsoft.UI.Xaml { public struct Data { } } 16 | extension Microsoft.UI.Xaml { public struct Documents { } } 17 | extension Microsoft.UI.Xaml { public struct Input { } } 18 | extension Microsoft.UI.Xaml { public struct Markup { } } 19 | extension Microsoft.UI.Xaml { public struct Media { } } 20 | extension Microsoft.UI.Xaml.Media { public struct Animation { } } 21 | extension Microsoft.UI.Xaml.Media { public struct Media3D { } } 22 | public struct Windows { } 23 | extension Windows { public struct ApplicationModel { } } 24 | extension Windows.ApplicationModel { public struct DataTransfer { } } 25 | extension Windows { public struct Foundation { } } 26 | extension Windows.Foundation { public struct Collections { } } 27 | extension Windows.Foundation { public struct Numerics { } } 28 | extension Windows { public struct System { } } 29 | extension Windows { public struct UI { } } 30 | extension Windows.UI { public struct Core { } } 31 | extension Windows.UI { public struct Text { } } 32 | extension Windows.UI { public struct Xaml { } } 33 | extension Windows.UI.Xaml { public struct Interop { } } 34 | -------------------------------------------------------------------------------- /Samples/Calc/Sources/Calc/generated/cg_Windows.Foundation.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xae44597e, Data2: 0xd411, Data3 : 0x5b7f, Data4 : (0xbb, 0xec, 0x6a, 0x96, 0xc9, 0x4a, 0x10, 0x7a)) } 16 | // method not needed: First 17 | } // IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 18 | // closed interface type 19 | public class IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 20 | : 21 | WinRT.IInspectable 22 | { 23 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x377f6162, Data2: 0x6e4d, Data3 : 0x574e, Data4 : (0xbf, 0x01, 0x77, 0xf4, 0xfd, 0x02, 0x1d, 0x0e)) } 24 | // method not needed: get_Current 25 | // method not needed: get_HasCurrent 26 | // method not needed: MoveNext 27 | // method not needed: GetMany 28 | } // IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 29 | // closed interface type 30 | public class IIterable_1__q_CWindows_CFoundation_CPoint 31 | : 32 | WinRT.IInspectable 33 | { 34 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc192280d, Data2: 0x3a09, Data3 : 0x5423, Data4 : (0x9d, 0xc5, 0x67, 0xb8, 0x3e, 0xbd, 0xe4, 0x1d)) } 35 | // method not needed: First 36 | } // IIterable_1__q_CWindows_CFoundation_CPoint 37 | // closed interface type 38 | public class IIterator_1__q_CWindows_CFoundation_CPoint 39 | : 40 | WinRT.IInspectable 41 | { 42 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc602b59e, Data2: 0x0a8e, Data3 : 0x5e99, Data4 : (0xb4, 0x78, 0x2b, 0x56, 0x45, 0x85, 0x27, 0x8d)) } 43 | // method not needed: get_Current 44 | // method not needed: get_HasCurrent 45 | // method not needed: MoveNext 46 | // method not needed: GetMany 47 | } // IIterator_1__q_CWindows_CFoundation_CPoint 48 | } 49 | -------------------------------------------------------------------------------- /Samples/Calc/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/Calc/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/Calc/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Microsoft.UI.Xaml.Window", 7 | "Microsoft.UI.Xaml.DispatcherTimer", 8 | "Microsoft.UI.Xaml.Controls.TextBlock", 9 | "Microsoft.UI.Xaml.Controls.TextBox", 10 | "Microsoft.UI.Xaml.Controls.ListView", 11 | "Microsoft.UI.Xaml.Controls.Grid", 12 | "Microsoft.UI.Xaml.Controls.ColumnDefinition", 13 | "Microsoft.UI.Xaml.Controls.RowDefinition", 14 | "Microsoft.UI.Xaml.Controls.Border", 15 | "Microsoft.UI.Xaml.Controls.ItemClickEventArgs", 16 | "Microsoft.UI.Xaml.Input.KeyRoutedEventArgs", 17 | "Microsoft.UI.Xaml.Media.SolidColorBrush", 18 | "Microsoft.UI.Colors" 19 | ], 20 | "interfaces" : 21 | [ 22 | "Microsoft.UI.Xaml.Markup.IXamlMetadataProvider", 23 | "Microsoft.UI.Xaml.Markup.IXamlType", 24 | "Microsoft.UI.Xaml.Markup.IXamlMember" 25 | ], 26 | "namespaces" : 27 | [ 28 | ], 29 | "blacklist" : 30 | [ 31 | ] 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Samples/Canvas/Microsoft.Graphics.Canvas.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Canvas/Microsoft.Graphics.Canvas.dll -------------------------------------------------------------------------------- /Samples/Canvas/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Canvas/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/Canvas/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Canvas/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/Canvas/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "Canvas", targets: ["Canvas"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "Canvas", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Microsoft.UI.Dispatching.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Dispatching { 10 | // type: Microsoft.UI.Dispatching.DispatcherQueue 11 | // runtime class 12 | public class DispatcherQueue 13 | : 14 | WinRT.Object 15 | { 16 | private var _self : Microsoft.UI.Dispatching.IDispatcherQueue; 17 | public init(plok: Microsoft.UI.Dispatching.IDispatcherQueue?) throws { 18 | _self = plok! 19 | try super.init(plok: _self.QueryInterface()) 20 | } 21 | public func Interface() -> Microsoft.UI.Dispatching.IDispatcherQueue { return _self; } 22 | // static interface not needed: Microsoft.UI.Dispatching.IDispatcherQueueStatics 23 | // method not needed: CreateTimer 24 | // method not needed: TryEnqueue 25 | // method not needed: TryEnqueue 26 | // method not needed: add_ShutdownStarting 27 | // method not needed: remove_ShutdownStarting 28 | // method not needed: add_ShutdownCompleted 29 | // method not needed: remove_ShutdownCompleted 30 | // instance interface not needed: Microsoft.UI.Dispatching.IDispatcherQueue2 31 | } 32 | 33 | // type: Microsoft.UI.Dispatching.IDispatcherQueue 34 | // interface type 35 | open class IDispatcherQueue 36 | : 37 | WinRT.IInspectable 38 | { 39 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xf6ebf8fa, Data2: 0xbe1c, Data3 : 0x5bf6, Data4 : (0xa4, 0x67, 0x73, 0xda, 0x28, 0x73, 0x8a, 0xe8)) } 40 | // method not needed: CreateTimer 41 | // method not needed: TryEnqueue 42 | // method not needed: TryEnqueueWithPriority 43 | // method not needed: add_ShutdownStarting 44 | // method not needed: remove_ShutdownStarting 45 | // method not needed: add_ShutdownCompleted 46 | // method not needed: remove_ShutdownCompleted 47 | } // IDispatcherQueue 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.ApplicationModel.DataTransfer.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.ApplicationModel.DataTransfer { 10 | // type: Windows.ApplicationModel.DataTransfer.DataPackageOperation 11 | // enum type 12 | public typealias DataPackageOperation = _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation; 13 | 14 | } 15 | extension Windows.ApplicationModel.DataTransfer.DataPackageOperation { 16 | public static var None : Self { 17 | get { 18 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_None; 19 | } 20 | } 21 | public static var Copy : Self { 22 | get { 23 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Copy; 24 | } 25 | } 26 | public static var Move : Self { 27 | get { 28 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Move; 29 | } 30 | } 31 | public static var Link : Self { 32 | get { 33 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Link; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.Foundation.Numerics.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Foundation.Numerics { 10 | // type: Windows.Foundation.Numerics.Matrix3x2 11 | // struct type 12 | public typealias Matrix3x2 = _q_CWindows_CFoundation_CNumerics_CMatrix3x2; 13 | 14 | // type: Windows.Foundation.Numerics.Matrix4x4 15 | // struct type 16 | public typealias Matrix4x4 = _q_CWindows_CFoundation_CNumerics_CMatrix4x4; 17 | 18 | // type: Windows.Foundation.Numerics.Vector2 19 | // struct type 20 | public typealias Vector2 = _q_CWindows_CFoundation_CNumerics_CVector2; 21 | 22 | // type: Windows.Foundation.Numerics.Vector3 23 | // struct type 24 | public typealias Vector3 = _q_CWindows_CFoundation_CNumerics_CVector3; 25 | 26 | // type: Windows.Foundation.Numerics.Vector4 27 | // struct type 28 | public typealias Vector4 = _q_CWindows_CFoundation_CNumerics_CVector4; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.Graphics.DirectX.Direct3D11.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.DirectX.Direct3D11 { 10 | // type: Windows.Graphics.DirectX.Direct3D11.Direct3DMultisampleDescription 11 | // struct type 12 | public typealias Direct3DMultisampleDescription = _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DMultisampleDescription; 13 | 14 | // type: Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription 15 | // struct type 16 | public typealias Direct3DSurfaceDescription = _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription; 17 | 18 | // type: Windows.Graphics.DirectX.Direct3D11.IDirect3DDevice 19 | // interface type 20 | open class IDirect3DDevice 21 | : 22 | WinRT.IInspectable 23 | { 24 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xa37624ab, Data2: 0x8d5f, Data3 : 0x4650, Data4 : (0x9d, 0x3e, 0x9e, 0xae, 0x3d, 0x9b, 0xc6, 0x70)) } 25 | // void Trim() 26 | private func _n_Trim() throws { 27 | return try perform(as: _q_CWindows_CGraphics_CDirectX_CDirect3D11_CIDirect3DDevice.self) { pThis in 28 | try CHECKED(pThis.pointee.lpVtbl.pointee.Trim(pThis)) 29 | } 30 | } 31 | public func Trim() throws -> Void { 32 | try self._n_Trim(); 33 | } 34 | } // IDirect3DDevice 35 | 36 | 37 | // type: Windows.Graphics.DirectX.Direct3D11.IDirect3DSurface 38 | // interface type 39 | open class IDirect3DSurface 40 | : 41 | WinRT.IInspectable 42 | { 43 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x0bf4a146, Data2: 0x13c1, Data3 : 0x4694, Data4 : (0xbe, 0xe3, 0x7a, 0xbf, 0x15, 0xea, 0xf5, 0x86)) } 44 | // [IsSpecialName] Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription get_Description() 45 | private func _n_get_Description(_ __presult: UnsafeMutablePointer<_q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription>?) throws { 46 | return try perform(as: _q_CWindows_CGraphics_CDirectX_CDirect3D11_CIDirect3DSurface.self) { pThis in 47 | try CHECKED(pThis.pointee.lpVtbl.pointee.get_Description(pThis, __presult)) 48 | } 49 | } 50 | public func get_Description() throws -> Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription { 51 | var __result : _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription = _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription(Width: 0, Height: 0, Format: _q_CWindows_CGraphics_CDirectX_CDirectXPixelFormat_Unknown, MultisampleDescription: _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DMultisampleDescription(Count: 0, Quality: 0)); 52 | try self._n_get_Description(&__result); 53 | return __result; 54 | } 55 | public var Description : Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription { 56 | get throws { 57 | return try get_Description(); 58 | } 59 | } 60 | } // IDirect3DSurface 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.Graphics.Effects.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.Effects { 10 | // type: Windows.Graphics.Effects.IGraphicsEffect 11 | // interface type 12 | open class IGraphicsEffect 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xcb51c0ce, Data2: 0x8fe6, Data3 : 0x4636, Data4 : (0xb2, 0x02, 0x86, 0x1f, 0xaa, 0x07, 0xd8, 0xf3)) } 17 | // [IsSpecialName] System.String get_Name() 18 | private func _n_get_Name(_ __presult: UnsafeMutablePointer>?) throws { 19 | return try perform(as: _q_CWindows_CGraphics_CEffects_CIGraphicsEffect.self) { pThis in 20 | try CHECKED(pThis.pointee.lpVtbl.pointee.get_Name(pThis, __presult)) 21 | } 22 | } 23 | public func get_Name() throws -> Swift.String { 24 | var __result : Optional = nil; 25 | try self._n_get_Name(&__result); 26 | return Swift.String(from: __result); 27 | } 28 | // [IsSpecialName] void put_Name(System.String) 29 | private func _n_put_Name(_ name : Optional) throws { 30 | return try perform(as: _q_CWindows_CGraphics_CEffects_CIGraphicsEffect.self) { pThis in 31 | try CHECKED(pThis.pointee.lpVtbl.pointee.put_Name(pThis, name)) 32 | } 33 | } 34 | public func put_Name(name : Optional) throws -> Void { 35 | let __hstr_name = try HString(name!); 36 | return try withExtendedLifetime(__hstr_name) { 37 | try self._n_put_Name(__hstr_name.Raw()); 38 | } 39 | } 40 | public var Name : Swift.String { 41 | get throws { 42 | return try get_Name(); 43 | } 44 | } 45 | } // IGraphicsEffect 46 | 47 | 48 | // type: Windows.Graphics.Effects.IGraphicsEffectSource 49 | // interface type 50 | open class IGraphicsEffectSource 51 | : 52 | WinRT.IInspectable 53 | { 54 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x2d8f9ddc, Data2: 0x4339, Data3 : 0x4eb9, Data4 : (0x92, 0x16, 0xf9, 0xde, 0xb7, 0x56, 0x58, 0xa2)) } 55 | } // IGraphicsEffectSource 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.Graphics.Printing.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.Printing { 10 | // type: Windows.Graphics.Printing.IPrintTaskOptionsCore 11 | // interface type 12 | open class IPrintTaskOptionsCore 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x1bdbb474, Data2: 0x4ed1, Data3 : 0x41eb, Data4 : (0xbe, 0x3c, 0x72, 0xd1, 0x8e, 0xd6, 0x73, 0x37)) } 17 | // method not needed: GetPageDescription 18 | } // IPrintTaskOptionsCore 19 | 20 | 21 | // type: Windows.Graphics.Printing.PrintTaskOptions 22 | // runtime class 23 | public class PrintTaskOptions 24 | : 25 | WinRT.Object 26 | { 27 | private var _self : Windows.Graphics.Printing.IPrintTaskOptionsCore; 28 | public init(plok: Windows.Graphics.Printing.IPrintTaskOptionsCore?) throws { 29 | _self = plok! 30 | try super.init(plok: _self.QueryInterface()) 31 | } 32 | public func Interface() -> Windows.Graphics.Printing.IPrintTaskOptionsCore { return _self; } 33 | // method not needed: GetPageDescription 34 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptionsCoreProperties 35 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptionsCoreUIConfiguration 36 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptions 37 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptions2 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.Storage.Streams.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage.Streams { 10 | // type: Windows.Storage.Streams.IBuffer 11 | // interface type 12 | open class IBuffer 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe0, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 17 | // method not needed: get_Capacity 18 | // method not needed: get_Length 19 | // method not needed: put_Length 20 | } // IBuffer 21 | 22 | 23 | // type: Windows.Storage.Streams.IRandomAccessStream 24 | // interface type 25 | open class IRandomAccessStream 26 | : 27 | WinRT.IInspectable 28 | { 29 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe1, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 30 | // method not needed: get_Size 31 | // method not needed: put_Size 32 | // method not needed: GetInputStreamAt 33 | // method not needed: GetOutputStreamAt 34 | // method not needed: get_Position 35 | // method not needed: Seek 36 | // method not needed: CloneStream 37 | // method not needed: get_CanRead 38 | // method not needed: get_CanWrite 39 | } // IRandomAccessStream 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.UI.Text.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Text { 10 | // type: Windows.UI.Text.FontStretch 11 | // enum type 12 | public typealias FontStretch = _q_CWindows_CUI_CText_CFontStretch; 13 | 14 | // type: Windows.UI.Text.FontStyle 15 | // enum type 16 | public typealias FontStyle = _q_CWindows_CUI_CText_CFontStyle; 17 | 18 | // type: Windows.UI.Text.FontWeight 19 | // struct type 20 | public typealias FontWeight = _q_CWindows_CUI_CText_CFontWeight; 21 | 22 | } 23 | extension Windows.UI.Text.FontStretch { 24 | public static var Undefined : Self { 25 | get { 26 | return _q_CWindows_CUI_CText_CFontStretch_Undefined; 27 | } 28 | } 29 | public static var UltraCondensed : Self { 30 | get { 31 | return _q_CWindows_CUI_CText_CFontStretch_UltraCondensed; 32 | } 33 | } 34 | public static var ExtraCondensed : Self { 35 | get { 36 | return _q_CWindows_CUI_CText_CFontStretch_ExtraCondensed; 37 | } 38 | } 39 | public static var Condensed : Self { 40 | get { 41 | return _q_CWindows_CUI_CText_CFontStretch_Condensed; 42 | } 43 | } 44 | public static var SemiCondensed : Self { 45 | get { 46 | return _q_CWindows_CUI_CText_CFontStretch_SemiCondensed; 47 | } 48 | } 49 | public static var Normal : Self { 50 | get { 51 | return _q_CWindows_CUI_CText_CFontStretch_Normal; 52 | } 53 | } 54 | public static var SemiExpanded : Self { 55 | get { 56 | return _q_CWindows_CUI_CText_CFontStretch_SemiExpanded; 57 | } 58 | } 59 | public static var Expanded : Self { 60 | get { 61 | return _q_CWindows_CUI_CText_CFontStretch_Expanded; 62 | } 63 | } 64 | public static var ExtraExpanded : Self { 65 | get { 66 | return _q_CWindows_CUI_CText_CFontStretch_ExtraExpanded; 67 | } 68 | } 69 | public static var UltraExpanded : Self { 70 | get { 71 | return _q_CWindows_CUI_CText_CFontStretch_UltraExpanded; 72 | } 73 | } 74 | } 75 | extension Windows.UI.Text.FontStyle { 76 | public static var Normal : Self { 77 | get { 78 | return _q_CWindows_CUI_CText_CFontStyle_Normal; 79 | } 80 | } 81 | public static var Oblique : Self { 82 | get { 83 | return _q_CWindows_CUI_CText_CFontStyle_Oblique; 84 | } 85 | } 86 | public static var Italic : Self { 87 | get { 88 | return _q_CWindows_CUI_CText_CFontStyle_Italic; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.UI.Xaml.Interop.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Xaml.Interop { 10 | // type: Windows.UI.Xaml.Interop.TypeKind 11 | // enum type 12 | public typealias TypeKind = _q_CWindows_CUI_CXaml_CInterop_CTypeKind; 13 | 14 | // type: Windows.UI.Xaml.Interop.TypeName 15 | // struct type 16 | public typealias TypeName = _q_CWindows_CUI_CXaml_CInterop_CTypeName; 17 | 18 | } 19 | extension Windows.UI.Xaml.Interop.TypeKind { 20 | public static var Primitive : Self { 21 | get { 22 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Primitive; 23 | } 24 | } 25 | public static var Metadata : Self { 26 | get { 27 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Metadata; 28 | } 29 | } 30 | public static var Custom : Self { 31 | get { 32 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Custom; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/Windows.UI.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI { 10 | // type: Windows.UI.Color 11 | // struct type 12 | public typealias Color = _q_CWindows_CUI_CColor; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Microsoft { } 6 | extension Microsoft { public struct Graphics { } } 7 | extension Microsoft.Graphics { public struct Canvas { } } 8 | extension Microsoft.Graphics.Canvas { public struct Brushes { } } 9 | extension Microsoft.Graphics.Canvas { public struct Effects { } } 10 | extension Microsoft.Graphics.Canvas { public struct Geometry { } } 11 | extension Microsoft.Graphics.Canvas { public struct Printing { } } 12 | extension Microsoft.Graphics.Canvas { public struct Svg { } } 13 | extension Microsoft.Graphics.Canvas { public struct Text { } } 14 | extension Microsoft.Graphics.Canvas { public struct UI { } } 15 | extension Microsoft.Graphics.Canvas.UI { public struct Composition { } } 16 | extension Microsoft.Graphics.Canvas.UI { public struct Xaml { } } 17 | extension Microsoft { public struct UI { } } 18 | extension Microsoft.UI { public struct Composition { } } 19 | extension Microsoft.UI { public struct Dispatching { } } 20 | extension Microsoft.UI { public struct Input { } } 21 | extension Microsoft.UI { public struct Xaml { } } 22 | extension Microsoft.UI.Xaml { public struct Automation { } } 23 | extension Microsoft.UI.Xaml.Automation { public struct Peers { } } 24 | extension Microsoft.UI.Xaml { public struct Controls { } } 25 | extension Microsoft.UI.Xaml.Controls { public struct Primitives { } } 26 | extension Microsoft.UI.Xaml { public struct Data { } } 27 | extension Microsoft.UI.Xaml { public struct Input { } } 28 | extension Microsoft.UI.Xaml { public struct Markup { } } 29 | extension Microsoft.UI.Xaml { public struct Media { } } 30 | extension Microsoft.UI.Xaml.Media { public struct Animation { } } 31 | extension Microsoft.UI.Xaml.Media { public struct Imaging { } } 32 | extension Microsoft.UI.Xaml.Media { public struct Media3D { } } 33 | public struct Windows { } 34 | extension Windows { public struct ApplicationModel { } } 35 | extension Windows.ApplicationModel { public struct DataTransfer { } } 36 | extension Windows { public struct Foundation { } } 37 | extension Windows.Foundation { public struct Collections { } } 38 | extension Windows.Foundation { public struct Numerics { } } 39 | extension Windows { public struct Graphics { } } 40 | extension Windows.Graphics { public struct DirectX { } } 41 | extension Windows.Graphics.DirectX { public struct Direct3D11 { } } 42 | extension Windows.Graphics { public struct Effects { } } 43 | extension Windows.Graphics { public struct Imaging { } } 44 | extension Windows.Graphics { public struct Printing { } } 45 | extension Windows { public struct Storage { } } 46 | extension Windows.Storage { public struct Streams { } } 47 | extension Windows { public struct UI { } } 48 | extension Windows.UI { public struct Core { } } 49 | extension Windows.UI { public struct Text { } } 50 | extension Windows.UI { public struct Xaml { } } 51 | extension Windows.UI.Xaml { public struct Interop { } } 52 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/cg_Microsoft.Graphics.Canvas.Effects.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CMicrosoft_CGraphics_CCanvas_CEffects_CColorManagementSimpleProfile 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x41db10c7, Data2: 0xf02c, Data3 : 0x5d7f, Data4 : (0xa1, 0x2e, 0x4e, 0x05, 0x04, 0x73, 0x88, 0xe7)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CMicrosoft_CGraphics_CCanvas_CEffects_CColorManagementSimpleProfile 18 | } 19 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/generated/cg_Windows.Foundation.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CWindows_CFoundation_CRect 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x80423f11, Data2: 0x054f, Data3 : 0x5eac, Data4 : (0xaf, 0xd3, 0x63, 0xb6, 0xce, 0x15, 0xe7, 0x7b)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CWindows_CFoundation_CRect 18 | // closed interface type 19 | public class IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 20 | : 21 | WinRT.IInspectable 22 | { 23 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xae44597e, Data2: 0xd411, Data3 : 0x5b7f, Data4 : (0xbb, 0xec, 0x6a, 0x96, 0xc9, 0x4a, 0x10, 0x7a)) } 24 | // method not needed: First 25 | } // IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 26 | // closed interface type 27 | public class IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 28 | : 29 | WinRT.IInspectable 30 | { 31 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x377f6162, Data2: 0x6e4d, Data3 : 0x574e, Data4 : (0xbf, 0x01, 0x77, 0xf4, 0xfd, 0x02, 0x1d, 0x0e)) } 32 | // method not needed: get_Current 33 | // method not needed: get_HasCurrent 34 | // method not needed: MoveNext 35 | // method not needed: GetMany 36 | } // IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 37 | // closed interface type 38 | public class IIterable_1__q_CWindows_CFoundation_CPoint 39 | : 40 | WinRT.IInspectable 41 | { 42 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc192280d, Data2: 0x3a09, Data3 : 0x5423, Data4 : (0x9d, 0xc5, 0x67, 0xb8, 0x3e, 0xbd, 0xe4, 0x1d)) } 43 | // method not needed: First 44 | } // IIterable_1__q_CWindows_CFoundation_CPoint 45 | // closed interface type 46 | public class IIterator_1__q_CWindows_CFoundation_CPoint 47 | : 48 | WinRT.IInspectable 49 | { 50 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc602b59e, Data2: 0x0a8e, Data3 : 0x5e99, Data4 : (0xb4, 0x78, 0x2b, 0x56, 0x45, 0x85, 0x27, 0x8d)) } 51 | // method not needed: get_Current 52 | // method not needed: get_HasCurrent 53 | // method not needed: MoveNext 54 | // method not needed: GetMany 55 | } // IIterator_1__q_CWindows_CFoundation_CPoint 56 | } 57 | -------------------------------------------------------------------------------- /Samples/Canvas/Sources/Canvas/main.swift: -------------------------------------------------------------------------------- 1 | 2 | import WinRT 3 | 4 | class MyApp : Microsoft.UI.Xaml.impl_Application { 5 | override func OnLaunched(args : Optional) throws -> Void 6 | { 7 | let w = try Microsoft.UI.Xaml.Window(); 8 | try w.put_Title(value: "Hello from Swift"); 9 | 10 | let canvas = try Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl() 11 | let textFormat = try Microsoft.Graphics.Canvas.Text.CanvasTextFormat() 12 | try textFormat.put_FontSize(value: 32) 13 | _ = try canvas.add_Draw 14 | { 15 | (sender, args: Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs?) in 16 | 17 | try args!.DrawingSession!.DrawText(text: "Win2D with Swift", x: 0, y: 0, color: Microsoft.UI.Colors.Black, format: textFormat); 18 | try args!.DrawingSession!.FillCircle(x: 100, y: 100, radius: 50, color: Microsoft.UI.Colors.Orange); 19 | try args!.DrawingSession!.FillEllipse(x: 200, y: 200, radiusX: 50, radiusY: 30, color: Microsoft.UI.Colors.Purple); 20 | try args!.DrawingSession!.FillRoundedRectangle(x: 300, y: 300, w: 80, h: 40, radiusX: 10, radiusY: 10, color: Microsoft.UI.Colors.Blue); 21 | try args!.DrawingSession!.FillRectangle(x: 400, y: 50, w: 80, h: 200, color: Microsoft.UI.Colors.DarkGreen); 22 | } 23 | try canvas.put_ClearColor(value: Microsoft.UI.Colors.LightBlue); 24 | 25 | try w.put_Content(value: canvas); 26 | 27 | try w.Activate(); 28 | } 29 | } 30 | 31 | @main 32 | class App { 33 | public static func main() async throws { 34 | try prepare_win2d() 35 | try RoInitialize() 36 | try WindowsAppSdkBootstrapInitialize() 37 | 38 | try Microsoft.UI.Xaml.Application.Start 39 | { 40 | _ in 41 | _ = try MyApp(); 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Samples/Canvas/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/Canvas/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/Canvas/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Microsoft.UI.Xaml.Application", 7 | "Microsoft.UI.Xaml.Window", 8 | "Microsoft.UI.Xaml.DispatcherTimer", 9 | "Microsoft.UI.Colors" 10 | ], 11 | "interfaces" : 12 | [ 13 | "Microsoft.UI.Xaml.Markup.IXamlMetadataProvider", 14 | "Microsoft.UI.Xaml.Markup.IXamlType", 15 | "Microsoft.UI.Xaml.Markup.IXamlMember" 16 | ], 17 | "namespaces" : 18 | [ 19 | "Microsoft.Graphics.Canvas" 20 | ], 21 | "blacklist" : 22 | [ 23 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11Surface", 24 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11SurfaceWithDpi", 25 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11SurfaceWithDpiAndAlpha" 26 | ] 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/DispatcherQueue/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/DispatcherQueue/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "DispatcherQueue", targets: ["DispatcherQueue"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "DispatcherQueue", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Sources/DispatcherQueue/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Windows { } 6 | extension Windows { public struct Foundation { } } 7 | extension Windows { public struct System { } } 8 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/Sources/DispatcherQueue/main.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinRT 5 | 6 | @main 7 | class WinRTAsyncDemo { 8 | public static func main() async throws { 9 | try RoInitialize() 10 | 11 | let controller = try Windows.System.DispatcherQueueController.CreateOnDedicatedThread()! 12 | 13 | try await controller.ShutdownQueue() 14 | 15 | print("Done!") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/DispatcherQueue/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/DispatcherQueue/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Windows.System.DispatcherQueueController" 7 | ], 8 | "interfaces" : 9 | [ 10 | ] 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Samples/HttpClient/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/HttpClient/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/HttpClient/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/HttpClient/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/HttpClient/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "HttpClient", targets: ["HttpClient"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "HttpClient", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/HttpClient/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/HttpClient/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/HttpClient/Sources/HttpClient/generated/Windows.Storage.Streams.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage.Streams { 10 | // type: Windows.Storage.Streams.IBuffer 11 | // interface type 12 | open class IBuffer 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe0, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 17 | // method not needed: get_Capacity 18 | // method not needed: get_Length 19 | // method not needed: put_Length 20 | } // IBuffer 21 | 22 | 23 | // type: Windows.Storage.Streams.IInputStream 24 | // interface type 25 | open class IInputStream 26 | : 27 | WinRT.IInspectable 28 | { 29 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe2, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 30 | // method not needed: ReadAsync 31 | } // IInputStream 32 | 33 | 34 | // type: Windows.Storage.Streams.IOutputStream 35 | // interface type 36 | open class IOutputStream 37 | : 38 | WinRT.IInspectable 39 | { 40 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe6, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 41 | // method not needed: WriteAsync 42 | // method not needed: FlushAsync 43 | } // IOutputStream 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Samples/HttpClient/Sources/HttpClient/generated/Windows.Web.Http.Filters.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Web.Http.Filters { 10 | // type: Windows.Web.Http.Filters.IHttpFilter 11 | // interface type 12 | open class IHttpFilter 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xa4cb6dd5, Data2: 0x0902, Data3 : 0x439e, Data4 : (0xbf, 0xd7, 0xe1, 0x25, 0x52, 0xb1, 0x65, 0xce)) } 17 | // method not needed: SendRequestAsync 18 | } // IHttpFilter 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Samples/HttpClient/Sources/HttpClient/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Windows { } 6 | extension Windows { public struct Foundation { } } 7 | extension Windows { public struct Storage { } } 8 | extension Windows.Storage { public struct Streams { } } 9 | extension Windows { public struct Web { } } 10 | extension Windows.Web { public struct Http { } } 11 | extension Windows.Web.Http { public struct Filters { } } 12 | extension Windows.Web.Http { public struct Headers { } } 13 | -------------------------------------------------------------------------------- /Samples/HttpClient/Sources/HttpClient/main.swift: -------------------------------------------------------------------------------- 1 | 2 | import WinRT 3 | 4 | @main 5 | class HttpClientDemo { 6 | public static func main() async throws { 7 | try RoInitialize() 8 | 9 | let httpClient = try Windows.Web.Http.HttpClient(); 10 | let requestUri = try Windows.Foundation.Uri(uri: "https://ericsink.com"); 11 | let httpResponse = try await httpClient.Get(uri: requestUri)!; 12 | let _ = try httpResponse.EnsureSuccessStatusCode(); 13 | let httpResponseBody = try await httpResponse.Content!.ReadAsString(); 14 | print(httpResponseBody); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Samples/HttpClient/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/HttpClient/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/HttpClient/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Windows.Foundation.Uri", 7 | "Windows.Web.Http.HttpClient", 8 | "Windows.Web.Http.HttpResponseMessage" 9 | ], 10 | "interfaces" : 11 | [ 12 | "Windows.Web.Http.IHttpContent" 13 | ] 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Samples/MazeGame/Microsoft.Graphics.Canvas.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/MazeGame/Microsoft.Graphics.Canvas.dll -------------------------------------------------------------------------------- /Samples/MazeGame/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/MazeGame/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/MazeGame/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/MazeGame/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/MazeGame/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "MazeGame", targets: ["MazeGame"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "MazeGame", dependencies: ["C", "WinRT"], 16 | resources: [ 17 | .process("Assets") 18 | ], 19 | swiftSettings: [ 20 | .unsafeFlags(["-parse-as-library"]), 21 | ], 22 | linkerSettings: [ 23 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 24 | .unsafeFlags(["-Xlinker"]), 25 | .unsafeFlags(["/MANIFEST:embed"]), 26 | ] 27 | ), 28 | ] 29 | ) 30 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/Assets/dino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/MazeGame/Sources/MazeGame/Assets/dino.png -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/Assets/gamegrid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/MazeGame/Sources/MazeGame/Assets/gamegrid.png -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/Assets/ninjacat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/MazeGame/Sources/MazeGame/Assets/ninjacat.png -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/AsyncAction.swift: -------------------------------------------------------------------------------- 1 | 2 | import WinRT 3 | 4 | open class MyAsyncAction : Windows.Foundation.AsyncAction { 5 | private var _status : Windows.Foundation.AsyncStatus = .Started 6 | open override func get_Id() throws -> Swift.UInt32 { 7 | //print("MyActionAction.get_Id") 8 | return 0; 9 | } 10 | open override func get_Status() throws -> Windows.Foundation.AsyncStatus { 11 | //print("MyActionAction.get_Status") 12 | return _status 13 | } 14 | open override func get_ErrorCode() throws -> Windows.Foundation.HResult { 15 | //print("MyActionAction.get_ErrorCode") 16 | return Windows.Foundation.HResult(Value: 0); 17 | } 18 | open override func Cancel() throws -> Void { 19 | //print("MyActionAction.Cancel") 20 | } 21 | open override func Close() throws -> Void { 22 | //print("MyActionAction.Close") 23 | // TODO what calls this? 24 | _del = nil 25 | } 26 | private var _del : Optional = nil 27 | open override func put_Completed(handler : Optional) throws -> Void { 28 | //print("MyActionAction.put_Completed") 29 | _del = handler; 30 | } 31 | open override func get_Completed() throws -> Optional { 32 | //print("MyActionAction.get_Completed") 33 | return nil; 34 | } 35 | open override func GetResults() throws -> Void { 36 | //print("MyActionAction.GetResults") 37 | } 38 | public func Done_Succeeded() throws -> Void { 39 | _status = .Completed 40 | if let d = _del { 41 | try d.Invoke(asyncInfo: self.to_IAsyncAction(), asyncStatus: _status) 42 | } 43 | } 44 | public func Done_Failed() throws -> Void { 45 | _status = .Error 46 | if let d = _del { 47 | try d.Invoke(asyncInfo: self.to_IAsyncAction(), asyncStatus: _status) 48 | } 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/Baddie.swift: -------------------------------------------------------------------------------- 1 | 2 | // This class contains the code that draws and moves the "badguy" image. 3 | 4 | public class Baddie 5 | { 6 | public var x: Int; 7 | public var y: Int 8 | private var direction: Int; 9 | 10 | // Call this to set starting position and the direction that the baddie will start going in. 11 | public init(_ start_x: Int, _ start_y: Int, _ start_direction: Int) 12 | { 13 | x = start_x; 14 | y = start_y; 15 | direction = start_direction; 16 | } 17 | 18 | public func Move(_ speed: Int, _ gamemaze: Maze) throws 19 | { 20 | // Update the position of the baddie depending on the direction. 21 | // We can change the speed to make them faster or slower, and so 22 | // make the game harder or easier. 23 | 24 | switch (direction) 25 | { 26 | case 1: y -= speed; break; 27 | case 2: x += speed; break; 28 | case 4: y += speed; break; 29 | case 8: x -= speed; break; 30 | 31 | default: break; 32 | } 33 | 34 | // Test to see if the baddie is in the middle of a square in the maze, and then we can decide 35 | // to change direction or not. 36 | 37 | if ((x % 64 == 0) && (y % 64 == 0)) 38 | { 39 | 40 | // Map the screen co-ordinates to the map co-ordinates 41 | // (the screen is 1024 by 1024, the maze data is 16 by 16) 42 | 43 | let mx = (x / 64); 44 | let my = (y / 64); 45 | 46 | // Get the number that tells us the possible directions at this tile 47 | let possible_directions = gamemaze.GetTile(my, mx); 48 | //print("baddie possible: \(possible_directions)") 49 | 50 | // Define the opposite value to the current direction, 51 | // because we don't want to double back 52 | 53 | var opposite_directon = 0; 54 | 55 | if (direction == 1) { opposite_directon = 4; } 56 | if (direction == 2) { opposite_directon = 8; } 57 | if (direction == 4) { opposite_directon = 1; } 58 | if (direction == 8) { opposite_directon = 2; } 59 | 60 | var new_direction = 1; 61 | 62 | // Pick a new direction that is both possible AND not doubling back. 63 | repeat 64 | { 65 | repeat 66 | { 67 | 68 | new_direction = gamemaze.NextDirection(); 69 | } while ((new_direction & possible_directions) == 0); 70 | } while (new_direction == opposite_directon); 71 | 72 | direction = new_direction; 73 | 74 | } 75 | } 76 | 77 | // Draw the baddie. Needs a reference to the canvas 78 | public func Draw(_ args: CanvasDrawEventArgs, _ dino: CanvasBitmap?) throws 79 | { 80 | let r = Windows.Foundation.Rect(X: Float(x + 4), Y: Float(y + 4), Width: 64, Height: 64) 81 | try args.DrawingSession!.DrawImage(bitmap: dino, destinationRectangle: r) 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Microsoft.UI.Dispatching.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Dispatching { 10 | // type: Microsoft.UI.Dispatching.DispatcherQueue 11 | // runtime class 12 | public class DispatcherQueue 13 | : 14 | WinRT.Object 15 | { 16 | private var _self : Microsoft.UI.Dispatching.IDispatcherQueue; 17 | public init(plok: Microsoft.UI.Dispatching.IDispatcherQueue?) throws { 18 | _self = plok! 19 | try super.init(plok: _self.QueryInterface()) 20 | } 21 | public func Interface() -> Microsoft.UI.Dispatching.IDispatcherQueue { return _self; } 22 | // static interface not needed: Microsoft.UI.Dispatching.IDispatcherQueueStatics 23 | // method not needed: CreateTimer 24 | // method not needed: TryEnqueue 25 | // method not needed: TryEnqueue 26 | // method not needed: add_ShutdownStarting 27 | // method not needed: remove_ShutdownStarting 28 | // method not needed: add_ShutdownCompleted 29 | // method not needed: remove_ShutdownCompleted 30 | // instance interface not needed: Microsoft.UI.Dispatching.IDispatcherQueue2 31 | } 32 | 33 | // type: Microsoft.UI.Dispatching.IDispatcherQueue 34 | // interface type 35 | open class IDispatcherQueue 36 | : 37 | WinRT.IInspectable 38 | { 39 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xf6ebf8fa, Data2: 0xbe1c, Data3 : 0x5bf6, Data4 : (0xa4, 0x67, 0x73, 0xda, 0x28, 0x73, 0x8a, 0xe8)) } 40 | // method not needed: CreateTimer 41 | // method not needed: TryEnqueue 42 | // method not needed: TryEnqueueWithPriority 43 | // method not needed: add_ShutdownStarting 44 | // method not needed: remove_ShutdownStarting 45 | // method not needed: add_ShutdownCompleted 46 | // method not needed: remove_ShutdownCompleted 47 | } // IDispatcherQueue 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.ApplicationModel.DataTransfer.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.ApplicationModel.DataTransfer { 10 | // type: Windows.ApplicationModel.DataTransfer.DataPackageOperation 11 | // enum type 12 | public typealias DataPackageOperation = _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation; 13 | 14 | } 15 | extension Windows.ApplicationModel.DataTransfer.DataPackageOperation { 16 | public static var None : Self { 17 | get { 18 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_None; 19 | } 20 | } 21 | public static var Copy : Self { 22 | get { 23 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Copy; 24 | } 25 | } 26 | public static var Move : Self { 27 | get { 28 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Move; 29 | } 30 | } 31 | public static var Link : Self { 32 | get { 33 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Link; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.Foundation.Numerics.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Foundation.Numerics { 10 | // type: Windows.Foundation.Numerics.Matrix3x2 11 | // struct type 12 | public typealias Matrix3x2 = _q_CWindows_CFoundation_CNumerics_CMatrix3x2; 13 | 14 | // type: Windows.Foundation.Numerics.Matrix4x4 15 | // struct type 16 | public typealias Matrix4x4 = _q_CWindows_CFoundation_CNumerics_CMatrix4x4; 17 | 18 | // type: Windows.Foundation.Numerics.Vector2 19 | // struct type 20 | public typealias Vector2 = _q_CWindows_CFoundation_CNumerics_CVector2; 21 | 22 | // type: Windows.Foundation.Numerics.Vector3 23 | // struct type 24 | public typealias Vector3 = _q_CWindows_CFoundation_CNumerics_CVector3; 25 | 26 | // type: Windows.Foundation.Numerics.Vector4 27 | // struct type 28 | public typealias Vector4 = _q_CWindows_CFoundation_CNumerics_CVector4; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.Graphics.DirectX.Direct3D11.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.DirectX.Direct3D11 { 10 | // type: Windows.Graphics.DirectX.Direct3D11.Direct3DMultisampleDescription 11 | // struct type 12 | public typealias Direct3DMultisampleDescription = _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DMultisampleDescription; 13 | 14 | // type: Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription 15 | // struct type 16 | public typealias Direct3DSurfaceDescription = _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription; 17 | 18 | // type: Windows.Graphics.DirectX.Direct3D11.IDirect3DDevice 19 | // interface type 20 | open class IDirect3DDevice 21 | : 22 | WinRT.IInspectable 23 | { 24 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xa37624ab, Data2: 0x8d5f, Data3 : 0x4650, Data4 : (0x9d, 0x3e, 0x9e, 0xae, 0x3d, 0x9b, 0xc6, 0x70)) } 25 | // void Trim() 26 | private func _n_Trim() throws { 27 | return try perform(as: _q_CWindows_CGraphics_CDirectX_CDirect3D11_CIDirect3DDevice.self) { pThis in 28 | try CHECKED(pThis.pointee.lpVtbl.pointee.Trim(pThis)) 29 | } 30 | } 31 | public func Trim() throws -> Void { 32 | try self._n_Trim(); 33 | } 34 | } // IDirect3DDevice 35 | 36 | 37 | // type: Windows.Graphics.DirectX.Direct3D11.IDirect3DSurface 38 | // interface type 39 | open class IDirect3DSurface 40 | : 41 | WinRT.IInspectable 42 | { 43 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x0bf4a146, Data2: 0x13c1, Data3 : 0x4694, Data4 : (0xbe, 0xe3, 0x7a, 0xbf, 0x15, 0xea, 0xf5, 0x86)) } 44 | // [IsSpecialName] Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription get_Description() 45 | private func _n_get_Description(_ __presult: UnsafeMutablePointer<_q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription>?) throws { 46 | return try perform(as: _q_CWindows_CGraphics_CDirectX_CDirect3D11_CIDirect3DSurface.self) { pThis in 47 | try CHECKED(pThis.pointee.lpVtbl.pointee.get_Description(pThis, __presult)) 48 | } 49 | } 50 | public func get_Description() throws -> Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription { 51 | var __result : _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription = _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DSurfaceDescription(Width: 0, Height: 0, Format: _q_CWindows_CGraphics_CDirectX_CDirectXPixelFormat_Unknown, MultisampleDescription: _q_CWindows_CGraphics_CDirectX_CDirect3D11_CDirect3DMultisampleDescription(Count: 0, Quality: 0)); 52 | try self._n_get_Description(&__result); 53 | return __result; 54 | } 55 | public var Description : Windows.Graphics.DirectX.Direct3D11.Direct3DSurfaceDescription { 56 | get throws { 57 | return try get_Description(); 58 | } 59 | } 60 | } // IDirect3DSurface 61 | 62 | 63 | } 64 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.Graphics.Effects.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.Effects { 10 | // type: Windows.Graphics.Effects.IGraphicsEffect 11 | // interface type 12 | open class IGraphicsEffect 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xcb51c0ce, Data2: 0x8fe6, Data3 : 0x4636, Data4 : (0xb2, 0x02, 0x86, 0x1f, 0xaa, 0x07, 0xd8, 0xf3)) } 17 | // [IsSpecialName] System.String get_Name() 18 | private func _n_get_Name(_ __presult: UnsafeMutablePointer>?) throws { 19 | return try perform(as: _q_CWindows_CGraphics_CEffects_CIGraphicsEffect.self) { pThis in 20 | try CHECKED(pThis.pointee.lpVtbl.pointee.get_Name(pThis, __presult)) 21 | } 22 | } 23 | public func get_Name() throws -> Swift.String { 24 | var __result : Optional = nil; 25 | try self._n_get_Name(&__result); 26 | return Swift.String(from: __result); 27 | } 28 | // [IsSpecialName] void put_Name(System.String) 29 | private func _n_put_Name(_ name : Optional) throws { 30 | return try perform(as: _q_CWindows_CGraphics_CEffects_CIGraphicsEffect.self) { pThis in 31 | try CHECKED(pThis.pointee.lpVtbl.pointee.put_Name(pThis, name)) 32 | } 33 | } 34 | public func put_Name(name : Optional) throws -> Void { 35 | let __hstr_name = try HString(name!); 36 | return try withExtendedLifetime(__hstr_name) { 37 | try self._n_put_Name(__hstr_name.Raw()); 38 | } 39 | } 40 | public var Name : Swift.String { 41 | get throws { 42 | return try get_Name(); 43 | } 44 | } 45 | } // IGraphicsEffect 46 | 47 | 48 | // type: Windows.Graphics.Effects.IGraphicsEffectSource 49 | // interface type 50 | open class IGraphicsEffectSource 51 | : 52 | WinRT.IInspectable 53 | { 54 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x2d8f9ddc, Data2: 0x4339, Data3 : 0x4eb9, Data4 : (0x92, 0x16, 0xf9, 0xde, 0xb7, 0x56, 0x58, 0xa2)) } 55 | } // IGraphicsEffectSource 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.Graphics.Printing.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.Printing { 10 | // type: Windows.Graphics.Printing.IPrintTaskOptionsCore 11 | // interface type 12 | open class IPrintTaskOptionsCore 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x1bdbb474, Data2: 0x4ed1, Data3 : 0x41eb, Data4 : (0xbe, 0x3c, 0x72, 0xd1, 0x8e, 0xd6, 0x73, 0x37)) } 17 | // method not needed: GetPageDescription 18 | } // IPrintTaskOptionsCore 19 | 20 | 21 | // type: Windows.Graphics.Printing.PrintTaskOptions 22 | // runtime class 23 | public class PrintTaskOptions 24 | : 25 | WinRT.Object 26 | { 27 | private var _self : Windows.Graphics.Printing.IPrintTaskOptionsCore; 28 | public init(plok: Windows.Graphics.Printing.IPrintTaskOptionsCore?) throws { 29 | _self = plok! 30 | try super.init(plok: _self.QueryInterface()) 31 | } 32 | public func Interface() -> Windows.Graphics.Printing.IPrintTaskOptionsCore { return _self; } 33 | // method not needed: GetPageDescription 34 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptionsCoreProperties 35 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptionsCoreUIConfiguration 36 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptions 37 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptions2 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.Storage.Streams.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage.Streams { 10 | // type: Windows.Storage.Streams.IBuffer 11 | // interface type 12 | open class IBuffer 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe0, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 17 | // method not needed: get_Capacity 18 | // method not needed: get_Length 19 | // method not needed: put_Length 20 | } // IBuffer 21 | 22 | 23 | // type: Windows.Storage.Streams.IRandomAccessStream 24 | // interface type 25 | open class IRandomAccessStream 26 | : 27 | WinRT.IInspectable 28 | { 29 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe1, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 30 | // method not needed: get_Size 31 | // method not needed: put_Size 32 | // method not needed: GetInputStreamAt 33 | // method not needed: GetOutputStreamAt 34 | // method not needed: get_Position 35 | // method not needed: Seek 36 | // method not needed: CloneStream 37 | // method not needed: get_CanRead 38 | // method not needed: get_CanWrite 39 | } // IRandomAccessStream 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.UI.Text.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Text { 10 | // type: Windows.UI.Text.FontStretch 11 | // enum type 12 | public typealias FontStretch = _q_CWindows_CUI_CText_CFontStretch; 13 | 14 | // type: Windows.UI.Text.FontStyle 15 | // enum type 16 | public typealias FontStyle = _q_CWindows_CUI_CText_CFontStyle; 17 | 18 | // type: Windows.UI.Text.FontWeight 19 | // struct type 20 | public typealias FontWeight = _q_CWindows_CUI_CText_CFontWeight; 21 | 22 | } 23 | extension Windows.UI.Text.FontStretch { 24 | public static var Undefined : Self { 25 | get { 26 | return _q_CWindows_CUI_CText_CFontStretch_Undefined; 27 | } 28 | } 29 | public static var UltraCondensed : Self { 30 | get { 31 | return _q_CWindows_CUI_CText_CFontStretch_UltraCondensed; 32 | } 33 | } 34 | public static var ExtraCondensed : Self { 35 | get { 36 | return _q_CWindows_CUI_CText_CFontStretch_ExtraCondensed; 37 | } 38 | } 39 | public static var Condensed : Self { 40 | get { 41 | return _q_CWindows_CUI_CText_CFontStretch_Condensed; 42 | } 43 | } 44 | public static var SemiCondensed : Self { 45 | get { 46 | return _q_CWindows_CUI_CText_CFontStretch_SemiCondensed; 47 | } 48 | } 49 | public static var Normal : Self { 50 | get { 51 | return _q_CWindows_CUI_CText_CFontStretch_Normal; 52 | } 53 | } 54 | public static var SemiExpanded : Self { 55 | get { 56 | return _q_CWindows_CUI_CText_CFontStretch_SemiExpanded; 57 | } 58 | } 59 | public static var Expanded : Self { 60 | get { 61 | return _q_CWindows_CUI_CText_CFontStretch_Expanded; 62 | } 63 | } 64 | public static var ExtraExpanded : Self { 65 | get { 66 | return _q_CWindows_CUI_CText_CFontStretch_ExtraExpanded; 67 | } 68 | } 69 | public static var UltraExpanded : Self { 70 | get { 71 | return _q_CWindows_CUI_CText_CFontStretch_UltraExpanded; 72 | } 73 | } 74 | } 75 | extension Windows.UI.Text.FontStyle { 76 | public static var Normal : Self { 77 | get { 78 | return _q_CWindows_CUI_CText_CFontStyle_Normal; 79 | } 80 | } 81 | public static var Oblique : Self { 82 | get { 83 | return _q_CWindows_CUI_CText_CFontStyle_Oblique; 84 | } 85 | } 86 | public static var Italic : Self { 87 | get { 88 | return _q_CWindows_CUI_CText_CFontStyle_Italic; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.UI.Xaml.Interop.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Xaml.Interop { 10 | // type: Windows.UI.Xaml.Interop.TypeKind 11 | // enum type 12 | public typealias TypeKind = _q_CWindows_CUI_CXaml_CInterop_CTypeKind; 13 | 14 | // type: Windows.UI.Xaml.Interop.TypeName 15 | // struct type 16 | public typealias TypeName = _q_CWindows_CUI_CXaml_CInterop_CTypeName; 17 | 18 | } 19 | extension Windows.UI.Xaml.Interop.TypeKind { 20 | public static var Primitive : Self { 21 | get { 22 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Primitive; 23 | } 24 | } 25 | public static var Metadata : Self { 26 | get { 27 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Metadata; 28 | } 29 | } 30 | public static var Custom : Self { 31 | get { 32 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Custom; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/Windows.UI.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI { 10 | // type: Windows.UI.Color 11 | // struct type 12 | public typealias Color = _q_CWindows_CUI_CColor; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Microsoft { } 6 | extension Microsoft { public struct Graphics { } } 7 | extension Microsoft.Graphics { public struct Canvas { } } 8 | extension Microsoft.Graphics.Canvas { public struct Brushes { } } 9 | extension Microsoft.Graphics.Canvas { public struct Effects { } } 10 | extension Microsoft.Graphics.Canvas { public struct Geometry { } } 11 | extension Microsoft.Graphics.Canvas { public struct Printing { } } 12 | extension Microsoft.Graphics.Canvas { public struct Svg { } } 13 | extension Microsoft.Graphics.Canvas { public struct Text { } } 14 | extension Microsoft.Graphics.Canvas { public struct UI { } } 15 | extension Microsoft.Graphics.Canvas.UI { public struct Composition { } } 16 | extension Microsoft.Graphics.Canvas.UI { public struct Xaml { } } 17 | extension Microsoft { public struct UI { } } 18 | extension Microsoft.UI { public struct Composition { } } 19 | extension Microsoft.UI { public struct Dispatching { } } 20 | extension Microsoft.UI { public struct Input { } } 21 | extension Microsoft.UI { public struct Xaml { } } 22 | extension Microsoft.UI.Xaml { public struct Automation { } } 23 | extension Microsoft.UI.Xaml.Automation { public struct Peers { } } 24 | extension Microsoft.UI.Xaml { public struct Controls { } } 25 | extension Microsoft.UI.Xaml.Controls { public struct Primitives { } } 26 | extension Microsoft.UI.Xaml { public struct Data { } } 27 | extension Microsoft.UI.Xaml { public struct Input { } } 28 | extension Microsoft.UI.Xaml { public struct Markup { } } 29 | extension Microsoft.UI.Xaml { public struct Media { } } 30 | extension Microsoft.UI.Xaml.Media { public struct Animation { } } 31 | extension Microsoft.UI.Xaml.Media { public struct Imaging { } } 32 | extension Microsoft.UI.Xaml.Media { public struct Media3D { } } 33 | public struct Windows { } 34 | extension Windows { public struct ApplicationModel { } } 35 | extension Windows.ApplicationModel { public struct DataTransfer { } } 36 | extension Windows { public struct Foundation { } } 37 | extension Windows.Foundation { public struct Collections { } } 38 | extension Windows.Foundation { public struct Numerics { } } 39 | extension Windows { public struct Graphics { } } 40 | extension Windows.Graphics { public struct DirectX { } } 41 | extension Windows.Graphics.DirectX { public struct Direct3D11 { } } 42 | extension Windows.Graphics { public struct Effects { } } 43 | extension Windows.Graphics { public struct Imaging { } } 44 | extension Windows.Graphics { public struct Printing { } } 45 | extension Windows { public struct Storage { } } 46 | extension Windows.Storage { public struct Streams { } } 47 | extension Windows { public struct System { } } 48 | extension Windows { public struct UI { } } 49 | extension Windows.UI { public struct Core { } } 50 | extension Windows.UI { public struct Text { } } 51 | extension Windows.UI { public struct Xaml { } } 52 | extension Windows.UI.Xaml { public struct Interop { } } 53 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/cg_Microsoft.Graphics.Canvas.Effects.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CMicrosoft_CGraphics_CCanvas_CEffects_CColorManagementSimpleProfile 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x41db10c7, Data2: 0xf02c, Data3 : 0x5d7f, Data4 : (0xa1, 0x2e, 0x4e, 0x05, 0x04, 0x73, 0x88, 0xe7)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CMicrosoft_CGraphics_CCanvas_CEffects_CColorManagementSimpleProfile 18 | } 19 | -------------------------------------------------------------------------------- /Samples/MazeGame/Sources/MazeGame/generated/cg_Windows.Foundation.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CWindows_CFoundation_CRect 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x80423f11, Data2: 0x054f, Data3 : 0x5eac, Data4 : (0xaf, 0xd3, 0x63, 0xb6, 0xce, 0x15, 0xe7, 0x7b)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CWindows_CFoundation_CRect 18 | // closed interface type 19 | public class IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 20 | : 21 | WinRT.IInspectable 22 | { 23 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xae44597e, Data2: 0xd411, Data3 : 0x5b7f, Data4 : (0xbb, 0xec, 0x6a, 0x96, 0xc9, 0x4a, 0x10, 0x7a)) } 24 | // method not needed: First 25 | } // IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 26 | // closed interface type 27 | public class IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 28 | : 29 | WinRT.IInspectable 30 | { 31 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x377f6162, Data2: 0x6e4d, Data3 : 0x574e, Data4 : (0xbf, 0x01, 0x77, 0xf4, 0xfd, 0x02, 0x1d, 0x0e)) } 32 | // method not needed: get_Current 33 | // method not needed: get_HasCurrent 34 | // method not needed: MoveNext 35 | // method not needed: GetMany 36 | } // IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 37 | // closed interface type 38 | public class IIterable_1__q_CWindows_CFoundation_CPoint 39 | : 40 | WinRT.IInspectable 41 | { 42 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc192280d, Data2: 0x3a09, Data3 : 0x5423, Data4 : (0x9d, 0xc5, 0x67, 0xb8, 0x3e, 0xbd, 0xe4, 0x1d)) } 43 | // method not needed: First 44 | } // IIterable_1__q_CWindows_CFoundation_CPoint 45 | // closed interface type 46 | public class IIterator_1__q_CWindows_CFoundation_CPoint 47 | : 48 | WinRT.IInspectable 49 | { 50 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc602b59e, Data2: 0x0a8e, Data3 : 0x5e99, Data4 : (0xb4, 0x78, 0x2b, 0x56, 0x45, 0x85, 0x27, 0x8d)) } 51 | // method not needed: get_Current 52 | // method not needed: get_HasCurrent 53 | // method not needed: MoveNext 54 | // method not needed: GetMany 55 | } // IIterator_1__q_CWindows_CFoundation_CPoint 56 | } 57 | -------------------------------------------------------------------------------- /Samples/MazeGame/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/MazeGame/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/MazeGame/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Microsoft.UI.Xaml.Application", 7 | "Microsoft.UI.Xaml.Window", 8 | "Microsoft.UI.Xaml.DispatcherTimer", 9 | "Microsoft.UI.Xaml.Input.KeyRoutedEventArgs", 10 | "Microsoft.UI.Colors", 11 | "Microsoft.UI.Xaml.Media.ImageBrush", 12 | "Microsoft.UI.Xaml.Media.Imaging.BitmapImage", 13 | "Microsoft.UI.Xaml.Controls.UIElementCollection" 14 | ], 15 | "interfaces" : 16 | [ 17 | "Microsoft.UI.Xaml.Markup.IXamlMetadataProvider", 18 | "Microsoft.UI.Xaml.Markup.IXamlType", 19 | "Microsoft.UI.Xaml.Markup.IXamlMember" 20 | ], 21 | "namespaces" : 22 | [ 23 | "Microsoft.Graphics.Canvas" 24 | ], 25 | "blacklist" : 26 | [ 27 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11Surface", 28 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11SurfaceWithDpi", 29 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11SurfaceWithDpiAndAlpha" 30 | ] 31 | } 32 | 33 | -------------------------------------------------------------------------------- /Samples/Physics/Microsoft.Graphics.Canvas.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Physics/Microsoft.Graphics.Canvas.dll -------------------------------------------------------------------------------- /Samples/Physics/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Physics/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/Physics/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Physics/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/Physics/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "Physics", targets: ["Physics"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name : "Chipmunk2D", 15 | cSettings: [ 16 | .unsafeFlags(["-I", "Sources/Chipmunk2D"]), 17 | ] 18 | ), 19 | .target(name: "C"), 20 | .executableTarget(name: "Physics", dependencies: ["C", "WinRT", "Chipmunk2D"], 21 | cSettings: [ 22 | .unsafeFlags(["-I", "Sources/Chipmunk2D"]), 23 | ], 24 | swiftSettings: [ 25 | .unsafeFlags(["-parse-as-library"]), 26 | ], 27 | linkerSettings: [ 28 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 29 | .unsafeFlags(["-Xlinker"]), 30 | .unsafeFlags(["/MANIFEST:embed"]), 31 | ] 32 | ), 33 | ] 34 | ) 35 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB chipmunk_source_files "*.c") 2 | file(GLOB chipmunk_public_header "${chipmunk_SOURCE_DIR}/include/chipmunk/*.h") 3 | 4 | include_directories(${chipmunk_SOURCE_DIR}/include) 5 | 6 | # Chipmunk2D 7.0.3 7 | set(CHIPMUNK_VERSION_MAJOR 7) 8 | set(CHIPMUNK_VERSION_MINOR 0) 9 | set(CHIPMUNK_VERSION_PATCH 3) 10 | set(CHIPMUNK_VERSION "${CHIPMUNK_VERSION_MAJOR}.${CHIPMUNK_VERSION_MINOR}.${CHIPMUNK_VERSION_PATCH}") 11 | message("Configuring Chipmunk2D version ${CHIPMUNK_VERSION}") 12 | 13 | 14 | if(BUILD_SHARED) 15 | add_library(chipmunk SHARED 16 | ${chipmunk_source_files} 17 | ) 18 | # Tell MSVC to compile the code as C++. 19 | if(MSVC) 20 | set_source_files_properties(${chipmunk_source_files} PROPERTIES LANGUAGE CXX) 21 | set_target_properties(chipmunk PROPERTIES LINKER_LANGUAGE CXX) 22 | endif(MSVC) 23 | # set the lib's version number 24 | # But avoid on Android because symlinks to version numbered .so's don't work with Android's Java-side loadLibrary. 25 | if(NOT ANDROID) 26 | set_target_properties(chipmunk PROPERTIES 27 | SOVERSION ${CHIPMUNK_VERSION_MAJOR} 28 | VERSION ${CHIPMUNK_VERSION}) 29 | endif(NOT ANDROID) 30 | if(ANDROID OR UNIX) 31 | # need to explicitly link to the math library because the CMake/Android toolchains may not do it automatically 32 | target_link_libraries(chipmunk m) 33 | endif(ANDROID OR UNIX) 34 | install(TARGETS chipmunk RUNTIME DESTINATION ${BIN_INSTALL_DIR} 35 | LIBRARY DESTINATION ${LIB_INSTALL_DIR} 36 | ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) 37 | endif(BUILD_SHARED) 38 | 39 | if(BUILD_STATIC) 40 | add_library(chipmunk_static STATIC 41 | ${chipmunk_source_files} 42 | ) 43 | # Tell MSVC to compile the code as C++. 44 | if(MSVC) 45 | set_source_files_properties(${chipmunk_source_files} PROPERTIES LANGUAGE CXX) 46 | set_target_properties(chipmunk_static PROPERTIES LINKER_LANGUAGE CXX) 47 | endif(MSVC) 48 | # Sets chipmunk_static to output "libchipmunk.a" not "libchipmunk_static.a" 49 | set_target_properties(chipmunk_static PROPERTIES OUTPUT_NAME chipmunk) 50 | if(INSTALL_STATIC) 51 | install(TARGETS chipmunk_static ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) 52 | endif(INSTALL_STATIC) 53 | endif(BUILD_STATIC) 54 | 55 | if(BUILD_SHARED OR INSTALL_STATIC) 56 | # FIXME: change to PUBLIC_HEADER to allow building frameworks 57 | install(FILES ${chipmunk_public_header} DESTINATION include/chipmunk) 58 | install(FILES ${chipmunk_constraint_header} DESTINATION include/chipmunk/constraints) 59 | endif(BUILD_SHARED OR INSTALL_STATIC) 60 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/cpArray.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #include "chipmunk/chipmunk_private.h" 25 | 26 | 27 | cpArray * 28 | cpArrayNew(int size) 29 | { 30 | cpArray *arr = (cpArray *)cpcalloc(1, sizeof(cpArray)); 31 | 32 | arr->num = 0; 33 | arr->max = (size ? size : 4); 34 | arr->arr = (void **)cpcalloc(arr->max, sizeof(void*)); 35 | 36 | return arr; 37 | } 38 | 39 | void 40 | cpArrayFree(cpArray *arr) 41 | { 42 | if(arr){ 43 | cpfree(arr->arr); 44 | arr->arr = NULL; 45 | 46 | cpfree(arr); 47 | } 48 | } 49 | 50 | void 51 | cpArrayPush(cpArray *arr, void *object) 52 | { 53 | if(arr->num == arr->max){ 54 | arr->max = 3*(arr->max + 1)/2; 55 | arr->arr = (void **)cprealloc(arr->arr, arr->max*sizeof(void*)); 56 | } 57 | 58 | arr->arr[arr->num] = object; 59 | arr->num++; 60 | } 61 | 62 | void * 63 | cpArrayPop(cpArray *arr) 64 | { 65 | arr->num--; 66 | 67 | void *value = arr->arr[arr->num]; 68 | arr->arr[arr->num] = NULL; 69 | 70 | return value; 71 | } 72 | 73 | void 74 | cpArrayDeleteObj(cpArray *arr, void *obj) 75 | { 76 | for(int i=0; inum; i++){ 77 | if(arr->arr[i] == obj){ 78 | arr->num--; 79 | 80 | arr->arr[i] = arr->arr[arr->num]; 81 | arr->arr[arr->num] = NULL; 82 | 83 | return; 84 | } 85 | } 86 | } 87 | 88 | void 89 | cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*)) 90 | { 91 | for(int i=0; inum; i++) freeFunc(arr->arr[i]); 92 | } 93 | 94 | cpBool 95 | cpArrayContains(cpArray *arr, void *ptr) 96 | { 97 | for(int i=0; inum; i++) 98 | if(arr->arr[i] == ptr) return cpTrue; 99 | 100 | return cpFalse; 101 | } 102 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/cpRobust.c: -------------------------------------------------------------------------------- 1 | #include "chipmunk/cpRobust.h" 2 | 3 | 4 | cpBool 5 | cpCheckPointGreater(const cpVect a, const cpVect b, const cpVect c) 6 | { 7 | return (b.y - a.y)*(a.x + b.x - 2*c.x) > (b.x - a.x)*(a.y + b.y - 2*c.y); 8 | } 9 | 10 | cpBool 11 | cpCheckAxis(cpVect v0, cpVect v1, cpVect p, cpVect n){ 12 | return cpvdot(p, n) <= cpfmax(cpvdot(v0, n), cpvdot(v1, n)); 13 | } 14 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/cpSpatialIndex.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | #include "chipmunk/chipmunk_private.h" 23 | 24 | void 25 | cpSpatialIndexFree(cpSpatialIndex *index) 26 | { 27 | if(index){ 28 | cpSpatialIndexDestroy(index); 29 | cpfree(index); 30 | } 31 | } 32 | 33 | cpSpatialIndex * 34 | cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) 35 | { 36 | index->klass = klass; 37 | index->bbfunc = bbfunc; 38 | index->staticIndex = staticIndex; 39 | 40 | if(staticIndex){ 41 | cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index."); 42 | staticIndex->dynamicIndex = index; 43 | } 44 | 45 | return index; 46 | } 47 | 48 | typedef struct dynamicToStaticContext { 49 | cpSpatialIndexBBFunc bbfunc; 50 | cpSpatialIndex *staticIndex; 51 | cpSpatialIndexQueryFunc queryFunc; 52 | void *data; 53 | } dynamicToStaticContext; 54 | 55 | static void 56 | dynamicToStaticIter(void *obj, dynamicToStaticContext *context) 57 | { 58 | cpSpatialIndexQuery(context->staticIndex, obj, context->bbfunc(obj), context->queryFunc, context->data); 59 | } 60 | 61 | void 62 | cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *staticIndex, cpSpatialIndexQueryFunc func, void *data) 63 | { 64 | if(staticIndex && cpSpatialIndexCount(staticIndex) > 0){ 65 | dynamicToStaticContext context = {dynamicIndex->bbfunc, staticIndex, func, data}; 66 | cpSpatialIndexEach(dynamicIndex, (cpSpatialIndexIteratorFunc)dynamicToStaticIter, &context); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpGearJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpGearJoint cpGearJoint 23 | /// @{ 24 | 25 | /// Check if a constraint is a damped rotary springs. 26 | CP_EXPORT cpBool cpConstraintIsGearJoint(const cpConstraint *constraint); 27 | 28 | /// Allocate a gear joint. 29 | CP_EXPORT cpGearJoint* cpGearJointAlloc(void); 30 | /// Initialize a gear joint. 31 | CP_EXPORT cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); 32 | /// Allocate and initialize a gear joint. 33 | CP_EXPORT cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); 34 | 35 | /// Get the phase offset of the gears. 36 | CP_EXPORT cpFloat cpGearJointGetPhase(const cpConstraint *constraint); 37 | /// Set the phase offset of the gears. 38 | CP_EXPORT void cpGearJointSetPhase(cpConstraint *constraint, cpFloat phase); 39 | 40 | /// Get the angular distance of each ratchet. 41 | CP_EXPORT cpFloat cpGearJointGetRatio(const cpConstraint *constraint); 42 | /// Set the ratio of a gear joint. 43 | CP_EXPORT void cpGearJointSetRatio(cpConstraint *constraint, cpFloat ratio); 44 | 45 | /// @} 46 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpGrooveJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpGrooveJoint cpGrooveJoint 23 | /// @{ 24 | 25 | /// Check if a constraint is a slide joint. 26 | CP_EXPORT cpBool cpConstraintIsGrooveJoint(const cpConstraint *constraint); 27 | 28 | /// Allocate a groove joint. 29 | CP_EXPORT cpGrooveJoint* cpGrooveJointAlloc(void); 30 | /// Initialize a groove joint. 31 | CP_EXPORT cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB); 32 | /// Allocate and initialize a groove joint. 33 | CP_EXPORT cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB); 34 | 35 | /// Get the first endpoint of the groove relative to the first body. 36 | CP_EXPORT cpVect cpGrooveJointGetGrooveA(const cpConstraint *constraint); 37 | /// Set the first endpoint of the groove relative to the first body. 38 | CP_EXPORT void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect grooveA); 39 | 40 | /// Get the first endpoint of the groove relative to the first body. 41 | CP_EXPORT cpVect cpGrooveJointGetGrooveB(const cpConstraint *constraint); 42 | /// Set the first endpoint of the groove relative to the first body. 43 | CP_EXPORT void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect grooveB); 44 | 45 | /// Get the location of the second anchor relative to the second body. 46 | CP_EXPORT cpVect cpGrooveJointGetAnchorB(const cpConstraint *constraint); 47 | /// Set the location of the second anchor relative to the second body. 48 | CP_EXPORT void cpGrooveJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); 49 | 50 | /// @} 51 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpHastySpace.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Howling Moon Software. All rights reserved. 2 | // See http://chipmunk2d.net/legal.php for more information. 3 | 4 | /// cpHastySpace is exclusive to Chipmunk Pro 5 | /// Currently it enables ARM NEON optimizations in the solver, but in the future will include other optimizations such as 6 | /// a multi-threaded solver and multi-threaded collision broadphases. 7 | 8 | struct cpHastySpace; 9 | typedef struct cpHastySpace cpHastySpace; 10 | 11 | /// Create a new hasty space. 12 | /// On ARM platforms that support NEON, this will enable the vectorized solver. 13 | /// cpHastySpace also supports multiple threads, but runs single threaded by default for determinism. 14 | CP_EXPORT cpSpace *cpHastySpaceNew(void); 15 | CP_EXPORT void cpHastySpaceFree(cpSpace *space); 16 | 17 | /// Set the number of threads to use for the solver. 18 | /// Currently Chipmunk is limited to 2 threads as using more generally provides very minimal performance gains. 19 | /// Passing 0 as the thread count on iOS or OS X will cause Chipmunk to automatically detect the number of threads it should use. 20 | /// On other platforms passing 0 for the thread count will set 1 thread. 21 | CP_EXPORT void cpHastySpaceSetThreads(cpSpace *space, unsigned long threads); 22 | 23 | /// Returns the number of threads the solver is using to run. 24 | CP_EXPORT unsigned long cpHastySpaceGetThreads(cpSpace *space); 25 | 26 | /// When stepping a hasty space, you must use this function. 27 | CP_EXPORT void cpHastySpaceStep(cpSpace *space, cpFloat dt); 28 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpMarch.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Howling Moon Software. All rights reserved. 2 | // See http://chipmunk2d.net/legal.php for more information. 3 | 4 | /// Function type used as a callback from the marching squares algorithm to sample an image function. 5 | /// It passes you the point to sample and your context pointer, and you return the density. 6 | typedef cpFloat (*cpMarchSampleFunc)(cpVect point, void *data); 7 | 8 | /// Function type used as a callback from the marching squares algorithm to output a line segment. 9 | /// It passes you the two endpoints and your context pointer. 10 | typedef void (*cpMarchSegmentFunc)(cpVect v0, cpVect v1, void *data); 11 | 12 | /// Trace an anti-aliased contour of an image along a particular threshold. 13 | /// The given number of samples will be taken and spread across the bounding box area using the sampling function and context. 14 | /// The segment function will be called for each segment detected that lies along the density contour for @c threshold. 15 | CP_EXPORT void cpMarchSoft( 16 | cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat threshold, 17 | cpMarchSegmentFunc segment, void *segment_data, 18 | cpMarchSampleFunc sample, void *sample_data 19 | ); 20 | 21 | /// Trace an aliased curve of an image along a particular threshold. 22 | /// The given number of samples will be taken and spread across the bounding box area using the sampling function and context. 23 | /// The segment function will be called for each segment detected that lies along the density contour for @c threshold. 24 | CP_EXPORT void cpMarchHard( 25 | cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat threshold, 26 | cpMarchSegmentFunc segment, void *segment_data, 27 | cpMarchSampleFunc sample, void *sample_data 28 | ); 29 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpPinJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpPinJoint cpPinJoint 23 | /// @{ 24 | 25 | /// Check if a constraint is a pin joint. 26 | CP_EXPORT cpBool cpConstraintIsPinJoint(const cpConstraint *constraint); 27 | 28 | /// Allocate a pin joint. 29 | CP_EXPORT cpPinJoint* cpPinJointAlloc(void); 30 | /// Initialize a pin joint. 31 | CP_EXPORT cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); 32 | /// Allocate and initialize a pin joint. 33 | CP_EXPORT cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); 34 | 35 | /// Get the location of the first anchor relative to the first body. 36 | CP_EXPORT cpVect cpPinJointGetAnchorA(const cpConstraint *constraint); 37 | /// Set the location of the first anchor relative to the first body. 38 | CP_EXPORT void cpPinJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); 39 | 40 | /// Get the location of the second anchor relative to the second body. 41 | CP_EXPORT cpVect cpPinJointGetAnchorB(const cpConstraint *constraint); 42 | /// Set the location of the second anchor relative to the second body. 43 | CP_EXPORT void cpPinJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); 44 | 45 | /// Get the distance the joint will maintain between the two anchors. 46 | CP_EXPORT cpFloat cpPinJointGetDist(const cpConstraint *constraint); 47 | /// Set the distance the joint will maintain between the two anchors. 48 | CP_EXPORT void cpPinJointSetDist(cpConstraint *constraint, cpFloat dist); 49 | 50 | ///@} 51 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpPivotJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpPivotJoint cpPivotJoint 23 | /// @{ 24 | 25 | /// Check if a constraint is a slide joint. 26 | CP_EXPORT cpBool cpConstraintIsPivotJoint(const cpConstraint *constraint); 27 | 28 | /// Allocate a pivot joint 29 | CP_EXPORT cpPivotJoint* cpPivotJointAlloc(void); 30 | /// Initialize a pivot joint. 31 | CP_EXPORT cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); 32 | /// Allocate and initialize a pivot joint. 33 | CP_EXPORT cpConstraint* cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot); 34 | /// Allocate and initialize a pivot joint with specific anchors. 35 | CP_EXPORT cpConstraint* cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); 36 | 37 | /// Get the location of the first anchor relative to the first body. 38 | CP_EXPORT cpVect cpPivotJointGetAnchorA(const cpConstraint *constraint); 39 | /// Set the location of the first anchor relative to the first body. 40 | CP_EXPORT void cpPivotJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); 41 | 42 | /// Get the location of the second anchor relative to the second body. 43 | CP_EXPORT cpVect cpPivotJointGetAnchorB(const cpConstraint *constraint); 44 | /// Set the location of the second anchor relative to the second body. 45 | CP_EXPORT void cpPivotJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); 46 | 47 | /// @} 48 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpPolyline.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Howling Moon Software. All rights reserved. 2 | // See http://chipmunk2d.net/legal.php for more information. 3 | 4 | // Polylines are just arrays of vertexes. 5 | // They are looped if the first vertex is equal to the last. 6 | // cpPolyline structs are intended to be passed by value and destroyed when you are done with them. 7 | typedef struct cpPolyline { 8 | int count, capacity; 9 | cpVect verts[]; 10 | } cpPolyline; 11 | 12 | /// Destroy and free a polyline instance. 13 | CP_EXPORT void cpPolylineFree(cpPolyline *line); 14 | 15 | /// Returns true if the first vertex is equal to the last. 16 | CP_EXPORT cpBool cpPolylineIsClosed(cpPolyline *line); 17 | 18 | /** 19 | Returns a copy of a polyline simplified by using the Douglas-Peucker algorithm. 20 | This works very well on smooth or gently curved shapes, but not well on straight edged or angular shapes. 21 | */ 22 | CP_EXPORT cpPolyline *cpPolylineSimplifyCurves(cpPolyline *line, cpFloat tol); 23 | 24 | /** 25 | Returns a copy of a polyline simplified by discarding "flat" vertexes. 26 | This works well on straight edged or angular shapes, not as well on smooth shapes. 27 | */ 28 | CP_EXPORT cpPolyline *cpPolylineSimplifyVertexes(cpPolyline *line, cpFloat tol); 29 | 30 | /// Get the convex hull of a polyline as a looped polyline. 31 | CP_EXPORT cpPolyline *cpPolylineToConvexHull(cpPolyline *line, cpFloat tol); 32 | 33 | 34 | /// Polyline sets are collections of polylines, generally built by cpMarchSoft() or cpMarchHard(). 35 | typedef struct cpPolylineSet { 36 | int count, capacity; 37 | cpPolyline **lines; 38 | } cpPolylineSet; 39 | 40 | /// Allocate a new polyline set. 41 | CP_EXPORT cpPolylineSet *cpPolylineSetAlloc(void); 42 | 43 | /// Initialize a new polyline set. 44 | CP_EXPORT cpPolylineSet *cpPolylineSetInit(cpPolylineSet *set); 45 | 46 | /// Allocate and initialize a polyline set. 47 | CP_EXPORT cpPolylineSet *cpPolylineSetNew(void); 48 | 49 | /// Destroy a polyline set. 50 | CP_EXPORT void cpPolylineSetDestroy(cpPolylineSet *set, cpBool freePolylines); 51 | 52 | /// Destroy and free a polyline set. 53 | CP_EXPORT void cpPolylineSetFree(cpPolylineSet *set, cpBool freePolylines); 54 | 55 | /** 56 | Add a line segment to a polyline set. 57 | A segment will either start a new polyline, join two others, or add to or loop an existing polyline. 58 | This is mostly intended to be used as a callback directly from cpMarchSoft() or cpMarchHard(). 59 | */ 60 | CP_EXPORT void cpPolylineSetCollectSegment(cpVect v0, cpVect v1, cpPolylineSet *lines); 61 | 62 | /** 63 | Get an approximate convex decomposition from a polyline. 64 | Returns a cpPolylineSet of convex hulls that match the original shape to within 'tol'. 65 | NOTE: If the input is a self intersecting polygon, the output might end up overly simplified. 66 | */ 67 | 68 | CP_EXPORT cpPolylineSet *cpPolylineConvexDecomposition(cpPolyline *line, cpFloat tol); 69 | 70 | #define cpPolylineConvexDecomposition_BETA cpPolylineConvexDecomposition 71 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpRatchetJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpRatchetJoint cpRatchetJoint 23 | /// @{ 24 | 25 | /// Check if a constraint is a damped rotary springs. 26 | CP_EXPORT cpBool cpConstraintIsRatchetJoint(const cpConstraint *constraint); 27 | 28 | /// Allocate a ratchet joint. 29 | CP_EXPORT cpRatchetJoint* cpRatchetJointAlloc(void); 30 | /// Initialize a ratched joint. 31 | CP_EXPORT cpRatchetJoint* cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); 32 | /// Allocate and initialize a ratchet joint. 33 | CP_EXPORT cpConstraint* cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); 34 | 35 | /// Get the angle of the current ratchet tooth. 36 | CP_EXPORT cpFloat cpRatchetJointGetAngle(const cpConstraint *constraint); 37 | /// Set the angle of the current ratchet tooth. 38 | CP_EXPORT void cpRatchetJointSetAngle(cpConstraint *constraint, cpFloat angle); 39 | 40 | /// Get the phase offset of the ratchet. 41 | CP_EXPORT cpFloat cpRatchetJointGetPhase(const cpConstraint *constraint); 42 | /// Get the phase offset of the ratchet. 43 | CP_EXPORT void cpRatchetJointSetPhase(cpConstraint *constraint, cpFloat phase); 44 | 45 | /// Get the angular distance of each ratchet. 46 | CP_EXPORT cpFloat cpRatchetJointGetRatchet(const cpConstraint *constraint); 47 | /// Set the angular distance of each ratchet. 48 | CP_EXPORT void cpRatchetJointSetRatchet(cpConstraint *constraint, cpFloat ratchet); 49 | 50 | /// @} 51 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpRobust.h: -------------------------------------------------------------------------------- 1 | #include "chipmunk/cpVect.h" 2 | 3 | // This is a private header for functions (currently just one) that need strict floating point results. 4 | // It was easier to put this in it's own file than to fiddle with 4 different compiler specific pragmas or attributes. 5 | // "Fast math" should be disabled here. 6 | 7 | // Check if c is to the left of segment (a, b). 8 | cpBool cpCheckPointGreater(const cpVect a, const cpVect b, const cpVect c); 9 | 10 | // Check if p is behind one of v0 or v1 on axis n. 11 | cpBool cpCheckAxis(cpVect v0, cpVect v1, cpVect p, cpVect n); 12 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpRotaryLimitJoint.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpRotaryLimitJoint cpRotaryLimitJoint 23 | /// @{ 24 | 25 | /// Check if a constraint is a damped rotary springs. 26 | CP_EXPORT cpBool cpConstraintIsRotaryLimitJoint(const cpConstraint *constraint); 27 | 28 | /// Allocate a damped rotary limit joint. 29 | CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointAlloc(void); 30 | /// Initialize a damped rotary limit joint. 31 | CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); 32 | /// Allocate and initialize a damped rotary limit joint. 33 | CP_EXPORT cpConstraint* cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max); 34 | 35 | /// Get the minimum distance the joint will maintain between the two anchors. 36 | CP_EXPORT cpFloat cpRotaryLimitJointGetMin(const cpConstraint *constraint); 37 | /// Set the minimum distance the joint will maintain between the two anchors. 38 | CP_EXPORT void cpRotaryLimitJointSetMin(cpConstraint *constraint, cpFloat min); 39 | 40 | /// Get the maximum distance the joint will maintain between the two anchors. 41 | CP_EXPORT cpFloat cpRotaryLimitJointGetMax(const cpConstraint *constraint); 42 | /// Set the maximum distance the joint will maintain between the two anchors. 43 | CP_EXPORT void cpRotaryLimitJointSetMax(cpConstraint *constraint, cpFloat max); 44 | 45 | /// @} 46 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/include/chipmunk/cpSimpleMotor.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | /// @defgroup cpSimpleMotor cpSimpleMotor 23 | /// @{ 24 | 25 | /// Opaque struct type for damped rotary springs. 26 | typedef struct cpSimpleMotor cpSimpleMotor; 27 | 28 | /// Check if a constraint is a damped rotary springs. 29 | CP_EXPORT cpBool cpConstraintIsSimpleMotor(const cpConstraint *constraint); 30 | 31 | /// Allocate a simple motor. 32 | CP_EXPORT cpSimpleMotor* cpSimpleMotorAlloc(void); 33 | /// initialize a simple motor. 34 | CP_EXPORT cpSimpleMotor* cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate); 35 | /// Allocate and initialize a simple motor. 36 | CP_EXPORT cpConstraint* cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate); 37 | 38 | /// Get the rate of the motor. 39 | CP_EXPORT cpFloat cpSimpleMotorGetRate(const cpConstraint *constraint); 40 | /// Set the rate of the motor. 41 | CP_EXPORT void cpSimpleMotorSetRate(cpConstraint *constraint, cpFloat rate); 42 | 43 | /// @} 44 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Chipmunk2D/prime.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * 10 | * The above copyright notice and this permission notice shall be included in 11 | * all copies or substantial portions of the Software. 12 | * 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | * SOFTWARE. 20 | */ 21 | 22 | // Used for resizing hash tables. 23 | // Values approximately double. 24 | // http://planetmath.org/encyclopedia/GoodHashTablePrimes.html 25 | static int primes[] = { 26 | 5, 27 | 13, 28 | 23, 29 | 47, 30 | 97, 31 | 193, 32 | 389, 33 | 769, 34 | 1543, 35 | 3079, 36 | 6151, 37 | 12289, 38 | 24593, 39 | 49157, 40 | 98317, 41 | 196613, 42 | 393241, 43 | 786433, 44 | 1572869, 45 | 3145739, 46 | 6291469, 47 | 12582917, 48 | 25165843, 49 | 50331653, 50 | 100663319, 51 | 201326611, 52 | 402653189, 53 | 805306457, 54 | 1610612741, 55 | 0, 56 | }; 57 | 58 | static inline int 59 | next_prime(int n) 60 | { 61 | int i = 0; 62 | while(n > primes[i]){ 63 | i++; 64 | cpAssertHard(primes[i], "Tried to resize a hash table to a size greater than 1610612741 O_o"); // realistically this should never happen 65 | } 66 | 67 | return primes[i]; 68 | } 69 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Microsoft.UI.Dispatching.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Dispatching { 10 | // type: Microsoft.UI.Dispatching.DispatcherQueue 11 | // runtime class 12 | public class DispatcherQueue 13 | : 14 | WinRT.Object 15 | { 16 | private var _self : Microsoft.UI.Dispatching.IDispatcherQueue; 17 | public init(plok: Microsoft.UI.Dispatching.IDispatcherQueue?) throws { 18 | _self = plok! 19 | try super.init(plok: _self.QueryInterface()) 20 | } 21 | public func Interface() -> Microsoft.UI.Dispatching.IDispatcherQueue { return _self; } 22 | // static interface not needed: Microsoft.UI.Dispatching.IDispatcherQueueStatics 23 | // method not needed: CreateTimer 24 | // method not needed: TryEnqueue 25 | // method not needed: TryEnqueue 26 | // method not needed: add_ShutdownStarting 27 | // method not needed: remove_ShutdownStarting 28 | // method not needed: add_ShutdownCompleted 29 | // method not needed: remove_ShutdownCompleted 30 | // instance interface not needed: Microsoft.UI.Dispatching.IDispatcherQueue2 31 | } 32 | 33 | // type: Microsoft.UI.Dispatching.IDispatcherQueue 34 | // interface type 35 | open class IDispatcherQueue 36 | : 37 | WinRT.IInspectable 38 | { 39 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xf6ebf8fa, Data2: 0xbe1c, Data3 : 0x5bf6, Data4 : (0xa4, 0x67, 0x73, 0xda, 0x28, 0x73, 0x8a, 0xe8)) } 40 | // method not needed: CreateTimer 41 | // method not needed: TryEnqueue 42 | // method not needed: TryEnqueueWithPriority 43 | // method not needed: add_ShutdownStarting 44 | // method not needed: remove_ShutdownStarting 45 | // method not needed: add_ShutdownCompleted 46 | // method not needed: remove_ShutdownCompleted 47 | } // IDispatcherQueue 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.ApplicationModel.DataTransfer.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.ApplicationModel.DataTransfer { 10 | // type: Windows.ApplicationModel.DataTransfer.DataPackageOperation 11 | // enum type 12 | public typealias DataPackageOperation = _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation; 13 | 14 | } 15 | extension Windows.ApplicationModel.DataTransfer.DataPackageOperation { 16 | public static var None : Self { 17 | get { 18 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_None; 19 | } 20 | } 21 | public static var Copy : Self { 22 | get { 23 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Copy; 24 | } 25 | } 26 | public static var Move : Self { 27 | get { 28 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Move; 29 | } 30 | } 31 | public static var Link : Self { 32 | get { 33 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Link; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.Foundation.Numerics.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Foundation.Numerics { 10 | // type: Windows.Foundation.Numerics.Matrix3x2 11 | // struct type 12 | public typealias Matrix3x2 = _q_CWindows_CFoundation_CNumerics_CMatrix3x2; 13 | 14 | // type: Windows.Foundation.Numerics.Matrix4x4 15 | // struct type 16 | public typealias Matrix4x4 = _q_CWindows_CFoundation_CNumerics_CMatrix4x4; 17 | 18 | // type: Windows.Foundation.Numerics.Vector2 19 | // struct type 20 | public typealias Vector2 = _q_CWindows_CFoundation_CNumerics_CVector2; 21 | 22 | // type: Windows.Foundation.Numerics.Vector3 23 | // struct type 24 | public typealias Vector3 = _q_CWindows_CFoundation_CNumerics_CVector3; 25 | 26 | // type: Windows.Foundation.Numerics.Vector4 27 | // struct type 28 | public typealias Vector4 = _q_CWindows_CFoundation_CNumerics_CVector4; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.Graphics.Effects.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.Effects { 10 | // type: Windows.Graphics.Effects.IGraphicsEffect 11 | // interface type 12 | open class IGraphicsEffect 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xcb51c0ce, Data2: 0x8fe6, Data3 : 0x4636, Data4 : (0xb2, 0x02, 0x86, 0x1f, 0xaa, 0x07, 0xd8, 0xf3)) } 17 | // [IsSpecialName] System.String get_Name() 18 | private func _n_get_Name(_ __presult: UnsafeMutablePointer>?) throws { 19 | return try perform(as: _q_CWindows_CGraphics_CEffects_CIGraphicsEffect.self) { pThis in 20 | try CHECKED(pThis.pointee.lpVtbl.pointee.get_Name(pThis, __presult)) 21 | } 22 | } 23 | public func get_Name() throws -> Swift.String { 24 | var __result : Optional = nil; 25 | try self._n_get_Name(&__result); 26 | return Swift.String(from: __result); 27 | } 28 | // [IsSpecialName] void put_Name(System.String) 29 | private func _n_put_Name(_ name : Optional) throws { 30 | return try perform(as: _q_CWindows_CGraphics_CEffects_CIGraphicsEffect.self) { pThis in 31 | try CHECKED(pThis.pointee.lpVtbl.pointee.put_Name(pThis, name)) 32 | } 33 | } 34 | public func put_Name(name : Optional) throws -> Void { 35 | let __hstr_name = try HString(name!); 36 | return try withExtendedLifetime(__hstr_name) { 37 | try self._n_put_Name(__hstr_name.Raw()); 38 | } 39 | } 40 | public var Name : Swift.String { 41 | get throws { 42 | return try get_Name(); 43 | } 44 | } 45 | } // IGraphicsEffect 46 | 47 | 48 | // type: Windows.Graphics.Effects.IGraphicsEffectSource 49 | // interface type 50 | open class IGraphicsEffectSource 51 | : 52 | WinRT.IInspectable 53 | { 54 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x2d8f9ddc, Data2: 0x4339, Data3 : 0x4eb9, Data4 : (0x92, 0x16, 0xf9, 0xde, 0xb7, 0x56, 0x58, 0xa2)) } 55 | } // IGraphicsEffectSource 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.Graphics.Printing.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Graphics.Printing { 10 | // type: Windows.Graphics.Printing.IPrintTaskOptionsCore 11 | // interface type 12 | open class IPrintTaskOptionsCore 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x1bdbb474, Data2: 0x4ed1, Data3 : 0x41eb, Data4 : (0xbe, 0x3c, 0x72, 0xd1, 0x8e, 0xd6, 0x73, 0x37)) } 17 | // method not needed: GetPageDescription 18 | } // IPrintTaskOptionsCore 19 | 20 | 21 | // type: Windows.Graphics.Printing.PrintTaskOptions 22 | // runtime class 23 | public class PrintTaskOptions 24 | : 25 | WinRT.Object 26 | { 27 | private var _self : Windows.Graphics.Printing.IPrintTaskOptionsCore; 28 | public init(plok: Windows.Graphics.Printing.IPrintTaskOptionsCore?) throws { 29 | _self = plok! 30 | try super.init(plok: _self.QueryInterface()) 31 | } 32 | public func Interface() -> Windows.Graphics.Printing.IPrintTaskOptionsCore { return _self; } 33 | // method not needed: GetPageDescription 34 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptionsCoreProperties 35 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptionsCoreUIConfiguration 36 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptions 37 | // instance interface not needed: Windows.Graphics.Printing.IPrintTaskOptions2 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.Storage.Streams.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage.Streams { 10 | // type: Windows.Storage.Streams.IBuffer 11 | // interface type 12 | open class IBuffer 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe0, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 17 | // method not needed: get_Capacity 18 | // method not needed: get_Length 19 | // method not needed: put_Length 20 | } // IBuffer 21 | 22 | 23 | // type: Windows.Storage.Streams.IRandomAccessStream 24 | // interface type 25 | open class IRandomAccessStream 26 | : 27 | WinRT.IInspectable 28 | { 29 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe1, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 30 | // method not needed: get_Size 31 | // method not needed: put_Size 32 | // method not needed: GetInputStreamAt 33 | // method not needed: GetOutputStreamAt 34 | // method not needed: get_Position 35 | // method not needed: Seek 36 | // method not needed: CloneStream 37 | // method not needed: get_CanRead 38 | // method not needed: get_CanWrite 39 | } // IRandomAccessStream 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.UI.Text.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Text { 10 | // type: Windows.UI.Text.FontStretch 11 | // enum type 12 | public typealias FontStretch = _q_CWindows_CUI_CText_CFontStretch; 13 | 14 | // type: Windows.UI.Text.FontStyle 15 | // enum type 16 | public typealias FontStyle = _q_CWindows_CUI_CText_CFontStyle; 17 | 18 | // type: Windows.UI.Text.FontWeight 19 | // struct type 20 | public typealias FontWeight = _q_CWindows_CUI_CText_CFontWeight; 21 | 22 | } 23 | extension Windows.UI.Text.FontStretch { 24 | public static var Undefined : Self { 25 | get { 26 | return _q_CWindows_CUI_CText_CFontStretch_Undefined; 27 | } 28 | } 29 | public static var UltraCondensed : Self { 30 | get { 31 | return _q_CWindows_CUI_CText_CFontStretch_UltraCondensed; 32 | } 33 | } 34 | public static var ExtraCondensed : Self { 35 | get { 36 | return _q_CWindows_CUI_CText_CFontStretch_ExtraCondensed; 37 | } 38 | } 39 | public static var Condensed : Self { 40 | get { 41 | return _q_CWindows_CUI_CText_CFontStretch_Condensed; 42 | } 43 | } 44 | public static var SemiCondensed : Self { 45 | get { 46 | return _q_CWindows_CUI_CText_CFontStretch_SemiCondensed; 47 | } 48 | } 49 | public static var Normal : Self { 50 | get { 51 | return _q_CWindows_CUI_CText_CFontStretch_Normal; 52 | } 53 | } 54 | public static var SemiExpanded : Self { 55 | get { 56 | return _q_CWindows_CUI_CText_CFontStretch_SemiExpanded; 57 | } 58 | } 59 | public static var Expanded : Self { 60 | get { 61 | return _q_CWindows_CUI_CText_CFontStretch_Expanded; 62 | } 63 | } 64 | public static var ExtraExpanded : Self { 65 | get { 66 | return _q_CWindows_CUI_CText_CFontStretch_ExtraExpanded; 67 | } 68 | } 69 | public static var UltraExpanded : Self { 70 | get { 71 | return _q_CWindows_CUI_CText_CFontStretch_UltraExpanded; 72 | } 73 | } 74 | } 75 | extension Windows.UI.Text.FontStyle { 76 | public static var Normal : Self { 77 | get { 78 | return _q_CWindows_CUI_CText_CFontStyle_Normal; 79 | } 80 | } 81 | public static var Oblique : Self { 82 | get { 83 | return _q_CWindows_CUI_CText_CFontStyle_Oblique; 84 | } 85 | } 86 | public static var Italic : Self { 87 | get { 88 | return _q_CWindows_CUI_CText_CFontStyle_Italic; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.UI.Xaml.Interop.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Xaml.Interop { 10 | // type: Windows.UI.Xaml.Interop.TypeKind 11 | // enum type 12 | public typealias TypeKind = _q_CWindows_CUI_CXaml_CInterop_CTypeKind; 13 | 14 | // type: Windows.UI.Xaml.Interop.TypeName 15 | // struct type 16 | public typealias TypeName = _q_CWindows_CUI_CXaml_CInterop_CTypeName; 17 | 18 | } 19 | extension Windows.UI.Xaml.Interop.TypeKind { 20 | public static var Primitive : Self { 21 | get { 22 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Primitive; 23 | } 24 | } 25 | public static var Metadata : Self { 26 | get { 27 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Metadata; 28 | } 29 | } 30 | public static var Custom : Self { 31 | get { 32 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Custom; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/Windows.UI.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI { 10 | // type: Windows.UI.Color 11 | // struct type 12 | public typealias Color = _q_CWindows_CUI_CColor; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Microsoft { } 6 | extension Microsoft { public struct Graphics { } } 7 | extension Microsoft.Graphics { public struct Canvas { } } 8 | extension Microsoft.Graphics.Canvas { public struct Brushes { } } 9 | extension Microsoft.Graphics.Canvas { public struct Effects { } } 10 | extension Microsoft.Graphics.Canvas { public struct Geometry { } } 11 | extension Microsoft.Graphics.Canvas { public struct Printing { } } 12 | extension Microsoft.Graphics.Canvas { public struct Svg { } } 13 | extension Microsoft.Graphics.Canvas { public struct Text { } } 14 | extension Microsoft.Graphics.Canvas { public struct UI { } } 15 | extension Microsoft.Graphics.Canvas.UI { public struct Composition { } } 16 | extension Microsoft.Graphics.Canvas.UI { public struct Xaml { } } 17 | extension Microsoft { public struct UI { } } 18 | extension Microsoft.UI { public struct Composition { } } 19 | extension Microsoft.UI { public struct Dispatching { } } 20 | extension Microsoft.UI { public struct Input { } } 21 | extension Microsoft.UI { public struct Xaml { } } 22 | extension Microsoft.UI.Xaml { public struct Automation { } } 23 | extension Microsoft.UI.Xaml.Automation { public struct Peers { } } 24 | extension Microsoft.UI.Xaml { public struct Controls { } } 25 | extension Microsoft.UI.Xaml.Controls { public struct Primitives { } } 26 | extension Microsoft.UI.Xaml { public struct Data { } } 27 | extension Microsoft.UI.Xaml { public struct Input { } } 28 | extension Microsoft.UI.Xaml { public struct Markup { } } 29 | extension Microsoft.UI.Xaml { public struct Media { } } 30 | extension Microsoft.UI.Xaml.Media { public struct Animation { } } 31 | extension Microsoft.UI.Xaml.Media { public struct Imaging { } } 32 | extension Microsoft.UI.Xaml.Media { public struct Media3D { } } 33 | public struct Windows { } 34 | extension Windows { public struct ApplicationModel { } } 35 | extension Windows.ApplicationModel { public struct DataTransfer { } } 36 | extension Windows { public struct Foundation { } } 37 | extension Windows.Foundation { public struct Collections { } } 38 | extension Windows.Foundation { public struct Numerics { } } 39 | extension Windows { public struct Graphics { } } 40 | extension Windows.Graphics { public struct DirectX { } } 41 | extension Windows.Graphics.DirectX { public struct Direct3D11 { } } 42 | extension Windows.Graphics { public struct Effects { } } 43 | extension Windows.Graphics { public struct Imaging { } } 44 | extension Windows.Graphics { public struct Printing { } } 45 | extension Windows { public struct Storage { } } 46 | extension Windows.Storage { public struct Streams { } } 47 | extension Windows { public struct UI { } } 48 | extension Windows.UI { public struct Core { } } 49 | extension Windows.UI { public struct Text { } } 50 | extension Windows.UI { public struct Xaml { } } 51 | extension Windows.UI.Xaml { public struct Interop { } } 52 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/cg_Microsoft.Graphics.Canvas.Effects.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CMicrosoft_CGraphics_CCanvas_CEffects_CColorManagementSimpleProfile 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x41db10c7, Data2: 0xf02c, Data3 : 0x5d7f, Data4 : (0xa1, 0x2e, 0x4e, 0x05, 0x04, 0x73, 0x88, 0xe7)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CMicrosoft_CGraphics_CCanvas_CEffects_CColorManagementSimpleProfile 18 | } 19 | -------------------------------------------------------------------------------- /Samples/Physics/Sources/Physics/generated/cg_Windows.Foundation.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CWindows_CFoundation_CRect 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x80423f11, Data2: 0x054f, Data3 : 0x5eac, Data4 : (0xaf, 0xd3, 0x63, 0xb6, 0xce, 0x15, 0xe7, 0x7b)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CWindows_CFoundation_CRect 18 | // closed interface type 19 | public class IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 20 | : 21 | WinRT.IInspectable 22 | { 23 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xae44597e, Data2: 0xd411, Data3 : 0x5b7f, Data4 : (0xbb, 0xec, 0x6a, 0x96, 0xc9, 0x4a, 0x10, 0x7a)) } 24 | // method not needed: First 25 | } // IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 26 | // closed interface type 27 | public class IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 28 | : 29 | WinRT.IInspectable 30 | { 31 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x377f6162, Data2: 0x6e4d, Data3 : 0x574e, Data4 : (0xbf, 0x01, 0x77, 0xf4, 0xfd, 0x02, 0x1d, 0x0e)) } 32 | // method not needed: get_Current 33 | // method not needed: get_HasCurrent 34 | // method not needed: MoveNext 35 | // method not needed: GetMany 36 | } // IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 37 | // closed interface type 38 | public class IIterable_1__q_CWindows_CFoundation_CPoint 39 | : 40 | WinRT.IInspectable 41 | { 42 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc192280d, Data2: 0x3a09, Data3 : 0x5423, Data4 : (0x9d, 0xc5, 0x67, 0xb8, 0x3e, 0xbd, 0xe4, 0x1d)) } 43 | // method not needed: First 44 | } // IIterable_1__q_CWindows_CFoundation_CPoint 45 | // closed interface type 46 | public class IIterator_1__q_CWindows_CFoundation_CPoint 47 | : 48 | WinRT.IInspectable 49 | { 50 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc602b59e, Data2: 0x0a8e, Data3 : 0x5e99, Data4 : (0xb4, 0x78, 0x2b, 0x56, 0x45, 0x85, 0x27, 0x8d)) } 51 | // method not needed: get_Current 52 | // method not needed: get_HasCurrent 53 | // method not needed: MoveNext 54 | // method not needed: GetMany 55 | } // IIterator_1__q_CWindows_CFoundation_CPoint 56 | } 57 | -------------------------------------------------------------------------------- /Samples/Physics/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/Physics/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/Physics/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Microsoft.UI.Xaml.Application", 7 | "Microsoft.UI.Xaml.Window", 8 | "Microsoft.UI.Xaml.DispatcherTimer", 9 | "Microsoft.UI.Colors" 10 | ], 11 | "interfaces" : 12 | [ 13 | "Microsoft.UI.Xaml.Markup.IXamlMetadataProvider", 14 | "Microsoft.UI.Xaml.Markup.IXamlType", 15 | "Microsoft.UI.Xaml.Markup.IXamlMember" 16 | ], 17 | "namespaces" : 18 | [ 19 | "Microsoft.Graphics.Canvas" 20 | ], 21 | "blacklist" : 22 | [ 23 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11Surface", 24 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11SurfaceWithDpi", 25 | "Microsoft.Graphics.Canvas.ICanvasRenderTargetStatics:CreateFromDirect3D11SurfaceWithDpiAndAlpha" 26 | ] 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Samples/Power/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Power/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/Power/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Power/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/Power/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "Power", targets: ["Power"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "Power", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/Power/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/Power/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/Power/Sources/Power/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Microsoft { } 6 | extension Microsoft { public struct Windows { } } 7 | extension Microsoft.Windows { public struct System { } } 8 | extension Microsoft.Windows.System { public struct Power { } } 9 | public struct Windows { } 10 | extension Windows { public struct Foundation { } } 11 | -------------------------------------------------------------------------------- /Samples/Power/Sources/Power/main.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinRT 5 | 6 | typealias PowerManager = Microsoft.Windows.System.Power.PowerManager 7 | 8 | @main 9 | class Power { 10 | public static func main() throws { 11 | try RoInitialize() 12 | try WindowsAppSdkBootstrapInitialize() 13 | 14 | print("PowerSupplyStatus: ", try PowerManager.PowerSupplyStatus); 15 | print("BatteryStatus: ", try PowerManager.BatteryStatus); 16 | print("EnergySaverStatus: ", try PowerManager.EnergySaverStatus); 17 | print("RemainingChargePercent: ", try PowerManager.RemainingChargePercent); 18 | print("RemainingDischargeTime: ", try PowerManager.RemainingDischargeTime); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Samples/Power/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/Power/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/Power/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "namespaces" : 5 | [ 6 | "Microsoft.Windows.System.Power" 7 | ] 8 | } 9 | 10 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/SystemIdentification/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/SystemIdentification/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/SystemIdentification/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/SystemIdentification/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "SystemIdentification", targets: ["SystemIdentification"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "SystemIdentification", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Sources/SystemIdentification/generated/Windows.Storage.Streams.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage.Streams { 10 | // type: Windows.Storage.Streams.IBuffer 11 | // interface type 12 | open class IBuffer 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe0, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 17 | // method not needed: get_Capacity 18 | // method not needed: get_Length 19 | // method not needed: put_Length 20 | } // IBuffer 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Sources/SystemIdentification/generated/Windows.System.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.System { 10 | // type: Windows.System.IUser 11 | // interface type 12 | open class IUser 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xdf9a26c6, Data2: 0xe746, Data3 : 0x4bcd, Data4 : (0xb5, 0xd4, 0x12, 0x01, 0x03, 0xc4, 0x20, 0x9b)) } 17 | // method not needed: get_NonRoamableId 18 | // method not needed: get_AuthenticationStatus 19 | // method not needed: get_Type 20 | // method not needed: GetPropertyAsync 21 | // method not needed: GetPropertiesAsync 22 | // method not needed: GetPictureAsync 23 | } // IUser 24 | 25 | 26 | // type: Windows.System.User 27 | // runtime class 28 | public class User 29 | : 30 | WinRT.Object 31 | { 32 | private var _self : Windows.System.IUser; 33 | public init(plok: Windows.System.IUser?) throws { 34 | _self = plok! 35 | try super.init(plok: _self.QueryInterface()) 36 | } 37 | public func Interface() -> Windows.System.IUser { return _self; } 38 | // static interface not needed: Windows.System.IUserStatics 39 | // static interface not needed: Windows.System.IUserStatics2 40 | // method not needed: get_NonRoamableId 41 | // method not needed: get_AuthenticationStatus 42 | // method not needed: get_Type 43 | // method not needed: GetPropertyAsync 44 | // method not needed: GetPropertiesAsync 45 | // method not needed: GetPictureAsync 46 | // instance interface not needed: Windows.System.IUser2 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Sources/SystemIdentification/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Windows { } 6 | extension Windows { public struct Foundation { } } 7 | extension Windows { public struct Security { } } 8 | extension Windows.Security { public struct Cryptography { } } 9 | extension Windows { public struct Storage { } } 10 | extension Windows.Storage { public struct Streams { } } 11 | extension Windows { public struct System { } } 12 | extension Windows.System { public struct Profile { } } 13 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/Sources/SystemIdentification/main.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinRT 5 | 6 | @main 7 | class WinRTDemo { 8 | public static func main() throws { 9 | try RoInitialize() 10 | 11 | let buffer = try Windows.System.Profile.SystemIdentification.GetSystemIdForPublisher()! 12 | 13 | let id = try buffer.Id! 14 | 15 | let hex: String = 16 | try Windows.Security.Cryptography.CryptographicBuffer.EncodeToHexString(buffer: id)! 17 | let base64: String = 18 | try Windows.Security.Cryptography.CryptographicBuffer.EncodeToBase64String(buffer: id)! 19 | 20 | print("System ID for Publisher [hex]: \(hex)") 21 | print("System ID for Publisher [base64]: \(base64)") 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/SystemIdentification/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/SystemIdentification/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "statics" : 5 | [ 6 | "Windows.System.Profile.SystemIdentification", 7 | "Windows.Security.Cryptography.CryptographicBuffer" 8 | ], 9 | "classes" : 10 | [ 11 | "Windows.System.Profile.SystemIdentificationInfo" 12 | ], 13 | "interfaces" : 14 | [ 15 | ] 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Samples/Toast/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Toast/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/Toast/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/Toast/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/Toast/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .executable(name: "Toast", targets: ["Toast"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .executableTarget(name: "Toast", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/generated/Windows.Storage.Streams.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage.Streams { 10 | // type: Windows.Storage.Streams.IBuffer 11 | // interface type 12 | open class IBuffer 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x905a0fe0, Data2: 0xbc53, Data3 : 0x11df, Data4 : (0x8c, 0x49, 0x00, 0x1e, 0x4f, 0xc6, 0x86, 0xda)) } 17 | // method not needed: get_Capacity 18 | // method not needed: get_Length 19 | // method not needed: put_Length 20 | } // IBuffer 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/generated/Windows.Storage.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Storage { 10 | // type: Windows.Storage.IStorageFile 11 | // interface type 12 | open class IStorageFile 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xfa3f6186, Data2: 0x4214, Data3 : 0x428c, Data4 : (0xa6, 0x4c, 0x14, 0xc9, 0xac, 0x73, 0x15, 0xea)) } 17 | // method not needed: get_FileType 18 | // method not needed: get_ContentType 19 | // method not needed: OpenAsync 20 | // method not needed: OpenTransactedWriteAsync 21 | // method not needed: CopyOverloadDefaultNameAndOptions 22 | // method not needed: CopyOverloadDefaultOptions 23 | // method not needed: CopyOverload 24 | // method not needed: CopyAndReplaceAsync 25 | // method not needed: MoveOverloadDefaultNameAndOptions 26 | // method not needed: MoveOverloadDefaultOptions 27 | // method not needed: MoveOverload 28 | // method not needed: MoveAndReplaceAsync 29 | } // IStorageFile 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/generated/Windows.System.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.System { 10 | // type: Windows.System.IUser 11 | // interface type 12 | open class IUser 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xdf9a26c6, Data2: 0xe746, Data3 : 0x4bcd, Data4 : (0xb5, 0xd4, 0x12, 0x01, 0x03, 0xc4, 0x20, 0x9b)) } 17 | // method not needed: get_NonRoamableId 18 | // method not needed: get_AuthenticationStatus 19 | // method not needed: get_Type 20 | // method not needed: GetPropertyAsync 21 | // method not needed: GetPropertiesAsync 22 | // method not needed: GetPictureAsync 23 | } // IUser 24 | 25 | 26 | // type: Windows.System.User 27 | // runtime class 28 | public class User 29 | : 30 | WinRT.Object 31 | { 32 | private var _self : Windows.System.IUser; 33 | public init(plok: Windows.System.IUser?) throws { 34 | _self = plok! 35 | try super.init(plok: _self.QueryInterface()) 36 | } 37 | public func Interface() -> Windows.System.IUser { return _self; } 38 | // static interface not needed: Windows.System.IUserStatics 39 | // static interface not needed: Windows.System.IUserStatics2 40 | // method not needed: get_NonRoamableId 41 | // method not needed: get_AuthenticationStatus 42 | // method not needed: get_Type 43 | // method not needed: GetPropertyAsync 44 | // method not needed: GetPropertiesAsync 45 | // method not needed: GetPictureAsync 46 | // instance interface not needed: Windows.System.IUser2 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Windows { } 6 | extension Windows { public struct Data { } } 7 | extension Windows.Data { public struct Xml { } } 8 | extension Windows.Data.Xml { public struct Dom { } } 9 | extension Windows { public struct Foundation { } } 10 | extension Windows.Foundation { public struct Collections { } } 11 | extension Windows { public struct Storage { } } 12 | extension Windows.Storage { public struct Streams { } } 13 | extension Windows { public struct System { } } 14 | extension Windows { public struct UI { } } 15 | extension Windows.UI { public struct Notifications { } } 16 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/generated/cg_Swift.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IIterable_1__cg_CWindows_CFoundation_CCollections_IKeyValuePair_2_HSTRING_HSTRING 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xe9bdaaf0, Data2: 0xcbf6, Data3 : 0x5c72, Data4 : (0xbe, 0x90, 0x29, 0xcb, 0xf3, 0xa1, 0x31, 0x9b)) } 16 | // method not needed: First 17 | } // IIterable_1__cg_CWindows_CFoundation_CCollections_IKeyValuePair_2_HSTRING_HSTRING 18 | // closed interface type 19 | public class IIterator_1__cg_CWindows_CFoundation_CCollections_IKeyValuePair_2_HSTRING_HSTRING 20 | : 21 | WinRT.IInspectable 22 | { 23 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x05eb86f1, Data2: 0x7140, Data3 : 0x5517, Data4 : (0xb8, 0x8d, 0xcb, 0xae, 0xbe, 0x57, 0xe6, 0xb1)) } 24 | // method not needed: get_Current 25 | // method not needed: get_HasCurrent 26 | // method not needed: MoveNext 27 | // method not needed: GetMany 28 | } // IIterator_1__cg_CWindows_CFoundation_CCollections_IKeyValuePair_2_HSTRING_HSTRING 29 | // closed interface type 30 | public class IKeyValuePair_2_HSTRING_HSTRING 31 | : 32 | WinRT.IInspectable 33 | { 34 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x60310303, Data2: 0x49c5, Data3 : 0x52e6, Data4 : (0xab, 0xc6, 0xa9, 0xb3, 0x6e, 0xcc, 0xc7, 0x16)) } 35 | // method not needed: get_Key 36 | // method not needed: get_Value 37 | } // IKeyValuePair_2_HSTRING_HSTRING 38 | } 39 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/generated/cg_Windows.Foundation.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IReference_1__q_CWindows_CFoundation_CDateTime 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x5541d8a7, Data2: 0x497c, Data3 : 0x5aa4, Data4 : (0x86, 0xfc, 0x77, 0x13, 0xad, 0xbf, 0x2a, 0x2c)) } 16 | // method not needed: get_Value 17 | } // IReference_1__q_CWindows_CFoundation_CDateTime 18 | } 19 | -------------------------------------------------------------------------------- /Samples/Toast/Sources/Toast/main.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | import WinRT 6 | 7 | @main 8 | class WinRTDemo { 9 | public static func main() throws { 10 | try RoInitialize() 11 | 12 | let doc = try Windows.Data.Xml.Dom.XmlDocument() 13 | let s = 14 | #""" 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | """# 26 | try doc.LoadXml(xml: s) 27 | let toast = try Windows.UI.Notifications.ToastNotification(content: doc) 28 | let notifier = try Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(applicationId: "VisualStudio.3ca2c57a")! 29 | try notifier.Show(notification: toast); 30 | Sleep(1) 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /Samples/Toast/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/Toast/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/Toast/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Windows.Data.Xml.Dom.XmlDocument", 7 | "Windows.UI.Notifications.ToastNotification", 8 | "Windows.UI.Notifications.ToastNotifier" 9 | ], 10 | "statics" : 11 | [ 12 | "Windows.UI.Notifications.ToastNotificationManager" 13 | ] 14 | } 15 | 16 | -------------------------------------------------------------------------------- /Samples/XamlApp/Microsoft.WindowsAppRuntime.Bootstrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/XamlApp/Microsoft.WindowsAppRuntime.Bootstrap.dll -------------------------------------------------------------------------------- /Samples/XamlApp/Microsoft.WindowsAppRuntime.Bootstrap.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ericsink/SwiftWinRT/6f5d97b37b035946f6594862079398307e97dbda/Samples/XamlApp/Microsoft.WindowsAppRuntime.Bootstrap.lib -------------------------------------------------------------------------------- /Samples/XamlApp/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "Samples", 7 | products: [ 8 | .library(name: "XamlApp", type: .dynamic, targets: ["XamlApp"]), 9 | ], 10 | dependencies : [ 11 | .package(name: "WinRT", path: "../../WinRT"), 12 | ], 13 | targets: [ 14 | .target(name: "C"), 15 | .target(name: "XamlApp", dependencies: ["C", "WinRT"], 16 | swiftSettings: [ 17 | .unsafeFlags(["-parse-as-library"]), 18 | ], 19 | linkerSettings: [ 20 | // need /MANIFEST:embed for bootstrap Windows App SDK to work 21 | .unsafeFlags(["-Xlinker"]), 22 | .unsafeFlags(["/MANIFEST:embed"]), 23 | ] 24 | ), 25 | ] 26 | ) 27 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/C/include/C.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | // the following file contains stuff that is automatically generated from winmd 17 | #include 18 | 19 | #pragma comment(lib, "runtimeobject") 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/C/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/Microsoft.UI.Dispatching.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Dispatching { 10 | // type: Microsoft.UI.Dispatching.DispatcherQueue 11 | // runtime class 12 | public class DispatcherQueue 13 | : 14 | WinRT.Object 15 | { 16 | private var _self : Microsoft.UI.Dispatching.IDispatcherQueue; 17 | public init(plok: Microsoft.UI.Dispatching.IDispatcherQueue?) throws { 18 | _self = plok! 19 | try super.init(plok: _self.QueryInterface()) 20 | } 21 | public func Interface() -> Microsoft.UI.Dispatching.IDispatcherQueue { return _self; } 22 | // static interface not needed: Microsoft.UI.Dispatching.IDispatcherQueueStatics 23 | // method not needed: CreateTimer 24 | // method not needed: TryEnqueue 25 | // method not needed: TryEnqueue 26 | // method not needed: add_ShutdownStarting 27 | // method not needed: remove_ShutdownStarting 28 | // method not needed: add_ShutdownCompleted 29 | // method not needed: remove_ShutdownCompleted 30 | // instance interface not needed: Microsoft.UI.Dispatching.IDispatcherQueue2 31 | } 32 | 33 | // type: Microsoft.UI.Dispatching.IDispatcherQueue 34 | // interface type 35 | open class IDispatcherQueue 36 | : 37 | WinRT.IInspectable 38 | { 39 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xf6ebf8fa, Data2: 0xbe1c, Data3 : 0x5bf6, Data4 : (0xa4, 0x67, 0x73, 0xda, 0x28, 0x73, 0x8a, 0xe8)) } 40 | // method not needed: CreateTimer 41 | // method not needed: TryEnqueue 42 | // method not needed: TryEnqueueWithPriority 43 | // method not needed: add_ShutdownStarting 44 | // method not needed: remove_ShutdownStarting 45 | // method not needed: add_ShutdownCompleted 46 | // method not needed: remove_ShutdownCompleted 47 | } // IDispatcherQueue 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/Microsoft.UI.Input.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Microsoft.UI.Input { 10 | // type: Microsoft.UI.Input.IInputCursor 11 | // interface type 12 | open class IInputCursor 13 | : 14 | WinRT.IInspectable 15 | { 16 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x359b15f9, Data2: 0x19c2, Data3 : 0x5714, Data4 : (0x84, 0x32, 0x75, 0x17, 0x68, 0x26, 0x40, 0x6b)) } 17 | } // IInputCursor 18 | 19 | 20 | // type: Microsoft.UI.Input.IPointerPoint 21 | // interface type 22 | open class IPointerPoint 23 | : 24 | WinRT.IInspectable 25 | { 26 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x0d430ee6, Data2: 0x252c, Data3 : 0x59a4, Data4 : (0xb2, 0xa2, 0xd4, 0x42, 0x64, 0xdc, 0x6a, 0x40)) } 27 | // method not needed: get_FrameId 28 | // method not needed: get_IsInContact 29 | // method not needed: get_PointerDeviceType 30 | // method not needed: get_PointerId 31 | // method not needed: get_Position 32 | // method not needed: get_Properties 33 | // method not needed: get_Timestamp 34 | // method not needed: GetTransformedPoint 35 | } // IPointerPoint 36 | 37 | 38 | // type: Microsoft.UI.Input.InputCursor 39 | // runtime class 40 | open class InputCursor 41 | : 42 | WinRT.Object 43 | { 44 | private var _self : Microsoft.UI.Input.IInputCursor; 45 | public init(plok: Microsoft.UI.Input.IInputCursor?) throws { 46 | _self = plok! 47 | try super.init(plok: _self.QueryInterface()) 48 | } 49 | public func Interface() -> Microsoft.UI.Input.IInputCursor { return _self; } 50 | // COMPOSABLE: Microsoft.UI.Input.IInputCursorFactory 51 | // composable interface not needed: Microsoft.UI.Input.IInputCursorFactory 52 | // static interface not needed: Microsoft.UI.Input.IInputCursorStatics 53 | // instance interface not needed: Windows.Foundation.IClosable 54 | } 55 | 56 | // type: Microsoft.UI.Input.PointerPoint 57 | // runtime class 58 | public class PointerPoint 59 | : 60 | WinRT.Object 61 | { 62 | private var _self : Microsoft.UI.Input.IPointerPoint; 63 | public init(plok: Microsoft.UI.Input.IPointerPoint?) throws { 64 | _self = plok! 65 | try super.init(plok: _self.QueryInterface()) 66 | } 67 | public func Interface() -> Microsoft.UI.Input.IPointerPoint { return _self; } 68 | // method not needed: get_FrameId 69 | // method not needed: get_IsInContact 70 | // method not needed: get_PointerDeviceType 71 | // method not needed: get_PointerId 72 | // method not needed: get_Position 73 | // method not needed: get_Properties 74 | // method not needed: get_Timestamp 75 | // method not needed: GetTransformedPoint 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/Windows.ApplicationModel.DataTransfer.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.ApplicationModel.DataTransfer { 10 | // type: Windows.ApplicationModel.DataTransfer.DataPackageOperation 11 | // enum type 12 | public typealias DataPackageOperation = _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation; 13 | 14 | } 15 | extension Windows.ApplicationModel.DataTransfer.DataPackageOperation { 16 | public static var None : Self { 17 | get { 18 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_None; 19 | } 20 | } 21 | public static var Copy : Self { 22 | get { 23 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Copy; 24 | } 25 | } 26 | public static var Move : Self { 27 | get { 28 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Move; 29 | } 30 | } 31 | public static var Link : Self { 32 | get { 33 | return _q_CWindows_CApplicationModel_CDataTransfer_CDataPackageOperation_Link; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/Windows.Foundation.Numerics.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.Foundation.Numerics { 10 | // type: Windows.Foundation.Numerics.Matrix4x4 11 | // struct type 12 | public typealias Matrix4x4 = _q_CWindows_CFoundation_CNumerics_CMatrix4x4; 13 | 14 | // type: Windows.Foundation.Numerics.Vector2 15 | // struct type 16 | public typealias Vector2 = _q_CWindows_CFoundation_CNumerics_CVector2; 17 | 18 | // type: Windows.Foundation.Numerics.Vector3 19 | // struct type 20 | public typealias Vector3 = _q_CWindows_CFoundation_CNumerics_CVector3; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/Windows.UI.Xaml.Interop.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI.Xaml.Interop { 10 | // type: Windows.UI.Xaml.Interop.TypeKind 11 | // enum type 12 | public typealias TypeKind = _q_CWindows_CUI_CXaml_CInterop_CTypeKind; 13 | 14 | // type: Windows.UI.Xaml.Interop.TypeName 15 | // struct type 16 | public typealias TypeName = _q_CWindows_CUI_CXaml_CInterop_CTypeName; 17 | 18 | } 19 | extension Windows.UI.Xaml.Interop.TypeKind { 20 | public static var Primitive : Self { 21 | get { 22 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Primitive; 23 | } 24 | } 25 | public static var Metadata : Self { 26 | get { 27 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Metadata; 28 | } 29 | } 30 | public static var Custom : Self { 31 | get { 32 | return _q_CWindows_CUI_CXaml_CInterop_CTypeKind_Custom; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/Windows.UI.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension Windows.UI { 10 | // type: Windows.UI.Color 11 | // struct type 12 | public typealias Color = _q_CWindows_CUI_CColor; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/__ns.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | public struct ClosedGenerics { } 5 | public struct Microsoft { } 6 | extension Microsoft { public struct UI { } } 7 | extension Microsoft.UI { public struct Composition { } } 8 | extension Microsoft.UI { public struct Dispatching { } } 9 | extension Microsoft.UI { public struct Input { } } 10 | extension Microsoft.UI { public struct Xaml { } } 11 | extension Microsoft.UI.Xaml { public struct Automation { } } 12 | extension Microsoft.UI.Xaml.Automation { public struct Peers { } } 13 | extension Microsoft.UI.Xaml { public struct Controls { } } 14 | extension Microsoft.UI.Xaml.Controls { public struct Primitives { } } 15 | extension Microsoft.UI.Xaml { public struct Data { } } 16 | extension Microsoft.UI.Xaml { public struct Documents { } } 17 | extension Microsoft.UI.Xaml { public struct Input { } } 18 | extension Microsoft.UI.Xaml { public struct Markup { } } 19 | extension Microsoft.UI.Xaml { public struct Media { } } 20 | extension Microsoft.UI.Xaml.Media { public struct Animation { } } 21 | extension Microsoft.UI.Xaml.Media { public struct Media3D { } } 22 | public struct Windows { } 23 | extension Windows { public struct ApplicationModel { } } 24 | extension Windows.ApplicationModel { public struct DataTransfer { } } 25 | extension Windows { public struct Foundation { } } 26 | extension Windows.Foundation { public struct Collections { } } 27 | extension Windows.Foundation { public struct Numerics { } } 28 | extension Windows { public struct UI { } } 29 | extension Windows.UI { public struct Core { } } 30 | extension Windows.UI { public struct Text { } } 31 | extension Windows.UI { public struct Xaml { } } 32 | extension Windows.UI.Xaml { public struct Interop { } } 33 | -------------------------------------------------------------------------------- /Samples/XamlApp/Sources/XamlApp/generated/cg_Windows.Foundation.swift: -------------------------------------------------------------------------------- 1 | // this file is automatically generated. 2 | // if you modify it by hand, your changes will probably be lost. 3 | 4 | 5 | import CWinRT; 6 | @_spi(IUnknown) import WinRT; 7 | import C; 8 | 9 | extension ClosedGenerics { 10 | // closed interface type 11 | public class IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 12 | : 13 | WinRT.IInspectable 14 | { 15 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xae44597e, Data2: 0xd411, Data3 : 0x5b7f, Data4 : (0xbb, 0xec, 0x6a, 0x96, 0xc9, 0x4a, 0x10, 0x7a)) } 16 | // method not needed: First 17 | } // IIterable_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 18 | // closed interface type 19 | public class IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 20 | : 21 | WinRT.IInspectable 22 | { 23 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0x377f6162, Data2: 0x6e4d, Data3 : 0x574e, Data4 : (0xbf, 0x01, 0x77, 0xf4, 0xfd, 0x02, 0x1d, 0x0e)) } 24 | // method not needed: get_Current 25 | // method not needed: get_HasCurrent 26 | // method not needed: MoveNext 27 | // method not needed: GetMany 28 | } // IIterator_1__cg_CWindows_CFoundation_CCollections_IIterable_1__q_CWindows_CFoundation_CPoint 29 | // closed interface type 30 | public class IIterable_1__q_CWindows_CFoundation_CPoint 31 | : 32 | WinRT.IInspectable 33 | { 34 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc192280d, Data2: 0x3a09, Data3 : 0x5423, Data4 : (0x9d, 0xc5, 0x67, 0xb8, 0x3e, 0xbd, 0xe4, 0x1d)) } 35 | // method not needed: First 36 | } // IIterable_1__q_CWindows_CFoundation_CPoint 37 | // closed interface type 38 | public class IIterator_1__q_CWindows_CFoundation_CPoint 39 | : 40 | WinRT.IInspectable 41 | { 42 | override public class var IID : CWinRT.IID { CWinRT.IID(Data1: 0xc602b59e, Data2: 0x0a8e, Data3 : 0x5e99, Data4 : (0xb4, 0x78, 0x2b, 0x56, 0x45, 0x85, 0x27, 0x8d)) } 43 | // method not needed: get_Current 44 | // method not needed: get_HasCurrent 45 | // method not needed: MoveNext 46 | // method not needed: GetMany 47 | } // IIterator_1__q_CWindows_CFoundation_CPoint 48 | } 49 | -------------------------------------------------------------------------------- /Samples/XamlApp/gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | dotnet run --project ../../../bridge/sg_gen_swift_winrt/sg_gen_swift_winrt.fsproj -- ./winrt.json 3 | 4 | -------------------------------------------------------------------------------- /Samples/XamlApp/winrt.json: -------------------------------------------------------------------------------- 1 | { 2 | "swift_output_dir" : "./Sources/XamlApp/generated", 3 | "c_output_dir" : "./Sources/C/include", 4 | "classes" : 5 | [ 6 | "Microsoft.UI.Xaml.Window", 7 | "Microsoft.UI.Xaml.DispatcherTimer", 8 | "Microsoft.UI.Xaml.Controls.TextBlock", 9 | "Microsoft.UI.Xaml.Controls.TextBox", 10 | "Microsoft.UI.Xaml.Controls.StackPanel", 11 | "Microsoft.UI.Xaml.Controls.Slider", 12 | "Microsoft.UI.Xaml.Controls.Button", 13 | "Microsoft.UI.Xaml.Media.LinearGradientBrush", 14 | "Microsoft.UI.Xaml.Media.GradientStop", 15 | "Microsoft.UI.Colors" 16 | ], 17 | "interfaces" : 18 | [ 19 | "Microsoft.UI.Xaml.Markup.IXamlMetadataProvider", 20 | "Microsoft.UI.Xaml.Markup.IXamlType", 21 | "Microsoft.UI.Xaml.Markup.IXamlMember" 22 | ], 23 | "namespaces" : 24 | [ 25 | ], 26 | "blacklist" : 27 | [ 28 | ] 29 | } 30 | 31 | -------------------------------------------------------------------------------- /WinRT/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | 3 | import PackageDescription 4 | 5 | let SwiftWinRT = Package( 6 | name: "WinRT", 7 | products: [ 8 | .library(name: "WinRT", type: .dynamic, targets: ["WinRT"]), 9 | ], 10 | targets: [ 11 | .target(name: "CWinRT"), 12 | .target(name: "WinRT", dependencies: ["CWinRT"], 13 | linkerSettings: [ 14 | .linkedLibrary("Microsoft.WindowsAppRuntime.Bootstrap"), 15 | .linkedLibrary("Ole32"), 16 | ] 17 | ), 18 | ] 19 | ) 20 | -------------------------------------------------------------------------------- /WinRT/Sources/CWinRT/include/CWinRT.h: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | #ifndef CWinRT_CWinRT_h 5 | #define CWinRT_CWinRT_h 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // TODO should get these by including MddBoostrap.h, 14 | // but it's in a nuget package, so we're working around 15 | // Swift's (obvious) lack of support for nuget. 16 | 17 | STDAPI MddBootstrapInitialize( 18 | UINT32 majorMinorVersion, 19 | PCWSTR versionTag, 20 | UINT64 minVersion 21 | ); 22 | 23 | STDAPI MddBootstrapInitialize2( 24 | UINT32 majorMinorVersion, 25 | PCWSTR versionTag, 26 | UINT64 minVersion, 27 | UINT32 options 28 | ); 29 | 30 | #include 31 | #include 32 | 33 | #pragma comment(lib, "runtimeobject") 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /WinRT/Sources/CWinRT/shim.c: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | // ISO C requires a translation unit to contain at least one declaration. 5 | extern unsigned _; 6 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/COM/IUnknown+Swift.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | extension IUnknown { 7 | public func QueryInterface() throws -> Interface { 8 | guard let pUnk = self.pUnk.borrow else { throw Error(hr: E_INVALIDARG) } 9 | 10 | var iid: IID = Interface.IID 11 | var pointer: UnsafeMutableRawPointer? 12 | try CHECKED(pUnk.pointee.lpVtbl.pointee.QueryInterface(pUnk, &iid, &pointer)) 13 | return Interface(consuming: pointer?.bindMemory(to: WinSDK.IUnknown.self, capacity: 1)) 14 | } 15 | } 16 | 17 | extension IUnknown { 18 | public static func CreateInstance(`class` clsid: CLSID, 19 | outer pUnkOuter: IUnknown? = nil, 20 | context dwClsContext: CLSCTX = CLSCTX_INPROC_SERVER) 21 | throws -> Interface { 22 | var clsid: CLSID = clsid 23 | var iid: IID = Interface.IID 24 | 25 | var pointer: UnsafeMutableRawPointer? 26 | try CHECKED(CoCreateInstance(&clsid, RawPointer(pUnkOuter), DWORD(dwClsContext.rawValue), &iid, &pointer)) 27 | return Interface(consuming: pointer?.bindMemory(to: WinSDK.IUnknown.self, capacity: 1)) 28 | } 29 | } 30 | 31 | extension IUnknown { 32 | @_spi(IUnknown) 33 | @_alwaysEmitIntoClient @inline(__always) 34 | public func perform(as type: Type.Type, 35 | _ body: (UnsafeMutablePointer) throws -> ResultType) 36 | throws -> ResultType { 37 | guard let pUnk = UnsafeMutableRawPointer(self.pUnk.borrow) else { 38 | throw Error(hr: E_INVALIDARG) 39 | } 40 | let pThis = pUnk.bindMemory(to: Type.self, capacity: 1) 41 | 42 | return try body(pThis) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/COM/IUnknown.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | open class IUnknown { 7 | @usableFromInline 8 | internal let pUnk: IUnknownRef 9 | 10 | open class var IID: IID { IID_IUnknown } 11 | 12 | public required init(_ pointer: UnsafeMutablePointer?) { 13 | self.pUnk = IUnknownRef(pointer) 14 | } 15 | 16 | public convenience init(_ pointer: UnsafeMutableRawPointer?) { 17 | let pUnk: UnsafeMutablePointer? = 18 | pointer?.bindMemory(to: WinSDK.IUnknown.self, capacity: 1) 19 | self.init(pUnk) 20 | } 21 | 22 | public required init(consuming pointer: UnsafeMutablePointer?) { 23 | self.pUnk = IUnknownRef(consuming: pointer) 24 | } 25 | 26 | public convenience init(consuming pointer: UnsafeMutableRawPointer?) { 27 | let pUnk: UnsafeMutablePointer? = 28 | pointer?.bindMemory(to: WinSDK.IUnknown.self, capacity: 1) 29 | self.init(consuming: pUnk) 30 | } 31 | 32 | @_alwaysEmitIntoClient @inline(__always) 33 | public func QueryInterface(_ iid: REFIID, _ ppvObject: UnsafeMutablePointer?) throws { 34 | let pUnk: UnsafeMutablePointer! = self.pUnk.borrow 35 | try CHECKED(pUnk.pointee.lpVtbl.pointee.QueryInterface(pUnk, iid, ppvObject)) 36 | } 37 | 38 | @_alwaysEmitIntoClient @inline(__always) 39 | public func AddRef() -> ULONG { 40 | let pUnk: UnsafeMutablePointer! = self.pUnk.borrow 41 | return pUnk.pointee.lpVtbl.pointee.AddRef(pUnk) 42 | } 43 | 44 | @_alwaysEmitIntoClient @inline(__always) 45 | public func Release() -> ULONG { 46 | let pUnk: UnsafeMutablePointer! = self.pUnk.borrow 47 | return pUnk.pointee.lpVtbl.pointee.Release(pUnk) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/COM/IUnknownRef.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | @_fixed_layout 7 | @usableFromInline 8 | internal final class IUnknownRef { 9 | private var pUnk: UnsafeMutablePointer? 10 | 11 | init(_ pUnk: UnsafeMutablePointer?) { 12 | self.pUnk = pUnk 13 | _ = self.pUnk?.pointee.lpVtbl.pointee.AddRef(self.pUnk) 14 | } 15 | 16 | convenience init(_ pointer: UnsafeMutableRawPointer?) { 17 | let pUnk = pointer?.bindMemory(to: WinSDK.IUnknown.self, capacity: 1) 18 | self.init(pUnk) 19 | } 20 | 21 | init(consuming pUnk: UnsafeMutablePointer?) { 22 | self.pUnk = pUnk 23 | } 24 | 25 | convenience init(consuming pointer: UnsafeMutableRawPointer?) { 26 | let pUnk = pointer?.bindMemory(to: WinSDK.IUnknown.self, capacity: 1) 27 | self.init(consuming: pUnk) 28 | } 29 | 30 | deinit { 31 | _ = self.pUnk?.pointee.lpVtbl.pointee.Release(self.pUnk) 32 | } 33 | 34 | @usableFromInline 35 | internal var borrow: UnsafeMutablePointer? { 36 | return self.pUnk 37 | } 38 | 39 | @usableFromInline 40 | internal var ref: UnsafeMutablePointer? { 41 | _ = self.pUnk?.pointee.lpVtbl.pointee.AddRef(self.pUnk) 42 | return self.pUnk 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Future.swift: -------------------------------------------------------------------------------- 1 | 2 | // TODO wish this were not public 3 | 4 | public protocol Future { 5 | associatedtype ValueType 6 | func get() throws -> ValueType 7 | } 8 | 9 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/HString.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | 6 | @_implementationOnly 7 | import func ucrt.wcslen 8 | 9 | public class HString { 10 | internal private(set) var hRef: HStringStorage 11 | 12 | public func Raw() -> Optional { 13 | return hRef.hString 14 | } 15 | 16 | public init(_ string: String) throws { 17 | self.hRef = try string.withCString(encodedAs: UTF16.self) { 18 | try HStringStorage(UnsafeBufferPointer(start: $0, count: wcslen($0))) 19 | } 20 | } 21 | 22 | public init(_ buffer: UnsafeBufferPointer?) throws { 23 | self.hRef = try HStringStorage(buffer) 24 | } 25 | 26 | public init(consuming hString: CWinRT.HSTRING?) { 27 | self.hRef = HStringStorage(consuming: hString) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/HStringStorage.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | 6 | @_fixed_layout 7 | @usableFromInline 8 | final internal class HStringStorage { 9 | internal private(set) var hString: HSTRING? 10 | 11 | internal init(_ hString: HSTRING?) throws { 12 | try CHECKED(WindowsDuplicateString(hString, &self.hString)) 13 | } 14 | 15 | internal init(consuming hString: HSTRING?) { 16 | self.hString = hString 17 | } 18 | 19 | internal init(_ buffer: UnsafeBufferPointer?) throws { 20 | try CHECKED(WindowsCreateString(buffer?.baseAddress ?? nil, 21 | UINT32(buffer?.count ?? 0), 22 | &self.hString)) 23 | } 24 | 25 | deinit { 26 | try! CHECKED(WindowsDeleteString(self.hString)) 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/IInspectable+Swift.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | 6 | extension IInspectable { 7 | public func GetIids() throws -> [IID] { 8 | var iids: UnsafeMutablePointer? 9 | var iidCount: ULONG = 0 10 | 11 | try self.GetIids(&iidCount, &iids) 12 | defer { CoTaskMemFree(iids) } 13 | 14 | return Array(unsafeUninitializedCapacity: Int(iidCount)) { 15 | _ = memcpy($0.baseAddress, iids, MemoryLayout.stride * Int(iidCount)) 16 | $1 = Int(iidCount) 17 | } 18 | } 19 | 20 | public func GetRuntimeClassName() throws -> HString { 21 | var className: CWinRT.HSTRING? 22 | try self.GetRuntimeClassName(&className) 23 | return HString(consuming: className) 24 | } 25 | 26 | public func GetTrustLevel() throws -> TrustLevel { 27 | var trustLevel: TrustLevel = .BaseTrust 28 | try self.GetTrustLevel(&trustLevel) 29 | return trustLevel 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/IInspectable.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | 6 | open class IInspectable: IUnknown { 7 | override open class var IID: IID { IID_IInspectable } 8 | 9 | public func GetIids(_ iidCount: UnsafeMutablePointer, _ iids: UnsafeMutablePointer?>?) throws { 10 | return try perform(as: CWinRT.IInspectable.self) { pThis in 11 | try CHECKED(pThis.pointee.lpVtbl.pointee.GetIids(pThis, iidCount, iids)) 12 | } 13 | } 14 | 15 | public func GetRuntimeClassName(_ className: UnsafeMutablePointer) throws { 16 | return try perform(as: CWinRT.IInspectable.self) { pThis in 17 | try CHECKED(pThis.pointee.lpVtbl.pointee.GetRuntimeClassName(pThis, className)) 18 | } 19 | } 20 | 21 | public func GetTrustLevel(_ trustLevel: UnsafeMutablePointer?) throws { 22 | return try perform(as: CWinRT.IInspectable.self) { pThis in 23 | try CHECKED(pThis.pointee.lpVtbl.pointee.GetTrustLevel(pThis, trustLevel)) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Object.swift: -------------------------------------------------------------------------------- 1 | 2 | open class Object 3 | { 4 | private var _self : WinRT.IInspectable; 5 | public init(plok: WinRT.IInspectable?) throws { 6 | _self = plok! 7 | } 8 | // TODO this deliberately has a different name from Interface(), 9 | // which all the derived clases use, because giving this the 10 | // same name triggers a ton of errors about needing an override 11 | // keyword, and when we add that keyword, we get errors saying 12 | // it isn't needed. probably because all the subclasses return 13 | // something that inherits from the type this one returns. 14 | public final func GetInterface() throws -> WinRT.IInspectable { 15 | return _self 16 | } 17 | public func QueryInterface() throws -> Interface { 18 | return try _self.QueryInterface() 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Setup.swift: -------------------------------------------------------------------------------- 1 | 2 | import CWinRT 3 | 4 | public func WindowsAppSdkBootstrapInitialize() throws { 5 | // TODO this currently hard-codes the arguments, 6 | // specifying Windows App SDK 1.1, no version tag, no minVersion 7 | // which is kinda wrong. 8 | try CHECKED(MddBootstrapInitialize2(0x00010001, nil, 0, 0x10)); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Support/COM+Extensions.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | public func ==(_ lhs: (T, T, T, T, T, T, T, T), 7 | _ rhs: (T, T, T, T, T, T, T, T)) -> Bool { 8 | return lhs.0 == rhs.0 && 9 | lhs.1 == rhs.1 && 10 | lhs.2 == rhs.2 && 11 | lhs.3 == rhs.3 && 12 | lhs.4 == rhs.4 && 13 | lhs.5 == rhs.5 && 14 | lhs.6 == rhs.6 && 15 | lhs.7 == rhs.7 16 | } 17 | 18 | public func ==(_ lhs: _GUID, _ rhs: _GUID) -> Bool { 19 | return lhs.Data1 == rhs.Data1 && 20 | lhs.Data2 == rhs.Data2 && 21 | lhs.Data3 == rhs.Data3 && 22 | lhs.Data4 == rhs.Data4 23 | } 24 | 25 | public func ~=(_ lhs: _GUID, _ rhs: _GUID) -> Bool { 26 | return lhs.Data1 == rhs.Data1 && 27 | lhs.Data2 == rhs.Data2 && 28 | lhs.Data3 == rhs.Data3 && 29 | lhs.Data4 == rhs.Data4 30 | } 31 | 32 | extension _GUID: CustomStringConvertible { 33 | public var description: String { 34 | withUnsafePointer(to: self) { pGUID in 35 | Array(unsafeUninitializedCapacity: 40) { 36 | $1 = Int(StringFromGUID2(pGUID, $0.baseAddress, CInt($0.count))) 37 | }.withUnsafeBufferPointer { 38 | String(decodingCString: $0.baseAddress!, as: UTF16.self) 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Support/Error.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | public struct Error: Swift.Error { 7 | public let hr: HRESULT 8 | 9 | public init(hr: HRESULT) { 10 | self.hr = hr 11 | } 12 | } 13 | 14 | extension Error: CustomStringConvertible { 15 | public var description: String { 16 | let dwFlags: DWORD = DWORD(FORMAT_MESSAGE_ALLOCATE_BUFFER) 17 | | DWORD(FORMAT_MESSAGE_FROM_SYSTEM) 18 | | DWORD(FORMAT_MESSAGE_IGNORE_INSERTS) 19 | 20 | var buffer: UnsafeMutablePointer? = nil 21 | let dwResult: DWORD = withUnsafeMutablePointer(to: &buffer) { 22 | $0.withMemoryRebound(to: WCHAR.self, capacity: 2) { 23 | FormatMessageW(dwFlags, nil, DWORD(bitPattern: hr), 24 | MAKELANGID(WORD(LANG_NEUTRAL), WORD(SUBLANG_DEFAULT)), 25 | $0, 0, nil) 26 | } 27 | } 28 | guard dwResult > 0, let message = buffer else { 29 | return "HRESULT(0x\(String(DWORD(bitPattern: hr), radix: 16)))" 30 | } 31 | defer { LocalFree(buffer) } 32 | return "0x\(String(DWORD(bitPattern: hr), radix: 16)) - \(String(decodingCString: message, as: UTF16.self))" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Support/ErrorHandling.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | @_alwaysEmitIntoClient @inline(__always) @discardableResult 7 | public func CHECKED(_ body: () -> HRESULT) throws -> HRESULT { 8 | let hr: HRESULT = body() 9 | guard hr >= 0 else { throw Error(hr: hr) } 10 | return hr 11 | } 12 | 13 | @_alwaysEmitIntoClient @inline(__always) @discardableResult 14 | public func CHECKED(_ body: @autoclosure () -> HRESULT) throws -> HRESULT { 15 | return try CHECKED(body) 16 | } 17 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Support/RawTyped.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | @_spi(IUnknown) 7 | public func RawPointer(_ pUnk: T?) -> UnsafeMutablePointer? { 8 | guard let pUnk = pUnk else { return nil } 9 | if let pUnk: UnsafeMutableRawPointer = UnsafeMutableRawPointer(pUnk.pUnk.borrow) { 10 | return pUnk.bindMemory(to: U.self, capacity: 1) 11 | } 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Support/Swift+Extensions.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | 6 | extension String { 7 | public init(from hString: HSTRING?) { 8 | var length: UINT32 = 0 9 | let pwszBuffer: PCWSTR = WindowsGetStringRawBuffer(hString, &length) 10 | self.init(decoding: UnsafeBufferPointer(start: pwszBuffer, count: Int(length)), as: UTF16.self) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/Support/WinSDK+Extensions.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import WinSDK 5 | 6 | public typealias REFIID = UnsafePointer 7 | 8 | // winerror.h 9 | 10 | @_transparent 11 | public var E_INVALIDARG: HRESULT { 12 | HRESULT(bitPattern: 0x80070057) 13 | } 14 | 15 | @_transparent 16 | public var E_NOTIMPL: HRESULT { 17 | HRESULT(bitPattern: 0x80004001) 18 | } 19 | 20 | @_transparent 21 | public var E_NOINTERFACE: HRESULT { 22 | HRESULT(bitPattern: 0x80004002) 23 | } 24 | 25 | @_transparent 26 | public var E_FAIL: HRESULT { 27 | HRESULT(bitPattern: 0x80004005) 28 | } 29 | 30 | // winnt.h 31 | 32 | @_transparent 33 | internal func MAKELANGID(_ p: WORD, _ s: WORD) -> DWORD { 34 | return DWORD((s << 10) | p) 35 | } 36 | -------------------------------------------------------------------------------- /WinRT/Sources/WinRT/TrustLevel+Swift.swift: -------------------------------------------------------------------------------- 1 | // Copyright © 2021 Saleem Abdulrasool 2 | // SPDX-License-Identifier: BSD-3 3 | 4 | import CWinRT 5 | 6 | extension TrustLevel { 7 | public static var BaseTrust: TrustLevel { 8 | TrustLevel(rawValue: 0) 9 | } 10 | 11 | public static var PartialTrust: TrustLevel { 12 | TrustLevel(rawValue: 1) 13 | } 14 | 15 | public static var FullTrust: TrustLevel { 16 | TrustLevel(rawValue: 2) 17 | } 18 | } 19 | --------------------------------------------------------------------------------