Giter VIP home page Giter VIP logo

go-capnproto's People

Contributors

alberts avatar darabos avatar glycerine avatar jmckaskill avatar peterwald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-capnproto's Issues

Decompressor bug?

    switch b[0] {
    case 0xFF:
        io.ReadFull(c.r, c.buf[:])
    case 0x00:

I think you need to read a byte and set c.raw after io.ReadFull. :-)

setting a value to a List(struct)

Not sure if this would be better on the main Cap'n Proto discussion, but I'll try here. How does one set a pointer in a list? I have a struct that looks like:

struct Map {
        map @0 :List(Item);
        struct Item {
                name @0 :Text;
                value :union {
                        int @1 :Int32;
                        string @2 :Text;
                        map @3 :Map;
                }
        }
}

I can create a Map. Then I create a MapItemList with the segment from the Map and the length that I want, and I set the MapItemList to the Map using SetMap(). I then use that segment to start creating MapItems, but I don't know how to set the pointers to my newly created MapItem's to their indexes in the MapItemList. If I print out the resulting bytes, I can see the data is there, but I can't get the data out of the list using the provided read functions, likely because I am not setting pointers to the data in the list. Here is the function I'm messing around with:

func WriteMap(mm map[string]interface{}) bytes.Buffer {
        ns := capn.NewBuffer(nil)
        m := NewRootMap(ns)
        mil := NewMapItemList(ns, len(mm))
        m.SetMap(mil)
        counter := 0
        for k, v := range mm {
                mi := NewMapItem(ns)
                mi.SetName(k)
                switch v.(type) {
                case string:
                        mi.Value().SetString(v.(string))
                case int:
                        mi.Value().SetInt(int32(v.(int)))
                default:
                        panic("OH SNAP")
                }
                counter++
        }
        buf := bytes.Buffer{}
        ns.WriteTo(&buf)
        return buf
}

Anyone see what I'm doing wrong? Or how I can do this?

JSON encoding should handle unions

Unions are only handled for struct union members. We should fix it so it handles all cases and also switch to using a switch statement.

List(List(struct)) Appears to be broken.

I'm using a List(List(Signature)) where

struct Signature {                                                              
    key @0: Data;                                                               
    signature @1: Data;                                                         
}  

and the generated code cannot compile

capnp compile -ogo src/libnode/message.capnp
go install libnode
# libnode
src/libnode/message.capnp.go:1033: cannot range over s.ToArray() (type *[]capn.Object)
Makefile:21: recipe for target 'pkg/linux_amd64/libnode.a' failed

Creating Union API

I'm not sure if I'm missing something here but the union API seems to have changed since the documentation was written. Specifically the lines

f.SetA()         // Set that we are using group A
f.A().SetV(true) // then we can use the group A getter to set the inner values

http://godoc.org/github.com/jmckaskill/go-capnproto#hdr-Unions

Instead it seems to generate the following which can make the api harder to use

a := NewA((*C.Segment)s)
f.SetA(a A)
a.SetV(true)

Would it be worth generating a NewA() & NewB() on the containing Foo struct given it already has a reference to the segment and by definition they would never be a RootStruct.

avoid using import go.capnp

Is that possible to automatic prepend contents of go.capnp when generating go files?
As i see i need to have this file in all my projects and update when new version comes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.