拿的起放的下是什么意思| 什么是二次元| 什么东西越洗越脏脑筋急转弯| ch2o是什么物质| 痦子和痣有什么区别| 梦见大领导有什么预兆| 喉咙痛挂什么科| 一百岁叫什么之年| 大安是什么意思| 孕妇不能吃什么食物| 空调抽湿是什么意思| 尔尔是什么意思| 口腔溃疡缺乏什么维生素| 合作医疗是什么| 咳必清又叫什么| 胆小如鼠是什么生肖| 常青藤是什么意思| 八败是什么意思| 胰腺在人体起什么作用| 粉色裤子搭什么上衣| 我看见了什么| 宫颈光滑说明什么| 背疼应该挂什么科| 布朗尼是什么| 吃什么补大脑| 元参别名叫什么| 水字五行属什么| 决明子是什么东西| 肺大泡用什么药| sg是什么意思| 子宫肌瘤有什么症状| 枣红色配什么颜色好看| 虎什么龙什么| 苹果和什么榨汁减肥| 杀青原指什么| 咽炎吃什么药最管用| 后嗣是什么意思| 拔完牙后能吃什么| 为什么天气热皮肤就痒| 什么是野鸡大学| 放疗有什么危害| 侍郎是什么官| 太虚幻境是什么意思| 头不自觉的晃动是什么原因| 孩子营养不良吃什么| 空调感冒吃什么药| 梦见自己被火烧是什么意思| b2b是什么| 仔细的什么| 属鸡的守护神是什么菩萨| 荆棘是什么植物| 花木兰是什么剧种| 怀孕什么时候显怀| 湿疹用什么药| cd4是什么意思| 什么化妆品好用哪个牌子的| 咸鸭蛋不能和什么一起吃| 轻度溶血是什么意思| 三个毛念什么字| 摩羯座是什么星象| 眼眶周围发黑什么原因| mica是什么意思| 支付宝余额和余额宝有什么区别| 肾结石是因什么而起| 125是什么意思| 肩膀上有痣代表什么| 区人大代表是什么级别| 脑白质疏松症是什么病| fzl什么意思| 频频是什么意思| 撸管是什么| pet一ct是一种什么检查| 双侧乳腺结构不良什么意思| 费玉清为什么不结婚| 一孕傻三年是什么意思| 笋不能和什么一起吃| 最新病毒感染什么症状| 孩子喝什么牛奶有助于长高| 京剧脸谱黑色代表什么| 淋巴细胞百分比低说明什么问题| 梦见摘菜是什么意思| 昆虫记是什么类型的书| 为什么会长口腔溃疡的原因| 杨玉环是什么星座| 二氧化碳是什么气体| 什么是执念| fla是什么牌子| 何方神圣是什么意思| 捧杀是什么意思| 煮毛豆放什么调料好吃| 肚子痛拉稀吃什么药| 胡牌是什么意思| 三大精神是什么| 腰疼吃什么药| 冰激凌和冰淇淋有什么区别| 一什么石头| 瓞是什么意思| 4月5日什么星座| 为什么会长虱子| 美仑美奂什么意思| 万言万当不如一默是什么意思| 有人的地方就有江湖什么意思| 2017年什么年| 7到9点是什么时辰| 本家是什么意思| 理工科是什么意思| 最好的烟是什么牌子| 二八佳人是什么意思| 忙什么呢幽默的回答| 烟头属于什么垃圾| 节源开流是什么意思| 茶花什么时候开花| 肘是什么意思| hpv16阳性有什么症状| 脑瘤早期什么症状| 啰嗦是什么意思| 什么事的英文| 咖啡有什么作用| 生命是什么意思| 常吐痰是什么原因| 喜大普奔什么意思| 香茗是什么意思| 平均血红蛋白含量偏低是什么意思| 杨柳代表什么生肖| denham是什么牌子| 什么是荨麻疹| 1993年出生属什么生肖| 低回声结节什么意思| 两胸之间是什么部位| 电商属于什么行业| 什么是微信号| 唵嘛呢叭咪吽是什么意思| 大专什么专业好就业| 肚子疼应该挂什么科| 梦见猫吃老鼠什么意思| 阴阳失调吃什么中成药| 真命天子是什么生肖| 尿肌酐低是什么原因| 勰读什么| 老是流眼泪是什么原因| 类风湿有什么症状| 奶糕是什么| 什么的天安门| 周文王叫什么| 做梦梦到钱是什么预兆| 女人为什么要嫁人| 刀个刀个刀刀那是什么刀| 为什么呢| 心脏彩超能查出什么| 黄鼠狼最怕什么| 摇头是什么病| 中元节开什么生肖| 液基薄层细胞制片术是检查什么的| 什么叫痤疮| 才子是什么意思| 唇珠在面相中代表什么| 慢性浅表性胃炎吃什么药好得快| hpu是什么意思| 拉肚子胃疼吃什么药| 语言障碍挂什么科| 耳朵后面疼是什么原因| 日久生情是什么意思| 孩子咬手指甲是什么原因| 寒门子弟是什么意思| 半什么半什么| 今天是什么日子 农历| 宁字属于五行属什么| 朝鲜和韩国什么关系| tia是什么| 阴茎中途疲软吃什么药| 什么时候看到的月亮最大| 126是什么邮箱| 什么是童话故事| 家里起火代表什么预兆| 胎儿偏小是什么原因| 什么是脑瘫| 淋巴细胞高是什么意思| 什么人不能坐飞机| 脚老是抽筋是什么原因| 白内障有什么症状| 便便是绿色的是什么原因| 眉毛长白毛是什么征兆| 浓茶喝多了有什么危害| 男性夜间盗汗什么原因| 因果循环是什么意思| 手没有力气是什么原因| 肠澼是什么意思| 尿酸高吃什么食物好| 舌尖起泡是什么原因| 开学买什么| 吃什么生精养精最快| 卤米松软膏主治什么| 像蜈蚣一样的虫子叫什么| 胃疼吃什么| 什么手机便宜又好用| 大禹姓什么| 多囊卵巢综合症有什么症状| 晚上喝什么茶有助于睡眠| 一纸空文是什么意思| essence什么意思| 大运是什么意思| 贡菜是什么做的| 什么中药化结石最厉害| 喝酒脸红是缺少什么酶| 手腕血管疼是什么原因| 脂肪肝喝什么茶| 双休什么意思| 子宫长什么样子图片| 夜尿增多是什么原因| 伤到骨头吃什么好得快| 淋巴滤泡形成什么意思| 打嗝是什么原因引起的| edp是什么意思| 抬头纹用什么护肤品可以去除| 75年的兔是什么命| 肠胃性感冒吃什么药| 湿疹是什么病的前兆| 眼睛充血是什么原因引起的| 茗字五行属什么| 白带发黄有异味是什么原因| 维生素b6有什么作用| 推杯换盏什么意思| 吃饭流汗是什么原因| 为什么长火疖子| 川字五行属什么| 孕囊是什么样的图片| 吃什么能降血压| 90年属于什么生肖| 大腿疼是什么原因| 风吹动窗吹动夜声响是什么歌| 癔症是什么病| 胶原蛋白的成分是什么| 急性腮腺炎吃什么药| 乳腺实性结节是什么意思| 林彪什么时候死的| 怀疑心衰做什么检查| 右眼皮一直跳是什么预兆| jz是什么意思| 神经衰弱吃什么药最好| 功名是什么意思| 光膀子什么意思| 睾丸潮湿是什么原因| 特务是什么| 免疫力低是什么原因| 严重失眠吃什么药最好| 肚脐左边是什么器官| 反流性胃炎吃什么药| 红枣为什么要去核煮| hcmv是什么病毒| 冠冕堂皇是什么意思| 一个斤一个页念什么| 1994年五行属什么| 贵妃是什么意思| 飞蚊症是什么| 白食是什么意思| 孩子胆子小用什么方法可以改变| 煎熬是什么意思| 条件反射是什么意思| 上海龙华医院擅长什么| 石膏是什么| 3月29号是什么星座| 鸡犬不宁是什么意思| 翡翠和玉有什么区别| 小学什么时候放假| 百度Pojdi na vsebino

