Esempio n. 1
0
 def qualified_superclass(self):
     if self.tome.superclass is None:
         return AS3_MUTABLE_TYPENAMES[s.TomeType]
     else:
         super_namespace = util.get_namespace(self.tome.superclass)
         super_name = mutable_tome_name(util.strip_namespace(self.tome.superclass))
         return util.qualified_name(super_namespace, super_name)
Esempio n. 2
0
 def qualified_superclass(self):
     if self.page.superclass is None:
         return BASE_PAGE_CLASS
     else:
         super_namespace = util.get_namespace(self.page.superclass)
         super_name = mutable_page_name(util.strip_namespace(self.page.superclass))
         return util.qualified_name(super_namespace, super_name)
Esempio n. 3
0
 def from_qualified_name(cls, lib, name):
     namespace = util.get_namespace(name)
     name = util.strip_namespace(name)
     # In the python microtome runtime, tomes are stored in their own individual modules -
     # e.g. 'from game.data.BaddieTome import BaddieTome' - so we account for that here
     if is_tome_name(lib, name):
         namespace += "." + name
     return ImportView(namespace, name)
Esempio n. 4
0
 def same_namespace(self, typename):
     return self.namespace == util.get_namespace(typename)
Esempio n. 5
0
def mutable_tome_name(tome_name):
    return util.qualified_name(util.get_namespace(tome_name),
                               "Mutable" + util.strip_namespace(tome_name))
Esempio n. 6
0
    s.IntType: "microtome.prop.IntProp",
    s.FloatType: "microtome.prop.NumberProp"
}

OBJECT_PROPNAME = "microtome.prop.ObjectProp"

LIBRARY_FILENAME = "MicrotomeTypes.as"
TOME_TEMPLATE_NAME = "Tome.as"
MUTABLE_TOME_TEMPLATE_NAME = "MutableTome.as"
TEMPLATES_DIR = util.abspath("templates/as")

# stuff we always import
BASE_CLASS_IMPORTS = set(["microtome.prop.Prop", "microtome.prop.PropSpec"])
BASE_INTERFACE_IMPORTS = set()
# stuff we never import (packageless typenames: Boolean, int, etc)
DISCARD_IMPORTS = set([name for name in AS3_TYPENAMES.values() if util.get_namespace(name) == ""])


def comment_prefix():
    return "//"

def generate_library(lib):
    '''Returns a list of (filename, filecontents) tuples representing the generated files to
    be written to disk'''

    # "escape" param disables html-escaping
    stache = pystache.Renderer(search_dirs=TEMPLATES_DIR, escape=lambda u: u)

    tome_types = [util.qualified_name(spec.namespace, mutable_tome_name(spec.name)) for spec in lib.tomes]

    library_view = {
Esempio n. 7
0
 def make_qualified_typename(self, typename):
     if util.get_namespace(typename) == "" and self.namespace != "":
         return self.namespace + "." + typename
     else:
         return typename
Esempio n. 8
0
    s.IntType: "int",
    s.FloatType: "float",
    s.StringType: "str",
    s.ListType: "list",
    s.TomeRefType: "microtome.core.tome_ref.TomeRef",
    s.TomeType: "microtome.tome.Tome",
}

LIBRARY_FILENAME = "MicrotomeTypes.py"
TOME_TEMPLATE_NAME = "Tome.py"
TEMPLATES_DIR = util.abspath("templates/py")

# stuff we always import
BASE_IMPORTS = {"microtome.core.prop.Prop", "microtome.core.prop.PropSpec"}
# stuff we never import (packageless typenames: bool, int, etc)
DISCARD_IMPORTS = {name for name in PY_TYPENAMES.values() if util.get_namespace(name) == ""}

def comment_prefix():
    return "#"

def generate_library(lib):
    """Returns a list of (filename, filecontents) tuples representing the generated files to
    be written to disk"""

    # "escape" param disables html-escaping
    stache = pystache.Renderer(search_dirs=TEMPLATES_DIR, escape=lambda u: u)

    tome_imports = [ImportView.from_qualified_name(lib, util.qualified_name(spec.namespace, spec.name)) for spec in lib.tomes]

    library_view = {
        "tome_imports": sorted(set(tome_imports)),
Esempio n. 9
0
}

OBJECT_PROPNAME = "microtome.prop.ObjectProp"

LIBRARY_FILENAME = "MicrotomeTypes.as"
TOME_TEMPLATE_NAME = "Tome.as"
MUTABLE_TOME_TEMPLATE_NAME = "MutableTome.as"
TEMPLATES_DIR = util.abspath("templates/as")

# stuff we always import
BASE_CLASS_IMPORTS = {"microtome.prop.Prop", "microtome.prop.PropSpec"}
BASE_INTERFACE_IMPORTS = set()
# stuff we never import (packageless typenames: Boolean, int, etc)
DISCARD_IMPORTS = {
    name
    for name in AS3_TYPENAMES.values() if util.get_namespace(name) == ""
}


def comment_prefix():
    return "//"


def generate_library(lib):
    '''Returns a list of (filename, filecontents) tuples representing the generated files to
    be written to disk'''

    # "escape" param disables html-escaping
    stache = pystache.Renderer(search_dirs=TEMPLATES_DIR, escape=lambda u: u)

    tome_types = [