Loading and using shared libraries¶
code, you can call the functions defined in the library directly in the
ExternalObject instance, or indirectly
through library-defined object types.
Direct access to library calls through the ExternalObject instance - Use the direct-access style for C-language libraries. For each function defined in the C library, there is a corresponding method in the ExternalObject object. You can pass data to these methods and receive the return value directly.
mylib = new ExternalObject ("lib:" + samplelib); // load the library alert(mylib.version) ; // access functions directly from ExternalObject instance var a = mylib.method_abc(1,2.0,true, "this is data") ; alert(a) ; mylib.unload() ; For details of how to define functions for direct access through the ExternalObject object, see :ref:`defining-entry-points-for-direct-access`.
anotherlib= new ExternalObject ("lib:" + filespec); // load the library alert(anotherlib.version) ; // instantiate library-defined class var myObject = new MyNewClass() ; // access functions from instance var a = myObject.method_abc(1,2.0,true,"this is data") ; alert(a) ; anotherlib.unload() ; For details of how to define functions for direct access through the ExternalObject object, see :ref:`defining-entry-points-for-indirect-access`.