Home
Name Modified Size InfoDownloads / Week
binaries 2015-09-13
examples 2015-09-05
README 2015-09-05 6.2 kB
Totals: 3 Items   6.2 kB 0
usage: c2s [options] module.c2s
  (generates: module.cpp)

options:
  -s         generate static functions (except interface)
  -e number  start number of auto generated eventd ids (0x10000)
  -h         generate a header file 'module.h' with the interface
  -p         use 'prama once' statement instead #ifndef clause
  -c name    generates files (name.cpp, name.h) for helper functions, than exit
  -g path    use above generated helper files (path to include file)
  -i path    provide full path for squirrel include file (<squirrel/squirrel.h>)
  -n         do not generate an advance error handler (sq_raiseerror)
  --debug    print trace information to stderr
  --version  show version infos

language:
  --                    local comments (will be ignored
  //                    C/C++ style comments (will be transferred into cpp file)
  /* ... */             C/C++ style comments (will be transferred into cpp file)
  #directive            C/C++ directive will be transferred into cpp file
  %command              invoke special commands, which can be
     PACKAGE { code }
                        generates structure SQPACKAGE with additional code
     EVENT { code } | number
                        uses provided code for event checking, class events check can
                           be accessed via class_checkEvents(void *user)
                        or sets the start number of auto generated event ids
     USERCALL func
     USERCODE(type[:flag]) { code }
                        generates either a usercall_module(void *user) interface with calls to
                           func(user,type,namespace,name,datatype,flag,params)
                        or an usercall_module(void *user) interface with provided code
                           (usercode can be provided more than once, with different type/flag
                           type can be 1=table, 2=class, 3=array, 4=function, 5=method,
                                       6=property, 7=value, 8=attribute, 9=event
                           flag can be table, array, value, attribute (1:const), class (1:abstract)
                                       property (1:read-only, 2:write-only)
     KEYWORDS(typelist) AS name
     KEYWORDS(typelist) { code }
                        generates either a const char *name[] (keywords) with all required keywords,
                           or interface keywords_module(void *user) with provided code
                           typelist := (type:flag, ...) see type and flag above
     VERSION string | number.number | { code }
                        generates a const char *version_module() interface which returns given number

  NATIVE { code }       C/C++ code will be transferred into cpp file
  DTOR() { code }       set global destructor for all following classes
  DTOR(:)               clear global class destructor
  BR(name) { code }     set global backward reference (backref) for all following classes
  BR(:)                 clear global class backref
  FOREIGN name AS type  generates foreign pointer for all following functions / methods
  FOREIGN ()            clear foreign function pointer

  CLASS name [ABSTRACT] [EXTENDS name]
     -- comments
     UP name AS type    use instancepointer as a special variable
     DTOR | BR
     CTOR (params) { code }
     FUNCTION | METHOD | VALUE | ATTRIBUTE
     PROPERTY name AS type
       [GET { code }]
       [SET { code }]
     EVENT [name, ...][[AS] number]
       [REGISTER (params) { code }]
       [RELEASE () { code }]
       [CHECK { code }]
  END CLASS

  TABLE name [CONST]
     -- comments
     TABLE | CLASS | ARRAY | FUNCTION | VALUE
  END TABLE

  ARRAY name [CONST]
     -- comments
     TABLE | CLASS | ARRAY | FUNCTION | VALUE
  END ARRAY

  FUNCTION name (params) [AS type] [PURE] { code }
  VALUE name [CONST] AS type [INIT|= value]
  params := (...) | ([+]name:type[=value], ...)
  type := NULL | BOOL | INT | FLOAT | STRING | USER
  value := TRUE | FALSE | 0x??? | number[.number]

internals:
  all functions/methods provide HSQUIRRELVM as 'v'
  where optinal arguments are given, int 'nargs' = sq_gettop(v)
     parameter count is always one greater (roottable, instance)
     parameter check is added with num type for int and float
  function/method parameter names in C/C++ are same as provided
  function which returns a type other than user, 'value' is used
  all functions common is stack(1) = roottable as first argument
  all class methods common is stack(1) = object instance as first argument
  all properties get/set common is stack(1) = object instance
     and stack(2) = property name
     and type other than user, 'value' is used
     for user types 'get' value sq_pushXXX(v), 'set' value sq_getXXX(v,3)
  register/release event methods has 'event_id', and 'handler'
     first user defined arg starts at 4 (method policies apply)
     register method should modify bool 'result' to reflect success/fail
     checking is supplied with user pointer (see optional interface)
  instead of using auto generated event ids, include a header file and
     #define '_module_Events' and all events via 'module_Events_class_event'
  all classes with events has a static EVENT table, and if defined
     method registerEvent(event_id:int, handler:closure, ...), and
     method releaseEvent(event_id:int, handler:closure)
  for all classes a special _typeof function is implemented

C/C++ helper/interface:
  [OBJGET]     void *c2s_getobj(HSQUIRRELVM v, int idx);
  [OBJPUSH]    void c2s_pushobj(HSQUIRRELVM v, void *obj);
  [OBJRELEASE] void c2s_relobj(HSQUIRRELVM v, void *obj);
  [macros]     UP_GET(X), UP_SET(X,V), UP_CLEAR(X)
  [optional]   void sq_raiseerror(HSQUIRRELVM v, const char *err = NULL);
  [abstract]   SQInteger abstract_base(HSQUIRRELVM v);
  [classes]    SQInteger c2s_typeof(HSQUIRRELVM v);
  [interface]  SQRESULT register_module(HSQUIRRELVM v, has_table = false);
  [optional]   void events_module(void *user = NULL);
  [optional]   void usercall_module(void *user = NULL);
  [optional]   void keywords_module(void *user = NULL);
  [optional]   const char *version_module();

Source: README, updated 2015-09-05