@@ -68,7 +68,7 @@ namespace MWLua
68
68
Log (Debug::Verbose) << " Read a large data chunk (" << size << " bytes) from '" << file.mFileName << " '." ;
69
69
}
70
70
71
- sol::object readFile (sol::this_state lua, FileHandle& file)
71
+ sol::object readFile (lua_State* lua, FileHandle& file)
72
72
{
73
73
std::ostringstream os;
74
74
if (file.mFilePtr && file.mFilePtr ->peek () != EOF)
@@ -79,7 +79,7 @@ namespace MWLua
79
79
return sol::make_object<std::string>(lua, std::move (result));
80
80
}
81
81
82
- sol::object readLineFromFile (sol::this_state lua, FileHandle& file)
82
+ sol::object readLineFromFile (lua_State* lua, FileHandle& file)
83
83
{
84
84
std::string result;
85
85
if (file.mFilePtr && std::getline (*file.mFilePtr , result))
@@ -91,7 +91,7 @@ namespace MWLua
91
91
return sol::nil;
92
92
}
93
93
94
- sol::object readNumberFromFile (sol::this_state lua, Files::IStreamPtr& file)
94
+ sol::object readNumberFromFile (lua_State* lua, Files::IStreamPtr& file)
95
95
{
96
96
double number = 0 ;
97
97
if (file && *file >> number)
@@ -100,7 +100,7 @@ namespace MWLua
100
100
return sol::nil;
101
101
}
102
102
103
- sol::object readCharactersFromFile (sol::this_state lua, FileHandle& file, size_t count)
103
+ sol::object readCharactersFromFile (lua_State* lua, FileHandle& file, size_t count)
104
104
{
105
105
if (count <= 0 && file.mFilePtr ->peek () != EOF)
106
106
return sol::make_object<std::string>(lua, std::string ());
@@ -189,7 +189,7 @@ namespace MWLua
189
189
190
190
return seek (lua, self, std::ios_base::cur, off);
191
191
});
192
- handle[" lines" ] = [](sol::this_state lua, sol::object self) {
192
+ handle[" lines" ] = [](sol::this_main_state lua, sol::main_object self) {
193
193
if (!self.is <FileHandle*>())
194
194
throw std::runtime_error (" self should be a file handle" );
195
195
return sol::as_function ([lua, self]() -> sol::object {
@@ -199,7 +199,7 @@ namespace MWLua
199
199
});
200
200
};
201
201
202
- api[" lines" ] = [vfs](sol::this_state lua, std::string_view fileName) {
202
+ api[" lines" ] = [vfs](sol::this_main_state lua, std::string_view fileName) {
203
203
auto normalizedName = VFS::Path::normalizeFilename (fileName);
204
204
return sol::as_function (
205
205
[lua, file = FileHandle (vfs->getNormalized (normalizedName), normalizedName)]() mutable {
0 commit comments