artefaktur
software engineer &        architecture

 
 
 
 

CfgScript Introduction

| Introduction | Start | acdkcfgscript | Language | Library | Embedding | CfgScript IDE | Debugging | Templates | Samples | Wish List |

CfgScript is a full featured scripting language based on ACDK. CfgScript is used in the the ACDK Metacompiler and the ACDK Make.



Content of this chapter:

   About CfgScript
   Use Cases
     Prototypes
     Tools
     Testing
     Component glue
     Configuration
     Customization
   Some features
     Object Oriented Language
     Rich call interface
     Instrumenting C++-Classes in scripting code
     Using third part frameworks and scripting languages
     Derive C++ in Scripting language
     Server Objects implemented in CfgScript
     CfgScript and GUI



 About CfgScript


CfgScript is a typed scripting language with similarities to Java and C#.

Nearly all that can be done with ACDK in C++ can also be done in CfgScript.
The same classes are used C++ as in CfgScript.

Of course some specific features of C++, like pointers, templates, and stack variables are not supported in the scripting language, but for compensation CfgScript provides high-level language constructs - missing in C++, like foreach loops, lamda expressions, backtick evaluation, multimethods and complex type literals.

CfgScript has a similar relationship to ACDK C++ as Tcl has to C. In component based development C++ classes can be tied by CfgScript together to an application.

CfgScript can also serve configuration components to an C++ application, communicating via C++ interfaces.
Complete Applications can be build in CfgScript in various domains, like multi threaded network application, handling XML files, accessing SQL databases and easily and fast written rich GUI applications.

 Use Cases


CfgScript can be used for many purposes.

 Prototypes

On the basis of the ACDK libraries prototypes can be implemented very fast.
  • No creation of make files is needed.
  • No compilation of the script needed.
  • One click/enter to run the application.
  • Easy translation from CfgScript to C++ if the prototype should be transformed to a compiled application.

 Tools

Often Prototypes lives longer than originally was planned.
Simple tools - which are somewhere between shell scripts and C++/Java - can be easily developed.

 Testing

For a given ACDK C++ library (or of course also CfgScript class libraries) test driver can be  implemented in CfgScript.
In the ACDK library  ACDK WX most test applications are not in C++, but in CfgScript.

 Component glue

Because of the neat integration of CfgScript with components implemented C++, COM, CORBA CfgScript is a good choice to connect these components with some scripting (see also below).

 Configuration

The standard configuration mechanism in ACDK for configuration are properties files with the same format known from Java.
But the properties files are limited to key=value string pairs.
CfgScript can be used to create typed, hierarchical structured configuration sets.
See in  Properties Type.

 Customization

Many complex software systems needs more than static data for configuration.
Configuration with dynamic parts (program code) often called Customization.

CfgScript can also be used as extended configuration with does not only setup some configuration data, but setup and glue components to a customized application.

 Some features


 Object Oriented Language

  • Same object model as Java, C# with owner defined:
  • Classes
  • Interfaces
  • Enums

 Rich call interface

  • user defined operator overloading
  • in, out, inout parameter attributes
  • byref, byval parameter attributes for remoting
  • Polymorphic functions
  • called by named parameters
  • default value for parameter
  • Call with rest (like ... in C/C++)
  • Call with named rest (similar to ..., but the elements are named parameters)
  • Delegates for signal/slot constructions
  • lambda expressions for in place function definition

 Instrumenting C++-Classes in scripting code

Every in ACDK defined C++-class, interface and Enumeration can be used inside the script as naturally and seamless.


// CfgScript
// StringBuffer is an ACDK-C++ class
acdk.lang.StringBuffer sb = new acdk.lang.StringBuffer("asdf");
sb.append("asdf");
acdk.lang.System.out.println(sb.toString());

CfgScript uses the ACDK C++ Classes as default library framework, which supports things like:
  • Reflection mechanism
  • IO
  • collections
  • regular expression
  • logging
  • networking
  • and many other libraries


 Using third part frameworks and scripting languages

ACDK has object integration of following frameworks:
  • Java
  • COM
  • CORBA

Object from these technology frameworks can be used inside CfgScript in a seamless way.
Example:

// create a Com Object, like Microsoft Word
word = new acdkx.com.ComObject("Word.Application");
// use this object, like it is own
word.Visible = 1;
doc = word.Documents.add();
sel = word.ActiveWindow.Selection;
sel.TypeText("This is ");
sel.Font.Bold =  1;
sel.TypeText("ACDK");
sel.Font.Bold = 0;
sel.TypeText(" instrumenting Word through acdk_cfgscript");
acdk.lang.Thread.sleep(3000);
word.Quit(0);

 Derive C++ in Scripting language

CfgScript can be used extend C++ classes. The extended class / implemented interface can be used inside C++ code, like it is a own native C++ class A common sample is:

class MyElement
extends acdk.lang.Object
implements acdk.lang.Comparable
{
  int _el;
  MyElement(int e) { _el = e; }
  int getElement() { return _el; }
  int compareTo(acdk.lang.Object other) { return _el - other._el; }
}
acdk.util.Collection coll = new acdk.util.TreeSet(); // TreeSet is a native C++-Class
coll.add(new MyElement(1)); // C++ implementation calls the native C++ 
                            // interface method compareTo() to inserted the element sorted
coll.add(new MyElement(3));
coll.add(new MyElement(2));
it = coll.iterator();
while (it.hasNext() == true)
{
  out.println(it.next().getElement());
}


 Server Objects implemented in CfgScript

Classes/Objects implemented in CfgScript can be used by other component languages:

// MyElement.csf
class MyElement
extends acdk.lang.Object
{
  int _el;
  MyElement(int e) { _el = e; }
  int getElement() { return _el; }
  acdk.lang.String toString() { return String.valueOf(_el); }
  void addElement(int i) { _el = _el + i; }
}

Now in VBScript:

Dim acdk
Set acdk = CreateObject("Acdk.Object")
dim script
' load script
set script = acdk.New("acdk.cfgscript.Script", "MyElement.csf")

' class MyElement is now available as ActiveX component
Dim myElement
Set myElement = acdk.New("MyElement", 42)
dim i
i = myElement.getElement()
myElement.addElement 42
dim s
s = myElement.toString()


 CfgScript and GUI

I started a project  ACDK WX to provide GUI functionality to ACDK and CfgScript.
 
Last modified 2005-05-08 22:24 by SYSTEM By Artefaktur, Ing. Bureau Kommer