Objects#

This page covers the objects a client holds for the instances of a server’s classes. An object is encoded as its id, as described under Protocol Buffers Encoding.

Equality#

objects-equality [core] [MUST]

Two objects with the same id are equal. Objects with different ids are not, and an object is not equal to null.

objects-hash [core] [MUST]

Equal objects hash equal, in a language that hashes values.

objects-sorting [ordering] [MUST]

Objects order by their ids, compared as unsigned integers. An object orders equal to itself and to another object with its id. Each of the language’s comparison operators agrees with this order.

Object Ids#

objects-get-object-id [core] [MUST]

The client’s object id helper returns the id of an object, and raises the argument error for null.

objects-object-id-range [core] [MUST]

An object holds any uint64 id, including 0, which the server never issues.

objects-unknown-object-id [core] [MUST]

The client sends the id of an object as it is, without checking it. An id the server never issued, including 0, raises the error for KRPC.ArgumentException, as the target of a call or as an argument.

Connections#

objects-method-connection [connections] [MUST]

A method calls over the connection that returned its object, whichever connection runs the call.

objects-static-method-connection [connections] [MUST]

A static method calls over the connection it is called on. Where classes are values, that is the connection of the service the class is reached through. Elsewhere it is the connection passed as the method’s first argument.

objects-bound-static-method-connection [connections, bound-classes] [MUST]

A static method called through its class bound to a connection calls over that connection.

objects-static-method-through-an-object-connection [connections] [MUST]

In a language that calls a static method on an object, a static method called through an object calls over the connection that returned the object.

objects-object-from-another-connection [connections] [MUST]

An object passes to a call on another connection to the same server: as an argument of a procedure, a method or a static method, as the value of a property, and inside a collection or a structure. The call gets the object with its id.

objects-equality-across-connections [connections] [MUST]

Objects with the same id are equal, whichever connections returned them.

objects-hash-across-connections [connections] [MUST]

Objects with the same id hash equal, whichever connections returned them, in a language that hashes values.

Closed Connections#

objects-call-after-close [core] [MUST]

A call through an object after its connection is closed raises the connection error.

Inheritance#

A class names its base class in the base field of its definition. The class also has a procedure for every instance member it inherits, such as Circle_get_Name for the Name property Circle inherits from Shape. A member added to a base class from outside its service has a procedure of the base class alone.

objects-inherited-member [core] [MUST]

An instance member a class inherits is a member of the class. Calling it, or the procedure of the base class, on an instance acts on that instance.

objects-derived-class-argument [core] [MUST]

An instance of a class is accepted where its base class is expected.

objects-equality-as-base-class [core] [MUST]

An object returned as its base class equals the object returned as its own class.

objects-object-of-its-own-class [inheritance] [MUST]

An object returned as its base class is an object of its own class, such as a Circle that EchoShape returns as a Shape. The members of its own class can be called on it.

objects-streamed-object-of-its-own-class [inheritance, streams] [MUST]

An object a stream returns as its base class is an object of its own class.

objects-object-of-the-declared-class [inheritance] [MUST]

An object with no class ids, or with the ids of a class no service defines, is an object of the class it is declared as.

objects-object-of-an-unrelated-class [inheritance] [MUST]

An object with the ids of a class that does not derive from the class it is declared as raises the encoding error, such as an unrelated class or a base of the declared class. A server sends no such object.

objects-object-with-an-unknown-field [core] [MUST]

An Object message with a field the client does not know is decoded without the field, as a later server can add one. The field can have any wire type, and come before or after the id.

objects-object-argument-is-its-id [core] [MUST]

A client sends an object as its id alone, without the class ids the server sent with it.

objects-base-class-in-another-service [core] [MUST]

A class derives from a class of another service. An instance of the class has the members of its base class, and is accepted where its base class is expected.

objects-member-of-a-base-of-a-base-class [core] [MUST]

A class inherits the members of every class above it, such as the Name that Pentagon inherits from Shape through Polygon.

objects-object-of-its-own-class-below-two-bases [inheritance] [MUST]

An object returned as a base of its base class is an object of its own class, such as a Pentagon that EchoShape returns as a Shape.

objects-list-of-objects-of-several-classes [inheritance] [MUST]

Each object in a list holds its own class, such as a Circle, a Triangle and a Pentagon in a list of Shape.

objects-derived-class-argument-from-another-connection [connections] [MUST]

An object of a derived class from another connection is accepted where its base class is expected.

objects-equality-as-base-class-across-connections [connections] [MUST]

An object returned as its base class on another connection equals the object returned as its own class.

objects-inherited-member-procedure [inheritance] [MUST]

A client calls an inherited member through the procedure of the class that declares it, such as Shape_get_Name for the Name of a Circle.

objects-inherited-member-procedure-of-another-service [inheritance] [MUST]

A client calls a member a class inherits from a class of another service through the procedure of the class that declares it, such as TestService.Shape_get_Name for the Name of a ConformanceService.Square.

objects-inherited-member-procedure-below-two-bases [inheritance] [MUST]

A client calls a member a class inherits from a base of its base class through the procedure of the class that declares it, such as Shape_get_Name for the Name of a Pentagon.

objects-extension-member-of-a-base-class [inheritance] [MUST]

A member added to a base class from outside its service is a member of each derived class. Calling it on an object of a derived class calls the procedure of the base class, as the derived class has none.

objects-unknown-base-class [dynamic] [MUST]

A client connects to a server whose definitions name a base class that no service defines. Each member of the class can be called, through the procedures of the class.