Giter Club home page Giter Club logo

zproto's Introduction

zproto

A simple protocol buffer for lua

Description

  • Struct consist of members, the type of which can be basic type or other struct type

  • Basic type can be 'boolean' or 'integer' or 'long' or 'string'

  • All comment line begin with '#'

  • All struct or field name begin with 'a-zA-Z'

  • All field name must be defined after the character '.'

  • Struct or field name and field tag must be unique in it's scope

  • Field tag must large then 0 and defined by ASC

  • When the suffix of type(include struct and basic type) is [], it means this field is array

  • Struct can be defined as follows:

      #only the struct which has no parent can specify the protocol
      #protocol is aka struct name when it's explicitly specified
      #protocol is option and default value is '0'
      #protocol value can be queryed by zproto:[email protected]
      name [protocol] {
      	.name:type 1
      	...
      }
    
  • A sample protocol define may like this:

      #comments line
      info {
      	.name:string 1
      	.age:integer 2
      	.girl:boolean 3
      }
      packet 0xfe {
      	phone {
      		.home:integer 1
      		.work:long 2
      	}
      	.phone:phone 1
      	.info:info[] 2
      	.address:string 3
      	.luck:integer[] 4
      }
    

##luabind

This code is a simply lua binding of zproto in luabind folder

It provide a simple test code and you can run it as follow:

  • Download lua-5.3 or later and extract into luabind/lua53
  • Execute 'make linux' or 'make macosx' to build zproto.so
  • Execute './test' to run the test code

##cppbind and csbind

This code is a simply [C++|C#] binding of zproto in [cppbind|csbind] folder

It also provide a simple test code and you can run it as follow:

  • Execute 'make' to build a executable file named 'zproto', 'zproto' used to generate [C++|C#] bind code from a file defined as zproto syntax
  • Execute './zproto test.zproto' to generate [C++|C#] bind code for test.zproto
  • Execute 'make test' to build a test program
  • Execute './test' to run the test code.

zproto's People

Contributors

findstr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.