1 #include <IO.oh>
2 
3 /* run-time meta data */
4 static RT0__ModuleDesc _mid;
5 RT0__StructDesc _td_IO__Channel = { (RT0__Struct[]){&_td_IO__ChannelDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"Channel", 8, -1, 0, RT0__strPointer };
6 RT0__StructDesc _td_IO__SelectionKey = { (RT0__Struct[]){&_td_IO__SelectionKeyDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"SelectionKey", 8, -1, 0, RT0__strPointer };
7 RT0__StructDesc _td_IO__2052 = { (RT0__Struct[]){&_td_IO__SelectionKey}, NULL, NULL, &_mid, NULL, 8, 1, 0, RT0__strOpenArray };
8 RT0__StructDesc _td_IO__SelectionKeyList = { (RT0__Struct[]){&_td_IO__2052}, NULL, NULL, &_mid, (OOC_CHAR8*)"SelectionKeyList", 8, -1, 0, RT0__strPointer };
9 RT0__StructDesc _td_IO__ChannelDesc = { (RT0__Struct[]){&_td_IO__ChannelDesc}, (void*[]){(void*)IO__ChannelDesc_INIT,(void*)IO__ChannelDesc_FileDescriptor,(void*)IO__ChannelDesc_RegisterWithSelector,(void*)IO__ChannelDesc_KeyForSelector,(void*)IO__ChannelDesc_SetBlocking,(void*)IO__ChannelDesc_Close,(void*)IO__ChannelDesc_CloseAndRegister,(void*)IO__ChannelDesc_SetPos}, NULL, &_mid, (OOC_CHAR8*)"ChannelDesc", 16, 0, 0, RT0__strRecord };
10 RT0__StructDesc _td_IO__ByteChannel = { (RT0__Struct[]){&_td_IO__ByteChannelDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"ByteChannel", 8, -1, 0, RT0__strPointer };
11 RT0__StructDesc _td_IO__ByteChannelDesc = { (RT0__Struct[]){&_td_IO__ChannelDesc,&_td_IO__ByteChannelDesc}, (void*[]){(void*)IO__ByteChannelDesc_INIT,(void*)IO__ChannelDesc_FileDescriptor,(void*)IO__ChannelDesc_RegisterWithSelector,(void*)IO__ChannelDesc_KeyForSelector,(void*)IO__ChannelDesc_SetBlocking,(void*)IO__ChannelDesc_Close,(void*)IO__ChannelDesc_CloseAndRegister,(void*)IO__ChannelDesc_SetPos,(void*)IO__ByteChannelDesc_Read,(void*)IO__ByteChannelDesc_Write,(void*)IO__ByteChannelDesc_Flush,(void*)IO__ByteChannelDesc_TransferTo}, NULL, &_mid, (OOC_CHAR8*)"ByteChannelDesc", 16, 1, 0, RT0__strRecord };
12 RT0__StructDesc _td_IO__Selector = { (RT0__Struct[]){&_td_IO__SelectorDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"Selector", 8, -1, 0, RT0__strPointer };
13 RT0__StructDesc _td_IO__SelectorDesc = { (RT0__Struct[]){&_td_RT0__ObjectDesc,&_td_Object__ObjectDesc,&_td_IO__SelectorDesc}, (void*[]){(void*)RT0__ObjectDesc_Finalize,(void*)Object__ObjectDesc_ToString,(void*)Object__ObjectDesc_Equals,(void*)Object__ObjectDesc_HashCode,(void*)IO__SelectorDesc_INIT,(void*)IO__SelectorDesc_Close,(void*)IO__SelectorDesc_Select,(void*)IO__SelectorDesc_NextKey,(void*)IO__SelectorDesc_AddSelectionKey,(void*)IO__SelectorDesc_RemoveSelectionKey,(void*)IO__SelectorDesc_RemoveCanceled}, NULL, &_mid, (OOC_CHAR8*)"SelectorDesc", 16, 2, 0, RT0__strRecord };
14 RT0__StructDesc _td_IO__SelectionKeyDesc = { (RT0__Struct[]){&_td_RT0__ObjectDesc,&_td_Object__ObjectDesc,&_td_IO__SelectionKeyDesc}, (void*[]){(void*)RT0__ObjectDesc_Finalize,(void*)Object__ObjectDesc_ToString,(void*)Object__ObjectDesc_Equals,(void*)Object__ObjectDesc_HashCode,(void*)IO__SelectionKeyDesc_INIT,(void*)IO__SelectionKeyDesc_Attach,(void*)IO__SelectionKeyDesc_Cancel,(void*)IO__SelectionKeyDesc_SetInterestOps}, NULL, &_mid, (OOC_CHAR8*)"SelectionKeyDesc", 48, 2, 0, RT0__strRecord };
15 RT0__StructDesc _td_IO__Error = { (RT0__Struct[]){&_td_IO__ErrorDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"Error", 8, -1, 0, RT0__strPointer };
16 RT0__StructDesc _td_IO__ErrorDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"ErrorDesc", 184, 2, 0, RT0__strRecord };
17 RT0__StructDesc _td_IO__FileNotFound = { (RT0__Struct[]){&_td_IO__FileNotFoundDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"FileNotFound", 8, -1, 0, RT0__strPointer };
18 RT0__StructDesc _td_IO__FileNotFoundDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__FileNotFoundDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"FileNotFoundDesc", 184, 3, 0, RT0__strRecord };
19 RT0__StructDesc _td_IO__AccessDenied = { (RT0__Struct[]){&_td_IO__AccessDeniedDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"AccessDenied", 8, -1, 0, RT0__strPointer };
20 RT0__StructDesc _td_IO__AccessDeniedDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__AccessDeniedDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"AccessDeniedDesc", 184, 3, 0, RT0__strRecord };
21 RT0__StructDesc _td_IO__FileExists = { (RT0__Struct[]){&_td_IO__FileExistsDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"FileExists", 8, -1, 0, RT0__strPointer };
22 RT0__StructDesc _td_IO__FileExistsDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__FileExistsDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"FileExistsDesc", 184, 3, 0, RT0__strRecord };
23 RT0__StructDesc _td_IO__FileBusy = { (RT0__Struct[]){&_td_IO__FileBusyDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"FileBusy", 8, -1, 0, RT0__strPointer };
24 RT0__StructDesc _td_IO__FileBusyDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__FileBusyDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"FileBusyDesc", 184, 3, 0, RT0__strRecord };
25 RT0__StructDesc _td_IO__InvalidArgument = { (RT0__Struct[]){&_td_IO__InvalidArgumentDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"InvalidArgument", 8, -1, 0, RT0__strPointer };
26 RT0__StructDesc _td_IO__InvalidArgumentDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__InvalidArgumentDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"InvalidArgumentDesc", 184, 3, 0, RT0__strRecord };
27 RT0__StructDesc _td_IO__OutOfRange = { (RT0__Struct[]){&_td_IO__OutOfRangeDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"OutOfRange", 8, -1, 0, RT0__strPointer };
28 RT0__StructDesc _td_IO__OutOfRangeDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__OutOfRangeDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"OutOfRangeDesc", 184, 3, 0, RT0__strRecord };
29 RT0__StructDesc _td_IO__NotImplemented = { (RT0__Struct[]){&_td_IO__NotImplementedDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"NotImplemented", 8, -1, 0, RT0__strPointer };
30 RT0__StructDesc _td_IO__NotImplementedDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__NotImplementedDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"NotImplementedDesc", 184, 3, 0, RT0__strRecord };
31 RT0__StructDesc _td_IO__FormatError = { (RT0__Struct[]){&_td_IO__FormatErrorDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"FormatError", 8, -1, 0, RT0__strPointer };
32 RT0__StructDesc _td_IO__FormatErrorDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__FormatErrorDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"FormatErrorDesc", 184, 3, 0, RT0__strRecord };
33 RT0__StructDesc _td_IO__ProtocolError = { (RT0__Struct[]){&_td_IO__ProtocolErrorDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"ProtocolError", 8, -1, 0, RT0__strPointer };
34 RT0__StructDesc _td_IO__ProtocolErrorDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__ProtocolErrorDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"ProtocolErrorDesc", 184, 3, 0, RT0__strRecord };
35 RT0__StructDesc _td_IO__ErrorResponse = { (RT0__Struct[]){&_td_IO__ErrorResponseDesc}, NULL, NULL, &_mid, (OOC_CHAR8*)"ErrorResponse", 8, -1, 0, RT0__strPointer };
36 RT0__StructDesc _td_IO__ErrorResponseDesc = { (RT0__Struct[]){&_td_Exception__ExceptionDesc,&_td_Exception__CheckedDesc,&_td_IO__ErrorDesc,&_td_IO__ErrorResponseDesc}, (void*[]){(void*)IO__ErrorDesc_INIT,(void*)Exception__ExceptionDesc_GetMessage,(void*)Exception__ExceptionDesc_WriteBacktrace,(void*)Exception__ExceptionDesc_Name}, NULL, &_mid, (OOC_CHAR8*)"ErrorResponseDesc", 184, 3, 0, RT0__strRecord };
37 RT0__StructDesc _td_IO__15171 = { (RT0__Struct[]){&RT0__byte}, NULL, NULL, &_mid, NULL, 1, 1, (1<<RT0__flagAtomic), RT0__strOpenArray };
38 RT0__StructDesc _td_IO__16499 = { (RT0__Struct[]){&RT0__byte}, NULL, NULL, &_mid, NULL, 1, 1, (1<<RT0__flagAtomic), RT0__strOpenArray };
39 RT0__StructDesc _td_IO__17851 = { (RT0__Struct[]){&RT0__byte}, NULL, NULL, &_mid, NULL, 8192, 8192, (1<<RT0__flagAtomic), RT0__strArray };
40 static RT0__ModuleDesc _mid = { (OOC_CHAR8*)"IO", (RT0__Struct[]) { &_td_IO__Channel, &_td_IO__SelectionKey, &_td_IO__SelectionKeyList, &_td_IO__ChannelDesc, &_td_IO__ByteChannel, &_td_IO__ByteChannelDesc, &_td_IO__Selector, &_td_IO__SelectorDesc, &_td_IO__SelectionKeyDesc, &_td_IO__Error, &_td_IO__ErrorDesc, &_td_IO__FileNotFound, &_td_IO__FileNotFoundDesc, &_td_IO__AccessDenied, &_td_IO__AccessDeniedDesc, &_td_IO__FileExists, &_td_IO__FileExistsDesc, &_td_IO__FileBusy, &_td_IO__FileBusyDesc, &_td_IO__InvalidArgument, &_td_IO__InvalidArgumentDesc, &_td_IO__OutOfRange, &_td_IO__OutOfRangeDesc, &_td_IO__NotImplemented, &_td_IO__NotImplementedDesc, &_td_IO__FormatError, &_td_IO__FormatErrorDesc, &_td_IO__ProtocolError, &_td_IO__ProtocolErrorDesc, &_td_IO__ErrorResponse, &_td_IO__ErrorResponseDesc, NULL }, 0 };
41 
OOC_IO_open(RT0__Module client)42 extern void OOC_IO_open(RT0__Module client) {
43   if (_mid.openCount == 0) {
44     OOC_Object_open(&_mid);
45     OOC_Exception_open(&_mid);
46     OOC_RT0_open(&_mid);
47     OOC_Object_open(&_mid);
48     OOC_Exception_open(&_mid);
49 
50     RT0__RegisterModule(&_mid);
51     OOC_IO_init();
52   }
53   _mid.openCount++;
54 }
OOC_IO_close(RT0__Module client)55 extern void OOC_IO_close(RT0__Module client) {
56   _mid.openCount--;
57   if (_mid.openCount == 0) {
58     OOC_IO_destroy();
59     RT0__UnregisterModule(&_mid);
60 
61     OOC_Object_close(&_mid);
62     OOC_Exception_close(&_mid);
63     OOC_RT0_close(&_mid);
64     OOC_Object_close(&_mid);
65     OOC_Exception_close(&_mid);
66   }
67 }
68 
69 /* --- */
70