Code Monkey home page Code Monkey logo

Comments (2)

chwarr avatar chwarr commented on August 15, 2024 1

BT_STOP_BASE is used to delimit where a base class ends when inheritance is used.

The following Bond

struct Foo
{
    0: string foo_string;
}

struct Bar : Foo
{
    0: string bar_string;
}

gets turned into C# that looks roughly like this:

class Foo
{
    public string foo_string { get; set; }
}

class Bar : Foo
{
    public string bar_string { get; set; }
}

Say you serialize one of these to Compact Binary v1:

var obj = new Bar { foo_string = "foo", bar_string = "bar" };

var output = new OutputBuffer();
var writer = new CompactBinaryWriter<OutputBuffer>(output);
Serialize.To(writer, src);

The Compact Binary payload would be, in pseudo payload:

  1. BT_STRING { id: 0, length: 3 }
  2. foo
  3. BT_STOP_BASE
  4. BT_STRING { id: 0, length: 3 }
  5. bar
  6. BT_STOP

If you added another layer, struct Baz : Bar { 0: string baz_string; }, there would be two BT_STOP_BASE tokens, one after the Foo and one after the Bar:

  1. BT_STRING { id: 0, length: 3 }
  2. foo
  3. BT_STOP_BASE
  4. BT_STRING { id: 0, length: 3 }
  5. bar
  6. BT_STOP_BASE
  7. BT_STRING { id: 0, length: 3 }
  8. baz
  9. BT_STOP

from bond.

dend avatar dend commented on August 15, 2024

@chwarr amazing - this works really well, thank you for a very thorough and concrete explanation!

from bond.

Related Issues (20)

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.