Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ameharoo committed Dec 7, 2023
2 parents 7dad9a5 + 9b14946 commit a42c003
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The Generated Code License:

Code generated by the Mess is owned by the owner of the input file used
when generating it.
8 changes: 8 additions & 0 deletions generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typing
from datetime import datetime

from ini_parser import MessageIniParser
from message import CppType
Expand Down Expand Up @@ -44,6 +45,13 @@ def write_to_file(self, filename: str):

print(f"** Render protocol")
with open(filename, "w") as output:
output.write("/*\n")
output.write(" This file is auto-generated by Mess\n")
output.write(" (https://github.com/ameharoo/Mess)\n")
output.write(f" Was generated at: {datetime.now()}\n")
output.write(f"*/\n\n")
output.write("#pragma once\n")

output.write(open("templates/vararray.cpp", "r").read())

for message_type in self.sorted_messages:
Expand Down
7 changes: 5 additions & 2 deletions message.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ def render_initialize_arguments(self):
return (", " + ", ".join(fields_definition)) if fields_definition else ""

def render_initialize_method(self):
initialize_self = f" auto value = ::new(buf) {self.render_type_name()}(); \n"
initialize_fields = self.render_initialize_fields()

return f"static void Initialize(std::int8_t* buf{self.render_initialize_arguments()}) {{ \n" \
f" auto value = ::new(buf) {self.render_type_name()}(); \n" \
f"{initialize_self if initialize_fields else ''}" \
f" // ...\n" \
f"{self.render_initialize_fields()}" \
f"{initialize_fields}" \
f"}};\n"

def render_get_alloc_size_method(self):
Expand Down

0 comments on commit a42c003

Please sign in to comment.