diff --git a/resources/tag.yml b/resources/tag.yml index 980355d..4d75f70 100644 --- a/resources/tag.yml +++ b/resources/tag.yml @@ -1,17 +1,25 @@ %YAML 1.2 %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_bool : !vala!bool false - type_char : !vala!char c - type_string : !vala!string mystring1 + type_int : !v!int 3306 + type_bool : !v!bool false + type_char : !v!char c + 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_bool : !vala!bool true - type_char : !vala!char g - type_string : !vala!string mystring2 + type_int : !v!int 3306 + type_bool : !v!bool true + type_char : !v!char g + 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 diff --git a/samples/yaml-tag.vala b/samples/yaml-tag.vala index c3ea197..0f82755 100644 --- a/samples/yaml-tag.vala +++ b/samples/yaml-tag.vala @@ -65,10 +65,13 @@ int main (string[] args) 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); if ((o = entry.value as Yaml.Example)!=null) { - of.keyval("type_int" , "%d".printf(o.type_int)); - of.keyval("type_bool" , "%s".printf(o.type_bool.to_string ())); - of.keyval("type_char" , "%c".printf(o.type_char)); - of.keyval("type_string", "%s".printf(o.type_string)); + of.keyval("type_int" , "%d" .printf(o.type_int)); + of.keyval("type_bool" , "%s" .printf(o.type_bool.to_string ())); + of.keyval("type_char" , "%c" .printf(o.type_char)); + 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)); } } diff --git a/src/c/yaml.c b/src/c/yaml.c index b023606..e8dd2e1 100644 --- a/src/c/yaml.c +++ b/src/c/yaml.c @@ -101,7 +101,6 @@ void yaml_parse_file(const char *srcPath, const char *destPath) break; 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); break; diff --git a/src/vala/Pluie/Yaml.Object.vala b/src/vala/Pluie/Yaml.Object.vala index 909ce30..0819796 100644 --- a/src/vala/Pluie/Yaml.Object.vala +++ b/src/vala/Pluie/Yaml.Object.vala @@ -141,7 +141,7 @@ public abstract class Pluie.Yaml.Object : GLib.Object if ((def = obj.get_class ().find_property (child.name)) != null) { if ((snode = child.first ()) != 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 { 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); var data = node.data; @@ -181,12 +181,32 @@ public abstract class Pluie.Yaml.Object : GLib.Object case Type.CHAR : v.set_schar((int8)data.data[0]); break; + case Type.UCHAR : + v.set_uchar((uint8)data.data[0]); + break; case Type.BOOLEAN : v.set_boolean (bool.parse(data.down ())); break; case Type.INT : v.set_int(int.parse(data)); 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); }