~monkey-libre/valide/vala-0.11.6

« back to all changes in this revision

Viewing changes to libvalide/libyaml-glib/src/builder.vala

  • Committer: Nicolas Joseph
  • Date: 2011-02-09 14:14:10 UTC
  • Revision ID: nicolas.joseph@valaide.org-20110209141410-65ntyu17ig6s5dva
Fix the fix r588

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
                                }
285
285
                                ParamSpec pspec = ((ObjectClass)obj.get_type().class_peek()).find_property(key);
286
286
                                if(pspec != null) {
287
 
                                        if(0 == (Buildable.get_property_hint_pspec(pspec)
288
 
                                                & Buildable.PropertyHint.SKIP)) {
 
287
                                        if(0 != Buildable.get_property_hint_pspec(pspec)
 
288
                                                & Buildable.PropertyHint.SKIP) {
 
289
                                                throw new GLib.YAML.Exception.BUILDER(
 
290
                                                "%s: trying to assign a skipped property: %s",
 
291
                                                node.get_location(),
 
292
                                                pspec.name);
 
293
                                        } else {
289
294
                                                process_property(obj, pspec, value_node);
290
295
                                        }
291
296
                                } else {
404
409
                                } else
405
410
                                        e = evalue.value;
406
411
                                gvalue.set_enum(e);
 
412
                        } else
 
413
                        if(pspec.value_type.is_a(Type.FLAGS)) {
 
414
                                weak string expression = cast_to_scalar(node);
 
415
                                FlagsClass klass = (FlagsClass) pspec.value_type.class_ref();
 
416
                                string[] names = expression.split("|");
 
417
                                uint flags = 0; /* flag is 0 */
 
418
                                foreach(weak string name in names) {
 
419
                                        uint f = 0;
 
420
                                        name._strip();
 
421
                                        if(name == "~") continue; /* null = 0 */
 
422
                                        /* try the full name first */
 
423
                                        unowned FlagsValue v = klass.get_value_by_name(name);
 
424
                                        if(v == null) {
 
425
                                        /* try the nick next */
 
426
                                        /* flags nicks are lowercase in vala, try the nick*/
 
427
                                                v = klass.get_value_by_nick(name.down());
 
428
                                        }
 
429
                                        if(v == null) {
 
430
                                                /* try if his is a raw number */
 
431
                                                weak string endptr = null;
 
432
                                                f = (uint) name.to_int64(out endptr, 0);
 
433
                                                if((void*)endptr == (void*)name) {
 
434
                                                        /* not actually an integer either */
 
435
                                                        throw new GLib.YAML.Exception.BUILDER (
 
436
                                                        "%s flag value `%s' is illegal",
 
437
                                                                node.get_location(),
 
438
                                                                name);
 
439
                                                }
 
440
                                        } else {
 
441
                                                f = v.value;
 
442
                                        }
 
443
                                        flags |= f;
 
444
                                }
 
445
                                gvalue.set_flags(flags);
407
446
                        }
408
447
                        else {
409
448
                                throw new GLib.YAML.Exception.UNIMPLEMENTED (