Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
|
da88e6b8db | |
|
1ae22cb86d | |
|
1fe32aecb3 | |
|
5cca57b440 | |
|
32bfa591d7 |
|
@ -1,5 +1,12 @@
|
|||
## v6.1.0
|
||||
- Removed redundant accessor interface declarations in generated slices
|
||||
|
||||
## v5.0.0
|
||||
- Splitting one huge codegenerated file into multiple ones
|
||||
|
||||
## v4.10.0
|
||||
- Added @flt_i18n token to support translations
|
||||
|
||||
## v4.9.2
|
||||
- Added @cs_obsolete token, that mark fields with [Obsolete]. @cs_obsolete:"Comment" will add summary with "Comment" to field
|
||||
|
||||
|
|
|
@ -2,9 +2,10 @@ This package is used for code generation of C# meta structs using Twig templates
|
|||
|
||||
Usage example:
|
||||
|
||||
$code = \metagen_cs\codegen(null, get_meta(),
|
||||
$output = \metagen_cs\codegen(null, get_meta(),
|
||||
[
|
||||
'namespace' => 'BitGames.Autogen'
|
||||
]);
|
||||
file_put_contents('bundle.cs', $code);
|
||||
foreach($output as $name => $text)
|
||||
file_put_contents($name, $text);
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ function cs_simple_type(\mtgType $type)
|
|||
case "bool":
|
||||
return "bool";
|
||||
case "blob":
|
||||
return "byte[]";
|
||||
return "ArraySegment<byte>";
|
||||
}
|
||||
throw new Exception("Unknown type '{$type}'");
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
$str .= " = ".trim($default, '"').";";
|
||||
}
|
||||
else
|
||||
$str .= ' = null;';
|
||||
$str .= ' = default;';
|
||||
}
|
||||
else
|
||||
throw new Exception("Unknown type '$type'");
|
||||
|
@ -419,16 +419,16 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
|
||||
if($default)
|
||||
{
|
||||
$default = is_array($default) ? $default : json_decode($default, true);
|
||||
if(is_array($default))
|
||||
$default_val = is_array($default) ? $default : json_decode($default, true);
|
||||
if(is_array($default_val))
|
||||
{
|
||||
foreach($default as $k => $v)
|
||||
foreach($default_val as $k => $v)
|
||||
{
|
||||
$kf = $type->getField($k);
|
||||
$str .= var_reset("$name." . $kf->getName(), $kf->getType(), $v);
|
||||
}
|
||||
}
|
||||
else if($default === null)
|
||||
else if(is_null_str($default))
|
||||
$str .= "$name = null; ";
|
||||
else
|
||||
throw new Exception("Bad default value for struct: " . var_export($default, true));
|
||||
|
@ -441,7 +441,7 @@ function var_reset($name, \mtgType $type, $default = null)
|
|||
|
||||
function is_null_str($default)
|
||||
{
|
||||
return is_string($default) && json_decode($default, true) === null;
|
||||
return is_string($default) && strtolower($default) === 'null';
|
||||
}
|
||||
|
||||
function var_sync($fname, \mtgType $type, $buf, array $tokens, $opts)
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
{%- endif ~%}
|
||||
{%- endfor ~%}
|
||||
|
||||
{%- for ai in get_all_declarable_accessor_interfaces(meta) ~%}
|
||||
{{ _self.decl_accessor_interface(ai) }}
|
||||
{%- endfor ~%}
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
{% macro decl_struct(o, extra = '') %}
|
||||
|
|
Loading…
Reference in New Issue