#import <appkit/appkit.h>
#import "Questor_API_Demo1Listener.h"
#import <mach.h>
#import <sys/message.h>
#import <servers/netname.h>
extern port_t name_server_port;
extern id NXResponsibleDelegate();
@implementation  Questor_API_Demo1Listener :Listener
{}
static NXRemoteMethod *remoteMethods = NULL;
#define REMOTEMETHODS 2
+ (void)initialize 
/* */
{
    if (!remoteMethods) {
	remoteMethods =
	(NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
	remoteMethods[0].key = 
	@selector(addA:andB:to:);
	remoteMethods[0].types = "iiI";
	remoteMethods[1].key = 
	@selector(questorData:len:fromRow:fromCol:toRow:toCol:sheet:ok:);
	remoteMethods[1].types = "biiiicI";
	remoteMethods[REMOTEMETHODS].key = NULL;
    }
}
-(int)addA : (int) a
	andB : (int) b
	to : (int *) c
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(addA:andB:to:)))
	return [_NXd addA : a
		andB : b
		to : c];
    return -1;
}

-(int)questorData : (char *) buf
	len : (int) len
	fromRow : (int) fromRow
	fromCol : (int) fromCol
	toRow : (int) toRow
	toCol : (int) toCol
	sheet : (char *) path
	ok : (int *) ok
/* */
{
    id _NXd;
    if (_NXd = NXResponsibleDelegate(self,
	@selector(questorData:len:fromRow:fromCol:toRow:toCol:sheet:ok:)))
	return [_NXd questorData : buf
		len : len
		fromRow : fromRow
		fromCol : fromCol
		toRow : toRow
		toCol : toCol
		sheet : path
		ok : ok];
    return -1;
}

- (int) performRemoteMethod : (NXRemoteMethod *) method
                  paramList : (NXParamValue *) paramList {
/* */
    switch (method - remoteMethods) {
    case 0:
	return [self addA : paramList[0].ival
		andB : paramList[1].ival
		to : &paramList[2].ival];
    case 1:
	return [self questorData : paramList[0].bval.p
		len : paramList[0].bval.len
		fromRow : paramList[1].ival
		fromCol : paramList[2].ival
		toRow : paramList[3].ival
		toCol : paramList[4].ival
		sheet : paramList[5].bval.p
		ok : &paramList[6].ival];
    default:
	return [super performRemoteMethod : method paramList : paramList];
    }
}
- (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
/* */
    NXRemoteMethod *rm;
    if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
        return rm;
    return [super remoteMethodFor : aSel];
}
@end
