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 • 301indfn=(..., ...) This specifies the indexing functions of the Array, Matrix,or Vector.Other Compound Types There are other types, including records(structs), and procedures that are supported when using wrapper generatedexternal linking. These data descriptors are described in Method2: Generating Wrappers on page 301.Specifying Argument Passing ConventionsDifferent programming languages have different conventions for parameterpassing. C always uses pass-by-value; pass-by-reference must be doneexplicitly by passing an address. Fortran uses pass-by-reference. Pascaluses either, depending on how the parameter was declared.The Maple external calling mechanism currently supports C, Fortran,and Java calling conventions. Automatic wrapper generation isonly supported for C. There is an external API for writing custom wrappersfor C and Fortran but not Java. The default convention used isC. To use Fortran calling, specify the name FORTRAN as a parameter todefine_external.> f := define_external(‘my_func‘,‘FORTRAN‘, ...);To use Java calling, specify the name JAVA as a parameter todefine_external. Also, specify the CLASSPATH= option to point to classesused.> f := define_external(‘my_func‘,‘JAVA‘, CLASSPATH="...", ...);Some other compiler implementations (such as Pascal and C++) canwork with C external calling by using the correct definitions and order ofpassed parameters.Method 2: Generating WrappersSome types in Maple are not suitable for automatic conversions. Twoof these types are procedures (callbacks), and records (structs). Mapleprovides an alternate mechanism for handling this kind of data.For a description of the steps required to use compiled code in Maple,see Method 1: Calling External Functions on page 294. The samethree basic steps (DLL creation, function specification, and function invocationas described on pages 295-296) are used in this method. Theinformation in this section extends the basic information by describingthe use of wrappers.Specifying the keyword WRAPPER in the call to define_externalcauses Maple to generate code for data translations. Maple compiles

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

Saved successfully!

Ooh no, something went wrong!