Esempio n. 1
0
def main_jsuic():
    argv = sys.argv
    input_file_name = "-"
    output_file_name = "-"
    base_class = None

    for i in range(len(sys.argv)):
        if sys.argv[i] == "-v":
            jsqt.loglevel = 1
            break

    for i in range(1,len(argv)):
        if argv[i] == "-o":
            if output_file_name == "-":
                try:
                    output_file_name = argv[i+1]
                except IndexError:
                    usage_jsuic()
            else:
                usage_jsuic()

            i+=1
  
        elif argv[i] == "-h":
            usage_jsuic()

        elif argv[i] == "-b":
            base_class = argv[i+1]

        elif argv[i][0] == "-":
            usage_jsuic()

        else:
            if input_file_name == "-":
                input_file_name = argv[i]
            else:
                usage_jsuic()

    if input_file_name == "-":
        input_file = sys.stdin
    else:
        input_file = open(input_file_name, 'r')


    parser = UiParser()
    parser.parse(input_file, input_file_name)
    parser.clazz.base_class = base_class
    compiled_object = parser.clazz.compile('javascript-qooxdoo-1.6')

    if output_file_name == "-":
        output_file = sys.stdout
    else:
        output_file = open(output_file_name, 'w')

    compiled_object.to_stream(JsPp(NoTrailingSpace(output_file)))
    output_file.write(";\n") # FIXME: Hack!

    if output_file_name != "-":
        output_file.close()
Esempio n. 2
0
def main_jsuic():
    argv = sys.argv
    input_file_name = "-"
    output_file_name = "-"
    base_class = None

    for i in range(len(sys.argv)):
        if sys.argv[i] == "-v":
            jsqt.loglevel = 1
            break

    for i in range(1, len(argv)):
        if argv[i] == "-o":
            if output_file_name == "-":
                try:
                    output_file_name = argv[i + 1]
                except IndexError:
                    usage_jsuic()
            else:
                usage_jsuic()

            i += 1

        elif argv[i] == "-h":
            usage_jsuic()

        elif argv[i] == "-b":
            base_class = argv[i + 1]

        elif argv[i][0] == "-":
            usage_jsuic()

        else:
            if input_file_name == "-":
                input_file_name = argv[i]
            else:
                usage_jsuic()

    if input_file_name == "-":
        input_file = sys.stdin
    else:
        input_file = open(input_file_name, 'r')

    parser = UiParser()
    parser.parse(input_file, input_file_name)
    parser.clazz.base_class = base_class
    compiled_object = parser.clazz.compile('javascript-qooxdoo-1.6')

    if output_file_name == "-":
        output_file = sys.stdout
    else:
        output_file = open(output_file_name, 'w')

    compiled_object.to_stream(JsPp(NoTrailingSpace(output_file)))
    output_file.write(";\n")  # FIXME: Hack!

    if output_file_name != "-":
        output_file.close()
Esempio n. 3
0
def compile(ui_file_name, js_file_name, root_namespace, base_class, dialect):
    print ui_file_name

    if js_file_name.rfind(root_namespace) == -1:
        raise Exception("root_namespace '%s' not found in class name '%s'" %
                        (root_namespace, js_file_name))

    object_name = js_file_name[js_file_name.rfind(root_namespace):].replace(
        os.sep * 2, os.sep).replace(os.sep, ".")[0:-3]
    parser = UiParser(object_name)
    parser.parse(ui_file_name, ui_file_name)
    parser.clazz.base_class = base_class

    jsqt.debug_print("")
    jsqt.debug_print("\tcompiling....")
    jsqt.debug_print("\t" + "=" * 20)
    compiled_object = parser.clazz.compile(dialect)

    f = open(js_file_name, 'w')
    for p in parser.clazz.preamble:
        p.compile(dialect).to_stream(f)
    compiled_object.to_stream(JsPp(NoTrailingSpace(f)))
    f.write(";\n")  # FIXME: Hack!
    f.close()
Esempio n. 4
0
def compile(ui_file_name, js_file_name, root_namespace, base_class, dialect):
    print ui_file_name

    if js_file_name.rfind(root_namespace) == -1:
        raise Exception("root_namespace '%s' not found in class name '%s'" % (
                root_namespace, js_file_name))

    object_name= js_file_name[js_file_name.rfind(root_namespace):].replace(
                                    os.sep*2, os.sep).replace(os.sep, ".")[0:-3]
    parser = UiParser(object_name)
    parser.parse(ui_file_name, ui_file_name)
    parser.clazz.base_class = base_class

    jsqt.debug_print("")
    jsqt.debug_print("\tcompiling....")
    jsqt.debug_print("\t"+"="*20)
    compiled_object = parser.clazz.compile(dialect)

    f=open(js_file_name, 'w')
    for p in parser.clazz.preamble:
        p.compile(dialect).to_stream(f)
    compiled_object.to_stream(JsPp(NoTrailingSpace(f)))
    f.write(";\n") # FIXME: Hack!
    f.close()