什么水果含铁量最高

Iz Wikipedije, proste enciklopedije
Documentation icon Dokumentacija modula[predogled] [uredi] [zgodovina] [osve?i]
百度 这里一共有63座帝王陵墓,埋葬着第17王朝到第20王朝期间的64位法老。

This module provides easy processing of arguments passed from #invoke. It is a meta-module, meant for use by other modules, and should not be called from #invoke directly. Its features include:

  • Easy trimming of arguments and removal of blank arguments.
  • Arguments can be passed by both the current frame and by the parent frame at the same time. (More details below.)
  • Arguments can be passed in directly from another Lua module or from the debug console.
  • Arguments are fetched as needed, which can help avoid (some) problems with <ref>...</ref> tags.
  • Most features can be customized.

Basic use

[uredi kodo]

First, you need to load the module. It contains one function, named getArgs.

local getArgs = require('Module:Arguments').getArgs

In the most basic scenario, you can use getArgs inside your main function. The variable args is a table containing the arguments from #invoke. (See below for details.)

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	-- Main module code goes here.
end

return p

However, the recommended practice is to use a function just for processing arguments from #invoke. This means that if someone calls your module from another Lua module you don't have to have a frame object available, which improves performance.

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	-- Main module code goes here.
end

return p

If you want multiple functions to use the arguments, and you also want them to be accessible from #invoke, you can use a wrapper function.

