suite tag impl
This commit is contained in:
parent
3de39868e6
commit
6c1e4d0251
|
@ -1,17 +1,25 @@
|
||||||
%YAML 1.2
|
%YAML 1.2
|
||||||
%TAG !yaml! tag:yaml.org,2002:
|
%TAG !yaml! tag:yaml.org,2002:
|
||||||
%TAG !vala! tag:pluie.org,2018:vala/
|
%TAG !v! tag:pluie.org,2018:vala/
|
||||||
---
|
---
|
||||||
!vala!Pluie.Yaml.Example test1 :
|
!v!Pluie.Yaml.Example test1 :
|
||||||
|
|
||||||
type_int : !vala!int 3306
|
type_int : !v!int 3306
|
||||||
type_bool : !vala!bool false
|
type_bool : !v!bool false
|
||||||
type_char : !vala!char c
|
type_char : !v!char c
|
||||||
type_string : !vala!string mystring1
|
type_string : !v!string mystring1
|
||||||
|
type_uchar : !v!uchar L
|
||||||
|
type_uint : !v!uint 62005
|
||||||
|
type_float : !v!float 42.36
|
||||||
|
type_double : !v!double 95542123.4579512128
|
||||||
|
|
||||||
!vala!Pluie.Yaml.Example test2 :
|
!v!Pluie.Yaml.Example test2 :
|
||||||
|
|
||||||
type_int : !vala!int 3306
|
type_int : !v!int 3306
|
||||||
type_bool : !vala!bool true
|
type_bool : !v!bool true
|
||||||
type_char : !vala!char g
|
type_char : !v!char g
|
||||||
type_string : !vala!string mystring2
|
type_string : !v!string mystring2
|
||||||
|
type_uchar : !v!uchar Y
|
||||||
|
type_uint : !v!uint 63005
|
||||||
|
type_float : !v!float 5.28
|
||||||
|
type_double : !v!double 9.28
|
||||||
|
|
|
@ -65,10 +65,13 @@ int main (string[] args)
|
||||||
foreach (var entry in list.entries) {
|
foreach (var entry in list.entries) {
|
||||||
of.action ("Getting Hard coded values for Yaml.Object %s".printf (of.c (ECHO.MICROTIME).s (o.type_from_self ())), entry.key);
|
of.action ("Getting Hard coded values for Yaml.Object %s".printf (of.c (ECHO.MICROTIME).s (o.type_from_self ())), entry.key);
|
||||||
if ((o = entry.value as Yaml.Example)!=null) {
|
if ((o = entry.value as Yaml.Example)!=null) {
|
||||||
of.keyval("type_int" , "%d".printf(o.type_int));
|
of.keyval("type_int" , "%d" .printf(o.type_int));
|
||||||
of.keyval("type_bool" , "%s".printf(o.type_bool.to_string ()));
|
of.keyval("type_bool" , "%s" .printf(o.type_bool.to_string ()));
|
||||||
of.keyval("type_char" , "%c".printf(o.type_char));
|
of.keyval("type_char" , "%c" .printf(o.type_char));
|
||||||
of.keyval("type_string", "%s".printf(o.type_string));
|
of.keyval("type_string", "%s" .printf(o.type_string));
|
||||||
|
of.keyval("type_uchar" , "%u" .printf(o.type_uchar));
|
||||||
|
of.keyval("type_float" , "%f" .printf(o.type_float));
|
||||||
|
of.keyval("type_double", "%f" .printf(o.type_double));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,6 @@ void yaml_parse_file(const char *srcPath, const char *destPath)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case YAML_TAG_DIRECTIVE_TOKEN :
|
case YAML_TAG_DIRECTIVE_TOKEN :
|
||||||
printf ("YAML_TAG_DIRECTIVE_TOKEN : handle : %s, prefix : %s\n", token.data.tag_directive.handle, token.data.tag_directive.prefix);
|
|
||||||
fprintf(wh, "%lu, %d, \"%s\", \"%s\"\n", line, token.type, token.data.tag_directive.handle, token.data.tag_directive.prefix);
|
fprintf(wh, "%lu, %d, \"%s\", \"%s\"\n", line, token.type, token.data.tag_directive.handle, token.data.tag_directive.prefix);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ public abstract class Pluie.Yaml.Object : GLib.Object
|
||||||
if ((def = obj.get_class ().find_property (child.name)) != null) {
|
if ((def = obj.get_class ().find_property (child.name)) != null) {
|
||||||
if ((snode = child.first ()) != null) {
|
if ((snode = child.first ()) != null) {
|
||||||
if (snode.tag != null) {
|
if (snode.tag != null) {
|
||||||
obj.set_by_basic_type (def.name, def.value_type, snode);
|
obj.set_from_scalar (def.name, def.value_type, snode);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj.set (child.name, snode.data);
|
obj.set (child.name, snode.data);
|
||||||
|
@ -165,7 +165,7 @@ public abstract class Pluie.Yaml.Object : GLib.Object
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void set_by_basic_type (string name, GLib.Type type, Yaml.Node node)
|
public void set_from_scalar (string name, GLib.Type type, Yaml.Node node)
|
||||||
{
|
{
|
||||||
GLib.Value v = GLib.Value(type);
|
GLib.Value v = GLib.Value(type);
|
||||||
var data = node.data;
|
var data = node.data;
|
||||||
|
@ -181,12 +181,32 @@ public abstract class Pluie.Yaml.Object : GLib.Object
|
||||||
case Type.CHAR :
|
case Type.CHAR :
|
||||||
v.set_schar((int8)data.data[0]);
|
v.set_schar((int8)data.data[0]);
|
||||||
break;
|
break;
|
||||||
|
case Type.UCHAR :
|
||||||
|
v.set_uchar((uint8)data.data[0]);
|
||||||
|
break;
|
||||||
case Type.BOOLEAN :
|
case Type.BOOLEAN :
|
||||||
v.set_boolean (bool.parse(data.down ()));
|
v.set_boolean (bool.parse(data.down ()));
|
||||||
break;
|
break;
|
||||||
case Type.INT :
|
case Type.INT :
|
||||||
v.set_int(int.parse(data));
|
v.set_int(int.parse(data));
|
||||||
break;
|
break;
|
||||||
|
case Type.UINT :
|
||||||
|
v.set_uint((uint)long.parse(data));
|
||||||
|
break;
|
||||||
|
case Type.LONG :
|
||||||
|
case Type.INT64 :
|
||||||
|
v.set_long((long)int64.parse(data));
|
||||||
|
break;
|
||||||
|
case Type.ULONG :
|
||||||
|
case Type.UINT64 :
|
||||||
|
v.set_ulong((ulong)uint64.parse(data));
|
||||||
|
break;
|
||||||
|
case Type.FLOAT :
|
||||||
|
v.set_float((float)double.parse(data));
|
||||||
|
break;
|
||||||
|
case Type.DOUBLE :
|
||||||
|
v.set_double(double.parse(data));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.set_property(name, v);
|
this.set_property(name, v);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user