/Protocol/generator/typedef.lua

http://awoe.googlecode.com/ · Lua · 53 lines · 43 code · 10 blank · 0 comment · 1 complexity · 26c2b53cb933931cdf8829f8cd9e155e MD5 · raw file

  1. local old_path = package.path
  2. package.path = ";..\\..\\Generator\\lua\\?.lua" .. package.path
  3. require 'codeengine'
  4. package.path = old_path
  5. typedef_cpp =
  6. {
  7. int8 = "char",
  8. uint8 = "unsigned char",
  9. int16 = "short",
  10. uint16 = "unsigned short",
  11. int32 = "int",
  12. uint32 = "unsigned int",
  13. int64 = "__int64",
  14. uint64 = "unsigned __int64",
  15. string = "string",
  16. }
  17. typedef_java =
  18. {
  19. int8 = "byte",
  20. uint8 = "byte",
  21. int16 = "short",
  22. uint16 = "short",
  23. int32 = "int",
  24. uint32 = "int",
  25. int64 = "long",
  26. uint64 = "long",
  27. string = "String",
  28. }
  29. function use_cpp_types()
  30. typedef = typedef_cpp
  31. end
  32. function use_java_types()
  33. typedef = typedef_java
  34. end
  35. function types(vtype)
  36. return typedef[vtype] or vtype
  37. end
  38. function is_simple_type(vtype)
  39. return typedef[vtype]
  40. end
  41. vname = function(name)
  42. return name
  43. end