local getArgs = require('Module:Arguments').getArgs

local p = {}

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame)
		return p[funcName](args)
	end
end

p.func1 = makeInvokeFunc('_func1')

function p._func1(args)
	-- Code for the first function goes here.
end

p.func2 = makeInvokeFunc('_func2')

function p._func2(args)
	-- Code for the second function goes here.
end

return p

Options

[uredi kodo]

The following options are available. They are explained in the sections below.

local args = getArgs(frame, {
	trim = false,
	removeBlanks = false,
	valueFunc = function (key, value)
		-- Code for processing one argument
	end,
	frameOnly = true,
	parentOnly = true,
	parentFirst = true,
	wrappers = {
		'Predloga:A wrapper template',
		'Predloga:Another wrapper template'
	},
	readOnly = true,
	noOverwrite = true
})

Trimming and removing blanks

[uredi kodo]

Blank arguments often trip up coders new to converting MediaWiki templates to Lua. In template syntax, blank strings and strings consisting only of whitespace are considered false. However, in Lua, blank strings and strings consisting of whitespace are considered true. This means that if you don't pay attention to such arguments when you write your Lua modules, you might treat something as true that should actually be treated as false. To avoid this, by default this module removes all blank arguments.

Similarly, whitespace can cause problems when dealing with positional arguments. Although whitespace is trimmed for named arguments coming from #invoke, it is preserved for positional arguments. Most of the time this additional whitespace is not desired, so this module trims it off by default.

However, sometimes you want to use blank arguments as input, and sometimes you want to keep additional whitespace. This can be necessary to convert some templates exactly as they were written. If you want to do this, you can set the trim and removeBlanks arguments to false.

local args = getArgs(frame, {
	trim = false,
	removeBlanks = false
})

Custom formatting of arguments

[uredi kodo]

Sometimes you want to remove some blank arguments but not others, or perhaps you might want to put all of the positional arguments in lower case. To do things like this you can use the valueFunc option. The input to this option must be a function that takes two parameters, key and value, and returns a single value. This value is what you will get when you access the field key in the args table.

Example 1: this function preserves whitespace for the first positional argument, but trims all other arguments and removes all other blank arguments.

local args = getArgs(frame, {
	valueFunc = function (key, value)
		if key == 1 then
			return value
		elseif value then
			value = mw.text.trim(value)
			if value ~= '' then
				return value
			end
		end
		return nil
	end
})

Example 2: this function removes blank arguments and converts all arguments to lower case, but doesn't trim whitespace from positional parameters.

local args = getArgs(frame, {
	valueFunc = function (key, value)
		if not value then
			return nil
		end
		value = mw.ustring.lower(value)
		if mw.ustring.find(value, '%S') then
			return value
		end
		return nil
	end
})

Note: the above functions will fail if passed input that is not of type string or nil. This might be the case if you use the getArgs function in the main function of your module, and that function is called by another Lua module. In this case, you will need to check the type of your input. This is not a problem if you are using a function specially for arguments from #invoke (i.e. you have p.main and p._main functions, or something similar).

Examples 1 and 2 with type checking

Example 1:

local args = getArgs(frame, {
	valueFunc = function (key, value)
		if key == 1 then
			return value
		elseif type(value) == 'string' then
			value = mw.text.trim(value)
			if value ~= '' then
				return value
			else
				return nil
			end
		else
			return value
		end
	end
})

Example 2:

