summaryrefslogtreecommitdiff
path: root/config/makeprops.py
diff options
context:
space:
mode:
Diffstat (limited to 'config/makeprops.py')
-rwxr-xr-xconfig/makeprops.py99
1 files changed, 95 insertions, 4 deletions
diff --git a/config/makeprops.py b/config/makeprops.py
index 615f71edcb9..fcbb9ef1bd5 100755
--- a/config/makeprops.py
+++ b/config/makeprops.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# **********************************************************************
#
-# Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
+# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
@@ -24,14 +24,14 @@ propertyClasses = {}
commonPreamble = """// **********************************************************************
//
-// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
+// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
-//
+///* jshint -W044*/
"""
commonPreamble = commonPreamble + "// Generated by " + progname + " from file %(inputfile)s, " + time.ctime()
commonPreamble = commonPreamble + """
@@ -117,9 +117,24 @@ namespace IceInternal
{
"""
+jsPreamble = commonPreamble + """
+(function(global){
+ var Ice = global.Ice || Ice;
+ require("Ice/Property");
+ var %(classname)s = {};
+ var Property = Ice.Property;
+"""
+
+jsEpilogue = \
+"""
+ Ice.%(classname)s = %(classname)s;
+ global.Ice = Ice;
+}(typeof (global) === "undefined" ? window : global));
+"""
+
def usage():
global progname
- print >> sys.stderr, "Usage: " + progname + " [--{cpp|java|cs} file]"
+ print >> sys.stderr, "Usage: " + progname + " [--{cpp|java|cs|js} file]"
def progError(msg):
global progname
@@ -516,6 +531,78 @@ class CSPropertyHandler(PropertyHandler):
os.remove(os.path.join(dest, self.className + ".cs"))
shutil.move(self.className + ".cs", dest)
+class JSPropertyHandler(PropertyHandler):
+ def __init__(self, inputfile, c):
+ PropertyHandler.__init__(self, inputfile, c)
+ self.srcFile = None
+ self.validSections = ["Ice"]
+
+ def cleanup(self):
+ if self.srcFile != None:
+ self.srcFile.close()
+ if os.path.exists(self.className + ".js"):
+ os.remove(self.className + ".js")
+
+ def startFiles(self):
+ self.srcFile = file(self.className + ".js", "wb")
+ self.srcFile.write(jsPreamble % {'inputfile' : self.inputfile, 'classname' : self.className})
+ self.srcFile.write(" /* jshint -W044*/\n\n");
+
+ def closeFiles(self):
+ self.srcFile.write(" /* jshint +W044*/\n\n");
+ self.srcFile.write(" %s.validProps =\n" % (self.className))
+ self.srcFile.write(" [\n")
+ for s in self.sections:
+ if s in self.validSections:
+ self.srcFile.write(" %s.%sProps,\n" % (self.className, s))
+ self.srcFile.write(" ];\n\n")
+
+ self.srcFile.write(" %s.clPropNames =\n" % (self.className))
+ self.srcFile.write(" [\n")
+ for s in self.cmdLineOptions:
+ if s in self.validSections:
+ self.srcFile.write(" \"%s\",\n" % s)
+ self.srcFile.write(" ];\n")
+
+ self.srcFile.write(jsEpilogue % {'classname' : self.className});
+ self.srcFile.close()
+
+ def fix(self, propertyName):
+ propertyName = string.replace(propertyName, ".", "\\.")
+ return string.replace(propertyName, "[any]", ".")
+
+ def deprecatedImpl(self, propertyName):
+ if self.currentSection in self.validSections:
+ self.srcFile.write(" new Property(\"/^%s\.%s/\", true, null),\n" % (self.currentSection, \
+ self.fix(propertyName)))
+
+ def deprecatedImplWithReplacementImpl(self, propertyName, deprecatedBy):
+ if self.currentSection in self.validSections:
+ self.srcFile.write(" new Property(\"/^%s\.%s/\", true, \"%s\"),\n" % \
+ (self.currentSection, self.fix(propertyName), deprecatedBy))
+
+ def propertyImpl(self, propertyName):
+ if self.currentSection in self.validSections:
+ self.srcFile.write(" new Property(\"/^%s\.%s/\", false, null),\n" % (self.currentSection, \
+ self.fix(propertyName)))
+
+ def newSection(self):
+ if self.currentSection in self.validSections:
+ self.skipSection = False
+ self.srcFile.write(" %s.%sProps =\n" % (self.className, self.currentSection));
+ self.srcFile.write(" [\n")
+
+ def closeSection(self):
+ if self.currentSection in self.validSections:
+ self.srcFile.write(" ];\n")
+ self.srcFile.write("\n")
+
+ def moveFiles(self, location):
+ dest = os.path.join(location, "js", "src", "Ice")
+ if os.path.exists(os.path.join(dest, self.className + ".js")):
+ os.remove(os.path.join(dest, self.className + ".js"))
+ shutil.move(self.className + ".js", dest)
+
class MultiHandler(PropertyHandler):
def __init__(self, inputfile, c):
self.handlers = []
@@ -597,6 +684,8 @@ def main():
lang = "java"
elif option == "--cs":
lang = "cs"
+ elif option == "--js":
+ lang = "js"
elif option in ["-h", "--help", "-?"]:
usage()
sys.exit(0)
@@ -619,6 +708,8 @@ def main():
contentHandler = JavaPropertyHandler(infile, className)
elif lang == "cs":
contentHandler = CSPropertyHandler(infile, className)
+ elif lang == "js":
+ contentHandler = JSPropertyHandler(infile, className)
#
# Install signal handler so we can remove the output files if we are interrupted.