Skip to content

Instantly share code, notes, and snippets.

@hintjens
Created January 1, 2015 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hintjens/219e9ded8f865713f09d to your computer and use it in GitHub Desktop.
Save hintjens/219e9ded8f865713f09d to your computer and use it in GitHub Desktop.
if !defined (my.field.type)
echo "field
endif
if type = "number"
elsif type = "string"
elsif type = "longstr"
elsif type = "chunk" | type = "frame" | type = "msg" | type = "list" | type = "hash"
elsif type = "msg"
if type = "number"
field.size ?= 1
if size = 1
field.ctype = "byte"
elsif size = 2
field.ctype = "uint16_t"
elsif size = 4
field.ctype = "uint32_t"
elsif size = 8
field.ctype = "uint64_t"
else
echo "E: bad size $(size) for $(name)"
endif
endif
property.name = "$(my.name:c)"
property.type = my.type
property.alloc = my.alloc
if type = "string"
property.ctype = "const char *"
elsif type = "number"
property.ctype = "int "
elsif type = "msg"
property.ctype = "zmsg_t *"
endif
endnew
if field.type = "string"
reply.pattern += "s"
elsif field.type = "number"
reply.pattern += "i"
else
method.args += ", const char *$(name)"
if type = "number"
method.args += ", int $(name)"
field.ctype = "int "
pattern += size
elsif type = "string"
method.args += ", const char *$(name)"
field.ctype = "const char *"
pattern += "s"
elsif type = "longstr"
method.args += ", const char *$(name)"
field.ctype = "const char *"
pattern += "S"
elsif type = "chunk" | type = "frame" | type = "msg" | type = "list" | type = "hash"
method.args += ", z$(type)_t **$(name)_p"
field.ctype = "z$(type)_t *"
pattern += "p"
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment