Artistic Style Developer Information

 

Artistic Style has compile options for creating a shared library (DLL) or static library for use with a Graphical User Interface (GUI). The shared library can be called from a C++ or C# program. There are also compile options for a Java Native Interface (JNI) that allows it to be called from a Java program. Information on compiling the various configurations of Artistic Style is in the Install Information.

Source code for all examples and the test files can be obtained from the Subversion repository. The repository address is "https://astyle.svn.sourceforge.net/svnroot/astyle". The current version is in the "trunk/AStyleDev" branch of the repository. The file and directory names in the repository are case sensitive. This project requires the source from the Artistic Style project. AStyle and AStyleDev should be installed in the same top level folder.

A sample checkout is:
svn  checkout  "https://astyle.svn.sourceforge.net/svnroot/astyle/trunk/AStyleDev"  "$HOME/astyledev" .

 You can also browse the subversion repository. The current development release is in the "trunk" directory. This gives you a view of the project's code without actually checking-out the files.

Examples

Source code from the following examples can be copied and pasted into an editor or development environment for compiling and running. Or it can be checked out of the repository.

Calling Artistic Style from a C++ Program contains information on calling Artistic Style as a shared or static library from a C++ program. It includes a C++ sample program that can be used to test the library.

Calling Artistic Style as a Java Native Interface contains information on calling Artistic Style as a shared library from a Java program using the Java Native Interface (JNI). It includes a Java sample program that can be used to test the shared library. The Java Development Kit (JDK) must be installed to compile Artistic Style.

Calling Artistic Style from a C# Program contains information on calling Artistic Style as a shared library from a C# program. It includes a C# sample program that can be used to test the shared library.

Calling Artistic Style from a Python Script contains information on calling Artistic Style as a shared library from a Python scripy. It includes a Python script that can be used to test the shared library.

Source Code Downloads

The downloads are source files that contain a more extensive example of the sample programs. The AStyleInterface class can be used by another program to call Artistic Style. It contains functions to load the shared library, build an option list, call the GetVersion and Format functions, and handle errors. An example program demonstrates using the class. Test data is included with the download. The source code can also be checked out of the repository.

C++ Interface

Example2 for C++ includes an AStyleInterface class that builds the option string and contains the error handling and memory allocation functions. Compile Artistic Style as a shared or static library using the macro ASTYLE_LIB. Compile Example2.cpp and AStyleInterface.cpp as an executable and link it to the library. It will format 'cpp' and 'h' files in the test-c directory. Artistic Style and the interface programs could also be compiled as a single executable.

Java Interface

Example2 for Java includes an AStyleInterface class that builds the option string and contains the methods to call the shared library using the Java Native Interface (JNI). Artistic Style must be compiled as a shared library using the macro ASTYLE_JNI. Copy the shared library to the same folder as the Java class files (it is loaded from the classpath directory). It will format java files in the test-j directory.

C# Interface

Example2 for C# includes an AStyleInterface class that builds the option string and contains the methods to call the shared library using a C# program. Compile Artistic Style as a shared library using the macro ASTYLE_LIB. Copy the shared library to the same folder as the C# class files (C# does a Windows type search for the shared library, looking first in the startup program's directory). It will format C# files in the test-s directory.

Script Downloads

Test data is included with the download. The scripts can also be checked out of the repository. You must have the appropriate software installed to run the scripts.

Python Scripts

This download contains three Python scripts. The script ExampleExe.py calls an Artistic Style executable to format C++ source code. The scripts ExampleByte.py and ExampleUnicode.py call the Artistic Style shared library. The executable and shared library must be compiled using the macro ASTYLE_LIB. Copy the executable and shared library to the same folder as the Python scripts. They will format C++ files in the test-c directory included in the download.