internal_rtti_nonbsd.odin 660 B

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