Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. import os, strutils
  2.  
  3. import nimterop/[build, cimport]
  4.  
  5. const
  6. baseDir* = getProjectCacheDir("libmongonim")
  7. bsonDir = baseDir / "src" / "libbson" / "src" / "bson"
  8.  
  9. static:
  10. cDebug()
  11. echo baseDir
  12.  
  13. getHeader(
  14. "src" / "libbson" / "src" / "bson" / "bson.h",
  15. giturl = "https://github.com/mongodb/mongo-c-driver",
  16. outdir = baseDir / "build"
  17. )
  18.  
  19. cPlugin:
  20. import regex, strutils
  21.  
  22. proc onSymbol*(sym: var Symbol) {.exportc, dynlib.} =
  23. sym.name = sym.name.replace(re"_[_]+", "_").strip(chars = {'_'})
  24.  
  25. cOverride:
  26. type
  27. INNER_C_STRUCT_a_38* {.bycopy.} = object
  28. timestamp*: uint32
  29. increment*: uint32
  30.  
  31. INNER_C_STRUCT_a_42* {.bycopy.} = object
  32. str*: cstring
  33. len*: uint32
  34.  
  35. INNER_C_STRUCT_a_46* {.bycopy.} = object
  36. data*: ptr uint8
  37. data_len*: uint32
  38.  
  39. INNER_C_STRUCT_a_50* {.bycopy.} = object
  40. data*: ptr uint8
  41. data_len*: uint32
  42. subtype*: bson_subtype_t
  43.  
  44. INNER_C_STRUCT_a_55* {.bycopy.} = object
  45. regex*: cstring
  46. options*: cstring
  47.  
  48. INNER_C_STRUCT_a_59* {.bycopy.} = object
  49. collection*: cstring
  50. collection_len*: uint32
  51. oid*: bson_oid_t
  52.  
  53. INNER_C_STRUCT_a_64* {.bycopy.} = object
  54. code*: cstring
  55. code_len*: uint32
  56.  
  57. INNER_C_STRUCT_a_68* {.bycopy.} = object
  58. code*: cstring
  59. scope_data*: ptr uint8
  60. code_len*: uint32
  61. scope_len*: uint32
  62.  
  63. INNER_C_STRUCT_a_74* {.bycopy.} = object
  64. symbol*: cstring
  65. len*: uint32
  66.  
  67. INNER_C_UNION_a_30* {.bycopy.} = object {.union.}
  68. v_oid*: bson_oid_t
  69. v_int64*: int64
  70. v_int32*: int32
  71. v_int8*: int8
  72. v_double*: cdouble
  73. v_bool*: bool
  74. v_datetime*: int64
  75. v_timestamp*: INNER_C_STRUCT_a_38
  76. v_utf8*: INNER_C_STRUCT_a_42
  77. v_doc*: INNER_C_STRUCT_a_46
  78. v_binary*: INNER_C_STRUCT_a_50
  79. v_regex*: INNER_C_STRUCT_a_55
  80. v_dbpointer*: INNER_C_STRUCT_a_59
  81. v_code*: INNER_C_STRUCT_a_64
  82. v_codewscope*: INNER_C_STRUCT_a_68
  83. v_symbol*: INNER_C_STRUCT_a_74
  84. v_decimal128*: bson_decimal128_t
  85.  
  86. bson_value_t* {.bycopy.} = object
  87. value_type*: bson_type_t
  88. padding*: int32
  89. value*: INNER_C_UNION_a_30
  90.  
  91. # When cmake is used to build
  92. cIncludeDir(baseDir / "build" / "buildcache" / "src" / "libbson" / "src" / "bson")
  93.  
  94. when not defined(bsonStatic):
  95. cImport(bsonPath, recurse = true, dynlib = "bsonLPath")
  96. else:
  97. cImport(bsonPath, recurse = true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement