Conversation
|
Implementing this was not straightforward as you have to use the method for the correct data type, which you first have to look up. I now create a symbol from the name of the C datatype and pass this to an internal method as another argument to be able to dispatch on it. |
Me too. Maybe you can ping Valentin and ask him if he knows of a better approach for what you are trying to achieve? Adding some context would be helpful as well. |
|
I think we may have something similar in ClimaCore (the DataLayouts module) |
| return new(nptr) | ||
| end | ||
|
|
||
| function ConduitNode(ptr::Ptr{API.conduit_node}) |
There was a problem hiding this comment.
What is the ownership model between Julia objects and the pointed to C-object? When is memory going to be released?
| node_at_path = API.conduit_node_fetch(node, path) | ||
| dtype = API.conduit_node_dtype(node_at_path) | ||
| dtypename = Symbol(unsafe_string(API.conduit_datatype_name(dtype))) | ||
| return node_get(node_at_path, Val(dtypename)) |
There was a problem hiding this comment.
This Val here seems unnecessarily clever, and guarantees a dynamic dispatch.
| return node | ||
| end | ||
|
|
||
| function node_get(nodeptr::Ptr{API.conduit_node}, ::Val{:object}) |
There was a problem hiding this comment.
It's likely better to have a function that uses if else to select between symbols, rather than using Val
This adds
getindexfor ConduitNode.Although not required for using the interface it makes testing easier.