cbuilderexprs.nim 823 B

1234567891011121314151617181920212223242526
  1. # XXX make complex ones like bitOr use builder instead
  2. proc ptrType(t: Snippet): Snippet =
  3. t & "*"
  4. const
  5. CallingConvToStr: array[TCallingConvention, string] = ["N_NIMCALL",
  6. "N_STDCALL", "N_CDECL", "N_SAFECALL",
  7. "N_SYSCALL", # this is probably not correct for all platforms,
  8. # but one can #define it to what one wants
  9. "N_INLINE", "N_NOINLINE", "N_FASTCALL", "N_THISCALL", "N_CLOSURE", "N_NOCONV",
  10. "N_NOCONV" #ccMember is N_NOCONV
  11. ]
  12. proc procPtrType(conv: TCallingConvention, rettype: Snippet, name: string): Snippet =
  13. CallingConvToStr[conv] & "_PTR(" & rettype & ", " & name & ")"
  14. proc cCast(typ, value: Snippet): Snippet =
  15. "((" & typ & ") " & value & ")"
  16. proc cAddr(value: Snippet): Snippet =
  17. "&" & value
  18. proc bitOr(a, b: Snippet): Snippet =
  19. "(" & a & " | " & b & ")"