function must match signature found in type lua_Reader: const char* ( lua_State*, void*, size_t* )
| 37 | // function must match signature found in type lua_Reader: |
| 38 | // const char* ( lua_State*, void*, size_t* ) |
| 39 | const char* custom_reader_function( |
| 40 | lua_State*, void* pointer_to_my_object, size_t* data_size) { |
| 41 | custom_reader& cr |
| 42 | = *(static_cast<custom_reader*>(pointer_to_my_object)); |
| 43 | if (cr.read()) { |
| 44 | *data_size = cr.current_size; |
| 45 | return cr.buffer; |
| 46 | } |
| 47 | else { |
| 48 | *data_size = 0; |
| 49 | return nullptr; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | int main() { |
| 54 | std::cout << "=== custom reader ===" << std::endl; |