Advertisement
Guest User

nim-typeImportC-template

a guest
Apr 6th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.54 KB | None | 0 0
  1. template typeImportC*(typeName: untyped, importC: string, header: string, baseType: typed): typed =
  2.   when defined(useHeaderImportC):
  3.     type typeName {.importC: importC, header: header.} = baseType
  4.   else:
  5.     type typeName = baseType
  6.  
  7. type NimTypeMarkup = object
  8.   f1*: uint
  9.   f2*: uint
  10.  
  11. typeImportC(`NimType *`, "NativeType", "imported.h", NimTypeMarkup)
  12.  
  13. # Should Produce
  14. when defined(useHeaderImportC):
  15.   type
  16.     NimType* {.importC: "NativeType", header: "imported.h".} = NimTypeMarkup
  17. else:
  18.   type
  19.     NimType* = NimTypeMarkup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement