-
Notifications
You must be signed in to change notification settings - Fork 1
/
context.cpp
128 lines (107 loc) · 3.85 KB
/
context.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <OpenColorIO/OpenColorIO.h>
#include "ocio.h"
#include "ocio_abi.h"
#include "storage.h"
namespace OCIO = OCIO_NAMESPACE;
namespace ocigo {
IndexMap<OCIO::ContextRcPtr> g_Context_map;
}
extern "C" {
void deleteContext(ContextId p) {
if (p != NULL) {
if (p->handle) {
ocigo::g_Context_map.remove(p->handle);
p->handle = 0;
}
freeHandleContext(p);
}
}
ContextId Context_Create() {
OCIO::ContextRcPtr ptr;
ContextId ctx = NEW_HANDLE_CONTEXT();
BEGIN_CATCH_CTX_ERR(ctx)
ctx->handle = ocigo::g_Context_map.add(OCIO::Context::Create());
END_CATCH_CTX_ERR(ctx)
return ctx;
}
ContextId Context_createEditableCopy(ContextId p) {
OCIO::ContextRcPtr ptr;
BEGIN_CATCH_CTX_ERR(p)
ptr = ocigo::g_Context_map.get(p->handle).get()->createEditableCopy();
END_CATCH_CTX_ERR(p)
if ( ptr == NULL) { return 0; }
return NEW_HANDLE_CONTEXT(ocigo::g_Context_map.add(ptr));
}
const char* Context_getCacheID(ContextId p) {
const char* ret = NULL;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Context_map.get(p->handle).get()->getCacheID();
END_CATCH_CTX_ERR(p)
return ret;
}
void Context_setSearchPath(ContextId p, const char* path) {
BEGIN_CATCH_CTX_ERR(p)
ocigo::g_Context_map.get(p->handle).get()->setSearchPath(path);
END_CATCH_CTX_ERR(p)
}
const char* Context_getSearchPath(ContextId p) {
BEGIN_CATCH_CTX_ERR(p)
return ocigo::g_Context_map.get(p->handle).get()->getSearchPath();
END_CATCH_CTX_ERR(p)
}
void Context_setWorkingDir(ContextId p, const char* dirname) {
BEGIN_CATCH_CTX_ERR(p)
ocigo::g_Context_map.get(p->handle).get()->setWorkingDir(dirname);
END_CATCH_CTX_ERR(p)
}
const char* Context_getWorkingDir(ContextId p) {
const char* ret = NULL;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Context_map.get(p->handle).get()->getWorkingDir();
END_CATCH_CTX_ERR(p)
return ret;
}
void Context_setStringVar(ContextId p, const char* name, const char* value) {
BEGIN_CATCH_CTX_ERR(p)
ocigo::g_Context_map.get(p->handle).get()->setStringVar(name, value);
END_CATCH_CTX_ERR(p)
}
const char* Context_getStringVar(ContextId p, const char* name) {
const char* ret = NULL;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Context_map.get(p->handle).get()->getStringVar(name);
END_CATCH_CTX_ERR(p)
return ret;
}
EnvironmentMode Context_getEnvironmentMode(ContextId p) {
EnvironmentMode ret;
BEGIN_CATCH_CTX_ERR(p)
ret = (EnvironmentMode)(ocigo::g_Context_map.get(p->handle).get()->getEnvironmentMode());
END_CATCH_CTX_ERR(p)
return ret;
}
void Context_setEnvironmentMode(ContextId p, EnvironmentMode mode) {
BEGIN_CATCH_CTX_ERR(p)
ocigo::g_Context_map.get(p->handle).get()->setEnvironmentMode((OCIO::EnvironmentMode)mode);
END_CATCH_CTX_ERR(p)
}
void Context_loadEnvironment(ContextId p) {
BEGIN_CATCH_CTX_ERR(p)
ocigo::g_Context_map.get(p->handle).get()->loadEnvironment();
END_CATCH_CTX_ERR(p)
}
const char* Context_resolveStringVar(ContextId p, const char* val) {
const char* ret = NULL;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Context_map.get(p->handle).get()->resolveStringVar(val);
END_CATCH_CTX_ERR(p)
return ret;
}
const char* Context_resolveFileLocation(ContextId p, const char* filename) {
const char* ret = NULL;
BEGIN_CATCH_CTX_ERR(p)
ret = ocigo::g_Context_map.get(p->handle).get()->resolveFileLocation(filename);
END_CATCH_CTX_ERR(p)
return ret;
}
}