CorbaScript is an object-orientedscripting language designed to support interaction with Common Object Request Broker Architecture (CORBA) objects. It was developed to provide a flexible scripting environment for both client- and server-side CORBA application development, leveraging dynamic invocation and interface reflection capabilities.
CorbaScript is a dynamic, interpreted language whose syntax resembles that of C++ and Java. However, it integrates several design elements from dynamic languages such as Python and Smalltalk. Like those languages, CorbaScript treats all values as objects and supports dynamic type checking at runtime. Source code is translated into pseudocode executed by a dedicated Virtual Object-Oriented Machine that includes a simple reference-counting garbage collector.[1]
CorbaScript includes typical scripting features:
The runtime includes a simple garbage collector based on reference counting.
CorbaScript is tightly integrated with CORBA middleware and provides full access to both the Dynamic Invocation Interface (DII) and Dynamic Skeleton Interface (DSI):
CorbaScript also includes additional capabilities beyond basic scripting:
CorbaScript allows any script to function as an importable module. Some standard modules include:
A number of example applications and tools are included in the CorbaScript distribution:
The following illustrates how CorbaScript can be used to interact with a CORBA object defined by the following OMG IDL interface:
interfaceHello{voidhello();voiddisplay(instringmessage);};Using CorbaScript, you can invoke operations on a CORBA object implementing this interface:
>>> # the `hello` variable refers to a CORBA `Hello` object.>>> hello=Hello("IOR:....")>>> # invoking the 'hello' operation>>> hello.hello()>>> # invoking the 'display' operation>>> hello.display("Hello World!")>>> # obtain the CORBA Naming Service>>> NS=CORBA.ORB.resolve_initial_references("NameService")>>> # resolve a name in the CORBA Naming Service>>> object=NS.resolve(CosNaming.Name(CosNaming.NameComponent("anHelloObject","")))>>> # easier syntax with automatic sequence conversion>>> object=NS.resolve([["anHelloObject",""]])>>> #解決されたオブジェクトに対して操作を実行する>>> object.display ( " Hello World!" )CorbaScriptを使用すると、CORBAオブジェクトを簡単かつ直感的に呼び出すことができます。
以下の例は、CorbaScriptで`Hello`インターフェースを実装する方法を示しています。
# Helloインターフェースを実装するスクリプトクラスを定義しますclass HelloImpl { # コンストラクタproc __HelloImpl__ ( self ) {}# `hello`操作の実装proc hello ( self ) { println ( "OMG IDLの`hello`操作が呼び出されました。" ) }# `display`操作の実装proc display ( self , message ) { println ( message ) } }>>> # インスタンスを作成>>> hello = HelloImpl ()>>> # ローカル呼び出し>>> hello . hello () OMG IDL の `hello` 操作が呼び出されます。>>> hello.display ( " Hello World!" ) Hello World!>>> # CORBAに接続し、実装インターフェースを指定します>>> CORBA.ORB.connect ( hello , Hello )>>> # CORBAネーミングサービスにオブジェクトを登録>>> NS = CORBA.ORB.resolve_initial_references ( " NameService" ) >>> NS.bind ( [[ " anHelloObject " , "" ] ] , hello._this )この例は、CorbaScript が CORBA オブジェクトの呼び出しと実装の両方をいかに簡素化するかを示しています。CORBA ネーミング サービス シェルや CORBA CosNaming の実装など、その他の例も CorbaScript の配布パッケージに含まれています。
CorbaScriptインタープリタはC++で実装されており、 Windowsだけでなく、ほとんどの主要なUnix系システムで利用可能です。