11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.2 Using Compiled Code in Maple • 303n of an appropriate size to match the size of the enumerated type of thecompiler with which the external function was compiled (usually this isthe same size as the int type).Procedure Call FormatsSome languages, like C, support passing functions as arguments. A Mapleprocedure can be passed to an external function in the same way. Thewrapper sets up a C style procedure to call Maple to execute the passedprocedure with the given arguments. This C callback is given to the externalcall to be used like any other C function.Each member :: descriptor pair describes one parameter of the procedure.The descriptor is any of the types described in this chapter.It is not permitted to declare a procedure that itself takes a procedureparameter. In other words, a callback cannot itself call back to the externalcode.Call by ReferenceUnless overridden, each argument is passed by value. The REF modifiercan be used to override this.argumentIdentifer :: REF( dataDescriptor, options )The REF modifier can take the following options.ANYTHING This option must be first in the list of options. Use thisoption to declare the equivalent of a C void* parameter. The wrappercode attempts to convert passed arguments to simple types, (4-byteinteger, 8-byte float, complex, or string), when encountered. If noconversion to one of these types is possible, NULL is passed to theexternal function.CALL_ONLY This option specifies that although the object is to bepassed by reference, any changes made by the external function are notwritten to the Maple symbol that was passed. This can be used bothto protect the objects passed (see section on Array Options), andto reduce overhead (as no translation back to Maple data structuresneed be made).RETURN_ONLY This option specifies that no data is actually passedto the external function. Instead, only a reference to the allocatedspace is passed, and the external function is expected to fill the spacewith data. The result is converted into an appropriate Maple object.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!