HowTo:Contribute a CoCoA 4 function that calls the CoCoAServer

From CoCoAWiki
Jump to: navigation, search

This article is intended to give contributors a rough overview of the process of creating a new CoCoA 4 function that makes use of the CoCoAServer. There is a CoCoA 4 part and a CoCoAServer part.

CoCoA 4 part

Create a new package file and place your function inside of it. Use the following skeleton package file if unsure how to do this:

Package $mypackage -- New package name

Define MyFunction5(Operand, Info5) -- New function
  -- Insert your function code here

  -- Use "MyComputationIdentifer" within CoCoAServer.C to identify
  -- your function call
  Computation := "MyComputationIdentifier"; 

  -- Look at the code in "cocoa5.cpkg" for the meaning of "Info5" or leave
  -- it empty
  Info5 := Record();

  -- Actually call CoCoAServer and return its output;
  -- see text below for more details
  Return $cocoa5.OperationCommunication(Operand, Computation, Info5);
  -- Return $cocoa5.OperationCommunication(Operand1, Operand2, Computation, Info5);


Communication with the CoCoAServer is covered by the "cocoa5.cpkg" package. The main interface is the "$cocoa5.OperationCommunication(...)" function. To find out what types of operands you can pass to "$cocoa5.OperationCommunication(...)" and how the communication with the CoCoAServer actually works you have to look at the code in "cocoa5.cpkg": Read at least the functions definitions of "$cocoa5.OperationCommunication(...)", "$cocoa5.ExtendedInfo(X, Info)", and "$cocoa5.ComputationRequestToDevice(Operands, Computation, Info5, D)". Especially the function mentioned last is of interest as it gives an overview of what types of operands already are supported. If your operands have a type that is not mentioned there you will have to extend both the functions in "cocoa5.cpkg" and the communication functions in "CoCoAServer.C" to pass your operands through to the CoCoAServer. Communication is performed by sending XML like sequences and you have to add new tags if necessary.

CoCoAServer part

This part is covered in the article Contribute a new CoCoAServer function.