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.

304 • Chapter 7: <strong>Advanced</strong> ConnectivityArray OptionsIf an ARRAY argument is declared as CALL_ONLY and an Array, Matrix, orVector with proper settings is passed to the external function (so that nocopying is required), CALL_ONLY has no effect and thus does not preventthe called function from overwriting the original array. To prevent thisfrom occurring, include the option COPY in the ARRAY descriptor.The ARRAY descriptor accepts extra options when used with wrappergeneration. These options can be specified as follows.ARRAY( dim1, ..., dimN, datatype=typename,order=..., ..., options )The dim1 through dimN parameters are integer ranges, specifying therange of each dimension of the array. Any of the upper or lower boundsmay be the name of another argument, in which case the value of thatargument specifies the corresponding array bound at run time.The options are used to specify how an array is passed. The followingare valid options.COPY Do not operate in-place on the given array. That is, make a copyfirst, and use the copy for passing to and from the external function.NO_COPY This ensures that a copy of the data is never made. Usually,when using a wrapper generated external call, if the Array, Matrix, orVector is of the wrong type, (say the order is wrong), a copy is madewith the correct properties before passing it to the external function.Using NO_COPY prevents this. Also, the returned array has the propertiesof the copy. If NO_COPY is specified, and an Array, Matrix, orVector with incorrect options is passed, an exception is raised. Arraysare always passed by reference. If no options are given (via a REFdescriptor), they are passed by using the CALL_ONLY behavior of REFwith the noted exception described at the beginning of this section.Non-Passed ArgumentsSometimes it is necessary to pass additional arguments to the Maple wrapperthat should not be passed on to the external function. For example,consider the following hypothetical C function:int sum( int *v1, int *v2 )This function takes two integer vectors, v1 and v2, and adds the elementsof v2 to v1, stopping when it finds an entry that is zero. The

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

Saved successfully!

Ooh no, something went wrong!