Skip to content

Commit fb5eafe

Browse files
committed
feat(shims): expose C path aliases
1 parent ab24fe2 commit fb5eafe

8 files changed

Lines changed: 118 additions & 5 deletions

File tree

‎Package.resolved‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Package.swift‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ extension Target {
197197
dependencies.append(
198198
.product(name: "RenderBox", package: "DarwinPrivateFrameworks")
199199
)
200-
var swiftSettings = swiftSettings ?? []
201-
swiftSettings.append(.define("OPENRENDERBOX_RENDERBOX"))
202-
self.swiftSettings = swiftSettings
200+
cSettings = (cSettings ?? []) + [.define("OPENRENDERBOX_RENDERBOX")]
201+
cxxSettings = (cxxSettings ?? []) + [.define("OPENRENDERBOX_RENDERBOX")]
202+
swiftSettings = (swiftSettings ?? []) + [.define("OPENRENDERBOX_RENDERBOX")]
203203
}
204204
}
205205

@@ -231,8 +231,19 @@ let openRenderBoxCxxTarget = Target.target(
231231
)
232232
let openRenderBoxShimsTarget = Target.target(
233233
name: "OpenRenderBoxShims",
234+
dependencies: ["OpenRenderBoxShimsCxx"],
234235
swiftSettings: sharedSwiftSettings
235236
)
237+
let openRenderBoxShimsCxxTarget = Target.target(
238+
name: "OpenRenderBoxShimsCxx",
239+
dependencies: renderBoxCondtion
240+
? [.product(name: "RenderBox", package: "DarwinPrivateFrameworks")]
241+
: ["OpenRenderBox"],
242+
sources: ["OpenRenderBoxShimsCxx.c"],
243+
publicHeadersPath: renderBoxCondtion ? "include/RenderBox" : "include/OpenRenderBox",
244+
cSettings: sharedCSettings,
245+
cxxSettings: sharedCxxSettings
246+
)
236247
let openRenderBoxTestsTarget = Target.testTarget(
237248
name: "OpenRenderBoxTests",
238249
dependencies: [
@@ -270,7 +281,7 @@ let package = Package(
270281
name: "OpenRenderBox",
271282
products: [
272283
.library(name: "OpenRenderBox", type: libraryType, targets: ["OpenRenderBox", "OpenRenderBoxCxx"]),
273-
.library(name: "OpenRenderBoxShims", type: libraryType, targets: ["OpenRenderBoxShims"]),
284+
.library(name: "OpenRenderBoxShims", type: libraryType, targets: ["OpenRenderBoxShims", "OpenRenderBoxShimsCxx"]),
274285
],
275286
dependencies: [
276287
.package(url: "https://github.com/apple/swift-numerics", from: "1.1.1"),
@@ -279,6 +290,7 @@ let package = Package(
279290
openRenderBoxTarget,
280291
openRenderBoxCxxTarget,
281292
openRenderBoxShimsTarget,
293+
openRenderBoxShimsCxxTarget,
282294
openRenderBoxTestsTarget,
283295
openRenderBoxCompatibilityTestTarget,
284296
],

‎README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,27 @@ Currently, this project is in early development.
2222

2323
The current suggested toolchain to build the project is Swift 6.3.3 / Xcode 26.6.
2424

25+
## Shims
26+
27+
The `OpenRenderBoxShims` product provides Swift aliases and a C header for path APIs.
28+
Swift clients use:
29+
30+
```swift
31+
import OpenRenderBoxShims
32+
```
33+
34+
C, C++, and Objective-C clients use:
35+
36+
```c
37+
#include <OpenRenderBoxShims/OpenRenderBoxShims.h>
38+
```
39+
40+
The C module is `OpenRenderBoxShimsCxx`; its public header uses the product name.
41+
42+
The package selects the public header directory for the configured backend.
43+
Clients use `ORB` names with either backend and do not need to define
44+
`OPENRENDERBOX_RENDERBOX` in their preprocessor settings.
45+
2546
## Supported platforms
2647

2748
| **CI Status** |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty file to make SwiftPM happy :)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//
2+
// OpenRenderBoxShims.h
3+
// OpenRenderBoxShims
4+
5+
#pragma once
6+
7+
#include <OpenRenderBox/ORBPath.h>
8+
#include <OpenRenderBox/ORBPathCallbacks.h>
9+
#include <OpenRenderBox/ORBPathStorage.h>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module OpenRenderBoxShimsCxx {
2+
umbrella header "OpenRenderBoxShims/OpenRenderBoxShims.h"
3+
export *
4+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// OpenRenderBoxShims.h
3+
// OpenRenderBoxShims
4+
5+
#pragma once
6+
7+
#include <RenderBox/RBPath.h>
8+
#include <RenderBox/RBPathCallbacks.h>
9+
#include <RenderBox/RBPathStorage.h>
10+
11+
typedef RBPath ORBPath;
12+
typedef RBPathElement ORBPathElement;
13+
typedef RBPathRoundedCornerStyle ORBPathRoundedCornerStyle;
14+
typedef RBPathApplyCallback ORBPathApplyCallback;
15+
typedef RBPathCallbacks ORBPathCallbacks;
16+
typedef RBPathCallbacksFlags ORBPathCallbacksFlags;
17+
typedef RBPathCallbacksExtended ORBPathCallbacksExtended;
18+
typedef RBPathStorageRef ORBPathStorageRef;
19+
20+
#define ORBPathElementMoveToPoint RBPathElementMoveToPoint
21+
#define ORBPathElementAddLineToPoint RBPathElementAddLineToPoint
22+
#define ORBPathElementAddQuadCurveToPoint RBPathElementAddQuadCurveToPoint
23+
#define ORBPathElementAddCurveToPoint RBPathElementAddCurveToPoint
24+
#define ORBPathElementCloseSubpath RBPathElementCloseSubpath
25+
#define ORBPathElementRect RBPathElementRect
26+
#define ORBPathElementRoundedRect RBPathElementRoundedRect
27+
#define ORBPathElementFixedRoundedRectCircular RBPathElementFixedRoundedRectCircular
28+
#define ORBPathElementFixedRoundedRectContinuous RBPathElementFixedRoundedRectContinuous
29+
#define ORBPathElementInvalid RBPathElementInvalid
30+
31+
#define ORBPathRoundedCornerStyleCircular RBPathRoundedCornerStyleCircular
32+
#define ORBPathRoundedCornerStyleContinuous RBPathRoundedCornerStyleContinuous
33+
34+
#define ORBPathEmpty RBPathEmpty
35+
#define ORBPathNull RBPathNull
36+
#define ORBPathRetain RBPathRetain
37+
#define ORBPathRelease RBPathRelease
38+
#define ORBPathMakeWithCGPath RBPathMakeWithCGPath
39+
#define ORBPathMakeRect RBPathMakeRect
40+
#define ORBPathMakeEllipse RBPathMakeEllipse
41+
#define ORBPathMakeRoundedRect RBPathMakeRoundedRect
42+
#define ORBPathMakeUnevenRoundedRect RBPathMakeUnevenRoundedRect
43+
#define ORBPathIsEmpty RBPathIsEmpty
44+
#define ORBPathApplyElements RBPathApplyElements
45+
#define ORBPathEqualToPath RBPathEqualToPath
46+
#define ORBPathCopyCGPath RBPathCopyCGPath
47+
#define ORBPathContainsPoint RBPathContainsPoint
48+
#define ORBPathContainsPoints RBPathContainsPoints
49+
50+
#define ORBPathCGPathCallbacks RBPathCGPathCallbacks
51+
#define ORBPathStorageInit RBPathStorageInit
52+
#define ORBPathStorageDestroy RBPathStorageDestroy
53+
#define ORBPathStorageClear RBPathStorageClear
54+
#define ORBPathStorageAppendElement RBPathStorageAppendElement
55+
#define ORBPathStorageAppendPath RBPathStorageAppendPath
56+
#define ORBPathStorageApplyElements RBPathStorageApplyElements
57+
#define ORBPathStorageIsEmpty RBPathStorageIsEmpty
58+
#define ORBPathStorageEqualToStorage RBPathStorageEqualToStorage
59+
#define ORBPathStorageIsSingleElement RBPathStorageIsSingleElement
60+
#define ORBPathStorageGetBezierOrder RBPathStorageGetBezierOrder
61+
#define ORBPathStorageGetBoundingRect RBPathStorageGetBoundingRect
62+
#define ORBPathStorageGetCGPath RBPathStorageGetCGPath
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module OpenRenderBoxShimsCxx {
2+
umbrella header "OpenRenderBoxShims/OpenRenderBoxShims.h"
3+
export *
4+
}

0 commit comments

Comments
 (0)