同步操作将从 saiigo/im4java 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash## This script creates the core im4java methods from an# interface-definition-file## $Author: bablokb $# $Revision: 1.34 $## License: GPL2# -----------------------------------------------------------------------------# usage message -------------------------------------------------------------usage() {echo -e "\n`basename 0ドル`: create core im4java methods\n\\nusage: `basename 0ドル` [options] [interface-definition-file [...]]\n\possible options:\n\-o dir create results in dir (default: $outputDir)\n\-p package create im4java class in package (default: $package)\n\-h show this help\n\-q run quiet\n\-v verbose messages (default)\n\"exit 3}# set defaults --------------------------------------------------------------setDefaults() {binDir=`dirname "0ドル"`outputDir="$binDir/../src"inputDir="$binDir/../input"package="org.im4java.core"eval idfs=(`find "$binDir/../input/" -type f \-name "*interface.txt" -printf '"%p" '`)CLASS_HEAD="$inputDir/java.class.head"TEMPLATE_OPERATION="$inputDir/operation.java.template"TEMPLATE_CMD="$inputDir/cmd.java.template"DEBUG=0quiet=0}# parse arguments and set variables -------------------------------------------parseArguments() {while getopts ":o:p:hqvd" opt; docase $opt ino) outputDir="$OPTARG";;p) package="$OPTARG";;h) usage;;q) quiet=1;;v) quiet=0;;d) let DEBUG+=1;;?) echo "error: illegal option: $OPTARG" >&2usage;;esacdoneshift $((OPTIND-1))[ "$#" -gt 0 ] && idfs=("$@")}# check arguments -----------------------------------------------------------checkArguments() {if [ ! -d "$outputDir" ]; thenecho "error: output-directory $outputDir does not exist!" >&2usagefitargetDir="$outputDir/${package//.//}"mkdir -p "$targetDir"}# process interface definition files ----------------------------------------processInterfaceFiles() {for f in "${idfs[@]}"; doecho -e "processing $f" >&2# set target-filename from interface-definitiondefCode="${f##*/}"defCode="${defCode%interface.txt}"# reset config-variablescode=""validInterface=""toolName=""getIdfSettings "$f": ${code:=$defCode} # set code from defCode if nottargetFile="$targetDir/${code}Ops.java" # set by idf# generate java-sourcefile for xxxOpsecho -e "writing $targetFile" >&2allMethods=""writeClassHeader > "$targetFile" # write class-headerwriteMethods "$f" >> "$targetFile" # parse file and generate methodswriteClassTail >> "$targetFile" # and write class-tail# generate java-sourcefile for xxxOperationtargetFile="$targetDir/${code}Operation.java"echo -e "writing $targetFile" >&2if [ -f "$targetFile" ]; thenecho -e "$targetFile already exists" >&2elsewriteOperationClass > "$targetFile"fi# generate java-sourcefile for xxxCmd# upper-case first character of toolName, because we use it as part of# the class namelocal toolNameU=`sed -e 's/.*/\u&/' <<< $toolName`targetFile="$targetDir/${toolNameU}Cmd.java"echo -e "writing $targetFile" >&2if [ "`find $targetDir -iname ${toolName}Cmd.java \-exec echo 1 \; -quit`" = "1" ]; thenecho -e "$targetFile already exists" >&2elsewriteCmdClass > "$targetFile"fidone}# parse a single line of the idf --------------------------------------------parseLine() {optionName="1ドル"# use explicit method-name if availablemethodName="${optionName#*|}"if [ "$methodName" = "$optionName" ]; then# convert option-name to method-name:# -append -> append# +append -> p_append# -adaptive-sharpen -> adaptiveSharpenmethodName=`sed -e 's/^-*//' -e 's/=$//' -e 's/^+/p_/' \-e 's/-\(.\)/\U1円\E/g' <<< $optionName`else# strip explicit methodName from optionNameoptionName="${optionName%|*}"fi# check for option typeif [ "${optionName: -1:1}" = "=" ]; thenoptionType="long"elseoptionType="short"fi# extract (optional) argumentsshiftdeclare -i i=0attachVarToOption=0 preOper=""while test $# -gt 0; dotoken="1ドル"if [ $i -eq 0 ]; thenif [ "$token" = "@" ]; thenattachVarToOption=1shifttoken="1ドル"elseattachVarToOption=0if [ "${#token}" -eq 1 ]; thenpreOper="$token"shifttoken="1ドル"fififivarType[$i]="${token%:*}"varName[$i]="${token#*:}"shiftif [ $# -gt 0 ]; thenoper[$i]="1ドル"shiftfilet i+=1doneargc="$i"}# dump interface-defintion --------------------------------------------------dumpDefs() {declare -i iecho "optionName=$optionName"echo "methodName=$methodName"echo "argc=$argc"for (( i=0; i<$argc; ++i )); doecho "varType[$i]=${varType[$i]}"echo "varName[$i]=${varName[$i]}"echo "oper[$i]=${oper[$i]}"done}# write class-header --------------------------------------------------------writeClassHeader() {sed -e "s/_PACKAGE_/$package/" -e "s/_CODE_/$code/g" \-e "s/_TOOLNAME_/$toolName/g" "$CLASS_HEAD"}# write template-class for operation ------------------------------------------writeOperationClass() {sed -e "s/_PACKAGE_/$package/" -e "s/_CODE_/$code/g" \-e "s/_TOOLNAME_/$toolName/g" "$TEMPLATE_OPERATION"}# write template-class for cmd ------------------------------------------------writeCmdClass() {sed -e "s/_PACKAGE_/$package/" -e "s/_CODE_/$code/g" \-e "s/_TOOLNAME_/$toolName/g" -e "s/_TOOLNAMEU_/$toolNameU/g" \"$TEMPLATE_CMD"}# write method-header -------------------------------------------------------writeMethodHeader() {local maxArgs="1ドル"# method comment and startcat <<EOF///////////////////////////////////////////////////////////////////////////////**Add option $optionName to the $toolName commandline(see the documentation of $toolName for details).*/EOF# add method-signaturedeclare -i iecho -en " public ${code}Ops $methodName("for (( i=0; i<$maxArgs-1; ++i )); doecho -en "${varType[$i]}${varName[$i]}, "done[ $i -lt $maxArgs ] && \echo -en "${varType[$i]}${varName[$i]}"echo -e ") {\n"# add start of codeif [ $maxArgs -gt 0 ]; thencat <<EOFString oper; // only used in some methodsStringBuffer buf = new StringBuffer(); // local buffer for option-argsEOFfiif [ "$optionType" = "short" -a $attachVarToOption -eq 0 ]; thenecho -e " iCmdArgs.add(\"$optionName\");\n"elseecho -e " buf.append(\"$optionName\");\n"fi}# write method-body ----------------------------------------------------------writeMethodBody() {local maxArgs="1ドル"declare -i iif [ $maxArgs -eq 0 ]; thenreturnfi[ -n "$preOper" ] && writeOperator "$preOper" "${varName[0]}"for (( i=0; i<$maxArgs-1; ++i )); dowriteVariablewriteOperator "${oper[$i]}" "${varName[$i+1]}" "${varName[$i]}"done# write last variablewriteVariable}# write method-tail ---------------------------------------------------------writeMethodTail() {local maxArgs="1ドル"if [ $maxArgs -gt 0 ]; thenecho -e " if (buf.length()>0) {"echo -e " iCmdArgs.add(buf.toString());"echo -e " }"fiecho -e " return this;\n }\n"}# write processing of given variable ----------------------------------------writeVariable() {echo -e " if (${varName[$i]} != null) {"if [ "${varType[$i]}" = "Boolean" ]; thenecho -e " if (${varName[$i]}.booleanValue())"echo -e " buf.append(\"%\");"elseecho -e " buf.append(${varName[$i]}.toString());"fiecho -e " }"}# write processing of given operator ----------------------------------------writeOperator() {local op="1ドル" nameNext="2ドル" namePrev="3ドル"if [ -n "$namePrev" ]; thenecho -e " if ($namePrev != null || $nameNext != null) {"fiif [ "$op" = "_" ]; thenecho -e " iCmdArgs.add(buf.toString());"echo -e " buf.setLength(0);"elif [ "$op" = "+" ]; thenecho -e " oper=\"+\";"echo -e " if ($nameNext.doubleValue() < 0)"echo -e " oper=\"\";"echo -e " buf.append(oper);"elif [ "$op" != "@" ]; thenecho -e " buf.append(\"$op\");"fiif [ -n "$namePrev" ]; thenecho -e " }"fi}# write methods for a single-definition -------------------------------------writeMethod() {[ $quiet -eq 0 ] && echo "processing $optionName" >&2# we create all variants with 0 to argc argumentsdeclare -i ilocal iStartif [ "$validInterface" = "true" ]; theniStart=$argc # argc is from parseLineelseiStart=0fifor (( i=$iStart; i<=$argc; ++i )); doif [ $i -eq $iStart ]; thenmethodSignature="$methodName"elsemethodSignature="${methodSignature}_${varType[$i-1]}"fi[ $DEBUG -gt 1 ] && echo $methodSignature 2>&1if grep -qw "$methodSignature" <<< "$allMethods"; then[ $quiet -eq 0 ] && echo "skipping $methodSignature" >&2continuefi[ $quiet -eq 0 ] && echo "processing $methodSignature" >&2writeMethodHeader $iwriteMethodBody $iwriteMethodTail $iallMethods="$allMethods${methodSignature}"done}# parse interface-definition-file and write methods -------------------------writeMethods() {local linedeclare -a varType varName operwhile read line; do[ "${line:0:1}" = "#" ] && continue # strip comment lines[ "${line:0:1}" = '!' ] && continue # strip settingsparseLine $line # parse given line[ $DEBUG -gt 0 ] && dumpDefs # dump parse-resultswriteMethod # write method-definitiondone < "1ドル"}# write class-tail ----------------------------------------------------------writeClassTail() {echo -e "\n}"}# extract and apply idf-settings --------------------------------------------getIdfSettings() {eval `sed -ne '/^!/s/!//p' "1ドル"`}# main program --------------------------------------------------------------setDefaultsparseArguments "$@"checkArgumentsprocessInterfaceFilesexit 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。