diff --git a/ObjectiveCCodeGenerator.py b/ObjectiveCCodeGenerator.py index 2449410..ae52304 100755 --- a/ObjectiveCCodeGenerator.py +++ b/ObjectiveCCodeGenerator.py @@ -1017,14 +1017,14 @@ def writeAPIParser(self) : finally : implDstFile.close() - def writeTemplates(self) : + def writeTemplates(self, templatePath) : - if self.dirPath.endswith("/") : - self.dirPath = self.dirPath[:-1] - baseDirPath = self.dirPath - self.dirPath = baseDirPath + "/Utilities/NSString" + if templatePath.endswith("/") : + templatePath = templatePath[:-1] + + self.dirPath = templatePath + "/NSString" self.writeNSStringCategory() - self.dirPath = baseDirPath + "/Utilities/APIParser" + self.dirPath = templatePath + "/APIParser" self.writeAPIParser() diff --git a/readJSON.py b/readJSON.py index eba084b..4b21ee0 100755 --- a/readJSON.py +++ b/readJSON.py @@ -39,6 +39,7 @@ projectPrefix = '' target = 'iOS' dirPathToSaveCodes = './src' +dirPathToSaveUtility = '' objectSuffix = "JSONObject" usageString = '\nreadJSON.py [ -p | -t | -o | -s ] [-i]\n' @@ -49,11 +50,12 @@ usageString += ' -t, --target= target platform iOS or Android (default: iOS)\n' usageString += ' -i, --input= meta-JSON file to read\n' usageString += ' -o, --output= ouput path of generated source codes\n' +usageString += ' -u, --utility= ouput path of generated Utility codes. Use "-u false" for no utility\n' if __name__ == "__main__": argv = sys.argv[1:] try: - opts, args = getopt.getopt(argv,"ho:p:s:t:i:",["prefix=","suffix=","target=","input=","output="]) + opts, args = getopt.getopt(argv,"ho:p:s:t:i:u:",["prefix=","suffix=","target=","input=","output=","utility="]) except getopt.GetoptError: print usageString sys.exit(2) @@ -74,7 +76,20 @@ objectSuffix = arg if objectSuffix == "false": objectSuffix = "" + elif opt in ("-u", "--utility"): + dirPathToSaveUtility = arg + + + if dirPathToSaveUtility == "": + tmpSourcePath = dirPathToSaveCodes + if tmpSourcePath.endswith("/") : + tmpSourcePath = tmpSourcePath[:-1] + dirPathToSaveUtility = tmpSourcePath + "/Utility" + + elif dirPathToSaveUtility == "false": + dirPathToSaveUtility = ""; + addFiles = False for arg in argv : if arg.endswith(inputfile) : @@ -142,7 +157,8 @@ def openFileAndParseJSON(filePath): templateCodeGen.templatePath = templatePath templateCodeGen.projectPrefix = projectPrefix templateCodeGen.dirPath = dirPathToSaveCodes - templateCodeGen.writeTemplates() + if len(dirPathToSaveUtility) != 0 : + templateCodeGen.writeTemplates(dirPathToSaveUtility) JSONScheme.projectPrefix = projectPrefix JSONScheme.objectSuffix = objectSuffix