Vuo 2.4.4
Loading...
Searching...
No Matches
VuoCompilerInputDataClass.cc
Go to the documentation of this file.
1
11
14#include "VuoStringUtilities.hh"
15#include "VuoType.hh"
16
24{
25 unloweredStructPointerInEventFunction = false;
26 unloweredStructPointerInInitFunction = false;
27 unloweredStructPointerInCallbackStartFunction = false;
28 unloweredStructPointerInCallbackUpdateFunction = false;
29 unloweredStructPointerInCallbackStopFunction = false;
30}
31
39
45{
46 if (details)
47 {
48 json_object *value = NULL;
49 if (json_object_object_get_ex(details, "default", &value))
50 {
51 return json_object_to_json_string_ext(value, JSON_C_TO_STRING_PLAIN);
52 }
53 else if (json_object_object_get_ex(details, "defaults", &value))
54 {
55 json_object *valueForType = NULL;
56 if (json_object_object_get_ex(value, getVuoType()->getModuleKey().c_str(), &valueForType))
57 return json_object_to_json_string_ext(valueForType, JSON_C_TO_STRING_PLAIN);
58 }
59 }
60
61 return "";
62}
63
69{
70 if (details)
71 {
72 json_object *value = NULL;
73 if (json_object_object_get_ex(details, "auto", &value))
74 return json_object_to_json_string_ext(value, JSON_C_TO_STRING_PLAIN);
75 }
76
77 return "";
78}
79
85{
86 if (details)
87 {
88 json_object *value = NULL;
89 if (json_object_object_get_ex(details, "autoSupersedesDefault", &value))
90 return json_object_get_boolean(value);
91 }
92
93 return false;
94}
95
99void VuoCompilerInputDataClass::setUnloweredStructPointer(Type *firstParameterType, bool &unloweredStructPointer)
100{
101 StructType *elementType = nullptr;
102 if (VuoCompilerCodeGenUtilities::isPointerToStruct(firstParameterType, &elementType))
103 {
104 // Check if the LLVM type name looks like e.g. "struct.VuoRange" or "struct.VuoRange.123" (hopefully faster than regex).
105 vector<string> parts = VuoStringUtilities::split(elementType->getStructName().str(), '.');
106 unloweredStructPointer = (parts.size() >= 2
107 && parts[0] == "struct"
108 && parts[1] == getVuoType()->getModuleKey()
109 && std::all_of(parts.begin() + 2, parts.end(), [](const string &s) { return s.find_first_not_of("0123456789") == string::npos; }));
110 }
111}
112
124{
125 setUnloweredStructPointer(firstParameterType, unloweredStructPointerInEventFunction);
126}
127
132{
133 return unloweredStructPointerInEventFunction;
134}
135
140{
141 setUnloweredStructPointer(firstParameterType, unloweredStructPointerInInitFunction);
142}
143
148{
149 return unloweredStructPointerInInitFunction;
150}
151
156{
157 setUnloweredStructPointer(firstParameterType, unloweredStructPointerInCallbackStartFunction);
158}
159
164{
165 return unloweredStructPointerInCallbackStartFunction;
166}
167
172{
173 setUnloweredStructPointer(firstParameterType, unloweredStructPointerInCallbackUpdateFunction);
174}
175
180{
181 return unloweredStructPointerInCallbackUpdateFunction;
182}
183
188{
189 setUnloweredStructPointer(firstParameterType, unloweredStructPointerInCallbackStopFunction);
190}
191
196{
197 return unloweredStructPointerInCallbackStopFunction;
198}