conv.odin 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package io
  2. to_reader :: proc(s: Stream) -> (r: Reader, ok: bool = true) {
  3. r.stream = s;
  4. if s.stream_vtable == nil || s.impl_read == nil {
  5. ok = false;
  6. }
  7. return;
  8. }
  9. to_writer :: proc(s: Stream) -> (w: Writer, ok: bool = true) {
  10. w.stream = s;
  11. if s.stream_vtable == nil || s.impl_write == nil {
  12. ok = false;
  13. }
  14. return;
  15. }
  16. to_closer :: proc(s: Stream) -> (c: Closer, ok: bool = true) {
  17. c.stream = s;
  18. if s.stream_vtable == nil || s.impl_close == nil {
  19. ok = false;
  20. }
  21. return;
  22. }
  23. to_flusher :: proc(s: Stream) -> (f: Flusher, ok: bool = true) {
  24. f.stream = s;
  25. if s.stream_vtable == nil || s.impl_flush == nil {
  26. ok = false;
  27. }
  28. return;
  29. }
  30. to_seeker :: proc(s: Stream) -> (seeker: Seeker, ok: bool = true) {
  31. seeker.stream = s;
  32. if s.stream_vtable == nil || s.impl_seek == nil {
  33. ok = false;
  34. }
  35. return;
  36. }
  37. to_read_writer :: proc(s: Stream) -> (r: Read_Writer, ok: bool = true) {
  38. r.stream = s;
  39. if s.stream_vtable == nil || s.impl_read == nil || s.impl_write == nil {
  40. ok = false;
  41. }
  42. return;
  43. }
  44. to_read_closer :: proc(s: Stream) -> (r: Read_Closer, ok: bool = true) {
  45. r.stream = s;
  46. if s.stream_vtable == nil || s.impl_read == nil || s.impl_close == nil {
  47. ok = false;
  48. }
  49. return;
  50. }
  51. to_read_write_closer :: proc(s: Stream) -> (r: Read_Write_Closer, ok: bool = true) {
  52. r.stream = s;
  53. if s.stream_vtable == nil || s.impl_read == nil || s.impl_write == nil || s.impl_close == nil {
  54. ok = false;
  55. }
  56. return;
  57. }
  58. to_read_write_seeker :: proc(s: Stream) -> (r: Read_Write_Seeker, ok: bool = true) {
  59. r.stream = s;
  60. if s.stream_vtable == nil || s.impl_read == nil || s.impl_write == nil || s.impl_seek == nil {
  61. ok = false;
  62. }
  63. return;
  64. }
  65. to_write_flusher :: proc(s: Stream) -> (w: Write_Flusher, ok: bool = true) {
  66. w.stream = s;
  67. if s.stream_vtable == nil || s.impl_write == nil || s.impl_flush == nil {
  68. ok = false;
  69. }
  70. return;
  71. }
  72. to_write_flush_closer :: proc(s: Stream) -> (w: Write_Flush_Closer, ok: bool = true) {
  73. w.stream = s;
  74. if s.stream_vtable == nil || s.impl_write == nil || s.impl_flush == nil || s.impl_close == nil {
  75. ok = false;
  76. }
  77. return;
  78. }
  79. to_reader_at :: proc(s: Stream) -> (r: Reader_At, ok: bool = true) {
  80. r.stream = s;
  81. if s.stream_vtable == nil || s.impl_read_at == nil {
  82. ok = false;
  83. }
  84. return;
  85. }
  86. to_writer_at :: proc(s: Stream) -> (w: Writer_At, ok: bool = true) {
  87. w.stream = s;
  88. if s.stream_vtable == nil || s.impl_write_at == nil {
  89. ok = false;
  90. }
  91. return;
  92. }
  93. to_reader_from :: proc(s: Stream) -> (r: Reader_From, ok: bool = true) {
  94. r.stream = s;
  95. if s.stream_vtable == nil || s.impl_read_from == nil {
  96. ok = false;
  97. }
  98. return;
  99. }
  100. to_writer_to :: proc(s: Stream) -> (w: Writer_To, ok: bool = true) {
  101. w.stream = s;
  102. if s.stream_vtable == nil || s.impl_write_to == nil {
  103. ok = false;
  104. }
  105. return;
  106. }
  107. to_write_closer :: proc(s: Stream) -> (w: Write_Closer, ok: bool = true) {
  108. w.stream = s;
  109. if s.stream_vtable == nil || s.impl_write == nil || s.impl_close == nil {
  110. ok = false;
  111. }
  112. return;
  113. }
  114. to_write_seeker :: proc(s: Stream) -> (w: Write_Seeker, ok: bool = true) {
  115. w.stream = s;
  116. if s.stream_vtable == nil || s.impl_write == nil || s.impl_seek == nil {
  117. ok = false;
  118. }
  119. return;
  120. }
  121. to_byte_reader :: proc(s: Stream) -> (b: Byte_Reader, ok: bool = true) {
  122. b.stream = s;
  123. if s.stream_vtable == nil || s.impl_read_byte == nil {
  124. ok = false;
  125. if s.stream_vtable != nil && s.impl_read != nil {
  126. ok = true;
  127. }
  128. }
  129. return;
  130. }
  131. to_byte_scanner :: proc(s: Stream) -> (b: Byte_Scanner, ok: bool = true) {
  132. b.stream = s;
  133. if s.stream_vtable != nil {
  134. if s.impl_unread_byte == nil {
  135. ok = false;
  136. return;
  137. }
  138. if s.impl_read_byte != nil {
  139. ok = true;
  140. } else if s.impl_read != nil {
  141. ok = true;
  142. } else {
  143. ok = false;
  144. }
  145. }
  146. return;
  147. }
  148. to_byte_writer :: proc(s: Stream) -> (b: Byte_Writer, ok: bool = true) {
  149. b.stream = s;
  150. if s.stream_vtable == nil || s.impl_write_byte == nil {
  151. ok = false;
  152. if s.stream_vtable != nil && s.impl_write != nil {
  153. ok = true;
  154. }
  155. }
  156. return;
  157. }
  158. to_rune_reader :: proc(s: Stream) -> (r: Rune_Reader, ok: bool = true) {
  159. r.stream = s;
  160. if s.stream_vtable == nil || s.impl_read_rune == nil {
  161. ok = false;
  162. if s.stream_vtable != nil && s.impl_read != nil {
  163. ok = true;
  164. }
  165. }
  166. return;
  167. }
  168. to_rune_scanner :: proc(s: Stream) -> (r: Rune_Scanner, ok: bool = true) {
  169. r.stream = s;
  170. if s.stream_vtable != nil {
  171. if s.impl_unread_rune == nil {
  172. ok = false;
  173. return;
  174. }
  175. if s.impl_read_rune != nil {
  176. ok = true;
  177. } else if s.impl_read != nil {
  178. ok = true;
  179. } else {
  180. ok = false;
  181. }
  182. } else {
  183. ok = false;
  184. }
  185. return;
  186. }