<commit_before>local assert = assert
local class  = require 'middleclass'


local VoxelAccessor = class('core/world/VoxelAccessor')

function VoxelAccessor:initialize( other )
    assert(not other or Object.isInstanceOf(other, VoxelAccessor),
           'Must be called without parameters or with another voxel accessor.')

    self.masks = {}
    self.nextPosition = 0

    if other then
        setmetatable(self.masks, {__index=other.masks})
        self.nextPosition = other.nextPosition
    end
end

function VoxelAccessor:setMask( name, bitPosition, bitCount )
    assert(not self.masks[name], 'A mask called "'..name..'" has already been set.')
    self.masks[name] = { bitPosition=bitPosition, bitCount=bitCount }
end

function VoxelAccessor:addMask( name, bitCount )
    self:setMask(name, self.nextPosition, bitCount)
    self.nextPosition = self.nextPosition + bitCount
end<commit_msg>VoxelAccessor can be setup with chained method calls.<commit_after>local assert = assert
local class  = require 'middleclass'


local VoxelAccessor = class('core/world/VoxelAccessor')

function VoxelAccessor:initialize( other )
    assert(not other or Object.isInstanceOf(other, VoxelAccessor),
           'Must be called without parameters or with another voxel accessor.')

    self.masks = {}
    self.nextPosition = 0

    if other then
        setmetatable(self.masks, {__index=other.masks})
        self.nextPosition = other.nextPosition
    end
end

function VoxelAccessor:setMask( name, bitPosition, bitCount )
    assert(not self.masks[name], 'A mask called "'..name..'" has already been set.')
    self.masks[name] = { bitPosition=bitPosition, bitCount=bitCount }
    return self
end

function VoxelAccessor:addMask( name, bitCount )
    self:setMask(name, self.nextPosition, bitCount)
    self.nextPosition = self.nextPosition + bitCount
    return self
end
{'fraction_non_alphanumeric': 0.09603004291845493, 'fraction_numerical': 0.001072961373390558, 'mean_word_length': 4.026954177897574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5188909', 'n_tokens_mistral': 564, 'n_tokens_neox': 551, 'n_words': 150}