codegen.templates.include.macros.fmpp Maven / Gradle / Ivy
<#global varPkgName="org.unix4j.vars">
<#global varPkgPath="org/unix4j/vars">
<#function isCommandSpecificOperand def operand>
<#return !operand.type?contains(".") && !isPrimitive(operand.type) && !isJavaLang(operand.type)>
#function>
<#function isPrimitive type>
<#return type=="long" || type=="int" || type=="short" || type=="byte" || type=="double" || type=="float" || type=="char" || type=="boolean">
#function>
<#function isJavaLang type>
<#return type=="String">
#function>
<#function boxPrimitive type>
<#if type == "int">
<#return "Integer">
<#elseif type == "long">
<#return "Long">
<#elseif type == "double">
<#return "Double">
<#elseif type == "float">
<#return "Float">
<#elseif type == "char">
<#return "Character">
<#elseif type == "boolean">
<#return "Boolean">
<#else>
<#return type>
#if>
#function>
<#function isGenericType type>
<#return type?contains("<")>
#function>
<#function normalizeVarArgType type boxPrimitives>
<#if boxPrimitives>
<#local normalized=boxPrimitive(type)>
<#else>
<#local normalized=type>
#if>
<#if normalized?ends_with("...")>
<#return normalized?substring(0, normalized?length-3)+"[]">
<#else>
<#return normalized>
#if>
#function>
<#function rawType type>
<#if type?contains("<")>
<#-- cut off the generic stuff -->
<#return type?substring(0, type?index_of("<"))>
<#else>
<#return type>
#if>
#function>
<#function typeClass type prefixWithCast>
<#local class=normalizeVarArgType(type,false)>
<#if isGenericType(class)>
<#local raw=rawType(class)>
<#if prefixWithCast>
<#return "(Class<" + class + ">)(Class>)" + raw + ".class">
<#else>
<#return class + ".class">
#if>
<#else>
<#return class + ".class">
#if>
#function>
<#function countUsesStandardInput def usesStandardInput>
<#local count=0>
<#foreach method in def.methods>
<#if method.usesStandardInput = usesStandardInput>
<#local count=count+1>
#if>
#foreach>
<#return count>
#function>
<#function indexOfOperandByType operands operand>
<#foreach opd in operands?values>
<#if opd.type == operand.type>
<#return opd_index>
#if>
#foreach>
<#return -1>
#function>
<#function setter operand>
<#return "set" + operand.name?cap_first>
#function>
<#function isStringOperand operand>
<#return operand.type == "String">
#function>
<#function hasStringOperand def>
<#foreach operand in def.operands?values>
<#if isStringOperand(operand)>
<#return true>
#if>
#foreach>
<#return false>
#function>
<#function getOptionsArgIfAny def args>
<#foreach arg in args>
<#if isOptionsArg(def, arg)>
<#return arg>
#if>
#foreach>
<#return "">
#function>
<#function hasOptionsArg def args>
<#return getOptionsArgIfAny(def, args)?length != 0>
#function>
<#function isOptionsArg def arg>
<#return def.operands[arg].type == optionsName>
#function>
<#function hasArgsOperand def>
<#foreach operand in def.operands?values>
<#if isArgsOperand(operand)>
<#return true>
#if>
#foreach>
<#return false>
#function>
<#function isArgsOperandName operandName>
<#return operandName == "args">
#function>
<#function isArgsOperand operand>
<#return isArgsOperandName(operand.name)>
#function>