Proto Games

0 views
Skip to first unread message

Chieko Boteler

unread,
Aug 5, 2024, 2:35:11 AM8/5/24
to hhonhandsikkee
Ourhelpful design aid demonstrates part features that are too thin or too thick, bad bosses, right and wrong ribs, and other considerations to be mindful of while designing parts for injection molding.

Want quality parts and additive expertise at a single 3D printing source? Choose from seven different additive manufacturing technologies for cost-effective prototyping and highly precise, repeatable production parts.


We offer both automated and live manufacturing support. With every quote, you get free interactive manufacturability analysis to quickly improve part design, but if you have additional questions, applications engineers are always available to talk through your project at 877-479-3680 or [email protected].


By signing up you agree to receive emails from PROTO with news, special offers, promotions and other information. You can unsubscribe at any time. See our Privacy Policy or contact us by emailing us at orders...@sbdinc.com or sending mail to 400 Executive Blvd S, Southington, CT 06489 for more information.


This guide describes how to use the protocol buffer language to structure yourprotocol buffer data, including .proto file syntax and how to generate dataaccess classes from your .proto files. It covers the proto3 version of theprotocol buffers language: for information on the proto2 syntax, see theProto2 Language Guide.


In the earlier example, all the fields are scalar types: two integers(page_number and results_per_page) and a string (query). You can alsospecify enumerations and composite types like other message types foryour field.


You should use the field numbers 1 through 15 for the most-frequently-setfields. Lower field number values take less space in the wire format. Forexample, field numbers in the range 1 through 15 take one byte to encode. Fieldnumbers in the range 16 through 2047 take two bytes. You can find out more aboutthis inProtocol Buffer Encoding.


When you no longer need a field and all references have been deleted from clientcode, you may delete the field definition from the message. However, youmust reserve the deleted field number. If you do notreserve the field number, it is possible for a developer to reuse that number inthe future.


Reusing an old field name later is generally safe, except when using TextProtoor JSON encodings where the field name is serialized. To avoid this risk, youcan add the deleted field name to the reserved list.


Reserved names affect only the protoc compiler behavior and not runtimebehavior, with one exception: TextProto implementations may discard unknownfields (without raising an error like with other unknown fields) with reservednames at parse time (only the C++ and Go implementations do so today). RuntimeJSON parsing is not affected by reserved names.


[4] 64-bit or unsigned 32-bit integers are always represented as longwhen decoded, but can be an int if an int is given when setting the field. Inall cases, the value must fit in the type represented when set. See [2].


When a message is parsed, if the encoded message does not contain a particularimplicit presence element, accessing the corresponding field in the parsedobject returns the default value for that field. These defaults aretype-specific:


You can define aliases by assigning the same value to different enum constants.To do this you need to set the allow_alias option to true. Otherwise, theprotocol buffer compiler generates a warning message when aliases arefound. Though all alias values are valid during deserialization, the first valueis always used when serializing.


During deserialization, unrecognized enum values will be preserved in themessage, though how this is represented when the message is deserialized islanguage-dependent. In languages that support open enum types with valuesoutside the range of specified symbols, such as C++ and Go, the unknown enumvalue is simply stored as its underlying integer representation. In languageswith closed enum types such as Java, a case in the enum is used to represent anunrecognized value, and the underlying integer can be accessed with specialaccessors. In either case, if the message is serialized the unrecognized valuewill still be serialized with the message.


By default, you can use definitions only from directly imported .proto files.However, sometimes you may need to move a .proto file to a new location.Instead of moving the .proto file directly and updating all the call sites ina single change, you can put a placeholder .proto file in the old location toforward all the imports to the new location using the import public notion.


The protocol compiler searches for imported files in a set of directoriesspecified on the protocol compiler command line using the -I/--proto_pathflag. If no flag was given, it looks in the directory in which the compiler wasinvoked. In general you should set the --proto_path flag to the root of yourproject and use fully qualified names for all imports.


Unknown fields are well-formed protocol buffer serialized data representingfields that the parser does not recognize. For example, when an old binaryparses data sent by a new binary with new fields, those new fields becomeunknown fields in the old binary.


