Mercurial > hg > orthanc-java
comparison CodeGeneration/CppNativeSDK.mustache @ 5:c8f19e93ff99
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 19 Oct 2023 08:49:07 +0200 |
parents | 3ecef5782f2c |
children | 26c08ff926a3 |
comparison
equal
deleted
inserted
replaced
4:9032ffb3a7d5 | 5:c8f19e93ff99 |
---|---|
47 OrthancPluginErrorCode code = {{c_function}}(context_ | 47 OrthancPluginErrorCode code = {{c_function}}(context_ |
48 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} | 48 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} |
49 {{#args}}, {{c_accessor}}{{/args}}); | 49 {{#args}}, {{c_accessor}}{{/args}}); |
50 if (code != OrthancPluginErrorCode_Success) | 50 if (code != OrthancPluginErrorCode_Success) |
51 { | 51 { |
52 JavaEnvironment::ThrowException(env, code); | 52 JavaEnvironment::ThrowOrthancException(env, code); |
53 } | 53 } |
54 {{/return.is_exception}} | 54 {{/return.is_exception}} |
55 | 55 |
56 {{#return.is_number}} | 56 {{#return.is_number}} |
57 return {{c_function}}(context_ | 57 return {{c_function}}(context_ |
63 const char* s = {{c_function}}(context_ | 63 const char* s = {{c_function}}(context_ |
64 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} | 64 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} |
65 {{#args}}, {{c_accessor}}{{/args}}); | 65 {{#args}}, {{c_accessor}}{{/args}}); |
66 if (s == NULL) | 66 if (s == NULL) |
67 { | 67 { |
68 JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); | 68 JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); |
69 return NULL; | 69 return NULL; |
70 } | 70 } |
71 else | 71 else |
72 { | 72 { |
73 return env->NewStringUTF(s); | 73 return env->NewStringUTF(s); |
78 OrthancString s({{c_function}}(context_ | 78 OrthancString s({{c_function}}(context_ |
79 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} | 79 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} |
80 {{#args}}, {{c_accessor}}{{/args}})); | 80 {{#args}}, {{c_accessor}}{{/args}})); |
81 if (s.GetValue() == NULL) | 81 if (s.GetValue() == NULL) |
82 { | 82 { |
83 JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); | 83 JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); |
84 return NULL; | 84 return NULL; |
85 } | 85 } |
86 else | 86 else |
87 { | 87 { |
88 jstring t = env->NewStringUTF(s.GetValue()); | 88 jstring t = env->NewStringUTF(s.GetValue()); |
89 if (t == NULL) | 89 if (t == NULL) |
90 { | 90 { |
91 JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); | 91 JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); |
92 return NULL; | 92 return NULL; |
93 } | 93 } |
94 else | 94 else |
95 { | 95 { |
96 return t; | 96 return t; |
106 if (code == OrthancPluginErrorCode_Success) | 106 if (code == OrthancPluginErrorCode_Success) |
107 { | 107 { |
108 jbyteArray answer = env->NewByteArray(b.GetSize()); | 108 jbyteArray answer = env->NewByteArray(b.GetSize()); |
109 if (answer == NULL) | 109 if (answer == NULL) |
110 { | 110 { |
111 JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_NotEnoughMemory); | 111 JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_NotEnoughMemory); |
112 return NULL; | 112 return NULL; |
113 } | 113 } |
114 else | 114 else |
115 { | 115 { |
116 env->SetByteArrayRegion(answer, 0, b.GetSize(), reinterpret_cast<const jbyte*>(b.GetData())); | 116 env->SetByteArrayRegion(answer, 0, b.GetSize(), reinterpret_cast<const jbyte*>(b.GetData())); |
117 return answer; | 117 return answer; |
118 } | 118 } |
119 } | 119 } |
120 else | 120 else |
121 { | 121 { |
122 JavaEnvironment::ThrowException(env, code); | 122 JavaEnvironment::ThrowOrthancException(env, code); |
123 return NULL; | 123 return NULL; |
124 } | 124 } |
125 {{/return.is_bytes}} | 125 {{/return.is_bytes}} |
126 | 126 |
127 {{#return.is_object}} | 127 {{#return.is_object}} |
128 {{return.class_name}}* answer = {{c_function}}(context_ | 128 {{return.class_name}}* answer = {{c_function}}(context_ |
129 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} | 129 {{#class_name}}, reinterpret_cast<{{class_name}}*>(static_cast<intptr_t>(self)){{/class_name}} |
130 {{#args}}, {{c_accessor}}{{/args}}); | 130 {{#args}}, {{c_accessor}}{{/args}}); |
131 if (answer == NULL) | 131 if (answer == NULL) |
132 { | 132 { |
133 JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); | 133 JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); |
134 return 0; | 134 return 0; |
135 } | 135 } |
136 else | 136 else |
137 { | 137 { |
138 return reinterpret_cast<intptr_t>(answer); | 138 return reinterpret_cast<intptr_t>(answer); |
145 {{#args}}, {{c_accessor}}{{/args}}); | 145 {{#args}}, {{c_accessor}}{{/args}}); |
146 {{/return.is_enumeration}} | 146 {{/return.is_enumeration}} |
147 } | 147 } |
148 catch (std::runtime_error& e) | 148 catch (std::runtime_error& e) |
149 { | 149 { |
150 JavaEnvironment::ThrowException(env, e.what()); | 150 JavaEnvironment::ThrowOrthancException(env, e.what()); |
151 {{#return.default_value}}return {{return.default_value}};{{/return.default_value}} | 151 {{#return.default_value}}return {{return.default_value}};{{/return.default_value}} |
152 } | 152 } |
153 catch (...) | 153 catch (...) |
154 { | 154 { |
155 JavaEnvironment::ThrowException(env, OrthancPluginErrorCode_Plugin); | 155 JavaEnvironment::ThrowOrthancException(env, OrthancPluginErrorCode_Plugin); |
156 {{#return.default_value}}return {{return.default_value}};{{/return.default_value}} | 156 {{#return.default_value}}return {{return.default_value}};{{/return.default_value}} |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 {{/functions}} | 160 {{/functions}} |