Quantcast
Viewing latest article 9
Browse Latest Browse All 47

include library “name”– native extensions

Since version 4.4.3.24 Sciter support native loadable extensions.

Native Sciter Extension (NSE) is a dynamically loadable library (.dll, .dylib, .so) that exports at least one function:

BOOL SCAPI SciterLibraryInit(ISciterAPI* psapi, SCITER_VALUE* plibobject);

where:

  • ISciterAPI* psapi – is a reference to Sciter API interface provided by the caller (sciter.dll or scapp.exe or quark application).
  • SCITER_VALUE* plibobject – is an output variable that receives your library object.

Library object can be anything that can be wrapped into SCITER_VALUE ( sciter::value in C++):

  • Asset instance – so  called native namespace;
  • Map containing name/value pairs of entities that will constitute native namespace;
  • Array that may contain native function references;
  • etc.

In order to load such NSEs script was extended by import library statement:

include library "libraryname";

Where libraryname is a DLL file name without extension.

The DLL must be located in the same folder as its hosting executable (sciter.dll or scapp.exe).

SDK example : SQLite as NSE.

Sciter SDK  contains SQLite wrapped into NSE

It demonstrates  use of SQLite as

  1. Statically linked namespace by using SciterSetGlobalAsset(new sqlite::SQLite()); (in usciter.exe) or
  2. as an external NSE – DLL that exports SciterLibraryInit function that provides instance of the same sqlite::SQLite namespace object.

Use of include library "libraryname" in script

Include library statement returns an object provided by NSE (plibobject) and so it can be used on the right side of assignments:

const NativeNS = include library "mynativelib";

namespace MyNS {
   const extras = include library "myotherlib";   
}

If your library returns instance of an asset then the assignment is not required – loader will use name defined in asset’s passport:

include library "sciter-sqlite";

This will create native object named “SQLite” in its passport.

Check script example that uses SQLite. Note that script sample, by using conditional include library, can be used as with usciter.exe (that links SQLite namespace statically) as in other Sciter applications by loading the DLL at runtime.

 


Viewing latest article 9
Browse Latest Browse All 47

Trending Articles