--[[The exported function, ExtractFuncs, takes an input file. It returnsa table that contains these things:- properties: A table of property values. It is a map between property name and values. The value can either be "*" or an array of possible string values that the property can take.- passthru: A string that is the pass-through data that should be put infront of the function definition header.- functions: An array of functions. Each function is a table with:-- name:-- any of the properties defined in the properties table. This will have values culled from the list of possibles, except if the property was defined as "*", in which case it will be any string.-- params: An array of parameters, in the order that they are defined as. Each param is a table with:--- name: the name of the parameter.--- type: The basic type. Something in the type-map.--- input: True if it is an input variable, valse otherwise.--- array: True if it is a pointer; false otehrwise.--- other: A string containing the other data. Kept for backwards compatibility.]]require("_line");localfunctionStoreParamOptions(param,paramData)localtestPattern="(%S*)%s+(.*)";localglType,rest=string.match(paramData,testPattern);param.type=glType;localinput;input,rest=string.match(rest,testPattern);if(input=="in")thenparam.input=true;elseparam.input=false;endlocaloldRest=rest;localarrayKind;arrayKind,rest=string.match(rest,testPattern);if(notarrayKind)thenparam.kind=oldRest;elseparam.kind=arrayKind;endif(restand#rest~=0)thenparam.other=rest;endendlocalfunctionCreateFunc(strFuncName,strParams)localfunc={};func.name=strFuncName;func.params={};func.AddParam=AddParamToFunc;--Parse the parameters, in order, into paramList.localcurrParamString=strParams;while((currParamString~=nil)and(#currParamString~=0))dolocalstrCurrParam;strCurrParam,currParamString=string.match(currParamString,"([%w_]+)(,?%s?.*)");localparamData={};paramData.name=strCurrParam;table.insert(func.params,paramData);endreturnfunc;end--If the pattern matches, then the function will be called on that match data.localjumpTable={{pattern="^required%-props:$",func=function(state,matchArray)state.frontMatter=true;end},--Passthrough data.{pattern="passthru: (.*)",func=function(state,matchArray)if(state.frontMatter)thentable.insert(state.funcData.passthru,matchArray[1]);endend},--Front matter{pattern="(%S*):%s*(.*)",func=function(state,matchArray)if(state.frontMatter)thenlocalparamData={};state.funcData.properties[matchArray[1]]=paramData;forterminstring.gmatch(matchArray[2],"%S*")doif(#term~=0)thentable.insert(paramData,term);endendendend},--Function definition{pattern="^([%w_]+)%((.*)%)",func=function(state,matchArray)state.frontMatter=false;state.currFunc=CreateFunc(matchArray[1],matchArray[2]);table.insert(state.funcData.functions,state.currFunc);end},--Profile property{pattern="^\tprofile:%s+compatibility",func=function(state,matchArray)state.currFunc.profile="compatibility"state.currFunc.deprecated="3.1"end},--Parameter Properties{pattern="^\tparam%s+(%S*)%s+(.*)",func=function(state,matchArray)localbFound=false;forcount=1,#state.currFunc.params,1doif(state.currFunc.params[count].name==matchArray[1])thenStoreParamOptions(state.currFunc.params[count],matchArray[2]);bFound=true;break;endendif(notbFound)thenprint(string.format("The func \"%s\" does not have parameter \"%s\".",state.currFunc.name,matchArray[1]));returntrue;end;end},--Non-param Properties{pattern="^\t(%S*)%s+(%S*)",func=function(state,matchArray)state.currFunc[matchArray[1]]=matchArray[2];end},}functionExtractFuncs(hFile)localfuncData={};funcData.properties={};funcData.passthru={};funcData.functions={};localstate={};state.funcData=funcData;forcurrLineinhFile:lines()dolocaloutLine=CullLine(currLine);if(outLine)thenfori,procinipairs(jumpTable)dolocalparseArray={string.match(outLine,proc.pattern);}if(parseArray[1])thenlocalbRet=proc.func(state,parseArray);if(bRet)thenprint("Bad line: "..outLine);endendendendendreturnstate.funcData;end