making progress on MCL linker and compiler, still many bugs
This commit is contained in:
parent
57b16fc34e
commit
fe6562e020
@ -31,6 +31,8 @@ class Yaml2Mcl:
|
||||
args = sys.argv[1:]
|
||||
# args = [ '-o', '/tmp/net.alcetech.Mocha.System.mcl', '/home/beckermj/Documents/Projects/mochapowered/mocha-dotnet/mocha-common/mocha-common/data/libraries/yaml/net.alcetech.Mocha.System' ]
|
||||
|
||||
# !! FIXME !! the instance key is probably not in the cache because the 'class' template is not loaded from the YAML so it doesn't know what to do
|
||||
|
||||
filenames = [ ]
|
||||
outputFileName = ""
|
||||
exportEntitiesFileName = None
|
||||
@ -69,6 +71,20 @@ class Yaml2Mcl:
|
||||
manager = MemoryLibraryManager()
|
||||
yl = YAMLLibraryParser(manager)
|
||||
|
||||
# before we load any files, load entity definitions from referenced libraries
|
||||
for libraryRef in libraryReferences:
|
||||
print ("loading entity definitions from library reference '" + libraryRef + "'")
|
||||
|
||||
from mocha.library.mcx.dataformats import McxDataFormat
|
||||
df = McxDataFormat()
|
||||
f = open(libraryRef, 'rb')
|
||||
df.load_internal(f)
|
||||
f.close()
|
||||
|
||||
for (k, v) in df.defs:
|
||||
manager.register_entity_reference(k, v, libraryRef, True)
|
||||
|
||||
|
||||
for filename in filenames:
|
||||
if not os.path.isdir(filename):
|
||||
print ("not a directory: '" + filename + "'")
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
# Copyright (C) 2024 Michael Becker <alcexhim@gmail.com>
|
||||
#
|
||||
# This file is part of yaml2mcl.
|
||||
#
|
||||
# yaml2mcl is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# yaml2mcl is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with yaml2mcl. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
class McxDataFormat (DataFormat):
|
||||
|
||||
def load_internal(self, stream):
|
||||
|
||||
r = Reader(stream)
|
||||
@ -25,6 +25,7 @@ class MochaLibraryManager:
|
||||
def __init__(self):
|
||||
self.entityReferences = dict()
|
||||
self.entityReferenceFileNames = dict()
|
||||
self.entityReferencesExternal = dict()
|
||||
self.db = None
|
||||
self._instances = []
|
||||
self._attOps = []
|
||||
@ -206,6 +207,9 @@ class MochaLibraryManager:
|
||||
|
||||
print ("preparing debug information (use --no-debug or undefine DEBUG or etc. [NOT IMPLEMENTED] to turn off)")
|
||||
for key in self.entityReferences:
|
||||
if self.is_entity_reference_external(key):
|
||||
continue
|
||||
|
||||
val = self.entityReferences[key]
|
||||
|
||||
gidEntityDefinition = Guid.create()
|
||||
@ -427,9 +431,13 @@ class MochaLibraryManager:
|
||||
def exists_entity_reference(self, name):
|
||||
return name in self.entityReferences
|
||||
|
||||
def register_entity_reference(self, name, value, filename = None):
|
||||
def register_entity_reference(self, name, value, filename = None, externalReference = False):
|
||||
self.entityReferences[name] = value
|
||||
self.entityReferenceFileNames[name] = filename
|
||||
self.entityReferencesExternal[name] = externalReference
|
||||
|
||||
def is_entity_reference_external(self, name):
|
||||
return self.entityReferencesExternal[name]
|
||||
|
||||
def define_entity_reference(self, name):
|
||||
return self.entityReferences[name]
|
||||
@ -475,6 +483,9 @@ class MochaLibraryManager:
|
||||
print("public static class KnownInstances", file=f)
|
||||
print("{", file=f)
|
||||
for name in self.entityReferences:
|
||||
if self.is_entity_reference_external(name):
|
||||
continue
|
||||
|
||||
if name.startswith("IDC_") or name.startswith("IDA_") or name.startswith("IDI_"):
|
||||
shortname = name
|
||||
if name.startswith("ID") and "_" in name:
|
||||
@ -491,6 +502,9 @@ class MochaLibraryManager:
|
||||
print("class KnownInstances:", file=f)
|
||||
print("", file=f)
|
||||
for name in self.entityReferences:
|
||||
if self.is_entity_reference_external(name):
|
||||
continue
|
||||
|
||||
if name.startswith("IDC_") or name.startswith("IDA_") or name.startswith("IDI_"):
|
||||
shortname = name
|
||||
if name.startswith("ID") and "_" in name:
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
# Copyright (C) 2024 Michael Becker <alcexhim@gmail.com>
|
||||
#
|
||||
# This file is part of yaml2mcl.
|
||||
#
|
||||
# yaml2mcl is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# yaml2mcl is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with yaml2mcl. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
from editor.core import DataFormat, InvalidDataFormatException
|
||||
from editor.core.io import Reader
|
||||
|
||||
from io import FileIO
|
||||
|
||||
class McxDataFormat (DataFormat):
|
||||
|
||||
def __init__(self):
|
||||
self.defs = [ ]
|
||||
|
||||
def get_signature(self) -> str:
|
||||
return "MCX!"
|
||||
|
||||
def load_internal(self, stream : FileIO):
|
||||
|
||||
r = Reader(stream)
|
||||
|
||||
# SectionFile header
|
||||
signature = r.read_fixedstring(4)
|
||||
if signature != self.get_signature():
|
||||
raise InvalidDataFormatException
|
||||
|
||||
version = r.read_single()
|
||||
if version != 2.0:
|
||||
raise InvalidDataFormatException
|
||||
|
||||
flags = r.read_int32()
|
||||
section_count = r.read_int32()
|
||||
guid = r.read_guid()
|
||||
|
||||
sections = [ ]
|
||||
|
||||
for i in range(0, section_count):
|
||||
section_name = r.read_fixedstring(16).strip(' \0')
|
||||
offset = r.read_int32()
|
||||
length = r.read_int32()
|
||||
length2 = r.read_int32()
|
||||
itemcount = r.read_int32()
|
||||
|
||||
print(' '+section_name)
|
||||
sections.append((section_name, offset, length, length2, itemcount))
|
||||
|
||||
for (section_name, offset, length, length2, itemcount) in sections:
|
||||
if section_name == "Defs":
|
||||
|
||||
r.get_stream().seek(offset)
|
||||
for j in range(0, itemcount):
|
||||
key = r.read_terminatedstring()
|
||||
value = r.read_terminatedstring()
|
||||
self.defs.append((key, value))
|
||||
|
||||
|
||||
def save_internal(self, stream : FileIO):
|
||||
|
||||
pass
|
||||
@ -0,0 +1 @@
|
||||
from .McxDataFormat import McxDataFormat
|
||||
@ -0,0 +1,3 @@
|
||||
class McxObjectModel :
|
||||
|
||||
pass
|
||||
@ -0,0 +1,3 @@
|
||||
class McxSection :
|
||||
|
||||
pass
|
||||
@ -8,4 +8,4 @@
|
||||
- relationship: '&IDR_Class__has_title__Translation;'
|
||||
values:
|
||||
- languageInstanceId: '&IDI_Language_English;'
|
||||
value: 'OMS'
|
||||
value: 'OMS'
|
||||
@ -1,4 +1,8 @@
|
||||
---
|
||||
- entityDefinitions:
|
||||
- IDM_OMS__get__Runtime_Version: '{58835bd3-21e2-43bb-a069-7f8befe9bf5d}'
|
||||
- IDMB_OMS__get__Runtime_Version: '{d5b09408-b000-4f45-9d97-df610ee15506}'
|
||||
|
||||
- library: '&IDL_MochaBaseSystem;'
|
||||
instances:
|
||||
- class: '&IDC_GetAttributeBySystemRoutineMethod;'
|
||||
@ -73,3 +77,16 @@
|
||||
destinationClassId: '&IDC_GetAttributeBySystemRoutineMethod;'
|
||||
siblingRelationshipId: '&IDR_Get_Attribute_by_System_Routine_Method__uses__System_Attribute_Routine;'
|
||||
singular: no
|
||||
|
||||
|
||||
- getAttributeBySystemRoutineMethod: '&IDM_OMS__get__Runtime_Version;'
|
||||
forClassId: '&IDC_OMS;'
|
||||
verb: 'get'
|
||||
name: 'Runtime Version'
|
||||
accessModifierId: '&IDI_AccessModifier_Public;'
|
||||
returnsAttributeId: '&IDA_Version;'
|
||||
systemAttributeRoutineId: '&IDI_SystemAttributeRoutine_GetRuntimeVersion;'
|
||||
moduleId: '&IDI_Module_MochaBaseSystem;'
|
||||
|
||||
- returnAttributeMethodBinding: '&IDMB_OMS__get__Runtime_Version;'
|
||||
executesMethod: '&IDM_OMS__get__Runtime_Version;'
|
||||
@ -1,4 +1,7 @@
|
||||
---
|
||||
- entityDefinitions:
|
||||
- IDI_SystemAttributeRoutine_GetRuntimeVersion: '{dc4e6c8d-936d-457f-90e9-af47e229b80c}' # {5d13d326-bbf2-4421-b1f0-4fa43892bcf5}
|
||||
|
||||
- library: '&IDL_MochaBaseSystem;'
|
||||
instances:
|
||||
- class: '&IDC_SystemAttributeRoutine;'
|
||||
@ -11,4 +14,6 @@
|
||||
- instance: '&IDI_SystemAttributeRoutine_GetGlobalIdentifier;'
|
||||
name: 'Get Global Identifier for Instance Parm'
|
||||
- instance: '&IDI_SystemAttributeRoutine_GetInstanceText;'
|
||||
name: 'Get Instance Text for Instance Parm'
|
||||
- instance: '&IDI_SystemAttributeRoutine_GetRuntimeVersion;'
|
||||
name: 'Get Instance Text for Instance Parm'
|
||||
Loading…
x
Reference in New Issue
Block a user