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

📄 gen_code.c

📁 股票主要技术指标源码
💻 C
📖 第 1 页 / 共 5 页
字号:
   #define FILE_CORE_JAVA_TMP "..\\temp\\CoreJava.tmp"   #define FILE_CORE_JAVA_UNF "..\\temp\\CoreJavaUnformated.tmp"   gOutCore_Java = fileOpen( FILE_CORE_JAVA, NULL, FILE_READ );   if( gOutCore_Java == NULL )      {         printf( "\nCannot access [%s]\n", gToOpen );         return -1;   }   tempFile = fileOpen( FILE_CORE_JAVA_TMP, NULL, FILE_WRITE|WRITE_ALWAYS );   if( tempFile == NULL )   {         printf( "Cannot create temporary Core.java project file!\n" );         return -1;   }   if( createTemplate( gOutCore_Java, tempFile ) != 0 )   {         printf( "Failed to parse and write the temporary Core.java project file!\n" );         return -1;   }   fileClose(gOutCore_Java);   fileClose(tempFile);   #endif   /* Create the .NET interface file template */   #ifdef _MSC_VER   #define FILE_NET_HEADER     "..\\..\\dotnet\\src\\Core\\TA-Lib-Core.h"   #define FILE_NET_HEADER_TMP "..\\temp\\dotneth.tmp"   gOutDotNet_H = fileOpen( FILE_NET_HEADER, NULL, FILE_READ );   if( gOutDotNet_H == NULL )      {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   tempFile = fileOpen( FILE_NET_HEADER_TMP, NULL, FILE_WRITE|WRITE_ALWAYS );   if( tempFile == NULL )   {      printf( "Cannot create temporary .NET header file!\n" );      return -1;   }   if( createTemplate( gOutDotNet_H, tempFile ) != 0 )   {      printf( "Failed to parse and write the temporary .NET header file!\n" );      return -1;   }   fileClose(gOutDotNet_H);   fileClose(tempFile);   #endif   /* Create ta_retcode.c */   if( gen_retcode() != 0 )   {      printf( "\nCannot generate src/ta_common/ta_retcode.c\n" );      return -1;   }   /* Create "ta_func.h" */   gOutFunc_H = fileOpen( "..\\include\\ta_func.h",                          "..\\src\\ta_abstract\\templates\\ta_func.h.template",                          FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutFunc_H == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   gOutFunc_XML = fileOpen( "..\\..\\ta_func_api.xml", NULL, FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if(gOutFunc_XML == NULL)   {	   printf( "\nCannot access ta_func_api.xml" );   }   /* Create "ta_func.swg" */   gOutFunc_SWG = fileOpen( "..\\..\\swig\\src\\interface\\ta_func.swg",                          "..\\src\\ta_abstract\\templates\\ta_func.swg.template",                          FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutFunc_SWG == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   /* Create the "ta_func_list.txt" */   gOutFuncList_TXT = fileOpen( "..\\..\\ta_func_list.txt",                                NULL,                                FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutFuncList_TXT == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   /* Create the "ta_frame.h" */   gOutFrame_H = fileOpen( "..\\src\\ta_abstract\\frames\\ta_frame.h",                           "..\\src\\ta_abstract\\templates\\ta_frame.h.template",                           FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutFrame_H == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   /* Create the "ta_frame.c" */   gOutFrame_C = fileOpen( "..\\src\\ta_abstract\\frames\\ta_frame.c",                           "..\\src\\ta_abstract\\templates\\ta_frame.c.template",                           FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutFrame_C == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   /* Create the "Makefile.am" */   gOutMakefile_AM = fileOpen( "..\\src\\ta_func\\Makefile.am",                               "..\\src\\ta_abstract\\templates\\Makefile.am.template",                               FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutMakefile_AM == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   #ifdef _MSC_VER      /* Create "excel_glue.c" */      gOutExcelGlue_C = fileOpen( "..\\src\\ta_abstract\\excel_glue.c",                              "..\\src\\ta_abstract\\templates\\excel_glue.c.template",                              FILE_WRITE|WRITE_ON_CHANGE_ONLY );      if( gOutExcelGlue_C == NULL )      {         printf( "\nCannot access [%s]\n", gToOpen );         return -1;      }      /* Create "java_defs.h" */      gOutJavaDefs_H = fileOpen( "..\\src\\ta_abstract\\ta_java_defs.h",                             "..\\src\\ta_abstract\\templates\\ta_java_defs.h.template",                             FILE_WRITE|WRITE_ON_CHANGE_ONLY );                                    if( gOutJavaDefs_H == NULL )      {         printf( "\nCannot access [%s]\n", gToOpen );         return -1;      }      /* Re-open the .NET project template. */      gOutProjFile = fileOpen( FILE_NET_PROJ, FILE_NET_PROJ_TMP, FILE_WRITE|WRITE_ON_CHANGE_ONLY );      if( gOutProjFile == NULL )      {         printf( "Cannot update [%s]\n", FILE_NET_PROJ );         return -1;      }      /* Re-open the MSVC project template. */      gOutMSVCProjFile = fileOpen( FILE_MSVC_PROJ, FILE_MSVC_PROJ_TMP, FILE_WRITE|WRITE_ON_CHANGE_ONLY );      if( gOutMSVCProjFile == NULL )      {         printf( "Cannot update [%s]\n", FILE_MSVC_PROJ );         return -1;      }      /* Re-open the VS2005 project template. */      gOutVS2005ProjFile = fileOpen( FILE_VS2005_PROJ, FILE_VS2005_PROJ_TMP, FILE_WRITE|WRITE_ON_CHANGE_ONLY );      if( gOutVS2005ProjFile == NULL )      {         printf( "Cannot update [%s]\n", FILE_VS2005_PROJ );         return -1;      }      /* Create "CoreAnnotated.java" */      gOutFunc_Annotation = fileOpen( "..\\..\\java\\src\\com\\tictactec\\ta\\lib\\CoreAnnotated.java",                                      "..\\src\\ta_abstract\\templates\\CoreAnnotated.java.template",                                       FILE_WRITE|WRITE_ON_CHANGE_ONLY );      if(gOutFunc_Annotation == NULL)      {	      printf( "\nCannot access CoreAnnotated.java" );      }   #endif   #ifdef _MSC_VER   /* Re-open the Core.java template. */   gOutCore_Java = fileOpen( FILE_CORE_JAVA_UNF, FILE_CORE_JAVA_TMP, FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutCore_Java == NULL )   {      printf( "Cannot update [%s]\n", FILE_CORE_JAVA_UNF );      return -1;   }   #endif   /* Re-open the .NET interface template. */   #ifdef _MSC_VER   gOutDotNet_H = fileOpen( FILE_NET_HEADER, FILE_NET_HEADER_TMP, FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutDotNet_H == NULL )   {      printf( "Cannot update [%s]\n", FILE_NET_HEADER );      return -1;   }   #endif   /* Process each functions. Two phase. */   TA_ForEachFunc( doForEachFunctionPhase1, NULL );   TA_ForEachFunc( doForEachFunctionPhase2, NULL );   /* Leave empty line for Makefile.am */   fprintf( gOutMakefile_AM->file, "\n" );   /* Seperate generation of xml description file */   fprintf(gOutFunc_XML->file, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");   fprintf(gOutFunc_XML->file, "<FinancialFunctions>\n");   retCode = TA_ForEachFunc( doForEachFunctionXml, NULL );   fprintf(gOutFunc_XML->file, "</FinancialFunctions>\n");   /* Append some "hard coded" prototype for ta_func */   appendToFunc( gOutFunc_H->file );   appendToFunc( gOutFunc_SWG->file );   /* Close all files who were updated with the list of TA functions. */   fileClose( gOutFuncList_TXT );   fileClose( gOutFunc_H );   fileClose( gOutFunc_SWG );   fileClose( gOutFrame_H );   fileClose( gOutFrame_C );   fileClose( gOutFunc_XML );   fileClose( gOutMakefile_AM );   #ifdef _MSC_VER      fileClose( gOutDotNet_H );      fileClose( gOutCore_Java );      fileClose( gOutProjFile );      fileClose( gOutMSVCProjFile );      fileClose( gOutVS2005ProjFile );      fileClose( gOutExcelGlue_C );      fileClose( gOutJavaDefs_H );      fileClose( gOutFunc_Annotation );      fileDelete( FILE_CORE_JAVA_TMP );   #endif   if( retCode != TA_SUCCESS )   {      printf( "Failed [%d]\n", retCode );      return -1;   }   /* Create the "ta_group_idx.c" file. */   genPrefix = 1;   gOutGroupIdx_C = fileOpen( "..\\src\\ta_abstract\\ta_group_idx.c",                              "..\\src\\ta_abstract\\templates\\ta_group_idx.c.template",                              FILE_WRITE|WRITE_ON_CHANGE_ONLY );   if( gOutGroupIdx_C == NULL )   {      printf( "\nCannot access [%s]\n", gToOpen );      return -1;   }   retCode = TA_ForEachFunc( printExternReferenceForEachFunction, NULL );   if( retCode != TA_SUCCESS )   {      fileClose( gOutGroupIdx_C );      return -1;   }   nbGroup = forEachGroup( printPerGroupList, NULL );   print( gOutGroupIdx_C->file, "const TA_FuncDef **TA_PerGroupFuncDef[%d] = {\n", nbGroup );   forEachGroup( printGroupListAddress, NULL );   print( gOutGroupIdx_C->file, "};\n\n" );   print( gOutGroupIdx_C->file, "const unsigned int TA_PerGroupSize[%d] = {\n", nbGroup );   forEachGroup( printGroupSize, NULL );   print( gOutGroupIdx_C->file, "};\n\n" );   print( gOutGroupIdx_C->file, "const unsigned int TA_TotalNbFunction =\n" );   forEachGroup( printGroupSizeAddition, NULL );   fileClose( gOutGroupIdx_C );   genPrefix = 0;   /* Update "ta_defs.h" */   doDefsFile();    /* Convert the xml description file into a format embedded in the library. */   if( generateFuncAPI_C() != 1 )   {      return -1; /*  Failed. */   }   /* Run Java Post-Processing.       * On Success, the Java program create a file named "java_success".     */   #ifndef _MSC_VER         printf( "\nWarning: Java code update supported only for MSVC compiler for now.\n" );   #else      printf( "\nPost-Processing Java Code\n" );      #define JAVA_SUCCESS_FILE     "..\\temp\\java_success"      #define JAVA_PRETTY_TEMP_FILE "..\\temp\\CoreJavaPretty.tmp"      fileDelete( JAVA_SUCCESS_FILE );            system( "javac -cp . -d . \"..\\src\\tools\\gen_code\\java\\PrettyCode.java" );      system( "javac -cp . -d . \"..\\src\\tools\\gen_code\\java\\Main.java" );      system( "java -cp . Main" );      tempFile = fileOpen(JAVA_SUCCESS_FILE,NULL,FILE_READ );      fileDelete( FILE_CORE_JAVA_UNF );      if( tempFile == NULL )      {                           printf( "\nWarning: Java code NOT updated.\n" );      }      else      {         fileClose( tempFile );         /* Java processing done. Overwrite the original Core.java ONLY if there          * is changes (re-use fileOpen/fileClose even if not efficient).          */         tempFile = fileOpen( JAVA_PRETTY_TEMP_FILE, NULL, FILE_READ );         tempFileOut = fileOpen( FILE_CORE_JAVA, NULL,                                 FILE_WRITE|WRITE_ON_CHANGE_ONLY );         if( (tempFile == NULL) || (tempFileOut == NULL) )         {            printf( "\nError: Java code update failed.\n" );            return -1;         }         else         {                        while( fgets( gTempBuf, BUFFER_SIZE, tempFile->file ) )               fputs(gTempBuf,tempFileOut->file);                        fileClose(tempFile);            fileClose(tempFileOut);         }            }      fileDelete( JAVA_SUCCESS_FILE );      fileDelete( JAVA_PRETTY_TEMP_FILE );   #endif   /* Remove temporary files. */   #ifdef _MSC_VER         fileDelete( FILE_NET_PROJ_TMP );      fileDelete( FILE_MSVC_PROJ_TMP );      fileDelete( FILE_NET_HEADER_TMP );      #endif   printf( "\n** Update completed with success **\n");   return 0;}static unsigned int forEachGroup( TA_ForEachGroup forEachGroupFunc,                                  void *opaqueData ){   TA_RetCode retCode;   TA_StringTable *table;   unsigned int i;      (void)opaqueData; /* Get ride of compiler warning */   retCode = TA_GroupTableAlloc( &table );   if( retCode != TA_SUCCESS )      return 0;   for( i=0; i < table->size; i++ )

⌨️ 快捷键说明

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