Skip to content

Commit b1897c9

Browse files
committed
Update OGTypeID
1 parent d65ec4a commit b1897c9

File tree

13 files changed

+69
-93
lines changed

13 files changed

+69
-93
lines changed

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.

Sources/OpenGraph_SPI/Graph/OGSubgraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ void OGSubgraphSetShouldRecordTree() {
196196
void OGSubgraphBeginTreeElement(OGAttribute attribute, OGTypeID type, uint32_t flags) {
197197
OG::Subgraph * subgraph = OG::Subgraph::get_current();
198198
if (subgraph) {
199-
subgraph->begin_tree(attribute, type, flags);
199+
subgraph->begin_tree(attribute, reinterpret_cast<OG::swift::metadata const*>(type), flags);
200200
}
201201
}
202202

203203
void OGSubgraphAddTreeValue(OGAttribute attribute, OGTypeID type, const char * key, uint32_t flags) {
204204
OG::Subgraph * subgraph = OG::Subgraph::get_current();
205205
if (subgraph) {
206-
subgraph->add_tree_value(attribute, type, key, flags);
206+
subgraph->add_tree_value(attribute, reinterpret_cast<OG::swift::metadata const*>(type), key, flags);
207207
}
208208
}
209209

Sources/OpenGraph_SPI/Runtime/OGSwiftMetadata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//
22
// OGSwiftMetadata.h
33
// OpenGraph_SPI
4+
//
45

56
#ifndef OGSwiftMetadata_h
67
#define OGSwiftMetadata_h

Sources/OpenGraph_SPI/Runtime/OGTypeDescription.cpp

Lines changed: 0 additions & 17 deletions
This file was deleted.

Sources/OpenGraph_SPI/Runtime/OGTypeDescription.h

Lines changed: 0 additions & 29 deletions
This file was deleted.

Sources/OpenGraph_SPI/Runtime/OGTypeID.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
#include "OGTypeID.h"
9+
#include "metadata.hpp"
910

1011
#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
1112
#include <swift/Runtime/Metadata.h>
@@ -39,6 +40,15 @@ OGTypeKind OGTypeGetKind(OGTypeID typeID) {
3940
#endif
4041
}
4142

43+
CFStringRef OGTypeDescription(OGTypeID id) {
44+
CFMutableStringRef ref = CFStringCreateMutable(CFAllocatorGetDefault(), 0);
45+
#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
46+
OG::swift::metadata const *metadata = reinterpret_cast<OG::swift::metadata const*>(id);
47+
metadata->append_description(ref);
48+
#endif
49+
return ref;
50+
}
51+
4252
const void * OGTypeNominalDescriptor(OGTypeID typeID) {
4353
return nullptr;
4454
}
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
11
//
22
// OGTypeID.h
3+
// OpenGraph_SPI
34
//
4-
//
5-
// Created by Kyle on 2024/1/8.
6-
//
5+
// Audited for iOS 18.0
6+
// Status: WIP
77

88
#ifndef OGTypeID_h
99
#define OGTypeID_h
1010

1111
#include "OGBase.h"
1212
#include "OGSwiftMetadata.h"
13-
#include "OGTypeKind.h"
1413

15-
typedef const OGSwiftMetadata *OGTypeID OG_SWIFT_STRUCT OG_SWIFT_NAME(Metadata);
14+
OG_ASSUME_NONNULL_BEGIN
1615

1716
OG_EXTERN_C_BEGIN
1817

18+
typedef const OGSwiftMetadata *OGTypeID OG_SWIFT_STRUCT OG_SWIFT_NAME(Metadata);
19+
20+
typedef OG_ENUM(uint32_t, OGTypeKind) {
21+
OGTypeKindNone,
22+
OGTypeKindClass,
23+
OGTypeKindStruct,
24+
OGTypeKindEnum,
25+
OGTypeKindOptional,
26+
OGTypeKindTuple,
27+
OGTypeKindFunction,
28+
OGTypeKindExistential,
29+
OGTypeKindMetatype,
30+
};
31+
1932
OG_EXPORT
2033
OG_REFINED_FOR_SWIFT
2134
OGTypeKind OGTypeGetKind(OGTypeID typeID) OG_SWIFT_NAME(getter:OGTypeID.kind(self:));
2235

36+
OG_EXPORT
37+
OG_REFINED_FOR_SWIFT
38+
CFStringRef OGTypeDescription(OGTypeID type);
39+
2340
OG_EXPORT
2441
OG_REFINED_FOR_SWIFT
2542
const void * OGTypeNominalDescriptor(OGTypeID typeID) OG_SWIFT_NAME(getter:OGTypeID.nominalDescriptor(self:));
2643

2744
OG_EXTERN_C_END
2845

46+
OG_ASSUME_NONNULL_END
47+
2948
#endif /* OGTypeID_h */

Sources/OpenGraph_SPI/Runtime/OGTypeKind.h

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
//
22
// metadata.cpp
3-
//
4-
//
5-
// Created by Kyle on 2024/4/4.
3+
// OpenGraph_SPI
64
//
5+
// Audited for iOS 18.0
6+
// Status: WIP
77

88
#include "metadata.hpp"
9+
10+
#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
11+
12+
using OG::swift::metadata;
13+
14+
void metadata::append_description(CFMutableStringRef description) const OG_NOEXCEPT {
15+
// TODO
16+
}
17+
18+
#endif /* OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
//
22
// metadata.hpp
3-
//
4-
//
5-
// Created by Kyle on 2024/4/4.
3+
// OpenGraph_SPI
64
//
5+
// Audited for iOS 18.0
6+
// Status: WIP
77

88
#ifndef metadata_hpp
99
#define metadata_hpp
1010

1111
#include "OGBase.h"
12-
#include "OGSwiftMetadata.h"
12+
13+
#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
14+
#include <swift/Runtime/Metadata.h>
15+
#endif
1316

1417
namespace OG {
1518
namespace swift {
16-
using metadata = OGSwiftMetadata; // FIXME: swift::Metadata
17-
}
18-
}
19+
#ifdef OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED
20+
class metadata: public ::swift::Metadata {
21+
public:
22+
void append_description(CFMutableStringRef description) const OG_NOEXCEPT;
23+
}; /* OG::swift::metadata */
24+
#else
25+
class metadata {};
26+
#endif /* OPENGRAPH_SWIFT_TOOLCHAIN_SUPPORTED */
27+
} /* OG::swift */
28+
} /* OG */
29+
1930
#endif /* metadata_hpp */

0 commit comments

Comments
 (0)