gopkg.in/olebedev/go-duktape.v1@v1.0.0-20151008052556-e2ae92f01e4a/api.go (about)

     1  package duktape
     2  
     3  /*
     4  # include "duktape.h"
     5  static void _duk_eval_string(duk_context *ctx, const char *str) {
     6    return duk_eval_string(ctx, str);
     7  }
     8  static void _duk_compile(duk_context *ctx, duk_uint_t flags) {
     9    return duk_compile(ctx, flags);
    10  }
    11  static void _duk_compile_file(duk_context *ctx, duk_uint_t flags, const char *path) {
    12    return duk_compile_file(ctx, flags, path);
    13  }
    14  static void _duk_compile_lstring(duk_context *ctx, duk_uint_t flags, const char *src, duk_size_t len) {
    15  	return duk_compile_lstring(ctx, flags, src, len);
    16  }
    17  static void _duk_compile_lstring_filename(duk_context *ctx, duk_uint_t flags, const char *src, duk_size_t len) {
    18  	return duk_compile_lstring_filename(ctx, flags, src, len);
    19  }
    20  static void _duk_compile_string(duk_context *ctx, duk_uint_t flags, const char *src) {
    21  	return duk_compile_string(ctx, flags, src);
    22  }
    23  static void _duk_compile_string_filename(duk_context *ctx, duk_uint_t flags, const char *src) {
    24  	return duk_compile_string_filename(ctx, flags, src);
    25  }
    26  static void _duk_dump_context_stderr(duk_context *ctx) {
    27  	return duk_dump_context_stderr(ctx);
    28  }
    29  static void _duk_dump_context_stdout(duk_context *ctx) {
    30  	return duk_dump_context_stdout(ctx);
    31  }
    32  static void _duk_eval(duk_context *ctx) {
    33  	return duk_eval(ctx);
    34  }
    35  static void _duk_eval_file(duk_context *ctx, const char *path) {
    36  	return duk_eval_file(ctx, path);
    37  }
    38  static void _duk_eval_file_noresult(duk_context *ctx, const char *path) {
    39  	return duk_eval_file_noresult(ctx, path);
    40  }
    41  static void _duk_eval_lstring(duk_context *ctx, const char *src, duk_size_t len) {
    42  	return duk_eval_lstring(ctx, src, len);
    43  }
    44  static void _duk_eval_lstring_noresult(duk_context *ctx, const char *src, duk_size_t len) {
    45  	return duk_eval_lstring_noresult(ctx, src, len);
    46  }
    47  static void _duk_eval_noresult(duk_context *ctx) {
    48  	return duk_eval_noresult(ctx);
    49  }
    50  static void _duk_eval_string_noresult(duk_context *ctx, const char *src) {
    51  	return duk_eval_string_noresult(ctx, src);
    52  }
    53  static duk_bool_t _duk_is_error(duk_context *ctx, duk_idx_t index) {
    54  	return duk_is_error(ctx, index);
    55  }
    56  static duk_bool_t _duk_is_object_coercible(duk_context *ctx, duk_idx_t index) {
    57  	return duk_is_object_coercible(ctx, index);
    58  }
    59  static duk_int_t _duk_pcompile(duk_context *ctx, duk_uint_t flags) {
    60  	return duk_pcompile(ctx, flags);
    61  }
    62  static duk_int_t _duk_pcompile_file(duk_context *ctx, duk_uint_t flags, const char *path) {
    63  	return duk_pcompile_file(ctx, flags, path);
    64  }
    65  static duk_int_t _duk_pcompile_lstring(duk_context *ctx, duk_uint_t flags, const char *src, duk_size_t len) {
    66  	return duk_pcompile_lstring(ctx, flags, src, len);
    67  }
    68  static duk_int_t _duk_pcompile_lstring_filename(duk_context *ctx, duk_uint_t flags, const char *src, duk_size_t len) {
    69  	return duk_pcompile_lstring_filename(ctx, flags, src, len);
    70  }
    71  static duk_int_t _duk_pcompile_string(duk_context *ctx, duk_uint_t flags, const char *src) {
    72  	return duk_pcompile_string(ctx, flags, src);
    73  }
    74  static duk_int_t _duk_pcompile_string_filename(duk_context *ctx, duk_uint_t flags, const char *src) {
    75  	return duk_pcompile_string_filename(ctx, flags, src);
    76  }
    77  static duk_int_t _duk_peval(duk_context *ctx) {
    78  	return duk_peval(ctx);
    79  }
    80  static duk_int_t _duk_peval_file(duk_context *ctx, const char *path) {
    81  	return duk_peval_file(ctx, path);
    82  }
    83  static duk_int_t _duk_peval_file_noresult(duk_context *ctx, const char *path) {
    84  	return duk_peval_file_noresult(ctx, path);
    85  }
    86  static duk_int_t _duk_peval_lstring(duk_context *ctx, const char *src, duk_size_t len) {
    87  	return duk_peval_lstring(ctx, src, len);
    88  }
    89  static duk_int_t _duk_peval_lstring_noresult(duk_context *ctx, const char *src, duk_size_t len) {
    90  	return duk_peval_lstring_noresult(ctx, src, len);
    91  }
    92  static duk_int_t _duk_peval_noresult(duk_context *ctx) {
    93  	return duk_peval_noresult(ctx);
    94  }
    95  static duk_int_t _duk_peval_string(duk_context *ctx, const char *src) {
    96  	return duk_peval_string(ctx, src);
    97  }
    98  static duk_int_t _duk_peval_string_noresult(duk_context *ctx, const char *src) {
    99  	return duk_peval_string_noresult(ctx, src);
   100  }
   101  static const char *_duk_push_string_file(duk_context *ctx, const char *path) {
   102  	return duk_push_string_file(ctx, path);
   103  }
   104  static duk_idx_t _duk_push_thread(duk_context *ctx) {
   105  	return duk_push_thread(ctx);
   106  }
   107  static duk_idx_t _duk_push_thread_new_globalenv(duk_context *ctx) {
   108  	return duk_push_thread_new_globalenv(ctx);
   109  }
   110  static void _duk_require_object_coercible(duk_context *ctx, duk_idx_t index) {
   111  	return duk_require_object_coercible(ctx, index);
   112  }
   113  static void _duk_require_type_mask(duk_context *ctx, duk_idx_t index, duk_uint_t mask) {
   114  	return duk_require_type_mask(ctx, index, mask);
   115  }
   116  static const char *_duk_safe_to_string(duk_context *ctx, duk_idx_t index) {
   117  	return duk_safe_to_string(ctx, index);
   118  }
   119  static void _duk_xcopy_top(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count) {
   120  	return duk_xcopy_top(to_ctx, from_ctx, count);
   121  }
   122  static void _duk_xmove_top(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count) {
   123  	return duk_xmove_top(to_ctx, from_ctx, count);
   124  }
   125  static void *_duk_to_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size) {
   126  	return duk_to_buffer(ctx, index, out_size);
   127  }
   128  static void *_duk_to_dynamic_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size) {
   129  	return duk_to_dynamic_buffer(ctx, index, out_size);
   130  }
   131  static void *_duk_to_fixed_buffer(duk_context *ctx, duk_idx_t index, duk_size_t *out_size) {
   132  	return duk_to_fixed_buffer(ctx, index, out_size);
   133  }
   134  static void *_duk_push_buffer(duk_context *ctx, duk_size_t size, duk_bool_t dynamic) {
   135  	return duk_push_buffer(ctx, size, dynamic);
   136  }
   137  static void *_duk_push_fixed_buffer(duk_context *ctx, duk_size_t size) {
   138  	return duk_push_fixed_buffer(ctx, size);
   139  }
   140  static void *_duk_push_dynamic_buffer(duk_context *ctx, duk_size_t size) {
   141  	return duk_push_dynamic_buffer(ctx, size);
   142  }
   143  static void _duk_error(duk_context *ctx, duk_errcode_t err_code, const char *str) {
   144  	duk_error(ctx, err_code, "%s", str);
   145  }
   146  static void _duk_push_error_object(duk_context *ctx, duk_errcode_t err_code, const char *str) {
   147  	duk_push_error_object(ctx, err_code, "%s", str);
   148  }
   149  static void _duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *text) {
   150  	duk_error_raw(ctx, err_code, filename, line, text);
   151  }
   152  */
   153  import "C"
   154  import (
   155  	"fmt"
   156  	"unsafe"
   157  )
   158  
   159  // See: http://duktape.org/api.html#duk_alloc
   160  func (d *Context) Alloc(size int) {
   161  	C.duk_alloc(d.duk_context, C.duk_size_t(size))
   162  }
   163  
   164  // See: http://duktape.org/api.html#duk_alloc_raw
   165  func (d *Context) AllocRaw(size int) {
   166  	C.duk_alloc_raw(d.duk_context, C.duk_size_t(size))
   167  }
   168  
   169  // See: http://duktape.org/api.html#duk_base64_decode
   170  func (d *Context) Base64Decode(index int) {
   171  	C.duk_base64_decode(d.duk_context, C.duk_idx_t(index))
   172  }
   173  
   174  // See: http://duktape.org/api.html#duk_base64_encode
   175  func (d *Context) Base64Encode(index int) string {
   176  	if s := C.duk_base64_encode(d.duk_context, C.duk_idx_t(index)); s != nil {
   177  		return C.GoString(s)
   178  	}
   179  	return ""
   180  }
   181  
   182  // See: http://duktape.org/api.html#duk_call
   183  func (d *Context) Call(nargs int) {
   184  	C.duk_call(d.duk_context, C.duk_idx_t(nargs))
   185  }
   186  
   187  // See: http://duktape.org/api.html#duk_call_method
   188  func (d *Context) CallMethod(nargs int) {
   189  	C.duk_call_method(d.duk_context, C.duk_idx_t(nargs))
   190  }
   191  
   192  // See: http://duktape.org/api.html#duk_call_prop
   193  func (d *Context) CallProp(objIndex int, nargs int) {
   194  	C.duk_call_prop(d.duk_context, C.duk_idx_t(objIndex), C.duk_idx_t(nargs))
   195  }
   196  
   197  // See: http://duktape.org/api.html#duk_check_stack
   198  func (d *Context) CheckStack(extra int) bool {
   199  	return int(C.duk_check_stack(d.duk_context, C.duk_idx_t(extra))) == 1
   200  }
   201  
   202  // See: http://duktape.org/api.html#duk_check_stack_top
   203  func (d *Context) CheckStackTop(top int) bool {
   204  	return int(C.duk_check_stack_top(d.duk_context, C.duk_idx_t(top))) == 1
   205  }
   206  
   207  // See: http://duktape.org/api.html#duk_check_type
   208  func (d *Context) CheckType(index int, typ int) bool {
   209  	return int(C.duk_check_type(d.duk_context, C.duk_idx_t(index), C.duk_int_t(typ))) == 1
   210  }
   211  
   212  // See: http://duktape.org/api.html#duk_check_type_mask
   213  func (d *Context) CheckTypeMask(index int, mask uint) bool {
   214  	return int(C.duk_check_type_mask(d.duk_context, C.duk_idx_t(index), C.duk_uint_t(mask))) == 1
   215  }
   216  
   217  // See: http://duktape.org/api.html#duk_compact
   218  func (d *Context) Compact(objIndex int) {
   219  	C.duk_compact(d.duk_context, C.duk_idx_t(objIndex))
   220  }
   221  
   222  // See: http://duktape.org/api.html#duk_compile
   223  func (d *Context) Compile(flags uint) {
   224  	C._duk_compile(d.duk_context, C.duk_uint_t(flags))
   225  }
   226  
   227  // See: http://duktape.org/api.html#duk_compile_file
   228  func (d *Context) CompileFile(flags uint, path string) {
   229  	__path__ := C.CString(path)
   230  	defer C.free(unsafe.Pointer(__path__))
   231  	C._duk_compile_file(d.duk_context, C.duk_uint_t(flags), __path__)
   232  }
   233  
   234  // See: http://duktape.org/api.html#duk_compile_lstring
   235  func (d *Context) CompileLstring(flags uint, src string, len int) {
   236  	__src__ := C.CString(src)
   237  	defer C.free(unsafe.Pointer(__src__))
   238  	C._duk_compile_lstring(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len))
   239  }
   240  
   241  // See: http://duktape.org/api.html#duk_compile_lstring_filename
   242  func (d *Context) CompileLstringFilename(flags uint, src string, len int) {
   243  	__src__ := C.CString(src)
   244  	defer C.free(unsafe.Pointer(__src__))
   245  	C._duk_compile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len))
   246  }
   247  
   248  // See: http://duktape.org/api.html#duk_compile_string
   249  func (d *Context) CompileString(flags uint, src string) {
   250  	__src__ := C.CString(src)
   251  	defer C.free(unsafe.Pointer(__src__))
   252  	C._duk_compile_string(d.duk_context, C.duk_uint_t(flags), __src__)
   253  }
   254  
   255  // See: http://duktape.org/api.html#duk_compile_string_filename
   256  func (d *Context) CompileStringFilename(flags uint, src string) {
   257  	__src__ := C.CString(src)
   258  	defer C.free(unsafe.Pointer(__src__))
   259  	C._duk_compile_string_filename(d.duk_context, C.duk_uint_t(flags), __src__)
   260  }
   261  
   262  // See: http://duktape.org/api.html#duk_concat
   263  func (d *Context) Concat(count int) {
   264  	C.duk_concat(d.duk_context, C.duk_idx_t(count))
   265  }
   266  
   267  // See: http://duktape.org/api.html#duk_copy
   268  func (d *Context) Copy(fromIndex int, toIndex int) {
   269  	C.duk_copy(d.duk_context, C.duk_idx_t(fromIndex), C.duk_idx_t(toIndex))
   270  }
   271  
   272  // See: http://duktape.org/api.html#duk_del_prop
   273  func (d *Context) DelProp(objIndex int) bool {
   274  	return int(C.duk_del_prop(d.duk_context, C.duk_idx_t(objIndex))) == 1
   275  }
   276  
   277  // See: http://duktape.org/api.html#duk_del_prop_index
   278  func (d *Context) DelPropIndex(objIndex int, arrIndex uint) bool {
   279  	return int(C.duk_del_prop_index(d.duk_context, C.duk_idx_t(objIndex), C.duk_uarridx_t(arrIndex))) == 1
   280  }
   281  
   282  // See: http://duktape.org/api.html#duk_del_prop_string
   283  func (d *Context) DelPropString(objIndex int, key string) bool {
   284  	__key__ := C.CString(key)
   285  	defer C.free(unsafe.Pointer(__key__))
   286  	return int(C.duk_del_prop_string(d.duk_context, C.duk_idx_t(objIndex), __key__)) == 1
   287  }
   288  
   289  // See: http://duktape.org/api.html#duk_def_prop
   290  func (d *Context) DefProp(objIndex int, flags uint) {
   291  	C.duk_def_prop(d.duk_context, C.duk_idx_t(objIndex), C.duk_uint_t(flags))
   292  }
   293  
   294  // See: http://duktape.org/api.html#duk_destroy_heap
   295  func (d *Context) DestroyHeap() {
   296  	d.Gc(0)
   297  	C.duk_destroy_heap(d.duk_context)
   298  	d.duk_context = nil
   299  }
   300  
   301  // See: http://duktape.org/api.html#duk_dump_context_stderr
   302  func (d *Context) DumpContextStderr() {
   303  	C._duk_dump_context_stderr(d.duk_context)
   304  }
   305  
   306  // See: http://duktape.org/api.html#duk_dump_context_stdout
   307  func (d *Context) DumpContextStdout() {
   308  	C._duk_dump_context_stdout(d.duk_context)
   309  }
   310  
   311  // See: http://duktape.org/api.html#duk_dup
   312  func (d *Context) Dup(fromIndex int) {
   313  	C.duk_dup(d.duk_context, C.duk_idx_t(fromIndex))
   314  }
   315  
   316  // See: http://duktape.org/api.html#duk_dup_top
   317  func (d *Context) DupTop() {
   318  	C.duk_dup_top(d.duk_context)
   319  }
   320  
   321  // See: http://duktape.org/api.html#duk_enum
   322  func (d *Context) Enum(objIndex int, enumFlags uint) {
   323  	C.duk_enum(d.duk_context, C.duk_idx_t(objIndex), C.duk_uint_t(enumFlags))
   324  }
   325  
   326  // See: http://duktape.org/api.html#duk_equals
   327  func (d *Context) Equals(index1 int, index2 int) bool {
   328  	return int(C.duk_equals(d.duk_context, C.duk_idx_t(index1), C.duk_idx_t(index2))) == 1
   329  }
   330  
   331  // Error pushes a new Error object to the stack and throws it. This will call
   332  // fmt.Sprint, forwarding arguments after the error code, to produce the
   333  // Error's message.
   334  //
   335  // See: http://duktape.org/api.html#duk_error
   336  func (d *Context) Error(errCode int, a ...interface{}) {
   337  	str := fmt.Sprint(a...)
   338  	__str__ := C.CString(str)
   339  	defer C.free(unsafe.Pointer(__str__))
   340  	C._duk_error(d.duk_context, C.duk_errcode_t(errCode), __str__)
   341  }
   342  
   343  func (d *Context) ErrorRaw(errCode int, filename string, line int, errMsg string) {
   344  	__filename__ := C.CString(filename)
   345  	__errMsg__ := C.CString(errMsg)
   346  	defer C.free(unsafe.Pointer(__filename__))
   347  	defer C.free(unsafe.Pointer(__errMsg__))
   348  
   349  	C._duk_error_raw(d.duk_context, C.duk_errcode_t(errCode), __filename__, C.duk_int_t(line), __errMsg__)
   350  }
   351  
   352  // Errorf pushes a new Error object to the stack and throws it. This will call
   353  // fmt.Sprintf, forwarding the format string and additional arguments, to
   354  // produce the Error's message.
   355  //
   356  // See: http://duktape.org/api.html#duk_error
   357  func (d *Context) Errorf(errCode int, format string, a ...interface{}) {
   358  	str := fmt.Sprintf(format, a...)
   359  	__str__ := C.CString(str)
   360  	defer C.free(unsafe.Pointer(__str__))
   361  	C._duk_error(d.duk_context, C.duk_errcode_t(errCode), __str__)
   362  }
   363  
   364  // See: http://duktape.org/api.html#duk_eval
   365  func (d *Context) Eval() {
   366  	C._duk_eval(d.duk_context)
   367  }
   368  
   369  // See: http://duktape.org/api.html#duk_eval_file
   370  func (d *Context) EvalFile(path string) {
   371  	__path__ := C.CString(path)
   372  	defer C.free(unsafe.Pointer(__path__))
   373  	C._duk_eval_file(d.duk_context, __path__)
   374  }
   375  
   376  // See: http://duktape.org/api.html#duk_eval_file_noresult
   377  func (d *Context) EvalFileNoresult(path string) {
   378  	__path__ := C.CString(path)
   379  	defer C.free(unsafe.Pointer(__path__))
   380  	C._duk_eval_file_noresult(d.duk_context, __path__)
   381  }
   382  
   383  // See: http://duktape.org/api.html#duk_eval_lstring
   384  func (d *Context) EvalLstring(src string, len int) {
   385  	__src__ := C.CString(src)
   386  	defer C.free(unsafe.Pointer(__src__))
   387  	C._duk_eval_lstring(d.duk_context, __src__, C.duk_size_t(len))
   388  }
   389  
   390  // See: http://duktape.org/api.html#duk_eval_lstring_noresult
   391  func (d *Context) EvalLstringNoresult(src string, len int) {
   392  	__src__ := C.CString(src)
   393  	defer C.free(unsafe.Pointer(__src__))
   394  	C._duk_eval_lstring_noresult(d.duk_context, __src__, C.duk_size_t(len))
   395  }
   396  
   397  // See: http://duktape.org/api.html#duk_eval_noresult
   398  func (d *Context) EvalNoresult() {
   399  	C._duk_eval_noresult(d.duk_context)
   400  }
   401  
   402  // See: http://duktape.org/api.html#duk_eval_string
   403  func (d *Context) EvalString(src string) {
   404  	__src__ := C.CString(src)
   405  	defer C.free(unsafe.Pointer(__src__))
   406  	C._duk_eval_string(d.duk_context, __src__)
   407  }
   408  
   409  // See: http://duktape.org/api.html#duk_eval_string_noresult
   410  func (d *Context) EvalStringNoresult(src string) {
   411  	__src__ := C.CString(src)
   412  	defer C.free(unsafe.Pointer(__src__))
   413  	C._duk_eval_string_noresult(d.duk_context, __src__)
   414  }
   415  
   416  // See: http://duktape.org/api.html#duk_fatal
   417  func (d *Context) Fatal(errCode int, errMsg string) {
   418  	__errMsg__ := C.CString(errMsg)
   419  	defer C.free(unsafe.Pointer(__errMsg__))
   420  	C.duk_fatal(d.duk_context, C.duk_errcode_t(errCode), __errMsg__)
   421  }
   422  
   423  // See: http://duktape.org/api.html#duk_gc
   424  func (d *Context) Gc(flags uint) {
   425  	C.duk_gc(d.duk_context, C.duk_uint_t(flags))
   426  }
   427  
   428  // See: http://duktape.org/api.html#duk_get_boolean
   429  func (d *Context) GetBoolean(index int) bool {
   430  	return int(C.duk_get_boolean(d.duk_context, C.duk_idx_t(index))) == 1
   431  }
   432  
   433  // See: http://duktape.org/api.html#duk_get_buffer
   434  func (d *Context) GetBuffer(index int, outSize int) {
   435  	C.duk_get_buffer(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outSize)))
   436  }
   437  
   438  // See: http://duktape.org/api.html#duk_get_context
   439  func (d *Context) GetContext(index int) *Context {
   440  	return contextFromPointer(C.duk_get_context(d.duk_context, C.duk_idx_t(index)))
   441  }
   442  
   443  // See: http://duktape.org/api.html#duk_get_current_magic
   444  func (d *Context) GetCurrentMagic() int {
   445  	return int(C.duk_get_current_magic(d.duk_context))
   446  }
   447  
   448  // See: http://duktape.org/api.html#duk_get_error_code
   449  func (d *Context) GetErrorCode(index int) int {
   450  	code := int(C.duk_get_error_code(d.duk_context, C.duk_idx_t(index)))
   451  	return code
   452  }
   453  
   454  // See: http://duktape.org/api.html#duk_get_finalizer
   455  func (d *Context) GetFinalizer(index int) {
   456  	C.duk_get_finalizer(d.duk_context, C.duk_idx_t(index))
   457  }
   458  
   459  // See: http://duktape.org/api.html#duk_get_global_string
   460  func (d *Context) GetGlobalString(key string) bool {
   461  	__key__ := C.CString(key)
   462  	defer C.free(unsafe.Pointer(__key__))
   463  	return int(C.duk_get_global_string(d.duk_context, __key__)) == 1
   464  }
   465  
   466  // See: http://duktape.org/api.html#duk_get_heapptr
   467  func (d *Context) GetHeapptr(index int) unsafe.Pointer {
   468  	return unsafe.Pointer(C.duk_get_heapptr(d.duk_context, C.duk_idx_t(index)))
   469  }
   470  
   471  // See: http://duktape.org/api.html#duk_get_int
   472  func (d *Context) GetInt(index int) int {
   473  	return int(C.duk_get_int(d.duk_context, C.duk_idx_t(index)))
   474  }
   475  
   476  // See: http://duktape.org/api.html#duk_get_length
   477  func (d *Context) GetLength(index int) int {
   478  	return int(C.duk_get_length(d.duk_context, C.duk_idx_t(index)))
   479  }
   480  
   481  // See: http://duktape.org/api.html#duk_get_lstring
   482  func (d *Context) GetLstring(index int, outLen int) string {
   483  	if s := C.duk_get_lstring(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outLen))); s != nil {
   484  		return C.GoString(s)
   485  	}
   486  	return ""
   487  }
   488  
   489  // See: http://duktape.org/api.html#duk_get_magic
   490  func (d *Context) GetMagic(index int) int {
   491  	return int(C.duk_get_magic(d.duk_context, C.duk_idx_t(index)))
   492  }
   493  
   494  // See: http://duktape.org/api.html#duk_get_number
   495  func (d *Context) GetNumber(index int) float64 {
   496  	return float64(C.duk_get_number(d.duk_context, C.duk_idx_t(index)))
   497  }
   498  
   499  // See: http://duktape.org/api.html#duk_get_pointer
   500  func (d *Context) GetPointer(index int) unsafe.Pointer {
   501  	return C.duk_get_pointer(d.duk_context, C.duk_idx_t(index))
   502  }
   503  
   504  // See: http://duktape.org/api.html#duk_get_prop
   505  func (d *Context) GetProp(objIndex int) bool {
   506  	return int(C.duk_get_prop(d.duk_context, C.duk_idx_t(objIndex))) == 1
   507  }
   508  
   509  // See: http://duktape.org/api.html#duk_get_prop_index
   510  func (d *Context) GetPropIndex(objIndex int, arrIndex uint) bool {
   511  	return int(C.duk_get_prop_index(d.duk_context, C.duk_idx_t(objIndex), C.duk_uarridx_t(arrIndex))) == 1
   512  }
   513  
   514  // See: http://duktape.org/api.html#duk_get_prop_string
   515  func (d *Context) GetPropString(objIndex int, key string) bool {
   516  	__key__ := C.CString(key)
   517  	defer C.free(unsafe.Pointer(__key__))
   518  	return int(C.duk_get_prop_string(d.duk_context, C.duk_idx_t(objIndex), __key__)) == 1
   519  }
   520  
   521  // See: http://duktape.org/api.html#duk_get_prototype
   522  func (d *Context) GetPrototype(index int) {
   523  	C.duk_get_prototype(d.duk_context, C.duk_idx_t(index))
   524  }
   525  
   526  // See: http://duktape.org/api.html#duk_get_string
   527  func (d *Context) GetString(i int) string {
   528  	if s := C.duk_get_string(d.duk_context, C.duk_idx_t(i)); s != nil {
   529  		return C.GoString(s)
   530  	}
   531  	return ""
   532  }
   533  
   534  // See: http://duktape.org/api.html#duk_get_top
   535  func (d *Context) GetTop() int {
   536  	return int(C.duk_get_top(d.duk_context))
   537  }
   538  
   539  // See: http://duktape.org/api.html#duk_get_top_index
   540  func (d *Context) GetTopIndex() int {
   541  	return int(C.duk_get_top_index(d.duk_context))
   542  }
   543  
   544  // See: http://duktape.org/api.html#duk_get_type
   545  func (d *Context) GetType(index int) Type {
   546  	return Type(C.duk_get_type(d.duk_context, C.duk_idx_t(index)))
   547  }
   548  
   549  // See: http://duktape.org/api.html#duk_get_type_mask
   550  func (d *Context) GetTypeMask(index int) uint {
   551  	return uint(C.duk_get_type_mask(d.duk_context, C.duk_idx_t(index)))
   552  }
   553  
   554  // See: http://duktape.org/api.html#duk_get_uint
   555  func (d *Context) GetUint(index int) uint {
   556  	return uint(C.duk_get_uint(d.duk_context, C.duk_idx_t(index)))
   557  }
   558  
   559  // See: http://duktape.org/api.html#duk_has_prop
   560  func (d *Context) HasProp(objIndex int) bool {
   561  	return int(C.duk_has_prop(d.duk_context, C.duk_idx_t(objIndex))) == 1
   562  }
   563  
   564  // See: http://duktape.org/api.html#duk_has_prop_index
   565  func (d *Context) HasPropIndex(objIndex int, arrIndex uint) bool {
   566  	return int(C.duk_has_prop_index(d.duk_context, C.duk_idx_t(objIndex), C.duk_uarridx_t(arrIndex))) == 1
   567  }
   568  
   569  // See: http://duktape.org/api.html#duk_has_prop_string
   570  func (d *Context) HasPropString(objIndex int, key string) bool {
   571  	__key__ := C.CString(key)
   572  	defer C.free(unsafe.Pointer(__key__))
   573  	return int(C.duk_has_prop_string(d.duk_context, C.duk_idx_t(objIndex), __key__)) == 1
   574  }
   575  
   576  // See: http://duktape.org/api.html#duk_hex_decode
   577  func (d *Context) HexDecode(index int) {
   578  	C.duk_hex_decode(d.duk_context, C.duk_idx_t(index))
   579  }
   580  
   581  // See: http://duktape.org/api.html#duk_hex_encode
   582  func (d *Context) HexEncode(index int) string {
   583  	if s := C.duk_hex_encode(d.duk_context, C.duk_idx_t(index)); s != nil {
   584  		return C.GoString(s)
   585  	}
   586  	return ""
   587  }
   588  
   589  // See: http://duktape.org/api.html#duk_insert
   590  func (d *Context) Insert(toIndex int) {
   591  	C.duk_insert(d.duk_context, C.duk_idx_t(toIndex))
   592  }
   593  
   594  // See: http://duktape.org/api.html#duk_is_array
   595  func (d *Context) IsArray(index int) bool {
   596  	return int(C.duk_is_array(d.duk_context, C.duk_idx_t(index))) == 1
   597  }
   598  
   599  // See: http://duktape.org/api.html#duk_is_boolean
   600  func (d *Context) IsBoolean(index int) bool {
   601  	return int(C.duk_is_boolean(d.duk_context, C.duk_idx_t(index))) == 1
   602  }
   603  
   604  // See: http://duktape.org/api.html#duk_is_bound_function
   605  func (d *Context) IsBoundFunction(index int) bool {
   606  	return int(C.duk_is_bound_function(d.duk_context, C.duk_idx_t(index))) == 1
   607  }
   608  
   609  // See: http://duktape.org/api.html#duk_is_buffer
   610  func (d *Context) IsBuffer(index int) bool {
   611  	return int(C.duk_is_buffer(d.duk_context, C.duk_idx_t(index))) == 1
   612  }
   613  
   614  // See: http://duktape.org/api.html#duk_is_c_function
   615  func (d *Context) IsCFunction(index int) bool {
   616  	return int(C.duk_is_c_function(d.duk_context, C.duk_idx_t(index))) == 1
   617  }
   618  
   619  // See: http://duktape.org/api.html#duk_is_callable
   620  func (d *Context) IsCallable(index int) bool {
   621  	return int(C.duk_is_callable(d.duk_context, C.duk_idx_t(index))) == 1
   622  }
   623  
   624  // See: http://duktape.org/api.html#duk_is_constructor_call
   625  func (d *Context) IsConstructorCall() bool {
   626  	return int(C.duk_is_constructor_call(d.duk_context)) == 1
   627  }
   628  
   629  // See: http://duktape.org/api.html#duk_is_dynamic_buffer
   630  func (d *Context) IsDynamicBuffer(index int) bool {
   631  	return int(C.duk_is_dynamic_buffer(d.duk_context, C.duk_idx_t(index))) == 1
   632  }
   633  
   634  // See: http://duktape.org/api.html#duk_is_ecmascript_function
   635  func (d *Context) IsEcmascriptFunction(index int) bool {
   636  	return int(C.duk_is_ecmascript_function(d.duk_context, C.duk_idx_t(index))) == 1
   637  }
   638  
   639  // See: http://duktape.org/api.html#duk_is_fixed_buffer
   640  func (d *Context) IsFixedBuffer(index int) bool {
   641  	return int(C.duk_is_fixed_buffer(d.duk_context, C.duk_idx_t(index))) == 1
   642  }
   643  
   644  // See: http://duktape.org/api.html#duk_is_function
   645  func (d *Context) IsFunction(index int) bool {
   646  	return int(C.duk_is_function(d.duk_context, C.duk_idx_t(index))) == 1
   647  }
   648  
   649  // See: http://duktape.org/api.html#duk_is_nan
   650  func (d *Context) IsNan(index int) bool {
   651  	return int(C.duk_is_nan(d.duk_context, C.duk_idx_t(index))) == 1
   652  }
   653  
   654  // See: http://duktape.org/api.html#duk_is_null
   655  func (d *Context) IsNull(index int) bool {
   656  	return int(C.duk_is_null(d.duk_context, C.duk_idx_t(index))) == 1
   657  }
   658  
   659  // See: http://duktape.org/api.html#duk_is_null_or_undefined
   660  func (d *Context) IsNullOrUndefined(index int) bool {
   661  	return int(C.duk_is_null_or_undefined(d.duk_context, C.duk_idx_t(index))) == 1
   662  }
   663  
   664  // See: http://duktape.org/api.html#duk_is_number
   665  func (d *Context) IsNumber(index int) bool {
   666  	return int(C.duk_is_number(d.duk_context, C.duk_idx_t(index))) == 1
   667  }
   668  
   669  // See: http://duktape.org/api.html#duk_is_object
   670  func (d *Context) IsObject(index int) bool {
   671  	return int(C.duk_is_object(d.duk_context, C.duk_idx_t(index))) == 1
   672  }
   673  
   674  // See: http://duktape.org/api.html#duk_is_error
   675  func (d *Context) IsError(index int) bool {
   676  	return int(C._duk_is_error(d.duk_context, C.duk_idx_t(index))) == 1
   677  }
   678  
   679  // See: http://duktape.org/api.html#duk_is_object_coercible
   680  func (d *Context) IsObjectCoercible(index int) bool {
   681  	return int(C._duk_is_object_coercible(d.duk_context, C.duk_idx_t(index))) == 1
   682  }
   683  
   684  // See: http://duktape.org/api.html#duk_is_pointer
   685  func (d *Context) IsPointer(index int) bool {
   686  	return int(C.duk_is_pointer(d.duk_context, C.duk_idx_t(index))) == 1
   687  }
   688  
   689  // See: http://duktape.org/api.html#duk_is_primitive
   690  func (d *Context) IsPrimitive(index int) bool {
   691  	return int(C.duk_is_primitive(d.duk_context, C.duk_idx_t(index))) == 1
   692  }
   693  
   694  // See: http://duktape.org/api.html#duk_is_strict_call
   695  func (d *Context) IsStrictCall() bool {
   696  	return int(C.duk_is_strict_call(d.duk_context)) == 1
   697  }
   698  
   699  // See: http://duktape.org/api.html#duk_is_string
   700  func (d *Context) IsString(index int) bool {
   701  	return int(C.duk_is_string(d.duk_context, C.duk_idx_t(index))) == 1
   702  }
   703  
   704  // See: http://duktape.org/api.html#duk_is_thread
   705  func (d *Context) IsThread(index int) bool {
   706  	return int(C.duk_is_thread(d.duk_context, C.duk_idx_t(index))) == 1
   707  }
   708  
   709  // See: http://duktape.org/api.html#duk_is_undefined
   710  func (d *Context) IsUndefined(index int) bool {
   711  	return int(C.duk_is_undefined(d.duk_context, C.duk_idx_t(index))) == 1
   712  }
   713  
   714  // See: http://duktape.org/api.html#duk_is_valid_index
   715  func (d *Context) IsValidIndex(index int) bool {
   716  	return int(C.duk_is_valid_index(d.duk_context, C.duk_idx_t(index))) == 1
   717  }
   718  
   719  // See: http://duktape.org/api.html#duk_join
   720  func (d *Context) Join(count int) {
   721  	C.duk_join(d.duk_context, C.duk_idx_t(count))
   722  }
   723  
   724  // See: http://duktape.org/api.html#duk_json_decode
   725  func (d *Context) JsonDecode(index int) {
   726  	C.duk_json_decode(d.duk_context, C.duk_idx_t(index))
   727  }
   728  
   729  // See: http://duktape.org/api.html#duk_json_encode
   730  func (d *Context) JsonEncode(index int) string {
   731  	if s := C.duk_json_encode(d.duk_context, C.duk_idx_t(index)); s != nil {
   732  		return C.GoString(s)
   733  	}
   734  	return ""
   735  }
   736  
   737  // See: http://duktape.org/api.html#duk_new
   738  func (d *Context) New(nargs int) {
   739  	C.duk_new(d.duk_context, C.duk_idx_t(nargs))
   740  }
   741  
   742  // See: http://duktape.org/api.html#duk_next
   743  func (d *Context) Next(enumIndex int, getValue bool) bool {
   744  	var __getValue__ int
   745  	if getValue {
   746  		__getValue__ = 1
   747  	}
   748  	return int(C.duk_next(d.duk_context, C.duk_idx_t(enumIndex), C.duk_bool_t(__getValue__))) == 1
   749  }
   750  
   751  // See: http://duktape.org/api.html#duk_normalize_index
   752  func (d *Context) NormalizeIndex(index int) int {
   753  	return int(C.duk_normalize_index(d.duk_context, C.duk_idx_t(index)))
   754  }
   755  
   756  // See: http://duktape.org/api.html#duk_pcall
   757  func (d *Context) Pcall(nargs int) int {
   758  	return int(C.duk_pcall(d.duk_context, C.duk_idx_t(nargs)))
   759  }
   760  
   761  // See: http://duktape.org/api.html#duk_pcall_method
   762  func (d *Context) PcallMethod(nargs int) int {
   763  	return int(C.duk_pcall_method(d.duk_context, C.duk_idx_t(nargs)))
   764  }
   765  
   766  // See: http://duktape.org/api.html#duk_pcall_prop
   767  func (d *Context) PcallProp(objIndex int, nargs int) int {
   768  	return int(C.duk_pcall_prop(d.duk_context, C.duk_idx_t(objIndex), C.duk_idx_t(nargs)))
   769  }
   770  
   771  // See: http://duktape.org/api.html#duk_pcompile
   772  func (d *Context) Pcompile(flags uint) error {
   773  	result := int(C._duk_pcompile(d.duk_context, C.duk_uint_t(flags)))
   774  	return d.castStringToError(result)
   775  }
   776  
   777  // See: http://duktape.org/api.html#duk_pcompile_file
   778  func (d *Context) PcompileFile(flags uint, path string) error {
   779  	__path__ := C.CString(path)
   780  	defer C.free(unsafe.Pointer(__path__))
   781  
   782  	result := int(C._duk_pcompile_file(d.duk_context, C.duk_uint_t(flags), __path__))
   783  	return d.castStringToError(result)
   784  }
   785  
   786  // See: http://duktape.org/api.html#duk_pcompile_lstring
   787  func (d *Context) PcompileLstring(flags uint, src string, len int) error {
   788  	__src__ := C.CString(src)
   789  	defer C.free(unsafe.Pointer(__src__))
   790  
   791  	result := int(C._duk_pcompile_lstring(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len)))
   792  	return d.castStringToError(result)
   793  }
   794  
   795  // See: http://duktape.org/api.html#duk_pcompile_lstring_filename
   796  func (d *Context) PcompileLstringFilename(flags uint, src string, len int) error {
   797  	__src__ := C.CString(src)
   798  	defer C.free(unsafe.Pointer(__src__))
   799  
   800  	result := int(C._duk_pcompile_lstring_filename(d.duk_context, C.duk_uint_t(flags), __src__, C.duk_size_t(len)))
   801  	return d.castStringToError(result)
   802  }
   803  
   804  // See: http://duktape.org/api.html#duk_pcompile_string
   805  func (d *Context) PcompileString(flags uint, src string) error {
   806  	__src__ := C.CString(src)
   807  	defer C.free(unsafe.Pointer(__src__))
   808  
   809  	result := int(C._duk_pcompile_string(d.duk_context, C.duk_uint_t(flags), __src__))
   810  	return d.castStringToError(result)
   811  }
   812  
   813  // See: http://duktape.org/api.html#duk_pcompile_string_filename
   814  func (d *Context) PcompileStringFilename(flags uint, src string) error {
   815  	__src__ := C.CString(src)
   816  	defer C.free(unsafe.Pointer(__src__))
   817  
   818  	result := int(C._duk_pcompile_string_filename(d.duk_context, C.duk_uint_t(flags), __src__))
   819  	return d.castStringToError(result)
   820  }
   821  
   822  // See: http://duktape.org/api.html#duk_peval
   823  func (d *Context) Peval() error {
   824  	result := int(C._duk_peval(d.duk_context))
   825  	return d.castStringToError(result)
   826  }
   827  
   828  // See: http://duktape.org/api.html#duk_peval_file
   829  func (d *Context) PevalFile(path string) error {
   830  	__path__ := C.CString(path)
   831  	defer C.free(unsafe.Pointer(__path__))
   832  
   833  	result := int(C._duk_peval_file(d.duk_context, __path__))
   834  	return d.castStringToError(result)
   835  }
   836  
   837  // See: http://duktape.org/api.html#duk_peval_file_noresult
   838  func (d *Context) PevalFileNoresult(path string) int {
   839  	__path__ := C.CString(path)
   840  	defer C.free(unsafe.Pointer(__path__))
   841  	return int(C._duk_peval_file_noresult(d.duk_context, __path__))
   842  }
   843  
   844  // See: http://duktape.org/api.html#duk_peval_lstring
   845  func (d *Context) PevalLstring(src string, len int) error {
   846  	__src__ := C.CString(src)
   847  	defer C.free(unsafe.Pointer(__src__))
   848  
   849  	result := int(C._duk_peval_lstring(d.duk_context, __src__, C.duk_size_t(len)))
   850  	return d.castStringToError(result)
   851  
   852  }
   853  
   854  // See: http://duktape.org/api.html#duk_peval_lstring_noresult
   855  func (d *Context) PevalLstringNoresult(src string, len int) int {
   856  	__src__ := C.CString(src)
   857  	defer C.free(unsafe.Pointer(__src__))
   858  	return int(C._duk_peval_lstring_noresult(d.duk_context, __src__, C.duk_size_t(len)))
   859  }
   860  
   861  // See: http://duktape.org/api.html#duk_peval_noresult
   862  func (d *Context) PevalNoresult() int {
   863  	return int(C._duk_peval_noresult(d.duk_context))
   864  }
   865  
   866  // See: http://duktape.org/api.html#duk_peval_string
   867  func (d *Context) PevalString(src string) error {
   868  	__src__ := C.CString(src)
   869  	defer C.free(unsafe.Pointer(__src__))
   870  
   871  	result := int(C._duk_peval_string(d.duk_context, __src__))
   872  	return d.castStringToError(result)
   873  }
   874  
   875  // See: http://duktape.org/api.html#duk_peval_string_noresult
   876  func (d *Context) PevalStringNoresult(src string) int {
   877  	__src__ := C.CString(src)
   878  	defer C.free(unsafe.Pointer(__src__))
   879  
   880  	return int(C._duk_peval_string_noresult(d.duk_context, __src__))
   881  }
   882  
   883  func (d *Context) castStringToError(result int) error {
   884  	if result == 0 {
   885  		return nil
   886  	}
   887  
   888  	err := &Error{}
   889  	for _, key := range []string{"name", "message", "fileName", "lineNumber", "stack"} {
   890  		d.GetPropString(-1, key)
   891  
   892  		switch key {
   893  		case "name":
   894  			err.Type = d.SafeToString(-1)
   895  		case "message":
   896  			err.Message = d.SafeToString(-1)
   897  		case "fileName":
   898  			err.FileName = d.SafeToString(-1)
   899  		case "lineNumber":
   900  			if d.IsNumber(-1) {
   901  				err.LineNumber = d.GetInt(-1)
   902  			}
   903  		case "stack":
   904  			err.Stack = d.SafeToString(-1)
   905  		}
   906  
   907  		d.Pop()
   908  	}
   909  
   910  	return err
   911  }
   912  
   913  // See: http://duktape.org/api.html#duk_pop
   914  func (d *Context) Pop() {
   915  	if d.GetTop() == 0 {
   916  		return
   917  	}
   918  	C.duk_pop(d.duk_context)
   919  }
   920  
   921  // See: http://duktape.org/api.html#duk_pop_2
   922  func (d *Context) Pop2() {
   923  	d.PopN(2)
   924  }
   925  
   926  // See: http://duktape.org/api.html#duk_pop_3
   927  func (d *Context) Pop3() {
   928  	d.PopN(3)
   929  }
   930  
   931  // See: http://duktape.org/api.html#duk_pop_n
   932  func (d *Context) PopN(count int) {
   933  	if d.GetTop() < count || count < 1 {
   934  		return
   935  	}
   936  	C.duk_pop_n(d.duk_context, C.duk_idx_t(count))
   937  }
   938  
   939  // See: http://duktape.org/api.html#duk_push_array
   940  func (d *Context) PushArray() int {
   941  	return int(C.duk_push_array(d.duk_context))
   942  }
   943  
   944  // See: http://duktape.org/api.html#duk_push_boolean
   945  func (d *Context) PushBoolean(val bool) {
   946  	var __val__ int
   947  	if val {
   948  		__val__ = 1
   949  	}
   950  	C.duk_push_boolean(d.duk_context, C.duk_bool_t(__val__))
   951  }
   952  
   953  // See: http://duktape.org/api.html#duk_push_buffer
   954  func (d *Context) PushBuffer(size int, dynamic bool) {
   955  	var __dynamic__ int
   956  	if dynamic {
   957  		__dynamic__ = 1
   958  	}
   959  	C._duk_push_buffer(d.duk_context, C.duk_size_t(size), C.duk_bool_t(__dynamic__))
   960  }
   961  
   962  // See: http://duktape.org/api.html#duk_push_c_function
   963  func (d *Context) PushCFunction(fn *[0]byte, nargs int) int {
   964  	return int(C.duk_push_c_function(d.duk_context, fn, C.duk_idx_t(nargs)))
   965  }
   966  
   967  // See: http://duktape.org/api.html#duk_push_context_dump
   968  func (d *Context) PushContextDump() {
   969  	C.duk_push_context_dump(d.duk_context)
   970  }
   971  
   972  // See: http://duktape.org/api.html#duk_push_current_function
   973  func (d *Context) PushCurrentFunction() {
   974  	C.duk_push_current_function(d.duk_context)
   975  }
   976  
   977  // See: http://duktape.org/api.html#duk_push_current_thread
   978  func (d *Context) PushCurrentThread() {
   979  	C.duk_push_current_thread(d.duk_context)
   980  }
   981  
   982  // See: http://duktape.org/api.html#duk_push_dynamic_buffer
   983  func (d *Context) PushDynamicBuffer(size int) {
   984  	C._duk_push_dynamic_buffer(d.duk_context, C.duk_size_t(size))
   985  }
   986  
   987  // PushErrorObject pushes a new Error object to the stack. This will call
   988  // fmt.Sprint, forwarding arguments after the error code, to produce the
   989  // Error's message.
   990  //
   991  // See: http://duktape.org/api.html#duk_push_error_object
   992  func (d *Context) PushErrorObject(errCode int, a ...interface{}) {
   993  	str := fmt.Sprint(a...)
   994  	__str__ := C.CString(str)
   995  	defer C.free(unsafe.Pointer(__str__))
   996  	C._duk_push_error_object(d.duk_context, C.duk_errcode_t(errCode), __str__)
   997  }
   998  
   999  // PushErrorObjectf pushes a new Error object to the stack. This will call
  1000  // fmt.Sprintf, forwarding the format string and additional arguments, to
  1001  // produce the Error's message.
  1002  //
  1003  // See: http://duktape.org/api.html#duk_push_error_object
  1004  func (d *Context) PushErrorObjectf(errCode int, format string, a ...interface{}) {
  1005  	str := fmt.Sprintf(format, a...)
  1006  	__str__ := C.CString(str)
  1007  	defer C.free(unsafe.Pointer(__str__))
  1008  	C._duk_push_error_object(d.duk_context, C.duk_errcode_t(errCode), __str__)
  1009  }
  1010  
  1011  // See: http://duktape.org/api.html#duk_push_false
  1012  func (d *Context) PushFalse() {
  1013  	C.duk_push_false(d.duk_context)
  1014  }
  1015  
  1016  // See: http://duktape.org/api.html#duk_push_fixed_buffer
  1017  func (d *Context) PushFixedBuffer(size int) {
  1018  	C._duk_push_fixed_buffer(d.duk_context, C.duk_size_t(size))
  1019  }
  1020  
  1021  // See: http://duktape.org/api.html#duk_push_global_object
  1022  func (d *Context) PushGlobalObject() {
  1023  	C.duk_push_global_object(d.duk_context)
  1024  }
  1025  
  1026  // See: http://duktape.org/api.html#duk_push_global_stash
  1027  func (d *Context) PushGlobalStash() {
  1028  	C.duk_push_global_stash(d.duk_context)
  1029  }
  1030  
  1031  // See: http://duktape.org/api.html#duk_push_heapptr
  1032  func (d *Context) PushHeapptr(ptr unsafe.Pointer) {
  1033  	C.duk_push_heapptr(d.duk_context, ptr)
  1034  }
  1035  
  1036  // See: http://duktape.org/api.html#duk_push_heap_stash
  1037  func (d *Context) PushHeapStash() {
  1038  	C.duk_push_heap_stash(d.duk_context)
  1039  }
  1040  
  1041  // See: http://duktape.org/api.html#duk_push_int
  1042  func (d *Context) PushInt(val int) {
  1043  	C.duk_push_int(d.duk_context, C.duk_int_t(val))
  1044  }
  1045  
  1046  // See: http://duktape.org/api.html#duk_push_lstring
  1047  func (d *Context) PushLstring(str string, len int) string {
  1048  	__str__ := C.CString(str)
  1049  	defer C.free(unsafe.Pointer(__str__))
  1050  	if s := C.duk_push_lstring(d.duk_context, __str__, C.duk_size_t(len)); s != nil {
  1051  		return C.GoString(s)
  1052  	}
  1053  	return ""
  1054  }
  1055  
  1056  // See: http://duktape.org/api.html#duk_push_nan
  1057  func (d *Context) PushNan() {
  1058  	C.duk_push_nan(d.duk_context)
  1059  }
  1060  
  1061  // See: http://duktape.org/api.html#duk_push_null
  1062  func (d *Context) PushNull() {
  1063  	C.duk_push_null(d.duk_context)
  1064  }
  1065  
  1066  // See: http://duktape.org/api.html#duk_push_number
  1067  func (d *Context) PushNumber(val float64) {
  1068  	C.duk_push_number(d.duk_context, C.duk_double_t(val))
  1069  }
  1070  
  1071  // See: http://duktape.org/api.html#duk_push_object
  1072  func (d *Context) PushObject() int {
  1073  	return int(C.duk_push_object(d.duk_context))
  1074  }
  1075  
  1076  // See: http://duktape.org/api.html#duk_push_string
  1077  func (d *Context) PushString(str string) string {
  1078  	__str__ := C.CString(str)
  1079  	defer C.free(unsafe.Pointer(__str__))
  1080  	if s := C.duk_push_string(d.duk_context, __str__); s != nil {
  1081  		return C.GoString(s)
  1082  	}
  1083  	return ""
  1084  }
  1085  
  1086  // See: http://duktape.org/api.html#duk_push_string_file
  1087  func (d *Context) PushStringFile(path string) string {
  1088  	__path__ := C.CString(path)
  1089  	defer C.free(unsafe.Pointer(__path__))
  1090  	if s := C._duk_push_string_file(d.duk_context, __path__); s != nil {
  1091  		return C.GoString(s)
  1092  	}
  1093  	return ""
  1094  }
  1095  
  1096  // See: http://duktape.org/api.html#duk_push_this
  1097  func (d *Context) PushThis() {
  1098  	C.duk_push_this(d.duk_context)
  1099  }
  1100  
  1101  // See: http://duktape.org/api.html#duk_push_thread
  1102  func (d *Context) PushThread() int {
  1103  	return int(C._duk_push_thread(d.duk_context))
  1104  }
  1105  
  1106  // See: http://duktape.org/api.html#duk_push_thread_new_globalenv
  1107  func (d *Context) PushThreadNewGlobalenv() int {
  1108  	return int(C._duk_push_thread_new_globalenv(d.duk_context))
  1109  }
  1110  
  1111  // See: http://duktape.org/api.html#duk_push_thread_stash
  1112  func (d *Context) PushThreadStash(targetCtx *Context) {
  1113  	C.duk_push_thread_stash(d.duk_context, targetCtx.duk_context)
  1114  }
  1115  
  1116  // See: http://duktape.org/api.html#duk_push_true
  1117  func (d *Context) PushTrue() {
  1118  	C.duk_push_true(d.duk_context)
  1119  }
  1120  
  1121  // See: http://duktape.org/api.html#duk_push_uint
  1122  func (d *Context) PushUint(val uint) {
  1123  	C.duk_push_uint(d.duk_context, C.duk_uint_t(val))
  1124  }
  1125  
  1126  // See: http://duktape.org/api.html#duk_push_undefined
  1127  func (d *Context) PushUndefined() {
  1128  	C.duk_push_undefined(d.duk_context)
  1129  }
  1130  
  1131  // See: http://duktape.org/api.html#duk_put_global_string
  1132  func (d *Context) PutGlobalString(key string) bool {
  1133  	__key__ := C.CString(key)
  1134  	defer C.free(unsafe.Pointer(__key__))
  1135  	return int(C.duk_put_global_string(d.duk_context, __key__)) == 1
  1136  }
  1137  
  1138  // See: http://duktape.org/api.html#duk_put_prop
  1139  func (d *Context) PutProp(objIndex int) bool {
  1140  	return int(C.duk_put_prop(d.duk_context, C.duk_idx_t(objIndex))) == 1
  1141  }
  1142  
  1143  // See: http://duktape.org/api.html#duk_put_prop_index
  1144  func (d *Context) PutPropIndex(objIndex int, arrIndex uint) bool {
  1145  	return int(C.duk_put_prop_index(d.duk_context, C.duk_idx_t(objIndex), C.duk_uarridx_t(arrIndex))) == 1
  1146  }
  1147  
  1148  // See: http://duktape.org/api.html#duk_put_prop_string
  1149  func (d *Context) PutPropString(objIndex int, key string) bool {
  1150  	__key__ := C.CString(key)
  1151  	defer C.free(unsafe.Pointer(__key__))
  1152  	return int(C.duk_put_prop_string(d.duk_context, C.duk_idx_t(objIndex), __key__)) == 1
  1153  }
  1154  
  1155  // See: http://duktape.org/api.html#duk_remove
  1156  func (d *Context) Remove(index int) {
  1157  	C.duk_remove(d.duk_context, C.duk_idx_t(index))
  1158  }
  1159  
  1160  // See: http://duktape.org/api.html#duk_replace
  1161  func (d *Context) Replace(toIndex int) {
  1162  	C.duk_replace(d.duk_context, C.duk_idx_t(toIndex))
  1163  }
  1164  
  1165  // See: http://duktape.org/api.html#duk_require_boolean
  1166  func (d *Context) RequireBoolean(index int) bool {
  1167  	return int(C.duk_require_boolean(d.duk_context, C.duk_idx_t(index))) == 1
  1168  }
  1169  
  1170  // See: http://duktape.org/api.html#duk_require_buffer
  1171  func (d *Context) RequireBuffer(index int, outSize int) {
  1172  	C.duk_require_buffer(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outSize)))
  1173  }
  1174  
  1175  // See: http://duktape.org/api.html#duk_require_context
  1176  func (d *Context) RequireContext(index int) *Context {
  1177  	return contextFromPointer(C.duk_require_context(d.duk_context, C.duk_idx_t(index)))
  1178  }
  1179  
  1180  // See: http://duktape.org/api.html#duk_require_heapptr
  1181  func (d *Context) RequireHeapptr(index int) unsafe.Pointer {
  1182  	return unsafe.Pointer(C.duk_require_heapptr(d.duk_context, C.duk_idx_t(index)))
  1183  }
  1184  
  1185  // See: http://duktape.org/api.html#duk_require_int
  1186  func (d *Context) RequireInt(index int) int {
  1187  	return int(C.duk_require_int(d.duk_context, C.duk_idx_t(index)))
  1188  }
  1189  
  1190  // See: http://duktape.org/api.html#duk_require_lstring
  1191  func (d *Context) RequireLstring(index int, outLen int) string {
  1192  	if s := C.duk_require_lstring(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outLen))); s != nil {
  1193  		return C.GoString(s)
  1194  	}
  1195  	return ""
  1196  }
  1197  
  1198  // See: http://duktape.org/api.html#duk_require_normalize_index
  1199  func (d *Context) RequireNormalizeIndex(index int) int {
  1200  	return int(C.duk_require_normalize_index(d.duk_context, C.duk_idx_t(index)))
  1201  }
  1202  
  1203  // See: http://duktape.org/api.html#duk_require_null
  1204  func (d *Context) RequireNull(index int) {
  1205  	C.duk_require_null(d.duk_context, C.duk_idx_t(index))
  1206  }
  1207  
  1208  // See: http://duktape.org/api.html#duk_require_number
  1209  func (d *Context) RequireNumber(index int) float64 {
  1210  	return float64(C.duk_require_number(d.duk_context, C.duk_idx_t(index)))
  1211  }
  1212  
  1213  // See: http://duktape.org/api.html#duk_require_object_coercible
  1214  func (d *Context) RequireObjectCoercible(index int) {
  1215  	C._duk_require_object_coercible(d.duk_context, C.duk_idx_t(index))
  1216  }
  1217  
  1218  // See: http://duktape.org/api.html#duk_require_pointer
  1219  func (d *Context) RequirePointer(index int) {
  1220  	C.duk_require_pointer(d.duk_context, C.duk_idx_t(index))
  1221  }
  1222  
  1223  // See: http://duktape.org/api.html#duk_require_stack
  1224  func (d *Context) RequireStack(extra int) {
  1225  	C.duk_require_stack(d.duk_context, C.duk_idx_t(extra))
  1226  }
  1227  
  1228  // See: http://duktape.org/api.html#duk_require_stack_top
  1229  func (d *Context) RequireStackTop(top int) {
  1230  	C.duk_require_stack_top(d.duk_context, C.duk_idx_t(top))
  1231  }
  1232  
  1233  // See: http://duktape.org/api.html#duk_require_string
  1234  func (d *Context) RequireString(index int) string {
  1235  	if s := C.duk_require_string(d.duk_context, C.duk_idx_t(index)); s != nil {
  1236  		return C.GoString(s)
  1237  	}
  1238  	return ""
  1239  }
  1240  
  1241  // See: http://duktape.org/api.html#duk_require_top_index
  1242  func (d *Context) RequireTopIndex() int {
  1243  	return int(C.duk_require_top_index(d.duk_context))
  1244  }
  1245  
  1246  // See: http://duktape.org/api.html#duk_require_type_mask
  1247  func (d *Context) RequireTypeMask(index int, mask uint) {
  1248  	C._duk_require_type_mask(d.duk_context, C.duk_idx_t(index), C.duk_uint_t(mask))
  1249  }
  1250  
  1251  // See: http://duktape.org/api.html#duk_require_uint
  1252  func (d *Context) RequireUint(index int) uint {
  1253  	return uint(C.duk_require_uint(d.duk_context, C.duk_idx_t(index)))
  1254  }
  1255  
  1256  // See: http://duktape.org/api.html#duk_require_undefined
  1257  func (d *Context) RequireUndefined(index int) {
  1258  	C.duk_require_undefined(d.duk_context, C.duk_idx_t(index))
  1259  }
  1260  
  1261  // See: http://duktape.org/api.html#duk_require_valid_index
  1262  func (d *Context) RequireValidIndex(index int) {
  1263  	C.duk_require_valid_index(d.duk_context, C.duk_idx_t(index))
  1264  }
  1265  
  1266  // See: http://duktape.org/api.html#duk_resize_buffer
  1267  func (d *Context) ResizeBuffer(index int, newSize int) {
  1268  	C.duk_resize_buffer(d.duk_context, C.duk_idx_t(index), C.duk_size_t(newSize))
  1269  }
  1270  
  1271  // See: http://duktape.org/api.html#duk_safe_call
  1272  func (d *Context) SafeCall(fn *[0]byte, nargs, nrets int) int {
  1273  	return int(C.duk_safe_call(
  1274  		d.duk_context,
  1275  		fn,
  1276  		C.duk_idx_t(nargs),
  1277  		C.duk_idx_t(nrets),
  1278  	))
  1279  }
  1280  
  1281  // See: http://duktape.org/api.html#duk_safe_to_lstring
  1282  func (d *Context) SafeToLstring(index int, outLen int) string {
  1283  	if s := C.duk_safe_to_lstring(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outLen))); s != nil {
  1284  		return C.GoString(s)
  1285  	}
  1286  	return ""
  1287  }
  1288  
  1289  // See: http://duktape.org/api.html#duk_safe_to_string
  1290  func (d *Context) SafeToString(index int) string {
  1291  	if s := C._duk_safe_to_string(d.duk_context, C.duk_idx_t(index)); s != nil {
  1292  		return C.GoString(s)
  1293  	}
  1294  	return ""
  1295  }
  1296  
  1297  // See: http://duktape.org/api.html#duk_set_finalizer
  1298  func (d *Context) SetFinalizer(index int) {
  1299  	C.duk_set_finalizer(d.duk_context, C.duk_idx_t(index))
  1300  }
  1301  
  1302  // See: http://duktape.org/api.html#duk_set_global_object
  1303  func (d *Context) SetGlobalObject() {
  1304  	C.duk_set_global_object(d.duk_context)
  1305  }
  1306  
  1307  // See: http://duktape.org/api.html#duk_set_magic
  1308  func (d *Context) SetMagic(index int, magic int) {
  1309  	C.duk_set_magic(d.duk_context, C.duk_idx_t(index), C.duk_int_t(magic))
  1310  }
  1311  
  1312  // See: http://duktape.org/api.html#duk_set_prototype
  1313  func (d *Context) SetPrototype(index int) {
  1314  	C.duk_set_prototype(d.duk_context, C.duk_idx_t(index))
  1315  }
  1316  
  1317  // See: http://duktape.org/api.html#duk_set_top
  1318  func (d *Context) SetTop(index int) {
  1319  	C.duk_set_top(d.duk_context, C.duk_idx_t(index))
  1320  }
  1321  
  1322  func (d *Context) StrictEquals(index1 int, index2 int) bool {
  1323  	return int(C.duk_strict_equals(d.duk_context, C.duk_idx_t(index1), C.duk_idx_t(index2))) == 1
  1324  }
  1325  
  1326  // See: http://duktape.org/api.html#duk_substring
  1327  func (d *Context) Substring(index int, startCharOffset int, endCharOffset int) {
  1328  	C.duk_substring(d.duk_context, C.duk_idx_t(index), C.duk_size_t(startCharOffset), C.duk_size_t(endCharOffset))
  1329  }
  1330  
  1331  // See: http://duktape.org/api.html#duk_swap
  1332  func (d *Context) Swap(index1 int, index2 int) {
  1333  	C.duk_swap(d.duk_context, C.duk_idx_t(index1), C.duk_idx_t(index2))
  1334  }
  1335  
  1336  // See: http://duktape.org/api.html#duk_swap_top
  1337  func (d *Context) SwapTop(index int) {
  1338  	C.duk_swap_top(d.duk_context, C.duk_idx_t(index))
  1339  }
  1340  
  1341  // See: http://duktape.org/api.html#duk_throw
  1342  func (d *Context) Throw() {
  1343  	C.duk_throw(d.duk_context)
  1344  }
  1345  
  1346  // See: http://duktape.org/api.html#duk_to_boolean
  1347  func (d *Context) ToBoolean(index int) bool {
  1348  	return int(C.duk_to_boolean(d.duk_context, C.duk_idx_t(index))) == 1
  1349  }
  1350  
  1351  // See: http://duktape.org/api.html#duk_to_buffer
  1352  func (d *Context) ToBuffer(index int, outSize int) {
  1353  	C._duk_to_buffer(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outSize)))
  1354  }
  1355  
  1356  // See: http://duktape.org/api.html#duk_to_defaultvalue
  1357  func (d *Context) ToDefaultvalue(index int, hint int) {
  1358  	C.duk_to_defaultvalue(d.duk_context, C.duk_idx_t(index), C.duk_int_t(hint))
  1359  }
  1360  
  1361  // See: http://duktape.org/api.html#duk_to_dynamic_buffer
  1362  func (d *Context) ToDynamicBuffer(index int, outSize int) {
  1363  	C._duk_to_dynamic_buffer(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outSize)))
  1364  }
  1365  
  1366  // See: http://duktape.org/api.html#duk_to_fixed_buffer
  1367  func (d *Context) ToFixedBuffer(index int, outSize int) {
  1368  	C._duk_to_fixed_buffer(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outSize)))
  1369  }
  1370  
  1371  // See: http://duktape.org/api.html#duk_to_int
  1372  func (d *Context) ToInt(index int) int {
  1373  	return int(C.duk_to_int(d.duk_context, C.duk_idx_t(index)))
  1374  }
  1375  
  1376  // See: http://duktape.org/api.html#duk_to_int32
  1377  func (d *Context) ToInt32(index int) int32 {
  1378  	return int32(C.duk_to_int32(d.duk_context, C.duk_idx_t(index)))
  1379  }
  1380  
  1381  // See: http://duktape.org/api.html#duk_to_lstring
  1382  func (d *Context) ToLstring(index int, outLen int) string {
  1383  	if s := C.duk_to_lstring(d.duk_context, C.duk_idx_t(index), (*C.duk_size_t)(unsafe.Pointer(&outLen))); s != nil {
  1384  		return C.GoString(s)
  1385  	}
  1386  	return ""
  1387  }
  1388  
  1389  // See: http://duktape.org/api.html#duk_to_null
  1390  func (d *Context) ToNull(index int) {
  1391  	C.duk_to_null(d.duk_context, C.duk_idx_t(index))
  1392  }
  1393  
  1394  // See: http://duktape.org/api.html#duk_to_number
  1395  func (d *Context) ToNumber(index int) float64 {
  1396  	return float64(C.duk_to_number(d.duk_context, C.duk_idx_t(index)))
  1397  }
  1398  
  1399  // See: http://duktape.org/api.html#duk_to_object
  1400  func (d *Context) ToObject(index int) {
  1401  	C.duk_to_object(d.duk_context, C.duk_idx_t(index))
  1402  }
  1403  
  1404  // See: http://duktape.org/api.html#duk_to_pointer
  1405  func (d *Context) ToPointer(index int) {
  1406  	C.duk_to_pointer(d.duk_context, C.duk_idx_t(index))
  1407  }
  1408  
  1409  // See: http://duktape.org/api.html#duk_to_primitive
  1410  func (d *Context) ToPrimitive(index int, hint int) {
  1411  	C.duk_to_primitive(d.duk_context, C.duk_idx_t(index), C.duk_int_t(hint))
  1412  }
  1413  
  1414  // See: http://duktape.org/api.html#duk_to_string
  1415  func (d *Context) ToString(index int) string {
  1416  	if s := C.duk_to_string(d.duk_context, C.duk_idx_t(index)); s != nil {
  1417  		return C.GoString(s)
  1418  	}
  1419  	return ""
  1420  }
  1421  
  1422  // See: http://duktape.org/api.html#duk_to_uint
  1423  func (d *Context) ToUint(index int) uint {
  1424  	return uint(C.duk_to_uint(d.duk_context, C.duk_idx_t(index)))
  1425  }
  1426  
  1427  // See: http://duktape.org/api.html#duk_to_uint16
  1428  func (d *Context) ToUint16(index int) uint16 {
  1429  	return uint16(C.duk_to_uint16(d.duk_context, C.duk_idx_t(index)))
  1430  }
  1431  
  1432  // See: http://duktape.org/api.html#duk_to_uint32
  1433  func (d *Context) ToUint32(index int) uint32 {
  1434  	return uint32(C.duk_to_uint32(d.duk_context, C.duk_idx_t(index)))
  1435  }
  1436  
  1437  // See: http://duktape.org/api.html#duk_to_undefined
  1438  func (d *Context) ToUndefined(index int) {
  1439  	C.duk_to_undefined(d.duk_context, C.duk_idx_t(index))
  1440  }
  1441  
  1442  // See: http://duktape.org/api.html#duk_trim
  1443  func (d *Context) Trim(index int) {
  1444  	C.duk_trim(d.duk_context, C.duk_idx_t(index))
  1445  }
  1446  
  1447  // See: http://duktape.org/api.html#duk_xcopy_top
  1448  func (d *Context) XcopyTop(fromCtx *Context, count int) {
  1449  	C._duk_xcopy_top(d.duk_context, fromCtx.duk_context, C.duk_idx_t(count))
  1450  }
  1451  
  1452  // See: http://duktape.org/api.html#duk_xmove_top
  1453  func (d *Context) XmoveTop(fromCtx *Context, count int) {
  1454  	C._duk_xmove_top(d.duk_context, fromCtx.duk_context, C.duk_idx_t(count))
  1455  }
  1456  
  1457  // See: http://duktape.org/api.html#duk_push_pointer
  1458  func (d *Context) PushPointer(p unsafe.Pointer) {
  1459  	C.duk_push_pointer(d.duk_context, p)
  1460  }
  1461  
  1462  /**
  1463   * Unimplemented.
  1464   *
  1465   * CharCodeAt see: http://duktape.org/api.html#duk_char_code_at
  1466   * CreateHeap see: http://duktape.org/api.html#duk_create_heap
  1467   * DecodeString see: http://duktape.org/api.html#duk_decode_string
  1468   * Free see: http://duktape.org/api.html#duk_free
  1469   * FreeRaw see: http://duktape.org/api.html#duk_free_raw
  1470   * GetMemoryFunctions see: http://duktape.org/api.html#duk_get_memory_functions
  1471   * MapString see: http://duktape.org/api.html#duk_map_string
  1472   * PushSprintf see: http://duktape.org/api.html#duk_push_sprintf
  1473   * PushVsprintf see: http://duktape.org/api.html#duk_push_vsprintf
  1474   * PutFunctionList see: http://duktape.org/api.html#duk_put_function_list
  1475   * PutNumberList see: http://duktape.org/api.html#duk_put_number_list
  1476   * Realloc see: http://duktape.org/api.html#duk_realloc
  1477   * ReallocRaw see: http://duktape.org/api.html#duk_realloc_raw
  1478   * GetCFunction see: http://duktape.org/api.html#duk_get_c_function
  1479   * RequireCFunction see: http://duktape.org/api.html#duk_require_c_function
  1480   */