diff Resources/GenerateErrorCodes.py @ 1644:939b921b2c81

plugin error dictionary
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Sep 2015 22:05:27 +0200
parents 8dc468f44661
children da799f767e5d
line wrap: on
line diff
--- a/Resources/GenerateErrorCodes.py	Wed Sep 23 14:42:20 2015 +0200
+++ b/Resources/GenerateErrorCodes.py	Wed Sep 23 22:05:27 2015 +0200
@@ -33,7 +33,9 @@
 import json
 import os
 import re
+import sys
 
+START_PLUGINS = 1000000
 BASE = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
 
 
@@ -45,6 +47,11 @@
 with open(os.path.join(BASE, 'Resources', 'ErrorCodes.json'), 'r') as f:
     ERRORS = json.loads(re.sub('/\*.*?\*/', '', f.read()))
 
+for error in ERRORS:
+    if error['Code'] >= START_PLUGINS:
+        print('ERROR: Error code must be below %d, but "%s" is set to %d' % (START_PLUGINS, error['Name'], error['Code']))
+        sys.exit(-1)
+
 with open(os.path.join(BASE, 'Core', 'Enumerations.h'), 'r') as f:
     a = f.read()
 
@@ -63,6 +70,8 @@
     a = f.read()
 
 s = ',\n'.join(map(lambda x: '    ErrorCode_%s = %d    /*!< %s */' % (x['Name'], int(x['Code']), x['Description']), ERRORS))
+
+s += ',\n    ErrorCode_START_PLUGINS = %d' % START_PLUGINS
 a = re.sub('(enum ErrorCode\s*{)[^}]*?(\s*};)', r'\1\n%s\2' % s, a, re.DOTALL)
 
 with open(path, 'w') as f: