home *** CD-ROM | disk | FTP | other *** search
/ NeXT 3rd Party Products 1993 / NEXT_3rd_party_products_93.iso / Xanthus / Graphity_Demo / API / Demo3 / Graphity_APIListener.m < prev    next >
Text File  |  1993-05-07  |  11KB  |  467 lines

  1. #import <appkit/appkit.h>
  2. #import "Graphity_APIListener.h"
  3. #import <mach/mach.h>
  4. #import <mach/message.h>
  5. #import <servers/netname.h>
  6. extern port_t name_server_port;
  7. extern id NXResponsibleDelegate();
  8. @implementation  Graphity_APIListener :Listener
  9. {}
  10. static NXRemoteMethod *remoteMethods = NULL;
  11. #define REMOTEMETHODS 17
  12. + initialize 
  13. /* */
  14. {
  15.     if (!remoteMethods) {
  16.     remoteMethods =
  17.     (NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
  18.     remoteMethods[0].key = 
  19.     @selector(API_setValueAtRow:serie:to:for:in:display:error:);
  20.     remoteMethods[0].types = "iidcciI";
  21.     remoteMethods[1].key = 
  22.     @selector(API_setLabelAt:to:for:in:display:error:);
  23.     remoteMethods[1].types = "iccciI";
  24.     remoteMethods[2].key = 
  25.     @selector(API_setSerieTitleFor:to:for:in:display:error:);
  26.     remoteMethods[2].types = "iccciI";
  27.     remoteMethods[3].key = 
  28.     @selector(API_redisplay:in:error:);
  29.     remoteMethods[3].types = "ccI";
  30.     remoteMethods[4].key = 
  31.     @selector(API_recalculate:in:error:);
  32.     remoteMethods[4].types = "ccI";
  33.     remoteMethods[5].key = 
  34.     @selector(API_newDocument:error:);
  35.     remoteMethods[5].types = "cI";
  36.     remoteMethods[6].key = 
  37.     @selector(API_saveDocument:type:to:error:);
  38.     remoteMethods[6].types = "cicI";
  39.     remoteMethods[7].key = 
  40.     @selector(API_shapeDocument:x:y:width:height:error:);
  41.     remoteMethods[7].types = "cddddI";
  42.     remoteMethods[8].key = 
  43.     @selector(API_closeDocument:warn:error:);
  44.     remoteMethods[8].types = "ciI";
  45.     remoteMethods[9].key = 
  46.     @selector(API_openDocument:type:error:);
  47.     remoteMethods[9].types = "ciI";
  48.     remoteMethods[10].key = 
  49.     @selector(API_addGraph:with:in:error:);
  50.     remoteMethods[10].types = "iccI";
  51.     remoteMethods[11].key = 
  52.     @selector(API_addSerie:for:in:error:);
  53.     remoteMethods[11].types = "cccI";
  54.     remoteMethods[12].key = 
  55.     @selector(API_addRow:for:in:error:);
  56.     remoteMethods[12].types = "cccI";
  57.     remoteMethods[13].key = 
  58.     @selector(API_shapeGraph:in:x:y:width:height:error:);
  59.     remoteMethods[13].types = "ccddddI";
  60.     remoteMethods[14].key = 
  61.     @selector(API_setGraphTypeFor:in:to:error:);
  62.     remoteMethods[14].types = "cciI";
  63.     remoteMethods[15].key = 
  64.     @selector(API_readDataFrom:graph:in:error:);
  65.     remoteMethods[15].types = "cccI";
  66.     remoteMethods[16].key = 
  67.     @selector(API_getGraphSize:in:rowCount:serieCount:error:);
  68.     remoteMethods[16].types = "ccIII";
  69.     remoteMethods[REMOTEMETHODS].key = NULL;
  70.     }
  71.     return self;
  72. }
  73. -(int)API_setValueAtRow : (int) row
  74.     serie : (int) serie
  75.     to : (double) v
  76.     for : (char *) name
  77.     in : (char *) doc
  78.     display : (int) display
  79.     error : (int *) error
  80. /* */
  81. {
  82.     id _NXd;
  83.     if (_NXd = NXResponsibleDelegate(self,
  84.     @selector(API_setValueAtRow:serie:to:for:in:display:error:)))
  85.     return [_NXd API_setValueAtRow : row
  86.         serie : serie
  87.         to : v
  88.         for : name
  89.         in : doc
  90.         display : display
  91.         error : error];
  92.     return -1;
  93. }
  94.  
  95. -(int)API_setLabelAt : (int) row
  96.     to : (char *) label
  97.     for : (char *) name
  98.     in : (char *) doc
  99.     display : (int) display
  100.     error : (int *) error
  101. /* */
  102. {
  103.     id _NXd;
  104.     if (_NXd = NXResponsibleDelegate(self,
  105.     @selector(API_setLabelAt:to:for:in:display:error:)))
  106.     return [_NXd API_setLabelAt : row
  107.         to : label
  108.         for : name
  109.         in : doc
  110.         display : display
  111.         error : error];
  112.     return -1;
  113. }
  114.  
  115. -(int)API_setSerieTitleFor : (int) serie
  116.     to : (char *) label
  117.     for : (char *) name
  118.     in : (char *) doc
  119.     display : (int) display
  120.     error : (int *) error
  121. /* */
  122. {
  123.     id _NXd;
  124.     if (_NXd = NXResponsibleDelegate(self,
  125.     @selector(API_setSerieTitleFor:to:for:in:display:error:)))
  126.     return [_NXd API_setSerieTitleFor : serie
  127.         to : label
  128.         for : name
  129.         in : doc
  130.         display : display
  131.         error : error];
  132.     return -1;
  133. }
  134.  
  135. -(int)API_redisplay : (char *) name
  136.     in : (char *) doc
  137.     error : (int *) error
  138. /* */
  139. {
  140.     id _NXd;
  141.     if (_NXd = NXResponsibleDelegate(self,
  142.     @selector(API_redisplay:in:error:)))
  143.     return [_NXd API_redisplay : name
  144.         in : doc
  145.         error : error];
  146.     return -1;
  147. }
  148.  
  149. -(int)API_recalculate : (char *) name
  150.     in : (char *) doc
  151.     error : (int *) error
  152. /* */
  153. {
  154.     id _NXd;
  155.     if (_NXd = NXResponsibleDelegate(self,
  156.     @selector(API_recalculate:in:error:)))
  157.     return [_NXd API_recalculate : name
  158.         in : doc
  159.         error : error];
  160.     return -1;
  161. }
  162.  
  163. -(int)API_newDocument : (char *) name
  164.     error : (int *) error
  165. /* */
  166. {
  167.     id _NXd;
  168.     if (_NXd = NXResponsibleDelegate(self,
  169.     @selector(API_newDocument:error:)))
  170.     return [_NXd API_newDocument : name
  171.         error : error];
  172.     return -1;
  173. }
  174.  
  175. -(int)API_saveDocument : (char *) name
  176.     type : (int) type
  177.     to : (char *) path
  178.     error : (int *) error
  179. /* */
  180. {
  181.     id _NXd;
  182.     if (_NXd = NXResponsibleDelegate(self,
  183.     @selector(API_saveDocument:type:to:error:)))
  184.     return [_NXd API_saveDocument : name
  185.         type : type
  186.         to : path
  187.         error : error];
  188.     return -1;
  189. }
  190.  
  191. -(int)API_shapeDocument : (char *) name
  192.     x : (double) x
  193.     y : (double) y
  194.     width : (double) w
  195.     height : (double) h
  196.     error : (int *) error
  197. /* */
  198. {
  199.     id _NXd;
  200.     if (_NXd = NXResponsibleDelegate(self,
  201.     @selector(API_shapeDocument:x:y:width:height:error:)))
  202.     return [_NXd API_shapeDocument : name
  203.         x : x
  204.         y : y
  205.         width : w
  206.         height : h
  207.         error : error];
  208.     return -1;
  209. }
  210.  
  211. -(int)API_closeDocument : (char *) name
  212.     warn : (int) warn
  213.     error : (int *) error
  214. /* */
  215. {
  216.     id _NXd;
  217.     if (_NXd = NXResponsibleDelegate(self,
  218.     @selector(API_closeDocument:warn:error:)))
  219.     return [_NXd API_closeDocument : name
  220.         warn : warn
  221.         error : error];
  222.     return -1;
  223. }
  224.  
  225. -(int)API_openDocument : (char *) path
  226.     type : (int) type
  227.     error : (int *) error
  228. /* */
  229. {
  230.     id _NXd;
  231.     if (_NXd = NXResponsibleDelegate(self,
  232.     @selector(API_openDocument:type:error:)))
  233.     return [_NXd API_openDocument : path
  234.         type : type
  235.         error : error];
  236.     return -1;
  237. }
  238.  
  239. -(int)API_addGraph : (int) type
  240.     with : (char *) name
  241.     in : (char *) doc
  242.     error : (int *) error
  243. /* */
  244. {
  245.     id _NXd;
  246.     if (_NXd = NXResponsibleDelegate(self,
  247.     @selector(API_addGraph:with:in:error:)))
  248.     return [_NXd API_addGraph : type
  249.         with : name
  250.         in : doc
  251.         error : error];
  252.     return -1;
  253. }
  254.  
  255. -(int)API_addSerie : (char *) title
  256.     for : (char *) name
  257.     in : (char *) doc
  258.     error : (int *) error
  259. /* */
  260. {
  261.     id _NXd;
  262.     if (_NXd = NXResponsibleDelegate(self,
  263.     @selector(API_addSerie:for:in:error:)))
  264.     return [_NXd API_addSerie : title
  265.         for : name
  266.         in : doc
  267.         error : error];
  268.     return -1;
  269. }
  270.  
  271. -(int)API_addRow : (char *) label
  272.     for : (char *) name
  273.     in : (char *) doc
  274.     error : (int *) error
  275. /* */
  276. {
  277.     id _NXd;
  278.     if (_NXd = NXResponsibleDelegate(self,
  279.     @selector(API_addRow:for:in:error:)))
  280.     return [_NXd API_addRow : label
  281.         for : name
  282.         in : doc
  283.         error : error];
  284.     return -1;
  285. }
  286.  
  287. -(int)API_shapeGraph : (char *) name
  288.     in : (char *) doc
  289.     x : (double) x
  290.     y : (double) y
  291.     width : (double) w
  292.     height : (double) h
  293.     error : (int *) error
  294. /* */
  295. {
  296.     id _NXd;
  297.     if (_NXd = NXResponsibleDelegate(self,
  298.     @selector(API_shapeGraph:in:x:y:width:height:error:)))
  299.     return [_NXd API_shapeGraph : name
  300.         in : doc
  301.         x : x
  302.         y : y
  303.         width : w
  304.         height : h
  305.         error : error];
  306.     return -1;
  307. }
  308.  
  309. -(int)API_setGraphTypeFor : (char *) name
  310.     in : (char *) doc
  311.     to : (int) type
  312.     error : (int *) error
  313. /* */
  314. {
  315.     id _NXd;
  316.     if (_NXd = NXResponsibleDelegate(self,
  317.     @selector(API_setGraphTypeFor:in:to:error:)))
  318.     return [_NXd API_setGraphTypeFor : name
  319.         in : doc
  320.         to : type
  321.         error : error];
  322.     return -1;
  323. }
  324.  
  325. -(int)API_readDataFrom : (char *) file
  326.     graph : (char *) name
  327.     in : (char *) docname
  328.     error : (int *) error
  329. /* */
  330. {
  331.     id _NXd;
  332.     if (_NXd = NXResponsibleDelegate(self,
  333.     @selector(API_readDataFrom:graph:in:error:)))
  334.     return [_NXd API_readDataFrom : file
  335.         graph : name
  336.         in : docname
  337.         error : error];
  338.     return -1;
  339. }
  340.  
  341. -(int)API_getGraphSize : (char *) name
  342.     in : (char *) docname
  343.     rowCount : (int *) rowCount
  344.     serieCount : (int *) serieCount
  345.     error : (int *) error
  346. /* */
  347. {
  348.     id _NXd;
  349.     if (_NXd = NXResponsibleDelegate(self,
  350.     @selector(API_getGraphSize:in:rowCount:serieCount:error:)))
  351.     return [_NXd API_getGraphSize : name
  352.         in : docname
  353.         rowCount : rowCount
  354.         serieCount : serieCount
  355.         error : error];
  356.     return -1;
  357. }
  358.  
  359. - (int) performRemoteMethod : (NXRemoteMethod *) method
  360.                   paramList : (NXParamValue *) paramList {
  361. /* */
  362.     switch (method - remoteMethods) {
  363.     case 0:
  364.     return [self API_setValueAtRow : paramList[0].ival
  365.         serie : paramList[1].ival
  366.         to : paramList[2].dval
  367.         for : paramList[3].bval.p
  368.         in : paramList[4].bval.p
  369.         display : paramList[5].ival
  370.         error : ¶mList[6].ival];
  371.     case 1:
  372.     return [self API_setLabelAt : paramList[0].ival
  373.         to : paramList[1].bval.p
  374.         for : paramList[2].bval.p
  375.         in : paramList[3].bval.p
  376.         display : paramList[4].ival
  377.         error : ¶mList[5].ival];
  378.     case 2:
  379.     return [self API_setSerieTitleFor : paramList[0].ival
  380.         to : paramList[1].bval.p
  381.         for : paramList[2].bval.p
  382.         in : paramList[3].bval.p
  383.         display : paramList[4].ival
  384.         error : ¶mList[5].ival];
  385.     case 3:
  386.     return [self API_redisplay : paramList[0].bval.p
  387.         in : paramList[1].bval.p
  388.         error : ¶mList[2].ival];
  389.     case 4:
  390.     return [self API_recalculate : paramList[0].bval.p
  391.         in : paramList[1].bval.p
  392.         error : ¶mList[2].ival];
  393.     case 5:
  394.     return [self API_newDocument : paramList[0].bval.p
  395.         error : ¶mList[1].ival];
  396.     case 6:
  397.     return [self API_saveDocument : paramList[0].bval.p
  398.         type : paramList[1].ival
  399.         to : paramList[2].bval.p
  400.         error : ¶mList[3].ival];
  401.     case 7:
  402.     return [self API_shapeDocument : paramList[0].bval.p
  403.         x : paramList[1].dval
  404.         y : paramList[2].dval
  405.         width : paramList[3].dval
  406.         height : paramList[4].dval
  407.         error : ¶mList[5].ival];
  408.     case 8:
  409.     return [self API_closeDocument : paramList[0].bval.p
  410.         warn : paramList[1].ival
  411.         error : ¶mList[2].ival];
  412.     case 9:
  413.     return [self API_openDocument : paramList[0].bval.p
  414.         type : paramList[1].ival
  415.         error : ¶mList[2].ival];
  416.     case 10:
  417.     return [self API_addGraph : paramList[0].ival
  418.         with : paramList[1].bval.p
  419.         in : paramList[2].bval.p
  420.         error : ¶mList[3].ival];
  421.     case 11:
  422.     return [self API_addSerie : paramList[0].bval.p
  423.         for : paramList[1].bval.p
  424.         in : paramList[2].bval.p
  425.         error : ¶mList[3].ival];
  426.     case 12:
  427.     return [self API_addRow : paramList[0].bval.p
  428.         for : paramList[1].bval.p
  429.         in : paramList[2].bval.p
  430.         error : ¶mList[3].ival];
  431.     case 13:
  432.     return [self API_shapeGraph : paramList[0].bval.p
  433.         in : paramList[1].bval.p
  434.         x : paramList[2].dval
  435.         y : paramList[3].dval
  436.         width : paramList[4].dval
  437.         height : paramList[5].dval
  438.         error : ¶mList[6].ival];
  439.     case 14:
  440.     return [self API_setGraphTypeFor : paramList[0].bval.p
  441.         in : paramList[1].bval.p
  442.         to : paramList[2].ival
  443.         error : ¶mList[3].ival];
  444.     case 15:
  445.     return [self API_readDataFrom : paramList[0].bval.p
  446.         graph : paramList[1].bval.p
  447.         in : paramList[2].bval.p
  448.         error : ¶mList[3].ival];
  449.     case 16:
  450.     return [self API_getGraphSize : paramList[0].bval.p
  451.         in : paramList[1].bval.p
  452.         rowCount : ¶mList[2].ival
  453.         serieCount : ¶mList[3].ival
  454.         error : ¶mList[4].ival];
  455.     default:
  456.     return [super performRemoteMethod : method paramList : paramList];
  457.     }
  458. }
  459. - (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
  460. /* */
  461.     NXRemoteMethod *rm;
  462.     if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
  463.         return rm;
  464.     return [super remoteMethodFor : aSel];
  465. }
  466. @end
  467.