TextFormat is a bit of a special case. Serializing to TextFormat prints unknownfields using their field numbers. But parsing TextFormat data back into a binaryproto fails if there are entries that use field numbers.


Oneof fields are like regular fields except all the fields in a oneof sharememory, and at most one field can be set at the same time. Setting any member ofthe oneof automatically clears all the other members. You can check which valuein a oneof is set (if any) using a special case() or WhichOneof() method,depending on your chosen language.


You then add your oneof fields to the oneof definition. You can add fields ofany type, except map fields and repeated fields. If you need to add arepeated field to a oneof, you can use a message containing the repeated field.


In your generated code, oneof fields have the same getters and setters asregular fields. You also get a special method for checking which value (if any)in the oneof is set. You can find out more about the oneof API for your chosenlanguage in the relevant API reference.


…where the key_type can be any integral or string type (so, anyscalar type except for floating point types and bytes). Note thatneither enum nor proto messages are valid for key_type.The value_type can be any type except another map.


Note that even when the package directive does not directly affect thegenerated code, for example in Python, it is still strongly recommended tospecify the package for the .proto file, as otherwise it may lead to namingconflicts in descriptors and make the proto not portable for other languages.


The protocol buffer compiler resolves all type names by parsing the imported.proto files. The code generator for each language knows how to refer to eachtype in that language, even if it has different scoping rules.


If you want to use your message types with an RPC (Remote Procedure Call)system, you can define an RPC service interface in a .proto file and theprotocol buffer compiler will generate service interface code and stubs in yourchosen language. So, for example, if you want to define an RPC service with amethod that takes your SearchRequest and returns a SearchResponse, you candefine it in your .proto file as follows:


The most straightforward RPC system to use with protocol buffers isgRPC: a language- and platform-neutral open source RPC systemdeveloped at Google. gRPC works particularly well with protocol buffers and letsyou generate the relevant RPC code directly from your .proto files using aspecial protocol buffer compiler plugin.


A proto3 field that is defined with the optional keyword supports fieldpresence. Fields that have a value set and that support field presence alwaysinclude the field value in the JSON-encoded output, even if it is the defaultvalue.


Individual declarations in a .proto file can be annotated with a number ofoptions. Options do not change the overall meaning of a declaration, but mayaffect the way it is handled in a particular context. The complete list ofavailable options is defined in /google/protobuf/descriptor.proto.


Some options are file-level options, meaning they should be written at thetop-level scope, not inside any message, enum, or service definition. Someoptions are message-level options, meaning they should be written inside messagedefinitions. Some options are field-level options, meaning they should bewritten inside field definitions. Options can also be written on enum types,enum values, oneof fields, service types, and service methods; however, nouseful options currently exist for any of these.


java_outer_classname (file option): The class name (and hence the filename) for the wrapper Java class you want to generate. If no explicitjava_outer_classname is specified in the .proto file, the class namewill be constructed by converting the .proto file name to camel-case (sofoo_bar.proto becomes FooBar.java). If the java_multiple_files optionis disabled, then all other classes/enums/etc. generated for the .protofile will be generated within this outer wrapper Java class as nestedclasses/enums/etc. If not generating Java code, this option has no effect.


objc_class_prefix (file option): Sets the Objective-C class prefix whichis prepended to all Objective-C generated classes and enums from this.proto. There is no default. You should use prefixes that are between 3-5uppercase characters asrecommended by Apple.Note that all 2 letter prefixes are reserved by Apple.


packed (field option): Defaults to true on a repeated field of a basicnumeric type, causing a more compactencoding to beused. There is no downside to using this option, but it can be set tofalse. Note that prior to version 2.3.0, parsers that received packed datawhen not expected would ignore it. Therefore, it was not possible to changean existing field to packed format without breaking wire compatibility. In2.3.0 and later, this change is safe, as parsers for packable fields willalways accept both formats, but be careful if you have to deal with oldprograms using old protobuf versions.

3a8082e126
Reply all
Reply to author
Forward
0 new messages