Skip to content

Commit d67e2bb

Browse files
committed
Add OAGGraphInternAttributeType
1 parent f611331 commit d67e2bb

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

Sources/OpenAttributeGraph/Attribute/Attribute/Attribute.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ public struct Attribute<Value> {
114114
}
115115
let index = Graph.typeIndex(
116116
ctx: context,
117-
body: Body.self,
118-
valueType: Metadata(Value.self),
119-
flags: flags,
120-
update: update
121-
)
117+
body: Metadata(Body.self)
118+
) {
119+
let pointer = UnsafeMutablePointer<_AttributeType>.allocate(capacity: 1)
120+
// TODO
121+
return UnsafePointer(pointer)
122+
}
122123
identifier = OAGGraphCreateAttribute(index: index, body: body, value: value)
123124
#endif
124125
}

Sources/OpenAttributeGraph/Graph/Graph.swift

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

1010
extension Graph {
11+
@_silgen_name("OAGGraphInternAttributeType")
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("OAGGraphSetInvalidationCallback")

Sources/OpenAttributeGraphCxx/Graph/OAGGraph.cpp

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

128+
uint32_t OAGGraphInternAttributeType(OAGUnownedGraphContextRef graph, OAGTypeID type,
129+
const OAGAttributeType *(*make_attribute_type)(const void *context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift),
130+
const void *context) {
131+
// TODO
132+
return 0;
133+
}
134+
128135
void OAGGraphInvalidateAllValues(OAGGraphRef graph) {
129136
if (graph->context.isInvalid()) {
130137
OAG::precondition_failure("invalidated graph");

Sources/OpenAttributeGraphCxx/include/OpenAttributeGraph/OAGGraph.h

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

88
#include <OpenAttributeGraph/OAGBase.h>
99
#include <OpenAttributeGraph/Private/CFRuntime.h>
10+
#include <OpenAttributeGraph/OAGAttributeType.h>
1011
#include <OpenAttributeGraph/OAGGraphCounterQueryType.h>
1112

1213
// Note: Place all structure declaration in a single place to avoid header cycle dependency
@@ -69,6 +70,12 @@ OAG_EXPORT
6970
OAG_REFINED_FOR_SWIFT
7071
void OAGGraphInvalidate(OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.invalidate(self:));
7172

73+
OAG_EXPORT
74+
OAG_REFINED_FOR_SWIFT
75+
uint32_t OAGGraphInternAttributeType(OAGUnownedGraphContextRef graph, OAGTypeID type,
76+
const OAGAttributeType * _Nonnull (* _Nonnull make_attribute_type)(const void * _Nullable context OAG_SWIFT_CONTEXT) OAG_SWIFT_CC(swift),
77+
const void * _Nullable context);
78+
7279
OAG_EXPORT
7380
OAG_REFINED_FOR_SWIFT
7481
void OAGGraphInvalidateAllValues(OAGGraphRef graph) OAG_SWIFT_NAME(OAGGraphRef.invalidateAllValues(self:));

0 commit comments

Comments
 (0)