Skip to content
This repository
Newer
Older
100755 270 lines (189 sloc) 9.745 kb
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
1 %% This is auto generated file. Please don't edit it
2
6ab3d158 »
2009-10-02 amf3 read complete
3 -module(record_utils).
4 -author("trung@mdkt.org").
5 -compile(export_all).
5ae03f2f »
2009-10-02 restructure include files
6 -include("../include/messages.hrl").
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
7 -include("../include/types.hrl").
8
9 fields(abstract_message) ->
10 ["clientId", "destination", "messageId", "timestamp", "timeToLive", "headers", "body"];
11
12 fields(async_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
13 fields(abstract_message) ++ ["correlationId", "correlationIdBytes"];
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
14
15 fields(command_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
16 fields(async_message) ++ ["operation"];
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
17
18 fields(remoting_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
19 fields(rpc_message) ++ ["source", "operation", "parameters"];
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
20
21 fields(rpc_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
22 fields(abstract_message) ++ ["remoteUsername", "remotePassword"].
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
23
24 fields_atom(abstract_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
25 lists:flatten([clientId, destination, messageId, timestamp, timeToLive, headers, body]);
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
26
27 fields_atom(async_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
28 lists:flatten([fields_atom(abstract_message), correlationId, correlationIdBytes]);
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
29
30 fields_atom(command_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
31 lists:flatten([fields_atom(async_message), operation]);
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
32
33 fields_atom(remoting_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
34 lists:flatten([fields_atom(rpc_message), source, operation, parameters]);
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
35
36 fields_atom(rpc_message) ->
0b92c57f »
2009-10-07 flatten fields list when return
37 lists:flatten([fields_atom(abstract_message), remoteUsername, remotePassword]).
38
39 get(Obj, body) when is_record(Obj, abstract_message) ->
40 {ok, Obj#abstract_message.body};
41
42 get(Obj, clientId) when is_record(Obj, abstract_message) ->
43 {ok, Obj#abstract_message.clientId};
44
45 get(Obj, destination) when is_record(Obj, abstract_message) ->
46 {ok, Obj#abstract_message.destination};
47
48 get(Obj, headers) when is_record(Obj, abstract_message) ->
49 {ok, Obj#abstract_message.headers};
50
51 get(Obj, messageId) when is_record(Obj, abstract_message) ->
52 {ok, Obj#abstract_message.messageId};
53
54 get(Obj, timeToLive) when is_record(Obj, abstract_message) ->
55 {ok, Obj#abstract_message.timeToLive};
56
57 get(Obj, timestamp) when is_record(Obj, abstract_message) ->
58 {ok, Obj#abstract_message.timestamp};
59
37ec5e43 »
2009-10-07 passed test case unregistered typed object for amf0
60 get(Obj, PropertyName) when is_record(Obj, asobject) ->
61 Ret = [X || {P, X} <- Obj#asobject.array, P == PropertyName],
62 if
63 length(Ret) == 0 -> {bad, {"PropertyName not found in the object", Obj, PropertyName}};
64 true ->
65 [Value|_] = Ret,
66 {ok, Value}
67 end;
0b92c57f »
2009-10-07 flatten fields list when return
68
69 get(Obj, correlationId) when is_record(Obj, async_message) ->
70 {ok, Obj#async_message.correlationId};
71
72 get(Obj, correlationIdBytes) when is_record(Obj, async_message) ->
73 {ok, Obj#async_message.correlationIdBytes};
74
75 get(Obj, parent) when is_record(Obj, async_message) ->
76 {ok, Obj#async_message.parent};
77
78 get(Obj, ParentProperty) when is_record(Obj, async_message) and is_atom(ParentProperty) ->
79 get(Obj#async_message.parent, ParentProperty);
80
81 get(Obj, operation) when is_record(Obj, command_message) ->
82 {ok, Obj#command_message.operation};
83
84 get(Obj, parent) when is_record(Obj, command_message) ->
85 {ok, Obj#command_message.parent};
86
87 get(Obj, ParentProperty) when is_record(Obj, command_message) and is_atom(ParentProperty) ->
88 get(Obj#command_message.parent, ParentProperty);
89
90 get(Obj, data) when is_record(Obj, ecma_array) ->
91 {ok, Obj#ecma_array.data};
92
93 get(Obj, data) when is_record(Obj, long_string) ->
94 {ok, Obj#long_string.data};
95
96 get(Obj, operation) when is_record(Obj, remoting_message) ->
97 {ok, Obj#remoting_message.operation};
98
99 get(Obj, parameters) when is_record(Obj, remoting_message) ->
100 {ok, Obj#remoting_message.parameters};
101
102 get(Obj, source) when is_record(Obj, remoting_message) ->
103 {ok, Obj#remoting_message.source};
104
105 get(Obj, parent) when is_record(Obj, remoting_message) ->
106 {ok, Obj#remoting_message.parent};
107
108 get(Obj, ParentProperty) when is_record(Obj, remoting_message) and is_atom(ParentProperty) ->
109 get(Obj#remoting_message.parent, ParentProperty);
110
111 get(Obj, remotePassword) when is_record(Obj, rpc_message) ->
112 {ok, Obj#rpc_message.remotePassword};
113
114 get(Obj, remoteUsername) when is_record(Obj, rpc_message) ->
115 {ok, Obj#rpc_message.remoteUsername};
116
117 get(Obj, parent) when is_record(Obj, rpc_message) ->
118 {ok, Obj#rpc_message.parent};
119
120 get(Obj, ParentProperty) when is_record(Obj, rpc_message) and is_atom(ParentProperty) ->
121 get(Obj#rpc_message.parent, ParentProperty);
122
123 get(Obj, data) when is_record(Obj, string) ->
124 {ok, Obj#string.data};
125
126 get(Obj, data) when is_record(Obj, string_3) ->
127 {ok, Obj#string_3.data};
128
129 get(Obj, data) when is_record(Obj, xml) ->
130 {ok, Obj#xml.data}.
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
131
132 set(Obj, body, Value) when is_record(Obj, abstract_message) ->
133 NewObj = Obj#abstract_message{body = Value},
134 {ok, NewObj, {body, Value}};
135
136 set(Obj, clientId, Value) when is_record(Obj, abstract_message) ->
137 NewObj = Obj#abstract_message{clientId = Value},
138 {ok, NewObj, {clientId, Value}};
139
140 set(Obj, destination, Value) when is_record(Obj, abstract_message) ->
141 NewObj = Obj#abstract_message{destination = Value},
142 {ok, NewObj, {destination, Value}};
143
144 set(Obj, headers, Value) when is_record(Obj, abstract_message) ->
145 NewObj = Obj#abstract_message{headers = Value},
146 {ok, NewObj, {headers, Value}};
147
148 set(Obj, messageId, Value) when is_record(Obj, abstract_message) ->
149 NewObj = Obj#abstract_message{messageId = Value},
150 {ok, NewObj, {messageId, Value}};
151
152 set(Obj, timeToLive, Value) when is_record(Obj, abstract_message) ->
153 NewObj = Obj#abstract_message{timeToLive = Value},
154 {ok, NewObj, {timeToLive, Value}};
155
156 set(Obj, timestamp, Value) when is_record(Obj, abstract_message) ->
157 NewObj = Obj#abstract_message{timestamp = Value},
158 {ok, NewObj, {timestamp, Value}};
159
37ec5e43 »
2009-10-07 passed test case unregistered typed object for amf0
160 set(Obj, PropertyName, Value) when is_record(Obj, asobject) ->
161 NewObj = #asobject{array = Obj#asobject.array ++ [{PropertyName, Value}]},
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
162 {ok, NewObj, {array, Value}};
163
164 set(Obj, correlationId, Value) when is_record(Obj, async_message) ->
165 NewObj = Obj#async_message{correlationId = Value},
166 {ok, NewObj, {correlationId, Value}};
167
168 set(Obj, correlationIdBytes, Value) when is_record(Obj, async_message) ->
169 NewObj = Obj#async_message{correlationIdBytes = Value},
170 {ok, NewObj, {correlationIdBytes, Value}};
171
172 set(Obj, parent, Value) when is_record(Obj, async_message) and is_record(Value, abstract_message) ->
173 NewObj = Obj#async_message{parent = Value},
174 {ok, NewObj, {parent, Value}};
175
176 set(Obj, ParentProperty, Value) when is_record(Obj, async_message) and is_atom(ParentProperty) ->
177 {ok, NewParentObject, _} = set(Obj#async_message.parent, ParentProperty, Value),
178 set(Obj, parent, NewParentObject);
179
180 set(Obj, operation, Value) when is_record(Obj, command_message) ->
181 NewObj = Obj#command_message{operation = Value},
182 {ok, NewObj, {operation, Value}};
183
184 set(Obj, parent, Value) when is_record(Obj, command_message) and is_record(Value, async_message) ->
185 NewObj = Obj#command_message{parent = Value},
186 {ok, NewObj, {parent, Value}};
187
188 set(Obj, ParentProperty, Value) when is_record(Obj, command_message) and is_atom(ParentProperty) ->
189 {ok, NewParentObject, _} = set(Obj#command_message.parent, ParentProperty, Value),
190 set(Obj, parent, NewParentObject);
191
192 set(Obj, data, Value) when is_record(Obj, ecma_array) ->
193 NewObj = Obj#ecma_array{data = Value},
194 {ok, NewObj, {data, Value}};
195
196 set(Obj, data, Value) when is_record(Obj, long_string) ->
197 NewObj = Obj#long_string{data = Value},
198 {ok, NewObj, {data, Value}};
199
200 set(Obj, operation, Value) when is_record(Obj, remoting_message) ->
201 NewObj = Obj#remoting_message{operation = Value},
202 {ok, NewObj, {operation, Value}};
203
204 set(Obj, parameters, Value) when is_record(Obj, remoting_message) ->
205 NewObj = Obj#remoting_message{parameters = Value},
206 {ok, NewObj, {parameters, Value}};
207
208 set(Obj, source, Value) when is_record(Obj, remoting_message) ->
209 NewObj = Obj#remoting_message{source = Value},
210 {ok, NewObj, {source, Value}};
211
212 set(Obj, parent, Value) when is_record(Obj, remoting_message) and is_record(Value, rpc_message) ->
213 NewObj = Obj#remoting_message{parent = Value},
214 {ok, NewObj, {parent, Value}};
215
216 set(Obj, ParentProperty, Value) when is_record(Obj, remoting_message) and is_atom(ParentProperty) ->
217 {ok, NewParentObject, _} = set(Obj#remoting_message.parent, ParentProperty, Value),
218 set(Obj, parent, NewParentObject);
219
220 set(Obj, remotePassword, Value) when is_record(Obj, rpc_message) ->
221 NewObj = Obj#rpc_message{remotePassword = Value},
222 {ok, NewObj, {remotePassword, Value}};
223
224 set(Obj, remoteUsername, Value) when is_record(Obj, rpc_message) ->
225 NewObj = Obj#rpc_message{remoteUsername = Value},
226 {ok, NewObj, {remoteUsername, Value}};
227
228 set(Obj, parent, Value) when is_record(Obj, rpc_message) and is_record(Value, abstract_message) ->
229 NewObj = Obj#rpc_message{parent = Value},
230 {ok, NewObj, {parent, Value}};
231
232 set(Obj, ParentProperty, Value) when is_record(Obj, rpc_message) and is_atom(ParentProperty) ->
233 {ok, NewParentObject, _} = set(Obj#rpc_message.parent, ParentProperty, Value),
234 set(Obj, parent, NewParentObject);
235
236 set(Obj, data, Value) when is_record(Obj, string) ->
237 NewObj = Obj#string{data = Value},
238 {ok, NewObj, {data, Value}};
239
240 set(Obj, data, Value) when is_record(Obj, string_3) ->
241 NewObj = Obj#string_3{data = Value},
242 {ok, NewObj, {data, Value}};
243
244 set(Obj, data, Value) when is_record(Obj, xml) ->
245 NewObj = Obj#xml{data = Value},
246 {ok, NewObj, {data, Value}}.
247
248 type(Obj) when is_record(Obj, abstract_message) -> abstract_message;
249
250 type(Obj) when is_record(Obj, asobject) -> asobject;
251
252 type(Obj) when is_record(Obj, async_message) -> async_message;
253
254 type(Obj) when is_record(Obj, command_message) -> command_message;
255
256 type(Obj) when is_record(Obj, ecma_array) -> ecma_array;
257
258 type(Obj) when is_record(Obj, long_string) -> long_string;
259
260 type(Obj) when is_record(Obj, remoting_message) -> remoting_message;
261
262 type(Obj) when is_record(Obj, rpc_message) -> rpc_message;
263
264 type(Obj) when is_record(Obj, string) -> string;
265
266 type(Obj) when is_record(Obj, string_3) -> string_3;
267
0b92c57f »
2009-10-07 flatten fields list when return
268 type(Obj) when is_record(Obj, xml) -> xml;
269
270 type(_) -> undefined.
0b13b0c4 »
2009-10-06 created helper to generate record_utils dynamically for records
271
Something went wrong with that request. Please try again.