Skip to content

Field Accessors Bug ( I think)! #25

@laithsakka

Description

@laithsakka

Hi ,
I was trying to use the plugin and I encountered what I think is a bug, please let me know if my understanding is wrong about how the generated API works.
The schema definitions that I used is the following:

struct Leaf{
        value @0 : Int32;
}
struct Inner {
        left @0  :TreeNode;
        right @1 : TreeNode;
}
struct TreeNode {
  nodeType @0 :Int32;
  leaf  @1 : Leaf;
  inner @2 :Inner;

}

For the following code I expect 1 to be printed but 0 is printed instead ;It looks like there is something wrong in the method Tree_Node_set_leaf(...) unless I misunderstand how it should work!

   struct capn c;
   struct capn_segment *cs;
   capn_ptr cr;
        
    capn_init_malloc(&c);
    cr = capn_root(&c);
    cs = cr.seg;

   TreeNode_ptr n = new_TreeNode(cs);
   TreeNode_set_nodeType(n, 1);
   Leaf_ptr l = new_Leaf(cs);
   Leaf_set_value(l , 1);
   TreeNode_set_leaf(n, l);
    cout<<Leaf_get_value(TreeNode_get_leaf(n))<<endl;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions