-
Notifications
You must be signed in to change notification settings - Fork 1
/
childscope.cpp
39 lines (30 loc) · 1.26 KB
/
childscope.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <cstring>
#include <unity/scopes/ChildScope.h>
#include <unity/scopes/ScopeMetadata.h>
extern "C" {
#include "_cgo_export.h"
}
#include "helpers.h"
using namespace unity::scopes;
using namespace gounityscopes::internal;
_ChildScope *new_child_scope(const StrData id, _ScopeMetadata *metadata, int enabled, const StrData keyword_list) {
ScopeMetadata *api_metadata = reinterpret_cast<ScopeMetadata *>(metadata);
std::set<std::string> keywords;
for (auto &k : split_strings(keyword_list)) {
keywords.emplace(std::move(k));
}
return reinterpret_cast<_ChildScope *>(new ChildScope(from_gostring(id), *api_metadata, enabled, keywords));
}
void destroy_child_scope(_ChildScope *childscope) {
delete reinterpret_cast<ChildScope*>(childscope);
}
char *child_scope_get_id(_ChildScope *childscope) {
return strdup(reinterpret_cast<ChildScope*>(childscope)->id.c_str());
}
void set_child_scopes_list(void *child_scopes_list, _ChildScope **source_child_scopes, int length) {
ChildScopeList *c_child_scopes_list = reinterpret_cast<ChildScopeList*>(child_scopes_list);
for (int i=0; i < length; ++i) {
ChildScope *pItem = reinterpret_cast<ChildScope*>(source_child_scopes[i]);
c_child_scopes_list->push_back(*pItem);
}
}