Skip to content

Commit 716f7bc

Browse files
committed
Add a non-symlink of MessagePack.mo
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19783 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 0b2a0bd commit 716f7bc

File tree

1 file changed

+256
-1
lines changed

1 file changed

+256
-1
lines changed

Compiler/Util/MessagePack.mo

Lines changed: 0 additions & 1 deletion
This file was deleted.

Compiler/Util/MessagePack.mo

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
// Do not modify this file: It was automatically generated from https://github.com/sjoelund/msgpack-modelica/
2+
encapsulated package MessagePack "MessagePack is an efficient binary serialization format for multiple languages."
3+
encapsulated package Pack
4+
package SimpleBuffer
5+
class SimpleBuffer
6+
extends ExternalObject;
7+
8+
function constructor
9+
output SimpleBuffer buf;
10+
11+
external "C" buf = msgpack_sbuffer_new() annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
12+
end constructor;
13+
14+
function destructor
15+
input SimpleBuffer buf;
16+
17+
external "C" msgpack_sbuffer_free(buf) annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
18+
end destructor;
19+
end SimpleBuffer;
20+
21+
function writeFile
22+
input SimpleBuffer sbuffer;
23+
input String file;
24+
25+
external "C" omc_sbuffer_to_file(sbuffer, file) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
26+
end writeFile;
27+
end SimpleBuffer;
28+
29+
class Packer
30+
extends ExternalObject;
31+
32+
function constructor
33+
input SimpleBuffer.SimpleBuffer buf;
34+
output Packer packer;
35+
36+
external "C" packer = msgpack_modelica_packer_new_sbuffer(buf) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
37+
end constructor;
38+
39+
function destructor
40+
input Packer packer;
41+
42+
external "C" msgpack_packer_free(packer) annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
43+
end destructor;
44+
end Packer;
45+
46+
function double
47+
input Packer packer;
48+
input Real dbl;
49+
output Boolean result;
50+
51+
external "C" result = msgpack_pack_double(packer, dbl) annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
52+
end double;
53+
54+
function integer
55+
input Packer packer;
56+
input Integer i;
57+
output Boolean result;
58+
59+
external "C" result = msgpack_pack_int(packer, i) annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
60+
end integer;
61+
62+
function bool
63+
input Packer packer;
64+
input Boolean bool;
65+
output Boolean result;
66+
protected
67+
function msgpack_pack_true
68+
input Packer packer;
69+
output Boolean result;
70+
71+
external "C" annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
72+
end msgpack_pack_true;
73+
74+
function msgpack_pack_false
75+
input Packer packer;
76+
output Boolean result;
77+
78+
external "C" annotation(Include = "#include <msgpack-modelica.h>", Library = "msgpackc");
79+
end msgpack_pack_false;
80+
algorithm
81+
result := if bool then msgpack_pack_true(packer) else msgpack_pack_false(packer);
82+
end bool;
83+
84+
function sequence
85+
input Packer packer;
86+
input Integer len;
87+
output Boolean result;
88+
89+
external "C" result = msgpack_modelica_pack_array(packer, len) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
90+
end sequence;
91+
92+
function map
93+
input Packer packer;
94+
input Integer len;
95+
output Boolean result;
96+
97+
external "C" result = msgpack_modelica_pack_map(packer, len) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
98+
end map;
99+
100+
function string
101+
input Packer packer;
102+
input String str;
103+
output Boolean result;
104+
105+
external "C" result = msgpack_modelica_pack_string(packer, str) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
106+
end string;
107+
end Pack;
108+
109+
package Unpack
110+
class Deserializer
111+
extends ExternalObject;
112+
113+
function constructor
114+
input String file;
115+
output Deserializer deserializer;
116+
117+
external "C" deserializer = msgpack_modelica_new_deserialiser(file) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
118+
end constructor;
119+
120+
function destructor
121+
input Deserializer deserializer;
122+
123+
external "C" msgpack_modelica_free_deserialiser(deserializer) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
124+
end destructor;
125+
end Deserializer;
126+
127+
function next
128+
input Deserializer deserializer;
129+
input Integer offset;
130+
output Boolean success;
131+
output Integer newoffset;
132+
133+
external "C" success = msgpack_modelica_unpack_next(deserializer, offset, newoffset) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
134+
end next;
135+
136+
function toStream
137+
input Deserializer deserializer;
138+
input MessagePack.Utilities.Stream.Stream ss;
139+
input Integer offset;
140+
output Integer newoffset;
141+
output Boolean success;
142+
143+
external "C" success = msgpack_modelica_unpack_next_to_stream(deserializer, ss, offset, newoffset) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
144+
end toStream;
145+
146+
function integer
147+
input Deserializer deserializer;
148+
input Integer offset;
149+
output Integer res;
150+
output Integer newoffset;
151+
output Boolean success;
152+
153+
external "C" res = msgpack_modelica_unpack_int(deserializer, offset, newoffset, success) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
154+
end integer;
155+
156+
function string
157+
input Deserializer deserializer;
158+
input Integer offset;
159+
output String res;
160+
output Integer newoffset;
161+
output Boolean success;
162+
163+
external "C" res = msgpack_modelica_unpack_string(deserializer, offset, newoffset, success) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
164+
end string;
165+
166+
function get_integer
167+
// TODO: Create package MessagePack.Object and move this there
168+
input Deserializer deserializer;
169+
output Integer res;
170+
171+
external "C" res = msgpack_modelica_get_unpacked_int(deserializer) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
172+
end get_integer;
173+
end Unpack;
174+
175+
package Utilities
176+
package Stream
177+
class Stream
178+
extends ExternalObject;
179+
180+
function constructor
181+
input String file = "" "Output file or \"\" for an in-memory string accessible using get()";
182+
output Stream ss;
183+
184+
external "C" ss = msgpack_modelica_new_stream(file) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
185+
end constructor;
186+
187+
function destructor
188+
input Stream ss;
189+
190+
external "C" msgpack_modelica_free_stream(ss) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
191+
end destructor;
192+
end Stream;
193+
194+
function get "Only works for in-memory streams"
195+
// Make this a part of the Stream class once the Modelica Spec allows it...
196+
input Stream ss;
197+
output String str;
198+
199+
external "C" str = msgpack_modelica_stream_get(ss) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
200+
end get;
201+
202+
function append
203+
// Make this a part of the Stream class once the Modelica Spec allows it...
204+
input Stream ss;
205+
input String str;
206+
207+
external "C" msgpack_modelica_stream_append(ss, str) annotation(Include = "#include <msgpack-modelica.h>", Library = {"msgpackc"});
208+
end append;
209+
end Stream;
210+
211+
function deserializeFileToFile
212+
input String inBinaryFile;
213+
input String outTextFile;
214+
input String separator = "\n";
215+
protected
216+
Unpack.Deserializer deserializer = Unpack.Deserializer(inBinaryFile);
217+
Stream.Stream ss = Stream.Stream(outTextFile);
218+
Boolean success = true;
219+
Integer offset = 0;
220+
algorithm
221+
while success loop
222+
(offset, success) := Unpack.toStream(deserializer, ss, offset);
223+
if success then
224+
Stream.append(ss, separator);
225+
end if;
226+
end while;
227+
end deserializeFileToFile;
228+
end Utilities;
229+
230+
package UsersGuide
231+
package License
232+
annotation(Documentation(info = "<html>
233+
<p>Copyright (c) 2014, Martin Sj&ouml;lund<br />
234+
All rights reserved.</p>
235+
236+
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
237+
238+
<ul>
239+
<li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
240+
<li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li>
241+
</ul>
242+
243+
<p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
244+
245+
</html>"));
246+
end License;
247+
annotation(Documentation(info = "<html>
248+
<p>This implementation uses <a href=\"https://github.com/msgpack/msgpack-c\">msgpack-c</a> together with external objects and external \"C\" functions (Modelica cannot represent binary objects, so everything has to be hidden inside external functions).</p>
249+
<p>You will need to install msgpack-c in order to use this Modelica package (msgpack.h and libmsgpack-c.*).</p>
250+
<p>The external C code of this package is inserted using Include annotations, so there should be no need to compile any libraries prior to using the package.</p>
251+
</html>"));
252+
end UsersGuide;
253+
annotation(version = "0.1", Documentation(info = "<html>
254+
<p>MessagePack is an efficient binary serialization format for multiple languages. Details on the binary format can be found on <a href=\"http://msgpack.org\">msgpack.org</a>.</p>
255+
</html>"));
256+
end MessagePack;

0 commit comments

Comments
 (0)