1 /****************************************************************************
2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * @brief Definitions for events. auto-generated file
29 * Generation Command Line:
30 * ${'\n * '.join(cmdline)}
32 ******************************************************************************/
36 #include "common/os.h"
37 #include "core/state.h"
41 % for name in protos['enum_names']:
43 {<% names = protos['enums'][name]['names'] %>
44 % for i in range(len(names)):
53 //////////////////////////////////////////////////////////////////////////
54 /// Event - interface for handling events.
55 //////////////////////////////////////////////////////////////////////////
61 virtual void Accept(EventHandler* pHandler) const = 0;
63 % for name in protos['event_names']:
65 //////////////////////////////////////////////////////////////////////////
67 //////////////////////////////////////////////////////////////////////////
71 fields = protos['events'][name]['fields'] %>
73 % for i in range(len(fields)):
74 % if fields[i]['size'] > 1:
75 ${fields[i]['type']} ${fields[i]['name']}[${fields[i]['size']}];
77 ${fields[i]['type']} ${fields[i]['name']};
83 //////////////////////////////////////////////////////////////////////////
85 //////////////////////////////////////////////////////////////////////////
86 struct ${name} : Event
88 fields = protos['events'][name]['fields'] %>
93 % for i in range(len(fields)):
94 % if i < len(fields)-1:
95 % if fields[i]['size'] > 1:
96 ${fields[i]['type']}* ${fields[i]['name']},
97 uint32_t ${fields[i]['name']}_size,
99 ${fields[i]['type']} ${fields[i]['name']},
102 % if i == len(fields)-1:
103 % if fields[i]['size'] > 1:
104 ${fields[i]['type']}* ${fields[i]['name']},
105 uint32_t ${fields[i]['name']}_size
107 ${fields[i]['type']} ${fields[i]['name']}
113 % for i in range(len(fields)):
114 % if fields[i]['size'] > 1:
115 % if fields[i]['type'] == 'char':
116 // Copy size of string (null-terminated) followed by string into entire buffer
117 SWR_ASSERT(${fields[i]['name']}_size + 1 < ${fields[i]['size']} - sizeof(uint32_t), "String length must be less than size of char buffer - size(uint32_t)!");
118 memcpy(data.${fields[i]['name']}, &${fields[i]['name']}_size, sizeof(uint32_t));
119 strcpy_s(data.${fields[i]['name']} + sizeof(uint32_t), ${fields[i]['name']}_size + 1, ${fields[i]['name']});
121 memcpy(data.${fields[i]['name']}, ${fields[i]['name']}, ${fields[i]['name']}_size);
124 data.${fields[i]['name']} = ${fields[i]['name']};
129 virtual void Accept(EventHandler* pHandler) const;
132 } // namespace ArchRast