Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
minimize the all-json-idls.js file. Closes #30
- added an option to collect-all-json-idl.py to allow creating
a min-ized version of the JSON

- add additional call to collect-all-json-idl.py in the ant build
to build the min-ized version

- switch client and target to load the min-ized version

The old IDL was 188KB.  The new IDL is 20KB.
  • Loading branch information
pmuellr committed Feb 28, 2011
1 parent 04bd227 commit f89a59cc80898bbe3bf878e23fa207fa9964e70c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
@@ -305,6 +305,13 @@
<arg file="${CACHED}/json-idl"/>
</exec>

<exec executable="python" failonerror="true" failifexecutionfails="true">
<arg file="scripts/collect-all-json-idl.py"/>
<arg value="-min"/>
<arg file="${CACHED}/json-idl/all-json-idls-min.js"/>
<arg file="${CACHED}/json-idl"/>
</exec>

</target>

<!-- ============================================================
@@ -66,7 +66,7 @@ def createIndexFile(iFileName, oFileName, moduleDir):
elif pattern_head_end.match(line):
foundEnd = True
newLines.append("<!-- ========== weinre additions: starting ========== -->\n")
newLines.append('<script type="text/javascript" src="../interfaces/all-json-idls.js"></script>\n')
newLines.append('<script type="text/javascript" src="../interfaces/all-json-idls-min.js"></script>\n')
newLines.append('<script type="text/javascript">require("weinre/client/Client").main()</script>\n')
newLines.append("<!-- ========== weinre additions: done ========== -->\n")
newLines.append(line)
@@ -18,8 +18,15 @@ def main():
if len(sys.argv) < 3:
error("expecting parameters outputFile inputDir")

oFileName = sys.argv[1]
iDirName = sys.argv[2]
min = False
if sys.argv[1] == "-min":
min = True
oFileName = sys.argv[2]
iDirName = sys.argv[3]

else:
oFileName = sys.argv[1]
iDirName = sys.argv[2]

entries = os.listdir(iDirName)
if 0 == len(entries): error("no files found in '" + iDirName + "'")
@@ -38,7 +45,13 @@ def main():

result.append(json.loads(contents))

jsonString = json.dumps(result, indent=4)
if min:
result = minimize(result)
jsonString = json.dumps(result)

else:
jsonString = json.dumps(result, indent=4)

jsString = "require('weinre/common/Weinre').addIDLs(%s)" % jsonString

oFile = open(oFileName, "w")
@@ -47,6 +60,29 @@ def main():

log("generated collected json idls in: " + oFileName)

#--------------------------------------------------------------------
def minimize(idl):
for module in idl:
for interface in module["interfaces"]:
if "extendedAttributes" in interface:
del interface["extendedAttributes"]

if "methods" in interface:
for method in interface["methods"]:
if "returns" in method:
del method["returns"]
if "callbackParameters" in method:
del method["callbackParameters"]
if "extendedAttributes" in method:
del method["extendedAttributes"]

if "parameters" in method:
for parameter in method["parameters"]:
if "type" in parameter:
del parameter["type"]

return idl

#--------------------------------------------------------------------
def log(message):
message = "%s: %s" % (PROGRAM_NAME, message)
@@ -41,7 +41,7 @@
<script src="/weinre/target/ElementHighlighter.transportd.js"></script>
<script src="/weinre/target/InjectedScript.js"></script>
<script src="/weinre/target/Timeline.transportd.js"></script>
<script src="/interfaces/all-json-idls.js"></script>
<script src="/interfaces/all-json-idls-min.js"></script>

<script type="text/javascript">
require("weinre/common/Weinre").showNotImplemented()

0 comments on commit f89a59c

Please sign in to comment.