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.

302 • Chapter 7: <strong>Advanced</strong> Connectivitythis code into a DLL and dynamically links to the new library. Subsequentlyinvoking the procedure returned by define_external calls thenewly generated conversion routine before calling the external function inthe library you provided.The C code generated by Maple wraps the Maple data structures bytranslating them to hardware equivalent types. Hence, the code file iscalled the wrapper, and the library generated by this code is called thewrapper library.Additional Types and OptionsGenerating a wrapper file allows Maple to translate more complicatedtypes that are difficult to handle without compilation technology. It alsoallows greater flexibility when dealing with pointers and passed data thatdo not exactly match the required type.Table 7.3 on page 339 lists additional types that are supported whenthe keyword WRAPPER is specified.Structured Data FormatsA structure is a non-homogeneous collection of members, correspondingto a struct in C, or a record in Pascal. A union is similar, except thatall the members start at the same memory address.Each member :: descriptor pair describes one member of the structureor union. The descriptor is any of the types described in this chapter.The options are used to specify what kind of datatype the wrappershould expect for conversion purposes. The following two options aresupported.TABLE Tables are used as the corresponding Maple type. Using tablesis the default behavior, and they are easier to use than lists. Whentables are used, the member names correspond to table indices.LIST Lists are used as the corresponding Maple type. Lists are primarilyused in a read-only basis. Lists cannot be modified in-place, so makingupdates to a list structure in external code requires a copy to be made.When structures must be passed back to Maple, or if they containpointer types, it is better to use tables.Lists and tables cannot be used interchangeably. Once the wrapperhas been generated, it accepts only the declared type, not both.Enumerated TypesThe Maple external calling mechanism does not directly support enumeratedtypes (such as enum in C). Instead, use the integer[n] type with

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

Saved successfully!

Ooh no, something went wrong!