WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

file.tm

is a WSTP template file.

Details

  • WSTP template files contain templates for linking external C functions to Wolfram Language functions.
  • Each template can contain the following:
  • :Begin: begin the template for a particular function
    :Function: the name of the function in the external program
    :Pattern: the pattern to be defined to call the function
    :Arguments: the arguments to the function
    :ArgumentTypes: the types of the arguments to the function
    :ReturnType: the type of value returned from the function
    :End: end the template
    :Evaluate: Wolfram Language input to evaluate when the function is installed
    ::text treat as a comment
  • Arbitrary C code can be interspersed between templates in a .tm file.
  • The following argument and return type specifications can be used:
  • Integer16 short
    Integer32 int
    Integer64 mlint64
    Real32 float
    Real64 double
    Integer16List short*, int (length)
    Integer32List int*, int (length)
    Integer64List mlint64 *, int (length)
    Real32List float*, int (length)
    Real64List double*, int (length)
    Real128List mlextended_double *, int (length)
    String char*
    ByteString unsignedchar*andint(length)
    UCS2String unsigned short*
    UTF8String unsigned char*, int (bytes), int (characters)
    UTF16String unsigned short*, int (length), int (characters)
    UTF32String unsigned int*, and int (length)
    Symbol char*
    ByteSymbol unsigned char*, int (length)
    UCS2Symbol unsigned short*, int (length)
    UTF8Symbol unsigned char*, int (bytes), int (characters)
    UTF16Symbol unsigned short*, int (length), int (characters)
    UTF32Symbol unsigned int*, int (length)
    ThisLink WSLINK
    $CurrentLink WSLINK
    Manual void
  • In order to use UCS2String, UCS2Symbol, UTF8String, UTF8Symbol, UTF16String, UTF16Symbol, UTF32String, and UTF32Symbol as a return type, the programmer must allocate a WSUnicodeContainer object to return in place of the Unicode string.
  • The WSUnicodeContainer object is a wrapper that contains a copy of the Unicode string and its length for easily passing Unicode strings between functions in a template file.
  • wsprep will only generate function signatures with WSUnicodeContainer as the return type when the return type is one of the listed Unicode string or symbol types. wsprep will not generate code that passes a WSUnicodeContainer object as an argument to a function when one of the arguments is a Unicode string or symbol type.
  • WSTP template files are converted to C code using wsprep . They are also processed automatically by wscc when available.

Examples

Basic Examples  (1)

Template file entry for a function named f that takes two integers as arguments and returns an integer:

:Begin:
:Function: f
:Pattern: f[x_Integer, y_Integer]
:Arguments: {x, y}
:ArgumentTypes: {Integer, Integer}
:ReturnType: Integer
:End:

See Also

Programs: wsprep   wscc

History

Introduced in 2007 (6.0) | Updated in 2014 (10.0)

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /