summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generator/README.md27
-rw-r--r--generator/generator.py4
-rw-r--r--generator/templates/SDLRPCFunctionNames.h.jinja2 (renamed from generator/templates/SDLRPCFunctionNames.h)2
-rw-r--r--generator/templates/SDLRPCFunctionNames.m.jinja2 (renamed from generator/templates/SDLRPCFunctionNames.m)2
-rw-r--r--generator/templates/SDLRPCParameterNames.h.jinja2 (renamed from generator/templates/SDLRPCParameterNames.h)2
-rw-r--r--generator/templates/SDLRPCParameterNames.m.jinja2 (renamed from generator/templates/SDLRPCParameterNames.m)2
-rw-r--r--generator/templates/base_struct_function.h.jinja2 (renamed from generator/templates/base_struct_function.h)6
-rw-r--r--generator/templates/base_struct_function.m.jinja2 (renamed from generator/templates/base_struct_function.m)2
-rw-r--r--generator/templates/copyright.jinja2 (renamed from generator/templates/copyright.txt)0
-rw-r--r--generator/templates/description.jinja2 (renamed from generator/templates/description.jinja)0
-rw-r--r--generator/templates/description_param.jinja2 (renamed from generator/templates/description_param.jinja)0
-rw-r--r--generator/templates/enums/template.h.jinja2 (renamed from generator/templates/enums/template.h)6
-rw-r--r--generator/templates/enums/template.m.jinja2 (renamed from generator/templates/enums/template.m)2
-rw-r--r--generator/templates/functions/template.h.jinja2 (renamed from generator/templates/functions/template.h)2
-rw-r--r--generator/templates/functions/template.m.jinja2 (renamed from generator/templates/functions/template.m)2
-rw-r--r--generator/templates/structs/template.h.jinja2 (renamed from generator/templates/structs/template.h)2
-rw-r--r--generator/templates/structs/template.m.jinja2 (renamed from generator/templates/structs/template.m)2
-rw-r--r--generator/transformers/common_producer.py15
18 files changed, 52 insertions, 26 deletions
diff --git a/generator/README.md b/generator/README.md
index 216e730a7..b6ec2a0b7 100644
--- a/generator/README.md
+++ b/generator/README.md
@@ -790,6 +790,33 @@ NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
```
+## Unit tests of Generator
+
+After you made any changes in python RPC generator to avoid affecting code logic you should run Unit tests as follow:
+
+```shell script
+$ cd sdl_ios
+$ python3 generator/test/runner.py
+```
+
+In case of successful execution of all Unit tests in output you will see the results as follow:
+
+```shell script
+Ran 12 tests in 0.464s
+
+OK
+```
+
+As well you can check coverage by Unit tests of python RPC generator as follow:
+
+```shell script
+coverage run generator/test/runner.py
+coverage html
+```
+
+after the you can check the report in `htmlcov/index.html`
+
+
## Other Utilities
### Generator
diff --git a/generator/generator.py b/generator/generator.py
index 6192b6816..17f0be091 100644
--- a/generator/generator.py
+++ b/generator/generator.py
@@ -343,7 +343,7 @@ class Generator:
data = render.copy()
data['imports'] = data['imports'][extension]
file_with_suffix = file.with_suffix(extension)
- templates = ['{}s/template{}'.format(type(item).__name__.lower(), extension)]
+ templates = ['{}s/template{}.jinja2'.format(type(item).__name__.lower(), extension)]
if 'template' in data:
templates.insert(0, data['template'] + extension)
tasks.append(self.process_common(skip, overwrite, file_with_suffix, data, templates))
@@ -372,7 +372,7 @@ class Generator:
self.logger.error('No "data" for %s', name)
continue
for extension in ('.h', '.m'):
- templates = [name + extension]
+ templates = ['{}{}.jinja2'.format(name, extension)]
file_with_suffix = file.with_suffix(extension)
tasks.append(self.process_common(skip, overwrite, file_with_suffix, data, templates))
diff --git a/generator/templates/SDLRPCFunctionNames.h b/generator/templates/SDLRPCFunctionNames.h.jinja2
index 3126c8169..5e13b735b 100644
--- a/generator/templates/SDLRPCFunctionNames.h
+++ b/generator/templates/SDLRPCFunctionNames.h.jinja2
@@ -1,4 +1,4 @@
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
// SDLRPCFunctionNames.h
#import "SDLEnum.h"
diff --git a/generator/templates/SDLRPCFunctionNames.m b/generator/templates/SDLRPCFunctionNames.m.jinja2
index 2ae5f21a6..c7dc5a374 100644
--- a/generator/templates/SDLRPCFunctionNames.m
+++ b/generator/templates/SDLRPCFunctionNames.m.jinja2
@@ -1,4 +1,4 @@
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
// SDLRPCFunctionNames.m
#import "SDLRPCFunctionNames.h"
diff --git a/generator/templates/SDLRPCParameterNames.h b/generator/templates/SDLRPCParameterNames.h.jinja2
index 4a00ce029..7a5bbb746 100644
--- a/generator/templates/SDLRPCParameterNames.h
+++ b/generator/templates/SDLRPCParameterNames.h.jinja2
@@ -1,4 +1,4 @@
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
// SDLRPCParameterNames.h
#import <Foundation/Foundation.h>
diff --git a/generator/templates/SDLRPCParameterNames.m b/generator/templates/SDLRPCParameterNames.m.jinja2
index ae6bdace7..b29a1705c 100644
--- a/generator/templates/SDLRPCParameterNames.m
+++ b/generator/templates/SDLRPCParameterNames.m.jinja2
@@ -1,4 +1,4 @@
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
// SDLRPCParameterNames.h
#import "NSMutableDictionary+Store.h"
diff --git a/generator/templates/base_struct_function.h b/generator/templates/base_struct_function.h.jinja2
index a0c697f64..cd1c23d6b 100644
--- a/generator/templates/base_struct_function.h
+++ b/generator/templates/base_struct_function.h.jinja2
@@ -1,6 +1,6 @@
{#- To avoid code duplication was crated this parent file, which contain common part used in:
"templates/functions/template.h" and "templates/structs/template.h". -#}
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
{% block imports %}
{%- for import in imports.enum %}
#import "{{import}}.h"
@@ -13,7 +13,7 @@
{%- endblock %}
NS_ASSUME_NONNULL_BEGIN
-{% include 'description.jinja' %}
+{% include 'description.jinja2' %}
@interface {{name}} : {{extends_class}}{{ending}}
{%- block constructors %}
{% for c in constructors %}
@@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
{%- endblock -%}
{%- block methods %}
{%- for param in params %}
-{%- include 'description_param.jinja' %}
+{%- include 'description_param.jinja2' %}
{%- if deprecated or param.deprecated %}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
diff --git a/generator/templates/base_struct_function.m b/generator/templates/base_struct_function.m.jinja2
index 8e98fddd4..30bb2e976 100644
--- a/generator/templates/base_struct_function.m
+++ b/generator/templates/base_struct_function.m.jinja2
@@ -1,6 +1,6 @@
{#- To avoid code duplication was crated this parent file, which contain common part used in:
"templates/functions/template.m" and "templates/structs/template.m". -#}
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
{%- block imports %}
#import "{{name}}.h"
#import "NSMutableDictionary+Store.h"
diff --git a/generator/templates/copyright.txt b/generator/templates/copyright.jinja2
index a037d487d..a037d487d 100644
--- a/generator/templates/copyright.txt
+++ b/generator/templates/copyright.jinja2
diff --git a/generator/templates/description.jinja b/generator/templates/description.jinja2
index fb4932270..fb4932270 100644
--- a/generator/templates/description.jinja
+++ b/generator/templates/description.jinja2
diff --git a/generator/templates/description_param.jinja b/generator/templates/description_param.jinja2
index cb0cc4244..cb0cc4244 100644
--- a/generator/templates/description_param.jinja
+++ b/generator/templates/description_param.jinja2
diff --git a/generator/templates/enums/template.h b/generator/templates/enums/template.h.jinja2
index e3d6927dc..edba9f0bf 100644
--- a/generator/templates/enums/template.h
+++ b/generator/templates/enums/template.h.jinja2
@@ -1,19 +1,19 @@
{#- String based enum -#}
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
{% block imports -%}
{%- for import in imports %}
#import "{{import}}.h"
{%- endfor %}
{%- endblock -%}
{%- block body %}
-{% include 'description.jinja' %}
+{% include 'description.jinja2' %}
typedef SDLEnum {{ name }} SDL_SWIFT_ENUM{{ending}};
{% if deprecated %}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
{% endif %}
{%- for param in params %}
-{%- include 'description_param.jinja' %}{% if param.deprecated %}
+{%- include 'description_param.jinja2' %}{% if param.deprecated %}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
{%- endif %}
diff --git a/generator/templates/enums/template.m b/generator/templates/enums/template.m.jinja2
index dc13f4611..0e8ca0b2b 100644
--- a/generator/templates/enums/template.m
+++ b/generator/templates/enums/template.m.jinja2
@@ -1,4 +1,4 @@
-{% include 'copyright.txt' %}
+{% include 'copyright.jinja2' %}
#import "{{name}}.h"
{%- block body %}
diff --git a/generator/templates/functions/template.h b/generator/templates/functions/template.h.jinja2
index b2301dba3..28e3fd0be 100644
--- a/generator/templates/functions/template.h
+++ b/generator/templates/functions/template.h.jinja2
@@ -1,2 +1,2 @@
{#- This template creates RPC requests, responses, and notification .h files -#}
-{% extends "base_struct_function.h" %} \ No newline at end of file
+{% extends "base_struct_function.h.jinja2" %} \ No newline at end of file
diff --git a/generator/templates/functions/template.m b/generator/templates/functions/template.m.jinja2
index f8d1bc59a..9809b8df2 100644
--- a/generator/templates/functions/template.m
+++ b/generator/templates/functions/template.m.jinja2
@@ -1,5 +1,5 @@
{#- This template creates RPC requests, responses, and notification .m files -#}
-{% extends "base_struct_function.m" %}
+{% extends "base_struct_function.m.jinja2" %}
{% block imports %}
{{super()}}
#import "SDLRPCFunctionNames.h"
diff --git a/generator/templates/structs/template.h b/generator/templates/structs/template.h.jinja2
index af44cb710..f57d273ca 100644
--- a/generator/templates/structs/template.h
+++ b/generator/templates/structs/template.h.jinja2
@@ -1,2 +1,2 @@
{#- This template creates RPC struct .h files -#}
-{% extends "base_struct_function.h" %} \ No newline at end of file
+{% extends "base_struct_function.h.jinja2" %} \ No newline at end of file
diff --git a/generator/templates/structs/template.m b/generator/templates/structs/template.m.jinja2
index 0d4c1b760..488b076af 100644
--- a/generator/templates/structs/template.m
+++ b/generator/templates/structs/template.m.jinja2
@@ -1,5 +1,5 @@
{#- This template creates RPC struct .m files -#}
-{% extends "base_struct_function.m" %}
+{% extends "base_struct_function.m.jinja2" %}
{% block imports %}
{{super()}}
#import "SDLRPCParameterNames.h"
diff --git a/generator/transformers/common_producer.py b/generator/transformers/common_producer.py
index 987ed5934..ac7bc6167 100644
--- a/generator/transformers/common_producer.py
+++ b/generator/transformers/common_producer.py
@@ -172,7 +172,7 @@ class InterfaceProducerCommon(ABC):
return ''
return 'nullable '
- def wrap(self, item):
+ def parentheses(self, item):
"""
Used for wrapping appropriate initiator (constructor) parameter with '@({})'
:param item: named tup[le with initiator (constructor) parameter
@@ -196,15 +196,14 @@ class InterfaceProducerCommon(ABC):
init = ['{}:({}{}){}'.format(self.title(first.constructor_prefix),
self.nullable(first.type_native, mandatory),
first.type_native.strip(), first.constructor_argument)]
- arguments = [self.argument_named(origin=first.origin, constructor_argument=self.wrap(first),
+ arguments = [self.argument_named(origin=first.origin, constructor_argument=self.parentheses(first),
variable=first.constructor_argument, deprecated=first.deprecated)]
for param in data:
- arguments.append(self.argument_named(origin=param.origin, constructor_argument=self.wrap(param),
+ arguments.append(self.argument_named(origin=param.origin, constructor_argument=self.parentheses(param),
variable=param.constructor_argument, deprecated=param.deprecated))
- init_str = '{}:({}{}){}'.format(self.minimize_first(param.constructor_prefix),
- self.nullable(param.type_native, mandatory),
- param.type_native.strip(), param.constructor_argument)
- init.append(init_str)
+ init.append('{}:({}{}){}'.format(self.minimize_first(param.constructor_prefix),
+ self.nullable(param.type_native, mandatory),
+ param.type_native.strip(), param.constructor_argument))
_self = True if 'functions' in self.__class__.__name__.lower() and mandatory else ''
return {'init': ' '.join(init), 'self': _self, 'arguments': arguments, 'all': arguments}
@@ -308,7 +307,7 @@ class InterfaceProducerCommon(ABC):
else:
data = self.evaluate_type(param.param_type)
- if not param.is_mandatory and re.match(r'\w*Int\d*', data['type_native']):
+ if not param.is_mandatory and re.match(r'\w*Int\d*|BOOL', data['type_native']):
data['type_native'] = data['type_sdl']
return data