local args = getArgs(frame, {
	valueFunc = function (key, value)
		if type(value) == 'string' then
			value = mw.ustring.lower(value)
			if mw.ustring.find(value, '%S') then
				return value
			else
				return nil
			end
		else
			return value
		end
	end
})

Also, please note that the valueFunc function is called more or less every time an argument is requested from the args table, so if you care about performance you should make sure you aren't doing anything inefficient with your code.

Frames and parent frames

[uredi kodo]

Arguments in the args table can be passed from the current frame or from its parent frame at the same time. To understand what this means, it is easiest to give an example. Let's say that we have a module called Module:ExampleArgs. This module prints the first two positional arguments that it is passed.

Module:ExampleArgs code
local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local first = args[1] or ''
	local second = args[2] or ''
	return first .. ' ' .. second
end

return p

Module:ExampleArgs is then called by Predloga:ExampleArgs, which contains the code {{#invoke:ExampleArgs|main|firstInvokeArg}}. This produces the result "firstInvokeArg".

Now if we were to call Predloga:ExampleArgs, the following would happen:

Code Result
{{ExampleArgs}} firstInvokeArg
{{ExampleArgs|firstTemplateArg}} firstInvokeArg
{{ExampleArgs|firstTemplateArg|secondTemplateArg}} firstInvokeArg secondTemplateArg

There are three options you can set to change this behaviour: frameOnly, parentOnly and parentFirst. If you set frameOnly then only arguments passed from the current frame will be accepted; if you set parentOnly then only arguments passed from the parent frame will be accepted; and if you set parentFirst then arguments will be passed from both the current and parent frames, but the parent frame will have priority over the current frame. Here are the results in terms of Predloga:ExampleArgs:

frameOnly
Code Result
{{ExampleArgs}} firstInvokeArg
{{ExampleArgs|firstTemplateArg}} firstInvokeArg
{{ExampleArgs|firstTemplateArg|secondTemplateArg}} firstInvokeArg
parentOnly
Code Result
{{ExampleArgs}}
{{ExampleArgs|firstTemplateArg}} firstTemplateArg
{{ExampleArgs|firstTemplateArg|secondTemplateArg}} firstTemplateArg secondTemplateArg
parentFirst
Code Result
{{ExampleArgs}} firstInvokeArg
{{ExampleArgs|firstTemplateArg}} firstTemplateArg
{{ExampleArgs|firstTemplateArg|secondTemplateArg}} firstTemplateArg secondTemplateArg

Notes:

  1. If you set both the frameOnly and parentOnly options, the module won't fetch any arguments at all from #invoke. This is probably not what you want.
  2. In some situations a parent frame may not be available, e.g. if getArgs is passed the parent frame rather than the current frame. In this case, only the frame arguments will be used (unless parentOnly is set, in which case no arguments will be used) and the parentFirst and frameOnly options will have no effect.

Wrappers

[uredi kodo]

The wrappers option is used to specify a limited number of templates as wrapper templates, that is, templates whose only purpose is to call a module. If the module detects that it is being called from a wrapper template, it will only check for arguments in the parent frame; otherwise it will only check for arguments in the frame passed to getArgs. This allows modules to be called by either #invoke or through a wrapper template without the loss of performance associated with having to check both the frame and the parent frame for each argument lookup.

For example, the only content of Predloga:Side box (excluding content in <noinclude>...</noinclude> tags) is {{#invoke:Side box|main}}. There is no point in checking the arguments passed directly to the #invoke statement for this template, as no arguments will ever be specified there. We can avoid checking arguments passed to #invoke by using the parentOnly option, but if we do this then #invoke will not work from other pages either. If this were the case, the |text=Some text in the code {{#invoke:Side box|main|text=Some text}} would be ignored completely, no matter what page it was used from. By using the wrappers option to specify 'Predloga:Side box' as a wrapper, we can make {{#invoke:Side box|main|text=Some text}} work from most pages, while still not requiring that the module check for arguments on the Predloga:Side box page itself.

Wrappers can be specified either as a string, or as an array of strings.

local args = getArgs(frame, {
	wrappers = 'Predloga:Wrapper template'
})


local args = getArgs(frame, {
	wrappers = {
		'Predloga:Wrapper 1',
		'Predloga:Wrapper 2',
		-- Any number of wrapper templates can be added here.
	}
})

Notes:

  1. The module will automatically detect if it is being called from a wrapper template's /sandbox subpage, so there is no need to specify sandbox pages explicitly.
  2. The wrappers option effectively changes the default of the frameOnly and parentOnly options. If, for example, parentOnly were explicitly set to false with wrappers set, calls via wrapper templates would result in both frame and parent arguments being loaded, though calls not via wrapper templates would result in only frame arguments being loaded.
  3. If the wrappers option is set and no parent frame is available, the module will always get the arguments from the frame passed to getArgs.

Writing to the args table

[uredi kodo]

Sometimes it can be useful to write new values to the args table. This is possible with the default settings of this module. (However, bear in mind that it is usually better coding style to create a new table with your new values and copy arguments from the args table as needed.)

args.foo = 'some value'

It is possible to alter this behaviour with the readOnly and noOverwrite options. If readOnly is set then it is not possible to write any values to the args table at all. If noOverwrite is set, then it is possible to add new values to the table, but it is not possible to add a value if it would overwrite any arguments that are passed from #invoke.

Ref tags

[uredi kodo]

This module uses metatables to fetch arguments from #invoke. This allows access to both the frame arguments and the parent frame arguments without using the pairs() function. This can help if your module might be passed <ref>...</ref> tags as input.

As soon as <ref>...</ref> tags are accessed from Lua, they are processed by the MediaWiki software and the reference will appear in the reference list at the bottom of the article. If your module proceeds to omit the reference tag from the output, you will end up with a phantom reference - a reference that appears in the reference list, but no number that links to it. This has been a problem with modules that use pairs() to detect whether to use the arguments from the frame or the parent frame, as those modules automatically process every available argument.

This module solves this problem by allowing access to both frame and parent frame arguments, while still only fetching those arguments when it is necessary. The problem will still occur if you use pairs(args) elsewhere in your module, however.

Known limitations

[uredi kodo]

The use of metatables also has its downsides. Most of the normal Lua table tools won't work properly on the args table, including the # operator, the next() function, and the functions in the table library. If using these is important for your module, you should use your own argument processing function instead of this module.

-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.

local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType

local arguments = {}

-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.

local function tidyValDefault(key, val)
	if type(val) == 'string' then
		val = val:match('^%s*(.-)%s*$')
		if val == '' then
			return nil
		else
			return val
		end
	else
		return val
	end
end

local function tidyValTrimOnly(key, val)
	if type(val) == 'string' then
		return val:match('^%s*(.-)%s*$')
	else
		return val
	end
end

local function tidyValRemoveBlanksOnly(key, val)
	if type(val) == 'string' then
		if val:find('%S') then
			return val
		else
			return nil
		end
	else
		return val
	end
end

local function tidyValNoChange(key, val)
	return val
end

local function matchesTitle(given, title)
	local tp = type( given )
	return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end

local translate_mt = { __index = function(t, k) return k end }

function arguments.getArgs(frame, options)
	checkType('getArgs', 1, frame, 'table', true)
	checkType('getArgs', 2, options, 'table', true)
	frame = frame or {}
	options = options or {}

	--[[
	-- Set up argument translation.
	--]]
	options.translate = options.translate or {}
	if getmetatable(options.translate) == nil then
		setmetatable(options.translate, translate_mt)
	end
	if options.backtranslate == nil then
		options.backtranslate = {}
		for k,v in pairs(options.translate) do
			options.backtranslate[v] = k
		end
	end
	if options.backtranslate and getmetatable(options.backtranslate) == nil then
		setmetatable(options.backtranslate, {
			__index = function(t, k)
				if options.translate[k] ~= k then
					return nil
				else
					return k
				end
			end
		})
	end

	--[[
	-- Get the argument tables. If we were passed a valid frame object, get the
	-- frame arguments (fargs) and the parent frame arguments (pargs), depending
	-- on the options set and on the parent frame's availability. If we weren't
	-- passed a valid frame object, we are being called from another Lua module
	-- or from the debug console, so assume that we were passed a table of args
	-- directly, and assign it to a new variable (luaArgs).
	--]]
	local fargs, pargs, luaArgs
	if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
		if options.wrappers then
			--[[
			-- The wrappers option makes Module:Arguments look up arguments in
			-- either the frame argument table or the parent argument table, but
			-- not both. This means that users can use either the #invoke syntax
			-- or a wrapper template without the loss of performance associated
			-- with looking arguments up in both the frame and the parent frame.
			-- Module:Arguments will look up arguments in the parent frame
			-- if it finds the parent frame's title in options.wrapper;
			-- otherwise it will look up arguments in the frame object passed
			-- to getArgs.
			--]]
			local parent = frame:getParent()
			if not parent then
				fargs = frame.args
			else
				local title = parent:getTitle():gsub('/peskovnik$', '')
				local found = false
				if matchesTitle(options.wrappers, title) then
					found = true
				elseif type(options.wrappers) == 'table' then
					for _,v in pairs(options.wrappers) do
						if matchesTitle(v, title) then
							found = true
							break
						end
					end
				end

				-- We test for false specifically here so that nil (the default) acts like true.
				if found or options.frameOnly == false then
					pargs = parent.args
				end
				if not found or options.parentOnly == false then
					fargs = frame.args
				end
			end
		else
			-- options.wrapper isn't set, so check the other options.
			if not options.parentOnly then
				fargs = frame.args
			end
			if not options.frameOnly then
				local parent = frame:getParent()
				pargs = parent and parent.args or nil
			end
		end
		if options.parentFirst then
			fargs, pargs = pargs, fargs
		end
	else
		luaArgs = frame
	end

	-- Set the order of precedence of the argument tables. If the variables are
	-- nil, nothing will be added to the table, which is how we avoid clashes
	-- between the frame/parent args and the Lua args.
	local argTables = {fargs}
	argTables[#argTables + 1] = pargs
	argTables[#argTables + 1] = luaArgs

	--[[
	-- Generate the tidyVal function. If it has been specified by the user, we
	-- use that; if not, we choose one of four functions depending on the
	-- options chosen. This is so that we don't have to call the options table
	-- every time the function is called.
	--]]
	local tidyVal = options.valueFunc
	if tidyVal then
		if type(tidyVal) ~= 'function' then
			error(
				"bad value assigned to option 'valueFunc'"
					.. '(function expected, got '
					.. type(tidyVal)
					.. ')',
				2
			)
		end
	elseif options.trim ~= false then
		if options.removeBlanks ~= false then
			tidyVal = tidyValDefault
		else
			tidyVal = tidyValTrimOnly
		end
	else
		if options.removeBlanks ~= false then
			tidyVal = tidyValRemoveBlanksOnly
		else
			tidyVal = tidyValNoChange
		end
	end

	--[[
	-- Set up the args, metaArgs and nilArgs tables. args will be the one
	-- accessed from functions, and metaArgs will hold the actual arguments. Nil
	-- arguments are memoized in nilArgs, and the metatable connects all of them
	-- together.
	--]]
	local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
	setmetatable(args, metatable)

	local function mergeArgs(tables)
		--[[
		-- Accepts multiple tables as input and merges their keys and values
		-- into one table. If a value is already present it is not overwritten;
		-- tables listed earlier have precedence. We are also memoizing nil
		-- values, which can be overwritten if they are 's' (soft).
		--]]
		for _, t in ipairs(tables) do
			for key, val in pairs(t) do
				if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
					local tidiedVal = tidyVal(key, val)
					if tidiedVal == nil then
						nilArgs[key] = 's'
					else
						metaArgs[key] = tidiedVal
					end
				end
			end
		end
	end

	--[[
	-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
	-- and are only fetched from the argument tables once. Fetching arguments
	-- from the argument tables is the most resource-intensive step in this
	-- module, so we try and avoid it where possible. For this reason, nil
	-- arguments are also memoized, in the nilArgs table. Also, we keep a record
	-- in the metatable of when pairs and ipairs have been called, so we do not
	-- run pairs and ipairs on the argument tables more than once. We also do
	-- not run ipairs on fargs and pargs if pairs has already been run, as all
	-- the arguments will already have been copied over.
	--]]

	metatable.__index = function (t, key)
		--[[
		-- Fetches an argument when the args table is indexed. First we check
		-- to see if the value is memoized, and if not we try and fetch it from
		-- the argument tables. When we check memoization, we need to check
		-- metaArgs before nilArgs, as both can be non-nil at the same time.
		-- If the argument is not present in metaArgs, we also check whether
		-- pairs has been run yet. If pairs has already been run, we return nil.
		-- This is because all the arguments will have already been copied into
		-- metaArgs by the mergeArgs function, meaning that any other arguments
		-- must be nil.
		--]]
		if type(key) == 'string' then
			key = options.translate[key]
		end
		local val = metaArgs[key]
		if val ~= nil then
			return val
		elseif metatable.donePairs or nilArgs[key] then
			return nil
		end
		for _, argTable in ipairs(argTables) do
			local argTableVal = tidyVal(key, argTable[key])
			if argTableVal ~= nil then
				metaArgs[key] = argTableVal
				return argTableVal
			end
		end
		nilArgs[key] = 'h'
		return nil
	end

	metatable.__newindex = function (t, key, val)
		-- This function is called when a module tries to add a new value to the
		-- args table, or tries to change an existing value.
		if type(key) == 'string' then
			key = options.translate[key]
		end
		if options.readOnly then
			error(
				'could not write to argument table key "'
					.. tostring(key)
					.. '"; the table is read-only',
				2
			)
		elseif options.noOverwrite and args[key] ~= nil then
			error(
				'could not write to argument table key "'
					.. tostring(key)
					.. '"; overwriting existing arguments is not permitted',
				2
			)
		elseif val == nil then
			--[[
			-- If the argument is to be overwritten with nil, we need to erase
			-- the value in metaArgs, so that __index, __pairs and __ipairs do
			-- not use a previous existing value, if present; and we also need
			-- to memoize the nil in nilArgs, so that the value isn't looked
			-- up in the argument tables if it is accessed again.
			--]]
			metaArgs[key] = nil
			nilArgs[key] = 'h'
		else
			metaArgs[key] = val
		end
	end

	local function translatenext(invariant)
		local k, v = next(invariant.t, invariant.k)
		invariant.k = k
		if k == nil then
			return nil
		elseif type(k) ~= 'string' or not options.backtranslate then
			return k, v
		else
			local backtranslate = options.backtranslate[k]
			if backtranslate == nil then
				-- Skip this one. This is a tail call, so this won't cause stack overflow
				return translatenext(invariant)
			else
				return backtranslate, v
			end
		end
	end

	metatable.__pairs = function ()
		-- Called when pairs is run on the args table.
		if not metatable.donePairs then
			mergeArgs(argTables)
			metatable.donePairs = true
		end
		return translatenext, { t = metaArgs }
	end

	local function inext(t, i)
		-- This uses our __index metamethod
		local v = t[i + 1]
		if v ~= nil then
			return i + 1, v
		end
	end

	metatable.__ipairs = function (t)
		-- Called when ipairs is run on the args table.
		return inext, t, 0
	end

	return args
end

return arguments
卵巢多囊症是什么原因造成 人体有365个什么 经常泡脚有什么好处 骨折吃什么恢复快 梅毒什么症状
乌鸡白凤丸有什么功效 补水什么意思 女性出汗多是什么原因 烂尾楼是什么意思 明胶是什么东西
叔叔的儿子叫什么 包皮龟头炎吃什么药 神经衰弱是什么病 腹泻拉水吃什么药 两面三刀是什么生肖
什么是钝角 腰椎间盘突出不能吃什么食物 小腿疼痛挂什么科 霉菌性阴道炎用什么药效果好 什么食物含锌多
大小便失禁是什么原因造成的travellingsim.com 1998年五行属什么hcv9jop0ns4r.cn 秦皇岛有什么特产hanqikai.com 黄豆加什么打豆浆好喝又营养luyiluode.com 女人被插入是什么感觉hcv8jop8ns0r.cn
脚热是什么原因hcv9jop1ns3r.cn 脚肿什么原因引起的cl108k.com 吃什么去湿气最快hcv7jop6ns6r.cn 舌苔白腻是什么原因hcv8jop8ns7r.cn 脂肪疝是什么病hcv8jop0ns0r.cn
06年属什么hcv9jop0ns2r.cn 湿热内蕴是什么意思hcv8jop3ns4r.cn 梦见游泳是什么预兆hcv9jop6ns6r.cn 两个菱形是什么牌子wuhaiwuya.com 赵云的马叫什么hcv8jop5ns3r.cn
种植牙是什么hcv9jop6ns8r.cn 履什么意思hcv8jop1ns9r.cn 怀孕初期头晕是什么原因hcv9jop3ns7r.cn ua医学上是什么意思hcv8jop1ns3r.cn 女儿红是什么hcv8jop0ns6r.cn
百度