Reply to comment

Languages Designed as Stand Alone Languages

Languages such as PHP, Perl, Python and Ruby are primarily used as standalone languages, but have support for using C or C++ modules.

The first thing necessary is to generate a module for the target language, this is where SWIG again helps us. Please see the SWIG documentation for examples on creating, testing and using a module.

The steps for using one of these languages inside your application is very similar to that of using one of the languages designed for embedding.

  1. Initialize Scripting Language Context
  2. Load Application API Module into Scripting Language Context
  3. Add Variables to Scripting Language Context
  4. Load Script into Context
  5. Execute Script
  6. Get Results from Context
  7. Close Scripting Language Context

The main difference between these languages and the languages designed for embedding is the extra work to compile and distribute the language specific module which adds your applications API to the scripting language. SWIG provides the standard SWIG_init, SWIG_NewPointerObj and SWIG_ConvertPtr helper functions mentioned in the previous section to help with many of these steps.

These languages tend to each have a different prefered method of compiling a module and integrating these compilation methods into an existing project can be difficult.

Specific resources regarding compiling language modules is covered in the next section.

Reply

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post PHP code. You should include <?php ?> tags.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Images can be added to this post.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.