WSO2 is now Choreo LabsLearn more

Trusted AI Governance
Build

Create agents and AI apps with the tools and languages your teams already use.

Connect

Link agents securely to your APIs, data, models and business systems.

Run

Deploy, observe and operate agents and AI apps reliably at any scale.

Govern

Control identity, access, cost and policy for every agent in production.

Agent Management

Developer Platform

  • API Management Cloud

    Design, secure and publish APIs with governance and analytics built in.

    Sign Up Now
  • Integration Cloud

    Connect apps, data and AI agents with low-code and pro-code integration.

    Sign Up Now
  • Identity & Access Management Cloud

    Secure sign-in and access for customers, partners, workforce and agents.

    Sign Up Now
  • Agent Management Cloud

    Build, run and govern AI agents with full visibility and control.

    Sign Up Now
  • Developer Platform Cloud

    Ship cloud-native apps faster on an internal developer platform.

    Sign Up Now

Self-Hosted

Full control over your stack. Deploy directly to your own servers, bare metal, cloud, or Kubernetes environment. Your data never leaves your perimeter.

Product Downloads
Choreo Labs
AI Governance
Platform
Solutions
Resources
Article

Scripting language wrappers for WSO2 WSF/c

Chintana is currently working on making WSO2 WSF/C more accessible to everyone by generating wrappers for scripting languages like Perl and Python. He talks about SWIG and its huge contribution to his work.

Chintana WilamunaChintana Wilamuna works on the development of the infrastructure as well as with the C team on scripting language bindings. His expertise is system administration and Ajax powered interfaces with Ruby on Rails. He has also been involved in developing PHP based applications. Chintana has a keen interest in getting XHTML, CSS and 508/AAA compliance to Web sites and also likes playing around with Content Management Systems (CMS).

Oxygen Tank (OT): So Chintana, tell us what you are working on at the moment?

Chintana: I'm working on scripting language bindings for WSO2 WSF/C. Mainly Perl, Python and Ruby. I'm using SWIG to ease up the development of the wrappers.

OT: Tell us something about SWIG.

Chintana: SWIG stands for Simplified Wrapper and Interface Generator. It is a tool that can be used to write a wrapper for a C/C++ library. A wrapper is a piece of code that encapsulates a C library and allows another language to talk to that C library. How SWIG works is that it allows to
build an interface to access a low level C/C++ library from a much high level language.

OT: Can you explain in more detail as to why we need such an interface?

Chintana: Say you have a library that has been written using C on your computer. You can access that library only from a C program. Now, if you want to access that library using Python, you have to write some code to bridge Python and C. One task in bridging the code is the conversion of the data types from Python to C and C to Python. You have to write this because an integer type in Python is different from an integer type in C. SWIG supports the mapping of primitive data types as well as complex types such as pointers.

OT: Great! What are these other languages you are referring to, and how do you exactly build a wrapper for them?

Chintana: Some of the different languages are Ruby, Python, Perl, Tcl, etc. SWIG generates wrappers for 13 different target languages (https://www.swig.org/compare.html.) You build a wrapper with SWIG by writing something called a SWIG interface file. Which, in a nutshell, is like a C header file. Once this has been written, you can generate wrappers for these languages without having to change the interface file.

OT:Is it only used for low-level languages?

Chintana:Well ... yes. It is specifically used to build scripting language interfaces for libraries built using C and C++. Although it was built to generate wrappers for scripting languages, now it has evolved to handle languages such as C# and Java as well.

OT: What are the advantages of using SWIG?

Chintana: Well ... for one, you don't have to be familiar with arcane APIs provided by various languages to build an interface for a C library. Two, you have the ability to generate wrappers for many different languages without having to change the SWIG interface file. Three, when new functions are added, they could be added with minimum effort.

OT: Is there any other tool that you can use, other than for SWIG, to build these wrappers?

Chintana:The other method would be to write the wrapper by hand. This is likely to take significantly more time than using a tool such as SWIG, because then you will spend time writing many things that SWIG does for you.

OT:What does all this mean for WSO2's products?

Chintana: Well ... we have WSO2 WSF/C which is the C version of the Web Services Framework. So we are building wrappers for scripting languages such as Perl, Python and Ruby. The problem with the C version for most people is that they don't want to write a fully fledged C program to get a simple thing done. For system administrators, Perl or Python is more appealing than C or Java. With the wrappers, they can incorporate Web services with one or two lines of code.

Currently there are many different Web service implementations with varying degrees of maturity for various scripting languages. After we develop wrappers for WSO2 WSF/C, programmers of major scripting languages will be able to enjoy the luxury of a full stack Web service implementation in a natural way.

OT: Finally, can you name some common applications or projects that use SWIG?

Chintana: Subversion, PyOgre, XML-Xerces are a few of them. You can find more at https://www.swig.org/projects.html