OR-1 dataflow CPU sketch
at main 30 lines 976 B view raw
1#ifndef NODE_TREE_SITTER_NODE_H_ 2#define NODE_TREE_SITTER_NODE_H_ 3 4#include "./tree.h" 5#include "tree_sitter/api.h" 6 7#include <napi.h> 8 9namespace node_tree_sitter::node_methods { 10 11void Init(Napi::Env env, Napi::Object exports); 12Napi::Value MarshalNode(const Napi::CallbackInfo &info, const Tree *, TSNode); 13Napi::Value GetMarshalNode(const Napi::CallbackInfo &info, const Tree *tree, TSNode node); 14Napi::Value GetMarshalNodes(const Napi::CallbackInfo &info, const Tree *tree, const TSNode *nodes, uint32_t node_count); 15TSNode UnmarshalNode(Napi::Env env, const Tree *tree, uint8_t offset = 0); 16 17static inline const void *UnmarshalNodeId(const uint32_t *buffer) { 18 const void *result; 19 memcpy(&result, buffer, sizeof(result)); 20 return result; 21} 22 23static inline void MarshalNodeId(const void *id, uint32_t *buffer) { 24 memset(buffer, 0, sizeof(uint64_t)); 25 memcpy(buffer, &id, sizeof(id)); 26} 27 28} // namespace node_tree_sitter::node_methods 29 30#endif // NODE_TREE_SITTER_NODE_H_