2005/5/10

     
 

CfgScript Library

artefaktur

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

CfgScript uses ACDK libraries.



Content of this chapter:

   The CfgScript standard library
     Available Classes
   Using ClassLoader to load the class
     System ClassLoader
   CfgScript Classes
     Included CfgScript Files
     CfgScript ClassLoader
     Using CfgScript Classes in C++
   DMI-able Classes


 The CfgScript standard library


CfgScript has no own standard library, but simply make use of the ACDK class libraries.

All ACDK Classes with provided meta information are available in CfgScript.

 Available Classes

By default all classes of the acdk_core package are available (including acdk.lang, acdk.lang.ref, acdk.lang.reflect, acdk.lang.dmi, acdk.io, acdk.util, acdk.util.logging, acdk.locale).
Also the classes of the Script interpreter are available (acdk.cfgscript).

Addionally all classes implemented in various  Packages are available in CfgScript.
For example  networking,  XML Processing,  GUI and so on.

 Using ClassLoader to load the class

If the type is not already loaded, CfgScript uses the available  acdk::lang::ClassLoader to load the class.

Two ClassLoader are available for CfgScript by default:


 System ClassLoader

The system class loader tries to load native code (.so/.dll) which contains the ACDK/C++ class definition.

See also:  ACDK Nameservice.

Hundrets of classes are avialable via System ClassLoader including  acdk.text (including RegExp),  acdk.net,  acdk.vfile,  acdk.sql and  acdk.wx for GUI programming.

 CfgScript Classes


 Included CfgScript Files

CfgScript classes may be included via the  include statement.

Alternativelly the interpreter uses the CfgScript ClassLoader:

 CfgScript ClassLoader


The CfgScript ClassLoader try to locate a .csf file with the same name as the loaded class:

For loading the class mymodule.tools.MyClass the CfgScript ClassLoader try to load the script mymodule/tools/MyClass.csf from
  • each directory defined in the CSFPATH enviroment variable.
  • and in the $ACDKHOME/cfg/csf/lib/ directory.

See also:  acdkcfgscript.

See also:  acdk::cfgscript::ScriptClassLoader.

 Using CfgScript Classes in C++

The CfgScript ClassLoader does not only work for Classes loaded in the CfgScript script itself, but also in ACDK C++ and any DMI-enabled Scripting language (like list, perl, python, tcl, visual basic, java):


// $ACDKHOME/cfg/csf/lib/mytest/MyCfgScriptTestClass.csf
class MyCfgScriptTestClass
implements Comparable
{
  String value;
  MyCfgScriptTestClass(String value)
  {
    value = val;
  }
  String getValue() { return value; }
  int compareTo(MyCfgScriptTestClass other)
  {
    return getValue().compareTo(other.getValue());
  }
  
}
And now in ACDK C++

  // asumes the acdk_cfgscript library is linked to the executable
  RString arg = "Hello";
  // uses the class loader to load a cfgscript class, which can be used in
  RComparable comp1 = (RComparable)Object::New("mytest.MyCfgScriptTestClass", arg);
  RComparable comp2 = (RComparable)Object::New("mytest.MyCfgScriptTestClass", arg);
  comp1->compareTo(comp2) == 0;


 DMI-able Classes

DMI is the basis language integration mechanism of ACDK called Dynamic Method Invocation.
With the DMI-Bridge CfgScript can make usage of  COM,  CORBA or  Java classes
in a way that the code looks exactly the same like the server classes were implemented in CfgScript.

Please refer to  Introduction for the COM sample.