Skip to content

Commit c71ccfc

Browse files
committed
Add OGGraphInternAttributeType
1 parent 4d0a921 commit c71ccfc

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

Sources/OpenGraph/Attribute/Attribute/Attribute.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ public struct Attribute<Value> {
5050
}
5151
let index = Graph.typeIndex(
5252
ctx: context,
53-
body: Body.self,
54-
valueType: Metadata(Value.self),
55-
flags: flags,
56-
update: update
57-
)
53+
body: Metadata(Body.self)
54+
) {
55+
let pointer = UnsafeMutablePointer<_AttributeType>.allocate(capacity: 1)
56+
// TODO
57+
return UnsafePointer(pointer)
58+
}
5859
identifier = OGGraphCreateAttribute(index: index, body: body, value: value)
5960
#endif
6061
}

Sources/OpenGraph/Graph/Graph.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@
88
public import OpenGraphCxx
99

1010
extension Graph {
11+
@_silgen_name("OGGraphInternAttributeType")
1112
public static func typeIndex(
1213
ctx: UnownedGraphContext,
13-
body: _AttributeBody.Type,
14-
valueType: Metadata,
15-
flags: _AttributeType.Flags,
16-
update: AttributeUpdateBlock
17-
) -> Int {
18-
// TODO: __AGGraphInternAttributeType
19-
0
20-
}
14+
body: Metadata,
15+
makeAttributeType: () -> UnsafePointer<_AttributeType>
16+
) -> Int
2117
}
2218

2319
@_silgen_name("OGGraphSetInvalidationCallback")

Sources/OpenGraphCxx/Graph/OGGraph.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ void OGGraphInvalidate(OGGraphRef graph) {
125125
graph->context.setInvalid(true);
126126
}
127127

128+
uint32_t OGGraphInternAttributeType(OGUnownedGraphContextRef graph, OGTypeID type,
129+
const OGAttributeType *(*make_attribute_type)(const void *context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift),
130+
const void *context) {
131+
// TODO
132+
return 0;
133+
}
134+
128135
void OGGraphInvalidateAllValues(OGGraphRef graph) {
129136
if (graph->context.isInvalid()) {
130137
OG::precondition_failure("invalidated graph");

Sources/OpenGraphCxx/include/OpenGraph/OGGraph.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <OpenGraph/OGBase.h>
99
#include <OpenGraph/Private/CFRuntime.h>
1010
#include <OpenGraph/OGGraphCounterQueryType.h>
11+
#include <OpenGraph/OGAttributeType.h>
1112

1213
// Note: Place all structure declaration in a single place to avoid header cycle dependency
1314

@@ -69,6 +70,12 @@ OG_EXPORT
6970
OG_REFINED_FOR_SWIFT
7071
void OGGraphInvalidate(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.invalidate(self:));
7172

73+
OG_EXPORT
74+
OG_REFINED_FOR_SWIFT
75+
uint32_t OGGraphInternAttributeType(OGUnownedGraphContextRef graph, OGTypeID type,
76+
const OGAttributeType * _Nonnull (* _Nonnull make_attribute_type)(const void * _Nullable context OG_SWIFT_CONTEXT) OG_SWIFT_CC(swift),
77+
const void * _Nullable context);
78+
7279
OG_EXPORT
7380
OG_REFINED_FOR_SWIFT
7481
void OGGraphInvalidateAllValues(OGGraphRef graph) OG_SWIFT_NAME(OGGraphRef.invalidateAllValues(self:));

0 commit comments

Comments
 (0)