internal_rtti_nonbsd.odin 657 B

1234567891011121314151617181920212223242526272829303132
  1. #+private
  2. #+build !netbsd
  3. #+build !openbsd
  4. package flags
  5. import "core:net"
  6. // This proc exists purely as a workaround for import restrictions.
  7. // Returns true if caller should return early.
  8. try_net_parse_workaround :: #force_inline proc (
  9. data_type: typeid,
  10. str: string,
  11. ptr: rawptr,
  12. out_error: ^Error,
  13. ) -> bool {
  14. if data_type == net.Host_Or_Endpoint {
  15. addr, net_error := net.parse_hostname_or_endpoint(str)
  16. if net_error != nil {
  17. // We pass along `net.Error` here.
  18. out_error^ = Parse_Error {
  19. net_error,
  20. "Invalid Host/Endpoint.",
  21. }
  22. return true
  23. }
  24. (cast(^net.Host_Or_Endpoint)ptr)^ = addr
  25. return true
  26. }
  27. return false
  28. }