artefaktur
software engineer &        architecture

 
 
 
 

acdk_python Manual


acdk_python contains an interface to an Pyton interperter and the DMI code to script ACDK objects from Python code.


Content of this chapter:

   Hello World Sample
   Installation & Compiling of acdk_python & acdkpyton
   ACDK / Python
     Type mapping
     command: sub acdk.Object("s|args")
     command: acdk.Object.invoke("s|args")
     command: acdk.invoke_static("ss|args")
     command: acdk.Object.peek("S")
     command: acdk.Object.poke("SO")
     command: acdk.peek_static("SS")
     command: acdk.poke_static("SSO")



 Hello World Sample


Here the standard hello world sample:

def foo(string1, string2):
  sb = acdk.Object("acdk/lang/StringBuffer", string1)
  sb.append(string2)
  return sb.toString()
  
acdk.peek_static("acdk/lang/System", "out").println(foo("Hello Python", " from ACDK"))


Other sample using an COM-Object

import acdk
classloader = acdk.Object("acdk/lang/ClassLoader")
classloader.findClass("acdkx/com/ComObject")    
word = acdk.invoke_static("acdkx/com/ComObject", "New", "Word.Application")
word.poke("Visible", 1)
doc = word.peek("Documents").Add()
sel = word.peek("ActiveWindow").peek("Selection")
sel.TypeText("This is ")
sel.peek("Font").poke("Bold", 1)
sel.TypeText("ACDK")
sel.peek("Font").poke("Bold", 0)
sel.TypeText(" instrumenting Word through acdk_python")
acdk.invoke_static("acdk/lang/Thread", "sleep", 3000)
word.Quit(0)


 Installation & Compiling of acdk_python & acdkpyton


To compile and rund acdkperl you need the Perl 2.1 (or later) package
 ftp://ftp.python.org/pub/python/2.1.1/Python-2.1.1.tgz
On Unix:
- [g]tar zxf Python-2.1.1.tgz
- cd Python-2.1.1
- ./configure
- make
- su 
- make install
On Windows:
- use gtar or winzip to extract Python-2.1.1.tgz
- Open the workspace .\Python-2.1.1\PCbuild\pcbuild.dsw
- Compile Debug and Release target.
- You may have to copy the python DLL's somewhere into the
  path or expand the path to python DLL's directory.

If you have already installed a runtime version of Python it may work to this, but there may missing includes/libs.

You may have to change some path in the acdk_python/python_cfg.lsp file and remake the Makefiles.
acdk_python/ > [n]make -f acdk_perl. makemake


 ACDK / Python


 Type mapping

  • Python: number <-> ACDK: int/Integer
  • Python: double <-> ACDK: double/Double
  • Python: string <-> ACDK: String
    Note may added more mappings later.

     command: sub acdk.Object("s|args")

    acdk::Object() creates a new ACDK-Object.
    argument 1: The fully qualified ACDK-Class name like "acdk/lang/StringBuffer".
    argument 2 - n: Arguments for the class constructor.
    return: a new acdk.Object with wrapps an ACDK object Usage:
    %sb ## Python import acdk sb = acdk.Object("acdk/lang/StringBuffer", "Hallo ") %se

     command: acdk.Object.invoke("s|args")

    acdk.Object.invoke invokes a method. argument 1: the name of the method.
    argument 2-n: arguments of the method.
    return: returns the result of the method.

    Instead of using invoke, you can also use the direcly the methodname
    
    ## Python
    import acdk
    sb = acdk.Object("acdk/lang/StringBuffer", "Hallo ")
    erg = sb.invoke("toString")
    # the same as 
    erg = sb.toString()
    

     command: acdk.invoke_static("ss|args")

    acdk.invoke_static calls a static method.
    argument 1: name of the class as string.
    argument 2: name of the method as string.
    arguments 3-n: arguments of the method.
    return: returns the result of the method.

     command: acdk.Object.peek("S")

    reads a member of an ACDK class.
    argument 1: name of the member as string.
    return: the readed value.


     command: acdk.Object.poke("SO")

    writes a member of an ACDK class.
    argument 1: name of the member as string.
    argument 2: The value to set.

     command: acdk.peek_static("SS")

    reads a static member of an ACDK class.
    argument 1: name of the class as string.
    argument 2: name of the member as string.
    return: the readed value.

     command: acdk.poke_static("SSO")

    writes a static member of an ACDK class.
    argument 1: name of the class as string.
    argument 2: name of the member as string.
    argument 3: The value to set.

  •  
    Last modified 2005-05-08 22:31 by SYSTEM By Artefaktur, Ing. Bureau Kommer