⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen_code.c

📁 股票主要技术指标源码
💻 C
📖 第 1 页 / 共 5 页
字号:
				fprintf(gOutFunc_XML->file, "					<Flag>Upper Limit</Flag>\n");			}			if(outputInfo->flags & TA_OUT_LOWER_LIMIT)			{				fprintf(gOutFunc_XML->file, "					<Flag>Lower Limit</Flag>\n");			}			fprintf(gOutFunc_XML->file, "				</Flags>\n");		}		fprintf(gOutFunc_XML->file, "			</OutputArgument>\n");	}	fprintf(gOutFunc_XML->file, "		</OutputArguments>\n");    fprintf(gOutFunc_XML->file, "	</FinancialFunction>\n");	fprintf(gOutFunc_XML->file, "\n");	fprintf(gOutFunc_XML->file, "\n");}static void doForEachFunctionPhase1( const TA_FuncInfo *funcInfo,                               void *opaqueData ){	(void)opaqueData;   #ifdef _MSC_VER      /* Run the func file through the pre-processor to generate the Java code. */      genJavaCodePhase1( funcInfo );         #else	  (void)funcInfo;   #endif}static void doForEachFunctionPhase2( const TA_FuncInfo *funcInfo,                               void *opaqueData ){   static int firstTime = 1;   (void)opaqueData; /* Get ride of compiler warning */   /* Add this function to the "ta_func_list.txt" */   genPrefix = 0;   fprintf( gOutFuncList_TXT->file, "%-20s%s\n", funcInfo->name, funcInfo->hint );     fprintf( gOutFunc_H->file, "\n" );   fprintf( gOutFunc_SWG->file, "\n" );   printf( "Processing [TA_%s]\n", funcInfo->name );   fprintf( gOutFunc_H->file, "/*\n" );   printFuncHeaderDoc( gOutFunc_H->file, funcInfo, " * " );   fprintf( gOutFunc_H->file, " */\n" );   fprintf( gOutFunc_SWG->file, "/*\n" );   printFuncHeaderDoc( gOutFunc_SWG->file, funcInfo, " * " );   fprintf( gOutFunc_SWG->file, " */\n" );   /* Generate the defines corresponding to this function. */   printDefines( gOutFunc_H->file, funcInfo );   printDefines( gOutFunc_SWG->file, funcInfo );   /* Generate the function prototype. */   printFunc( gOutFunc_H->file, NULL, funcInfo, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );   fprintf( gOutFunc_H->file, "\n" );   printFunc( gOutFunc_H->file, NULL, funcInfo, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 );   fprintf( gOutFunc_H->file, "\n" );   /* Generate the SWIG interface. */   printFunc( gOutFunc_SWG->file, NULL, funcInfo, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );   fprintf( gOutFunc_SWG->file, "\n" );   /* Generate the corresponding lookback function prototype. */   printFunc( gOutFunc_H->file, NULL, funcInfo, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );   printFunc( gOutFunc_SWG->file, NULL, funcInfo, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );   /* Create the frame definition (ta_frame.c) and declaration (ta_frame.h) */   genPrefix = 1;   printFrameHeader( gOutFrame_H->file, funcInfo, 0 );   fprintf( gOutFrame_H->file, ";\n" );   printFrameHeader( gOutFrame_H->file, funcInfo, 1 );   fprintf( gOutFrame_H->file, ";\n\n" );   printCallFrame( gOutFrame_C->file, funcInfo );   /* Add this function to the Makefile.am */   if( firstTime )      fprintf( gOutMakefile_AM->file, "\tta_%s.c", funcInfo->name );   else      fprintf( gOutMakefile_AM->file, " \\\n\tta_%s.c", funcInfo->name );      #ifdef _MSC_VER      /* Add the entry in the .NET project file. */      fprintf( gOutProjFile->file, "				<File\n" );      fprintf( gOutProjFile->file, "					RelativePath=\"..\\..\\..\\c\\src\\ta_func\\ta_%s.c\">\n", funcInfo->name );      fprintf( gOutProjFile->file, "					<FileConfiguration\n" );      fprintf( gOutProjFile->file, "						Name=\"Debug|Win32\">\n" );      fprintf( gOutProjFile->file, "						<Tool\n" );      fprintf( gOutProjFile->file, "							Name=\"VCCLCompilerTool\"\n" );      fprintf( gOutProjFile->file, "							AdditionalIncludeDirectories=\"\"\n" );      fprintf( gOutProjFile->file, "							UsePrecompiledHeader=\"0\"\n" );      fprintf( gOutProjFile->file, "							CompileAs=\"2\"/>\n" );      fprintf( gOutProjFile->file, "					</FileConfiguration>\n" );      fprintf( gOutProjFile->file, "					<FileConfiguration\n" );      fprintf( gOutProjFile->file, "						Name=\"Release|Win32\">\n" );      fprintf( gOutProjFile->file, "						<Tool\n" );      fprintf( gOutProjFile->file, "							Name=\"VCCLCompilerTool\"\n" );      fprintf( gOutProjFile->file, "							AdditionalIncludeDirectories=\"\"\n" );      fprintf( gOutProjFile->file, "							UsePrecompiledHeader=\"0\"\n" );      fprintf( gOutProjFile->file, "							CompileAs=\"2\"/>\n" );      fprintf( gOutProjFile->file, "					</FileConfiguration>\n" );      fprintf( gOutProjFile->file, "					<FileConfiguration\n" );      fprintf( gOutProjFile->file, "						Name=\"Debug SubArray|Win32\">\n" );      fprintf( gOutProjFile->file, "						<Tool\n" );      fprintf( gOutProjFile->file, "							Name=\"VCCLCompilerTool\"\n" );      fprintf( gOutProjFile->file, "							AdditionalIncludeDirectories=\"\"\n" );      fprintf( gOutProjFile->file, "							UsePrecompiledHeader=\"0\"\n" );      fprintf( gOutProjFile->file, "							CompileAs=\"2\"/>\n" );      fprintf( gOutProjFile->file, "					</FileConfiguration>\n" );      fprintf( gOutProjFile->file, "					<FileConfiguration\n" );      fprintf( gOutProjFile->file, "						Name=\"Release SubArray|Win32\">\n" );      fprintf( gOutProjFile->file, "						<Tool\n" );      fprintf( gOutProjFile->file, "							Name=\"VCCLCompilerTool\"\n" );      fprintf( gOutProjFile->file, "							AdditionalIncludeDirectories=\"\"\n" );      fprintf( gOutProjFile->file, "							UsePrecompiledHeader=\"0\"\n" );      fprintf( gOutProjFile->file, "							CompileAs=\"2\"/>\n" );      fprintf( gOutProjFile->file, "					</FileConfiguration>\n" );      fprintf( gOutProjFile->file, "				</File>\n" );      /* Add the entry in the MSVC project file. */      fprintf( gOutMSVCProjFile->file, "# Begin Source File\n" );      fprintf( gOutMSVCProjFile->file, "\n" );      fprintf( gOutMSVCProjFile->file, "SOURCE=..\\..\\..\\..\\src\\ta_func\\ta_%s.c\n", funcInfo->name );      fprintf( gOutMSVCProjFile->file, "# End Source File\n" );      /* Add the entry in the VS2005 project file. */	  printVS2005FileNode( gOutVS2005ProjFile->file, funcInfo->name );      /* Generate the excel glue code */      printExcelGlueCode( gOutExcelGlue_C->file, funcInfo );      /* Generate CoreAnnotated */      printJavaFunctionAnnotation( funcInfo );      /* Generate the functions declaration for the .NET interface. */      printFunc( gOutDotNet_H->file, NULL, funcInfo, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 );	  fprintf( gOutDotNet_H->file, "         #if defined( _MANAGED ) && defined( USE_SUBARRAY )\n" );   	  printFunc( gOutDotNet_H->file, NULL, funcInfo, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0 );	  fprintf( gOutDotNet_H->file, "\n" );	  printFunc( gOutDotNet_H->file, NULL, funcInfo, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 );	  fprintf( gOutDotNet_H->file, "         { return " );	  printFunc( gOutDotNet_H->file, NULL, funcInfo, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1 );	  fprintf( gOutDotNet_H->file, "         }\n" );	  fprintf( gOutDotNet_H->file, "         #elif defined( _MANAGED )\n" );	  printFunc( gOutDotNet_H->file, NULL, funcInfo, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 );	  fprintf( gOutDotNet_H->file, "         #endif\n" );	  printFunc( gOutDotNet_H->file, NULL, funcInfo, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0 );	  fprintf( gOutDotNet_H->file, "\n" );	  fprintf( gOutDotNet_H->file, "         #define TA_%s Core::%s\n", funcInfo->name, funcInfo->camelCaseName );	  fprintf( gOutDotNet_H->file, "         #define TA_%s_Lookback Core::%sLookback\n\n", funcInfo->name, funcInfo->camelCaseName );   #endif   doFuncFile( funcInfo );   #ifdef _MSC_VER      /* Run the func file through the pre-processor to generate the Java code. */      genJavaCodePhase2( funcInfo );      #endif   firstTime = 0;}static void doForEachUnstableFunction( const TA_FuncInfo *funcInfo,                                       void *opaqueData ){   unsigned int *i;   i = (unsigned int *)opaqueData;   if( funcInfo->flags & TA_FUNC_FLG_UNST_PER )   {      print( gOutDefs_H->file, "    /* %03d */  ENUM_DEFINE( TA_FUNC_UNST_%s, %s),\n", *i, funcInfo->name, funcInfo->camelCaseName );      (*i)++;   }}static void printDefines( FILE *out, const TA_FuncInfo *funcInfo ){   TA_RetCode retCode;   const TA_OptInputParameterInfo *optInputParamInfo;   unsigned int i, j;   unsigned int paramNb;   const char *paramName;   const char *defaultParamName;   TA_IntegerList *intList;   TA_RealList    *realList;   /* Go through the optional parameter and print    * the corresponding define for the TA_OptInput_IntegerList    * and TA_OptInput_RealList having a string.    */   paramNb = 0;   for( i=0; i < funcInfo->nbOptInput; i++ )   {      retCode = TA_GetOptInputParameterInfo( funcInfo->handle,                                             i, &optInputParamInfo );      if( retCode != TA_SUCCESS )      {         printf( "[%s] invalid 'optional input' information\n", funcInfo->name );         return;      }      paramName = optInputParamInfo->paramName;      /* TA_MA: Value for parameter */      switch( optInputParamInfo->type )      {      case TA_OptInput_RealList:         defaultParamName = "optInReal";         break;      case TA_OptInput_IntegerList:         defaultParamName = "optInInteger";         break;      default:         paramNb++;         continue; /* Skip other type of parameter */      }      if( !paramName )         paramName = defaultParamName;      /* Output a comment to guide the user. */         switch( optInputParamInfo->type )         {         case TA_OptInput_IntegerList:            intList = (TA_IntegerList *)optInputParamInfo->dataSet;            if( intList != (TA_IntegerList *)TA_DEF_UI_MA_Method.dataSet )            {               fprintf( out, "\n/* TA_%s: Optional Parameter %s */\n",                        funcInfo->name, paramName );               for( j=0; j < intList->nbElement; j++ )               {                  strcpy( gTempBuf, intList->data[j].string );                  cnvtChar( gTempBuf, ' ', '_' );                  trimWhitespace( gTempBuf );                  cnvtToUpperCase( gTempBuf );                  fprintf( out, "#define TA_%s_%s %d\n",                           funcInfo->name,                           gTempBuf,                           intList->data[j].value );               }               fprintf( out, "\n" );            }            break;         case TA_OptInput_RealList:            fprintf( out, "\n/* TA_%s: Optional Parameter %s */\n",                     funcInfo->name, paramName );            realList = (TA_RealList *)optInputParamInfo->dataSet;            for( j=0; j < realList->nbElement; j++ )            {               strcpy( gTempBuf, realList->data[j].string );               cnvtChar( gTempBuf, ' ', '_' );               trimWhitespace( gTempBuf );               cnvtToUpperCase( gTempBuf );               fprintf( out, "#define TA_%s_%s %s\n",                        funcInfo->name,                        gTempBuf,                        doubleToStr(realList->data[j].value) );            }            fprintf( out, "\n" );            break;         default:            /* Do nothing */            break;         }      paramNb++;   }}static void printFunc( FILE *out,                       const char *prefix, /* Can be NULL */                       const TA_FuncInfo *funcInfo,                       unsigned int prototype, /* Boolean */                       unsigned int frame,     /* Boolean */                       unsigned int semiColonNeeded, /* Boolean */                       unsigned int validationCode, /* Boolean */                       unsigned int lookbackSignature, /* Boolean */                       unsigned int managedCPPCode, /* Boolean */                       unsigned int managedCPPDeclaration, /* Boolean */                       unsigned int inputIsSinglePrecision, /* Boolean */                       unsigned int outputForSWIG, /* Boolean */                       unsigned int outputForJava, /* Boolean */                       unsigned int lookbackValidationCode, /* Boolean */					   unsigned int useSubArrayObject,      /* Boolean */					   unsigned int arrayToSubArrayCnvt     /* Boolean */                      ){   TA_RetCode retCode;   unsigned int i, j, k, lastParam;   int indent;   unsigned int paramNb;   const char *paramName;   const char *defaultParamName;   const TA_InputParameterInfo *inputParamInfo;   const TA_OptInputParameterInfo *optInputParamInfo;   const TA_OutputParameterInfo *outputParamInfo;   const char *typeString;   const char *inputDoubleArrayType;   const char *inputIntArrayType;   const char *outputDoubleArrayType;   const char *outputIntArrayType;   const char *outputIntParam;   const char *arrayBracket;   const char *funcName;   int excludeFromManaged;   int isMAType;   const char *startIdxString;   const char *endIdxString;   const char *outNbElementString;   const char *outBegIdxString;   char funcNameBuffer[1024]; /* Not safe, but 1024 is realistic, */   if( arrayToSubArrayCnvt )   {      inputIntArrayType     = " ";	  inputDoubleArrayType  = " ";      outputDoubleArrayType = " ";      outputIntArrayType    = " ";      outputIntParam        = " ";      arrayBracket          = " ";      startIdxString        = "startIdx";      endIdxString          = "endIdx";      outNbElementString    = "outNBElement";      outBegIdxString       = "outBegIdx";      funcName              = funcInfo->camelCaseName;   }   else if( managedCPPCode )   {	  if( inputIsSinglePrecision )	  {          inputDoubleArrayType  = "cli::array<float>^";	  }	  else	  {		  inputDoubleArrayType  = useSubArrayObject? "SubArray^":"cli::array<double>^";         	  }      inputIntArrayType     = "cli::array<int>^";      outputDoubleArrayType = "cli::array<double>^";      outputIntArrayType    = "cli::array<int>^";      outputIntParam        = "[Out]int%";      arrayBracket          = "";      startIdxString        = "startIdx";      endIdxString          = "endIdx";      outNbElementString    = "outNBElement";      outBegIdxString       = "outBegIdx";      funcName              = funcInfo->camelCaseName;   }   else if( outputForSWIG )   {      if( inputIsSinglePrecision )         inputDoubleArrayType  = "const float  *";      el

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -