Skip to content
  • Eric Blake's avatar
    5c5e51a0
    qapi-visit: Remove redundant functions for flat union base · 5c5e51a0
    Eric Blake authored
    
    
    The code for visiting the base class of a child struct created
    visit_type_Base_fields() which covers all fields of Base; while
    the code for visiting the base class of a flat union created
    visit_type_Union_fields() covering all fields of the base
    except the discriminator.  But since the base class includes
    the discriminator of a flat union, we can just visit the entire
    base, without needing a separate visit of the discriminator.
    Not only is consistently visiting all fields easier to
    understand, it lets us share code.
    
    The generated code in qapi-visit.c loses several now-unused
    visit_type_UNION_fields(), along with changes like:
    
    |@@ -1654,11 +1557,7 @@ void visit_type_BlockdevOptions(Visitor
    |     if (!*obj) {
    |         goto out_obj;
    |     }
    |-    visit_type_BlockdevOptions_fields(v, obj, &err);
    |-    if (err) {
    |-        goto out_obj;
    |-    }
    |-    visit_type_BlockdevDriver(v, &(*obj)->driver, "driver", &err);
    |+    visit_type_BlockdevOptionsBase_fields(v, (BlockdevOptionsBase **)obj, &err);
    |     if (err) {
    |         goto out_obj;
    |     }
    
    and forward declarations where needed.  Note that the cast of obj
    to BASE ** is necessary to call visit_type_BASE_fields() (and we
    can't use our upcast wrappers, because those work on pointers while
    we have a pointer-to-pointer).
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <1445898903-12082-12-git-send-email-eblake@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    5c5e51a0
    qapi-visit: Remove redundant functions for flat union base
    Eric Blake authored
    
    
    The code for visiting the base class of a child struct created
    visit_type_Base_fields() which covers all fields of Base; while
    the code for visiting the base class of a flat union created
    visit_type_Union_fields() covering all fields of the base
    except the discriminator.  But since the base class includes
    the discriminator of a flat union, we can just visit the entire
    base, without needing a separate visit of the discriminator.
    Not only is consistently visiting all fields easier to
    understand, it lets us share code.
    
    The generated code in qapi-visit.c loses several now-unused
    visit_type_UNION_fields(), along with changes like:
    
    |@@ -1654,11 +1557,7 @@ void visit_type_BlockdevOptions(Visitor
    |     if (!*obj) {
    |         goto out_obj;
    |     }
    |-    visit_type_BlockdevOptions_fields(v, obj, &err);
    |-    if (err) {
    |-        goto out_obj;
    |-    }
    |-    visit_type_BlockdevDriver(v, &(*obj)->driver, "driver", &err);
    |+    visit_type_BlockdevOptionsBase_fields(v, (BlockdevOptionsBase **)obj, &err);
    |     if (err) {
    |         goto out_obj;
    |     }
    
    and forward declarations where needed.  Note that the cast of obj
    to BASE ** is necessary to call visit_type_BASE_fields() (and we
    can't use our upcast wrappers, because those work on pointers while
    we have a pointer-to-pointer).
    
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <1445898903-12082-12-git-send-email-eblake@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Loading