aboutsummaryrefslogtreecommitdiff
path: root/io/init.lua
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2015-05-30 20:52:05 +0800
committerDeterminant <[email protected]>2015-05-30 20:52:05 +0800
commit5edaa7d5649a2e124496159f7e8a14edab4f7484 (patch)
treed880fd9587acb87701921583ada3b6aae65bbbda /io/init.lua
parentf10330fd95aa87cf6b21d292cf54c77bacfd2e40 (diff)
rename param file to chunk file (intend to generalize it)
Diffstat (limited to 'io/init.lua')
-rw-r--r--io/init.lua26
1 files changed, 13 insertions, 13 deletions
diff --git a/io/init.lua b/io/init.lua
index dc1c6c3..8c3701e 100644
--- a/io/init.lua
+++ b/io/init.lua
@@ -1,4 +1,4 @@
-function nerv.ParamFile:write_chunkdata(metadata, writer)
+function nerv.ChunkFile:write_chunkdata(metadata, writer)
if type(metadata) ~= "table" then
nerv.error("metadata should be a Lua table")
return
@@ -6,25 +6,25 @@ function nerv.ParamFile:write_chunkdata(metadata, writer)
return self:_write_chunkdata(table.tostring(metadata), writer)
end
-function nerv.ParamFile:write_param(param)
- local id = param.id
- local type = param.__typename
+function nerv.ChunkFile:write_chunk(chunk)
+ local id = chunk.id
+ local type = chunk.__typename
if id == nil then
- nerv_error("id of param %s must be specified", type)
+ nerv_error("id of chunk %s must be specified", type)
end
self:write_chunkdata({id = id,
type = type,
- info = param:get_info()}, param)
+ info = chunk:get_info()}, chunk)
end
-function nerv.ParamFile:read_param(id)
+function nerv.ChunkFile:read_chunk(id, global_conf)
local metadata = self.metadata[id]
if metadata == nil then
- nerv_error("param with id %s does not exist", id)
+ nerv_error("chunk with id %s does not exist", id)
end
- local param = assert(loadstring("return " ..
- metadata.type .. "(\"" .. id .. "\")"))()
- param:set_info(metadata.info)
- param:read(self:get_chunkdata(id))
- return param
+ local chunk_type = assert(loadstring("return " .. metadata.type))()
+ local chunk = chunk_type(id, global_conf)
+ chunk:set_info(metadata.info)
+ chunk:read(self:get_chunkdata(id))
+ return chunk
end