home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / ML / FUNC.C < prev    next >
C/C++ Source or Header  |  1995-03-20  |  2KB  |  82 lines

  1. /*
  2.  *        関数の管理
  3.  *
  4.  *        1994.5.21        T.Koabayashi
  5.  */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <assert.h>
  10.  
  11. #include "data.h"
  12. #include "err.h"
  13.  
  14. #include "inlib.h"
  15.  
  16. /*    関数用バッファの初期化    */
  17. FuncBuffer    *FunctionAlloc( funcs )
  18. int            funcs ;
  19. {
  20.     int            i ;
  21.     FuncBuffer    *func ;
  22.  
  23.     func = MemoryAlloc( funcs * sizeof( FuncBuffer ) );
  24.     if ( func == NULL )
  25.     {
  26.         ParseFatal( "関数管理バッファが確保できません" );
  27.         return NULL ;
  28.     }
  29.     for( i = 0 ; i < funcs ; i++ )
  30.     {
  31.         func[i].type = FUNC_NO ;
  32.     }
  33.     return func ;
  34. }
  35.  
  36. void    FunctionFree( func )
  37. FuncBuffer    *func ;
  38. {
  39.     MemoryFree( func );
  40. }
  41.  
  42. /*    組み込み関数の設定    */
  43. int        FunctionSet( id, name, ptr )
  44. int        id ;
  45. char    *name ;
  46. int        (*ptr)();
  47. {
  48.     int        ident ;
  49.     FuncBuffer    *func ;
  50.  
  51.     assert( 0 <= id && id < MAX_CLASS && ClassList[id].name != NULL );
  52.     func = ClassList[id].func ;
  53.  
  54.     ident = IdentSearch( IdentFunction, name );
  55.     if ( ident < 0 )
  56.         ident = IdentAppend( IdentFunction, name, IDENT_FUNC );
  57.     if ( ident >= ClassList[id].funcs )
  58.         ParseFatal( "新しいメンバー関数が登録できません。" );
  59.  
  60.     func[ident].type = FUNC_SYS ;
  61.     func[ident].name = name ;
  62.     func[ident].ptr = ptr ;
  63.     
  64.     return ident ;
  65. }
  66.  
  67. /*    演算子の設定    */
  68. void    OperatorSet( id, ident, ptr )
  69. int        id ;
  70. int        ident ;
  71. int        (*ptr)();
  72. {
  73.     FuncBuffer    *func ;
  74.  
  75.     assert( 0 <= id && id < MAX_CLASS && ClassList[id].name != NULL );
  76.     func = ClassList[id].func ;
  77.  
  78.     func[ident].type = FUNC_SYS ;
  79.     func[ident].name = "" ;
  80.     func[ident].ptr = ptr ;
  81. }
  82.