Пример #1
0
def compile_js(manifest, config):
    js_file = os.path.join(cwd, "assets", "ti.mediapicker.js")
    if not os.path.exists(js_file):
        js_file = os.path.join(cwd, "..", "assets", "ti.mediapicker.js")
    if not os.path.exists(js_file):
        return

    from compiler import Compiler

    try:
        import json
    except:
        import simplejson as json

    compiler = Compiler(cwd, manifest["moduleid"], manifest["name"], "commonjs")
    root_asset, module_assets = compiler.compile_module()

    root_asset_content = (
        """
%s

	return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[0]);
"""
        % root_asset
    )

    module_asset_content = (
        """
%s

	NSNumber *index = [map objectForKey:path];
	if (index == nil) {
		return nil;
	}
	return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[index.integerValue]);
"""
        % module_assets
    )

    from tools import splice_code

    assets_router = os.path.join(cwd, "Classes", "TiMediapickerModuleAssets.m")
    splice_code(assets_router, "asset", root_asset_content)
    splice_code(assets_router, "resolve_asset", module_asset_content)

    # Generate the exports after crawling all of the available JS source
    exports = open("metadata.json", "w")
    json.dump({"exports": compiler.exports}, exports)
    exports.close()
Пример #2
0
def compile_js(manifest,config):
    moduleid = manifest['moduleid']
    js_file = os.path.join(cwd,'assets',moduleid + '.js')
    if not os.path.exists(js_file): return

    from compiler import Compiler
    try:
        import json
    except:
        import simplejson as json

    compiler = Compiler(cwd, moduleid, manifest['name'], 'commonjs')
    root_asset, module_assets = compiler.compile_module()

    root_asset_content = """
%s

    return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[0]);
""" % root_asset

    module_asset_content = """
%s

    NSNumber *index = [map objectForKey:path];
    if (index == nil) {
        return nil;
    }
    return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[index.integerValue]);
""" % module_assets

    from tools import splice_code


    paths = glob.glob(os.path.join(cwd,'Classes','*ModuleAssets.m' ));
    if (len(paths) == 0):
        return;
    assets_router = paths[0]
    print(assets_router)
    splice_code(assets_router, 'asset', root_asset_content)
    splice_code(assets_router, 'resolve_asset', module_asset_content)

    # Generate the exports after crawling all of the available JS source
    exports = open('metadata.json','w')
    json.dump({'exports':compiler.exports }, exports)
    exports.close()
def compile_js(manifest, config):
    js_file = os.path.join(cwd, 'assets',
                           'ro.toshi.ti.mod.twilioipmessaging.js')
    if not os.path.exists(js_file):
        js_file = os.path.join(cwd, '..', 'assets',
                               'ro.toshi.ti.mod.twilioipmessaging.js')
    if not os.path.exists(js_file): return

    from compiler import Compiler
    try:
        import json
    except:
        import simplejson as json

    compiler = Compiler(cwd, manifest['moduleid'], manifest['name'],
                        'commonjs')
    root_asset, module_assets = compiler.compile_module()

    root_asset_content = """
%s

	return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[0]);
""" % root_asset

    module_asset_content = """
%s

	NSNumber *index = [map objectForKey:path];
	if (index == nil) {
		return nil;
	}
	return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[index.integerValue]);
""" % module_assets

    from tools import splice_code

    assets_router = os.path.join(
        cwd, 'Classes', 'RoToshiTiModTwilioipmessagingModuleAssets.m')
    splice_code(assets_router, 'asset', root_asset_content)
    splice_code(assets_router, 'resolve_asset', module_asset_content)

    # Generate the exports after crawling all of the available JS source
    exports = open('metadata.json', 'w')
    json.dump({'exports': compiler.exports}, exports)
    exports.close()
Пример #4
0
def compile_js(manifest,config):
	js_file = os.path.join(cwd,'assets','rebel.Parse.js')
	if not os.path.exists(js_file):
		js_file = os.path.join(cwd,'..','assets','rebel.Parse.js')
	if not os.path.exists(js_file): return

	from compiler import Compiler
	try:
		import json
	except:
		import simplejson as json

	compiler = Compiler(cwd, manifest['moduleid'], manifest['name'], 'commonjs')
	root_asset, module_assets = compiler.compile_module()

	root_asset_content = """
{0!s}

	return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[0]);
""".format(root_asset)

	module_asset_content = """
{0!s}

	NSNumber *index = [map objectForKey:path];
	if (index == nil) {{
		return nil;
	}}
	return filterDataInRange([NSData dataWithBytesNoCopy:data length:sizeof(data) freeWhenDone:NO], ranges[index.integerValue]);
""".format(module_assets)

	from tools import splice_code

	assets_router = os.path.join(cwd,'Classes','RebelParseModuleAssets.m')
	splice_code(assets_router, 'asset', root_asset_content)
	splice_code(assets_router, 'resolve_asset', module_asset_content)

	# Generate the exports after crawling all of the available JS source
	exports = open('metadata.json','w')
	json.dump({'exports':compiler.exports }, exports)
	exports.close()