libc.monkey2 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. Namespace libc
  2. #Import "native/libc.cpp"
  3. #Import "native/libc.h"
  4. Extern
  5. #rem monkeydoc C/C++ 'char' type.
  6. #end
  7. Struct char_t="char"
  8. End
  9. #rem monkeydoc C/C++ 'const char' type.
  10. #end
  11. Struct const_char_t="const char"
  12. End
  13. #rem monkeydoc C/C++ 'signed char' type.
  14. #end
  15. Struct signed_char_t="signed char"
  16. End
  17. #rem monkeydoc C/C++ 'unsigned char' type
  18. #end
  19. Struct unsigned_char_t="unsigned char"
  20. End
  21. #rem monkeydoc C/C++ 'wchar_t' type
  22. #end
  23. Struct wchar_t="wchar_t"
  24. End
  25. #rem monkeydoc C/C++ 'size_t' type
  26. #end
  27. Alias size_t:UInt
  28. #rem monkeydoc C/C++ 'int8_t' type
  29. #end
  30. Alias int8_t:Byte
  31. #rem monkeydoc C/C++ 'uint8_t' type
  32. #end
  33. Alias uint8_t:UByte
  34. #rem monkeydoc C/C++ 'int16_t' type
  35. #end
  36. Alias int16_t:Short
  37. #rem monkeydoc C/C++ 'uint16_t' type
  38. #end
  39. Alias uint16_t:UShort
  40. #rem monkeydoc C/C++ 'int32_t' type
  41. #end
  42. Alias int32_t:Int
  43. #rem monkeydoc C/C++ 'uint32_t' type
  44. #end
  45. Alias uint32_t:UInt
  46. #rem monkeydoc C/C++ 'int64_t' type
  47. #end
  48. Alias int64_t:Long
  49. #rem monkeydoc C/C++ 'uint64_t' type
  50. #end
  51. Alias uint64_t:ULong
  52. #rem monkeydoc C/C++ 'intptr_t' type
  53. #end
  54. Alias intptr_t:ULong
  55. #rem monkeydoc C/C++ 'uintptr_t' type
  56. #end
  57. Alias uintptr_t:ULong
  58. Function sizeof<T>:size_t( t:T )="sizeof"
  59. '***** limits.h *****
  60. Const PATH_MAX:Int
  61. '***** stdio.h *****
  62. Struct FILE
  63. End
  64. Const stdin:FILE Ptr
  65. Const stdout:FILE Ptr
  66. Const stderr:FILE Ptr
  67. Const SEEK_SET:Int
  68. Const SEEK_CUR:Int
  69. Const SEEK_END:Int
  70. Function fopen:FILE Ptr( path:CString,mode:CString )="fopen_utf8"
  71. Function rewind:Void( stream:FILE )
  72. Function ftell:Int( stream:FILE Ptr )
  73. Function fseek:Int( stream:FILE Ptr,offset:Int,whence:Int )
  74. Function fread:Int( buf:Void Ptr,size:Int,count:Int,stream:FILE Ptr )
  75. Function fwrite:Int( buf:Void Ptr,size:Int,count:Int,stream:FILE Ptr )
  76. Function fflush:Int( stream:FILE Ptr )
  77. Function fclose:Int( stream:FILE Ptr )
  78. Function fputs:Int( str:CString,stream:FILE Ptr )="fputs_utf8"
  79. Function remove:Int( path:CString )="remove_utf8"
  80. Function rename:Int( oldPath:CString,newPath:CString )="rename_utf8"
  81. Function puts:Int( str:CString )="puts_utf8"
  82. '***** stdlib.h *****
  83. Function malloc:Void Ptr( size:Int )
  84. Function free:Void( mem:Void Ptr )
  85. #If __TARGET__<>"ios" 'gone in ios11!
  86. Function system:Int( cmd:CString )="system_utf8"
  87. #endif
  88. Function setenv:Int( name:CString,value:CString,overwrite:Int )="setenv_utf8"
  89. Function getenv:char_t Ptr( name:CString )="getenv_utf8"
  90. Function exit_:Void( status:Int )="exit"
  91. Function atexit:Int( func:Void() )="atexit"
  92. Function abort:Void()
  93. Function realpath:char_t Ptr( path:CString,resolved_path:char_t Ptr )="realpath_utf8"
  94. '***** string.h *****
  95. Function strlen:Int( str:CString )
  96. Function memset:Void Ptr( dst:Void Ptr,value:Int,count:Int )
  97. Function memcpy:Void Ptr( dst:Void Ptr,src:Void Ptr,length:Int )
  98. Function memmove:Void Ptr( dst:Void Ptr,src:Void Ptr,length:Int )
  99. Function memcmp:Int( dst:Void Ptr,src:Void Ptr,length:Int )
  100. '***** time.h *****
  101. Struct time_t
  102. End
  103. Struct tm_t
  104. Field tm_sec:Int
  105. Field tm_min:Int
  106. Field tm_hour:Int
  107. Field tm_mday:Int
  108. Field tm_mon:Int
  109. Field tm_year:Int
  110. Field tm_wday:Int
  111. Field tm_yday:Int
  112. Field tm_isdst:Int
  113. End
  114. Struct timeval
  115. Field tv_sec:Long 'dodgy - should be time_t
  116. Field tv_usec:Long 'dodyy - should be suseconds_t
  117. End
  118. Struct timezone
  119. End
  120. 'Note: clock() scary - pauses while process sleeps!
  121. Const CLOCKS_PER_SEC:Long="((bbLong)CLOCKS_PER_SEC)"
  122. Function clock:Long()="(bbLong)clock"
  123. Function tolong:Long( timer:time_t )="bbLong"
  124. Function time:time_t( timer:time_t Ptr )
  125. Function localtime:tm_t Ptr( timer:time_t Ptr )
  126. Function gmtime:tm_t Ptr( timer:time_t Ptr )
  127. Function difftime:Double( endtime:time_t,starttime:time_t )
  128. Function gettimeofday:Int( tv:timeval Ptr )="gettimeofday_utf8"
  129. '***** unistd.h *****
  130. Function getcwd:char_t Ptr( buf:char_t Ptr,size:Int )="getcwd_utf8"
  131. Function chdir:Int( path:CString )="chdir_utf8"
  132. Function rmdir:Int( path:CString )="rmdir_utf8"
  133. '***** sys/stat.h *****
  134. Enum mode_t
  135. End
  136. Const S_IFMT:mode_t '$f000
  137. Const S_IFIFO:mode_t '$1000
  138. Const S_IFCHR:mode_t '$2000
  139. Const S_IFBLK:mode_t '$3000
  140. Const S_IFDIR:mode_t '$4000
  141. Const S_IFREG:mode_t '$8000
  142. Struct stat_t
  143. Field st_mode:mode_t
  144. Field st_size:Long
  145. Field st_atime:time_t 'last access
  146. Field st_mtime:time_t 'last modification
  147. Field st_ctime:time_t 'status change
  148. End
  149. Function stat:Int( path:CString,buf:stat_t Ptr )="stat_utf8"
  150. Function mkdir:Int( path:CString,mode:Int )="mkdir_utf8"
  151. '***** dirent.h *****
  152. Struct DIR
  153. End
  154. Struct dirent
  155. Field d_name:CString
  156. End
  157. Function opendir:DIR Ptr( path:CString )="opendir_utf8"
  158. Function readdir:dirent Ptr( dir:DIR Ptr )="readdir_utf8"
  159. Function closedir( dir:DIR Ptr )="closedir_utf8"