Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field Accessors Bug ( I think)! #25

Open
laithsakka opened this issue Apr 10, 2018 · 1 comment
Open

Field Accessors Bug ( I think)! #25

laithsakka opened this issue Apr 10, 2018 · 1 comment

Comments

@laithsakka
Copy link

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;
@eqvinox
Copy link

eqvinox commented Apr 12, 2018

Hrm, yes, the problem seems to be that TreeNode_set_leaf sets up an unresolved pointer and TreeNode_get_leaf doesn't resolve it (3rd argument to capn_getp is 0...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants