Ejemplo n.º 1
0
void dump_error(duk_context *ctx) {
	duk_dup(ctx, -1);
	printf("ToString(error): %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "name");
	printf("name: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "message");
	printf("message: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	/* 'code' is no longer set, test that it reads back as 'undefined' */
	duk_get_prop_string(ctx, -1, "code");
	printf("code: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "fileName");
	printf("fileName is a string: %d\n", (int) duk_is_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "lineNumber");
	printf("lineNumber: %ld\n", (long) duk_get_int(ctx, -1));
	duk_pop(ctx);

	/* 'isNative' has also been removed, check that it reads back as 'undefined' */
	duk_get_prop_string(ctx, -1, "isNative");
	printf("isNative: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);
}
Ejemplo n.º 2
0
// ====== Xtase drawing routines ======
duk_ret_t nsp_texture_draw_line(duk_context *ctx) {
    int x1 = duk_require_int(ctx, 0);
    int y1 = duk_require_int(ctx, 1);

    int x2 = duk_require_int(ctx, 2);
    int y2 = duk_require_int(ctx, 3);

    uint16_t color = duk_require_int(ctx, 4);


    duk_push_this(ctx);
    duk_get_prop_string(ctx, -1, "width");
    int w = duk_require_int(ctx, -1);
    duk_pop(ctx);
    duk_get_prop_string(ctx, -1, "height");
    int h = duk_require_int(ctx, -1);
    duk_pop(ctx);

    if (w <= 0 || h <= 0) {
			duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "width and height must be positive");
			duk_throw(ctx);
    }

    duk_get_prop_string(ctx, -1, "bitmap");
    size_t size;
    uint16_t *bitmap = duk_get_buffer(ctx, -1, &size);
    if (bitmap == NULL) {
			duk_push_error_object(ctx, DUK_ERR_ERROR, "bitmap pointer is NULL");
			duk_throw(ctx);
    }

		FbDev* fb = (FbDev*)malloc( 1 * sizeof(FbDev) );
		  fb->width = w;
		  fb->height = h;
		  fb->fb_size = w * h;
		  fb->fb = bitmap;
		  drawLine(x1,y1,x2,y2,color,fb);
		free(fb);
    return 0;
}
Ejemplo n.º 3
0
void dump_error(duk_context *ctx) {
	duk_dup(ctx, -1);
	printf("ToString(error): %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "name");
	printf("name: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "message");
	printf("message: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "code");
	printf("code: %d\n", duk_get_int(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "fileName");
	printf("fileName: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "lineNumber");
	printf("lineNumber: %d\n", duk_get_int(ctx, -1));
	duk_pop(ctx);

	duk_get_prop_string(ctx, -1, "isNative");
	printf("isNative: %s\n", duk_to_string(ctx, -1));
	duk_pop(ctx);
}
Ejemplo n.º 4
0
static duk_ret_t
js_Font_drawTextBox(duk_context* ctx)
{
	int x = duk_require_int(ctx, 0);
	int y = duk_require_int(ctx, 1);
	int w = duk_require_int(ctx, 2);
	int h = duk_require_int(ctx, 3);
	int offset = duk_require_int(ctx, 4);
	const char* text = duk_to_string(ctx, 5);

	font_t*     font;
	int         line_height;
	const char* line_text;
	color_t     mask;
	int         num_lines;

	int i;

	duk_push_this(ctx);
	font = duk_require_sphere_obj(ctx, -1, "Font");
	duk_get_prop_string(ctx, -1, "\xFF" "color_mask"); mask = duk_require_sphere_color(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	if (!screen_is_skipframe(g_screen)) {
		duk_push_c_function(ctx, js_Font_wordWrapString, DUK_VARARGS);
		duk_push_this(ctx);
		duk_push_string(ctx, text);
		duk_push_int(ctx, w);
		duk_call_method(ctx, 2);
		duk_get_prop_string(ctx, -1, "length"); num_lines = duk_get_int(ctx, -1); duk_pop(ctx);
		line_height = get_font_line_height(font);
		for (i = 0; i < num_lines; ++i) {
			duk_get_prop_index(ctx, -1, i); line_text = duk_get_string(ctx, -1); duk_pop(ctx);
			draw_text(font, mask, x + offset, y, TEXT_ALIGN_LEFT, line_text);
			y += line_height;
		}
		duk_pop(ctx);
	}
	return 0;
}
Ejemplo n.º 5
0
static duk_ret_t
js_Font_getStringWidth(duk_context* ctx)
{
	const char* text = duk_to_string(ctx, 0);
	
	font_t* font;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_int(ctx, get_text_width(font, text));
	return 1;
}
Ejemplo n.º 6
0
static duk_ret_t
js_Font_getStringHeight(duk_context* ctx)
{
	const char* text = duk_to_string(ctx, 0);
	int width = duk_require_int(ctx, 1);
	
	font_t* font;
	int     num_lines;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_c_function(ctx, js_Font_wordWrapString, DUK_VARARGS);
	duk_push_this(ctx);
	duk_push_string(ctx, text);
	duk_push_int(ctx, width);
	duk_call_method(ctx, 2);
	duk_get_prop_string(ctx, -1, "length"); num_lines = duk_get_int(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_int(ctx, get_font_line_height(font) * num_lines);
	return 1;
}
Ejemplo n.º 7
0
static duk_ret_t
js_Font_getCharacterImage(duk_context* ctx)
{
	int cp = duk_require_int(ctx, 0);

	font_t* font;
	
	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); font = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	duk_push_sphere_image(ctx, get_glyph_image(font, cp));
	return 1;
}
Ejemplo n.º 8
0
void duk_module_node_init(duk_context *ctx) {
	/*
	 *  Stack: [ ... options ] => [ ... ]
	 */

	duk_idx_t options_idx;

	duk_require_object_coercible(ctx, -1);  /* error before setting up requireCache */
	options_idx = duk_require_normalize_index(ctx, -1);

	/* Initialize the require cache to a fresh object. */
	duk_push_global_stash(ctx);
	duk_push_object(ctx);
	duk_put_prop_string(ctx, -2, "\xff" "requireCache");
	duk_pop(ctx);

	/* Stash callbacks for later use.  User code can overwrite them later
	 * on directly by accessing the global stash.
	 */
	duk_push_global_stash(ctx);
	duk_get_prop_string(ctx, options_idx, "resolve");
	duk_require_function(ctx, -1);
	duk_put_prop_string(ctx, -2, "\xff" "modResolve");
	duk_get_prop_string(ctx, options_idx, "load");
	duk_require_function(ctx, -1);
	duk_put_prop_string(ctx, -2, "\xff" "modLoad");
	duk_pop(ctx);

	/* register `require` as a global function */
	duk_push_global_object(ctx);
	duk_push_string(ctx, "require");
	duk__push_require_function(ctx, "");
	duk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE |
	                      DUK_DEFPROP_SET_WRITABLE |
	                      DUK_DEFPROP_SET_CONFIGURABLE);
	duk_pop(ctx);

	duk_pop(ctx);  /* pop argument */
}
Ejemplo n.º 9
0
/*
 * If there is a callback registered for this interface pushes the function onto the stack
 */
static int PushServiceCallback(duk_context* ctx, const char* iface)
{
    AJS_GetGlobalStashObject(ctx, "serviceCB");

    duk_get_prop_string(ctx, -1, iface);
    duk_remove(ctx, -2);
    if (duk_is_callable(ctx, -1)) {
        return 1;
    } else {
        duk_pop(ctx);
        return 0;
    }
}
Ejemplo n.º 10
0
static duk_ret_t
js_Sound_setVolume(duk_context* ctx)
{
	float new_gain = duk_require_int(ctx, 0);
	
	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	set_sound_gain(sound, (float)new_gain / 255);
	return 0;
}
Ejemplo n.º 11
0
static duk_ret_t
js_Sound_setRepeat(duk_context* ctx)
{
	bool is_looped = duk_require_boolean(ctx, 0);
	
	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	set_sound_looping(sound, is_looped);
	return 0;
}
Ejemplo n.º 12
0
static unzFile dukzip_require_unz(duk_context *ctx, int index) {
	unzFile result;

	duk_get_prop_string(ctx, index, ZIPHANDLE_PROP);
	result = duk_get_pointer(ctx, -1);
	duk_pop(ctx);
	if (!result) {
		duk_error(ctx, DUK_ERR_TYPE_ERROR, "Expected dukzip archive at index %d", index);
		return NULL;
	}

	return result;
}
Ejemplo n.º 13
0
static duk_ret_t
js_Sound_setPitch(duk_context* ctx)
{
	float new_pitch = duk_require_number(ctx, 0);

	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	set_sound_pitch(sound, new_pitch);
	return 0;
}
Ejemplo n.º 14
0
static duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_name) {
	duk_uint_t flags = (duk_uint_t) duk_get_current_magic(ctx);
	FILE *output = (flags & DUK_CONSOLE_STDOUT_ONLY) ? stdout : stderr;
	duk_idx_t n = duk_get_top(ctx);
	duk_idx_t i;

	duk_get_global_string(ctx, "console");
	duk_get_prop_string(ctx, -1, "format");

	for (i = 0; i < n; i++) {
		if (duk_check_type_mask(ctx, i, DUK_TYPE_MASK_OBJECT)) {
			/* Slow path formatting. */
			duk_dup(ctx, -1);  /* console.format */
			duk_dup(ctx, i);
			duk_call(ctx, 1);
			duk_replace(ctx, i);  /* arg[i] = console.format(arg[i]); */
		}
	}

	duk_pop_2(ctx);

	duk_push_string(ctx, " ");
	duk_insert(ctx, 0);
	duk_join(ctx, n);

	if (error_name) {
		duk_push_error_object(ctx, DUK_ERR_ERROR, "%s", duk_require_string(ctx, -1));
		duk_push_string(ctx, "name");
		duk_push_string(ctx, error_name);
		duk_def_prop(ctx, -3, DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE);  /* to get e.g. 'Trace: 1 2 3' */
		duk_get_prop_string(ctx, -1, "stack");
	}

	fprintf(output, "%s\n", duk_to_string(ctx, -1));
	if (flags & DUK_CONSOLE_FLUSH) {
		fflush(output);
	}
	return 0;
}
Ejemplo n.º 15
0
        static BindingInfo * GetBinding( duk_context * ctx )
        {
            duk_push_global_stash( ctx );
            duk_get_prop_string( ctx, -1, DUKBIND_BINDING_NAME );

            duk_size_t buffer_size;
            void * buffer = duk_to_buffer( ctx, -1, &buffer_size);
            dukbind_assert( buffer_size == sizeof( BindingInfo * ), "Invalid buffer size" );

            duk_pop_2( ctx );

            return *reinterpret_cast<BindingInfo**>( buffer );
        }
Ejemplo n.º 16
0
gboolean
_gum_duk_is_arg0_equal_to_prototype (duk_context * ctx,
                                     const gchar * class_name)
{
  gboolean result;

  duk_get_global_string (ctx, class_name);
  duk_get_prop_string (ctx, -1, "prototype");
  result = duk_equals (ctx, 0, -1);
  duk_pop_2 (ctx);

  return result;
}
Ejemplo n.º 17
0
static duk_ret_t
js_Sound_setPosition(duk_context* ctx)
{
	int new_pos = duk_require_int(ctx, 0);

	sound_t* sound;

	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, "\xFF" "ptr"); sound = duk_get_pointer(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	seek_sound(sound, new_pos);
	return 0;
}
Ejemplo n.º 18
0
static duk_ret_t test_getprop(duk_context *ctx, void *udata) {
	(void) udata;

	prep(ctx);

	/* Property exists, own property */
	duk_get_prop_string(ctx, 0, "foo");
	printf("getprop foo: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	/* Property exists, inherited property */
	duk_get_prop_string(ctx, 0, "bar");
	printf("getprop bar: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	/* Property doesn't exist, terminate with error */
	duk_get_prop_string(ctx, 0, "quux");
	printf("getprop quux: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	return 0;
}
Ejemplo n.º 19
0
WeakPtr<Object>* GetWeakPtr(duk_context* ctx, duk_idx_t stackIndex)
{
    if (!duk_is_object(ctx, stackIndex))
        return nullptr;

    WeakPtr<Object>* ptr = nullptr;
    duk_get_prop_string(ctx, stackIndex, "\xff""weak");
    if (duk_is_pointer(ctx, -1))
        ptr = static_cast<WeakPtr<Object>*>(duk_to_pointer(ctx, -1));
    duk_pop(ctx);

    return ptr;
}
Ejemplo n.º 20
0
static int _worker_dispatch_cb (evHandle *handle){
    comoWorker *worker = handle->data;
    duk_context *ctx = worker->Mainctx;

    mtx_lock(&worker->mtx);
    QUEUE *q;
    while ( !QUEUE_EMPTY(&worker->queueOut) ){

        q = QUEUE_HEAD(&(worker)->queueOut);
        QUEUE_REMOVE(q);
        comoQueue *queue = QUEUE_DATA(q, comoQueue, queue);

        if (worker->destroy != 0){
            goto FREE;
        }

        duk_push_heapptr(ctx, worker->self);
        
        if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT){
            dump_stack(ctx, "DUK");
            assert(0);
        }

        como_push_worker_value(ctx, queue);

        duk_call(ctx, 1);
        duk_pop(ctx);

        FREE :
        /* free except in case of pointers */
        if (queue->data != NULL && queue->type != DUK_TYPE_POINTER){
            free(queue->data);
        }

        free(queue);
    }
    mtx_unlock(&worker->mtx);

    if (worker->destroy == 2){
        
        duk_push_global_stash(ctx);
        duk_get_prop_string(ctx, -1, "comoWorkersCallBack");
        duk_push_number(ctx, (double) handle->id);
        duk_del_prop(ctx, -2);

        handle_close(handle);
        free(worker);
    }

    return 0;
}
Ejemplo n.º 21
0
/*
 * Signals require an object path, interface, and member
 */
static void InitSignal(duk_context* ctx, const char* dest, uint32_t session)
{
    const char* path = duk_require_string(ctx, 0);
    const char* iface;
    const char* member;

    /*
     * Build up a dummy service object
     */
    duk_push_object(ctx);
    /*
     * Get the interfaces from the object path
     */
    AJS_GetAllJoynProperty(ctx, "objectDefinition");
    duk_get_prop_string(ctx, -1, path);
    if (duk_is_undefined(ctx, -1)) {
        duk_error(ctx, DUK_ERR_TYPE_ERROR, "Unknown object path '%s'", path);
    }
    duk_get_prop_string(ctx, -1, "interfaces");
    duk_put_prop_string(ctx, -4, "interfaces");
    duk_pop_2(ctx);
    /*
     * Set the endpoint information
     */
    duk_push_string(ctx, dest);
    duk_put_prop_string(ctx, -2, "dest");
    duk_push_number(ctx, session);
    duk_put_prop_string(ctx, -2, "session");
    /*
     * Resolve the interface name
     */
    iface = FindInterfaceForMember(ctx, 1, &member);
    MessageSetup(ctx, iface, member, path, AJ_MSG_SIGNAL);
    duk_dup(ctx, 0);
    duk_put_prop_string(ctx, -2, "path");
    duk_push_c_lightfunc(ctx, AJS_MarshalSignal, DUK_VARARGS, 0, 0);
    duk_put_prop_string(ctx, -2, "send");
}
Ejemplo n.º 22
0
static duk_ret_t duk_java_property_get(duk_context *ctx) {
	const char* key  = duk_to_string(ctx, 0);
	DEBUG_LOG("ScriptEngine", "duk_java_property_get  key %s", key);
	duk_push_this(ctx);
	if(duk_get_prop_string(ctx, -1, JAVA_OBJECT_MARK)){
		jobject  ref = duk_to_pointer(ctx, -1);
		JNIEnv*  env =  get_java_jni_env();
		jstring fieldName = (*env)->NewStringUTF(env, key);
		DEBUG_LOG("ScriptEngine", "duk_get_prop_string  key %s", key);
		jobject  value =  (*env)->CallStaticObjectMethod(env, java_api_class, java_field_get_method, ref, fieldName);
		jthrowable exp = ( *env)->ExceptionOccurred(env);
		if(exp != NULL){
				  ( *env)->ExceptionClear(env);
				  jstring exceptionMessage = (*env)->CallStaticObjectMethod(env, java_api_class, java_exception_get_stack_trace_method, exp);
			      jboolean isCopy = JNI_FALSE;
				  const char* cstrMessage = (*env)->GetStringUTFChars(env, exceptionMessage, &isCopy);
				  duk_push_error_object(ctx, DUK_ERR_EVAL_ERROR, "get java property %s error \n %s",  key, cstrMessage);
				  (*env)->ReleaseStringUTFChars(env, exceptionMessage, cstrMessage);
				  ( *env)->DeleteLocalRef(env , exceptionMessage);
				  (*env)->DeleteLocalRef(env, value);
				  (*env)->DeleteLocalRef(env, fieldName);
				  duk_throw(ctx);
				  return 0;
		 }
		DEBUG_LOG("ScriptEngine", "duk_get_prop_string push object %s value ", key);
		duk_push_java_object(ctx, env, value);
		DEBUG_LOG("ScriptEngine", "duk_get_prop_string  push object %s success", key);
		(*env)->DeleteLocalRef(env, value);
		(*env)->DeleteLocalRef(env, fieldName);
		return 1;
	}else{
		duk_get_prop_string(ctx, 1, key);
		if(duk_is_undefined(ctx, -1)){
			LOGW("ScriptEngine", "ScriptEngine warn property  %s not found ", key);
		}
		return 1;
	}
}
Ejemplo n.º 23
0
 void OnSignal(IAsset * param0)
 {
     duk_context* ctx = ctx_;
     duk_push_global_object(ctx);
     duk_get_prop_string(ctx, -1, "_OnSignal");
     duk_remove(ctx, -2);
     duk_push_number(ctx, (size_t)key_);
     duk_push_array(ctx);
     PushWeakObject(ctx, param0);
     duk_put_prop_index(ctx, -2, 0);
     bool success = duk_pcall(ctx, 2) == 0;
     if (!success) LogError("[JavaScript] OnSignal: " + GetErrorString(ctx));
     duk_pop(ctx);
 }
Ejemplo n.º 24
0
static duk_ret_t dukky_before_unload_event_returnValue_setter(duk_context *ctx)
{
	/* Get private data for method */
	before_unload_event_private_t *priv = NULL;
	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, dukky_magic_string_private);
	priv = duk_get_pointer(ctx, -1);
	duk_pop_2(ctx);
	if (priv == NULL) {
		return 0; /* can do? No can do. */
	}

	return 0;
}
Ejemplo n.º 25
0
gboolean
_gum_duk_parse_bytes (duk_context * ctx,
                      duk_idx_t index,
                      GBytes ** bytes)
{
  gpointer data;
  duk_size_t size;

  data = duk_get_buffer_data (ctx, index, &size);
  if (data != NULL)
  {
    *bytes = g_bytes_new (data, size);
    return TRUE;
  }
  else if (duk_is_array (ctx, index))
  {
    duk_size_t i;

    duk_get_prop_string (ctx, index, "length");
    size = duk_get_uint (ctx, -1);
    duk_pop (ctx);

    if (size >= GUM_MAX_JS_BYTE_ARRAY_LENGTH)
      return FALSE;

    data = g_malloc (size);

    for (i = 0; i != size; i++)
    {
      duk_get_prop_index (ctx, index, (duk_uarridx_t) i);
      ((guint8 *) data)[i] = duk_get_uint (ctx, -1) & 0xff;
      duk_pop (ctx);
    }

    *bytes = g_bytes_new_take (data, size);
    return TRUE;
  }
  else if (duk_is_null_or_undefined (ctx, index) ||
      duk_is_boolean (ctx, index) ||
      duk_is_number (ctx, index) ||
      duk_is_nan (ctx, index) ||
      duk_is_string (ctx, index) ||
      duk_is_function (ctx, index))
  {
    return FALSE;
  }

  *bytes = g_bytes_new (NULL, 0);
  return TRUE;
}
Ejemplo n.º 26
0
const char *
dukky_message_event_init_get_lastEventId(duk_context *ctx, duk_idx_t idx)
{
	const char *ret = NULL; /* No default */
	/* ... obj@idx ... */
	duk_get_prop_string(ctx, idx, "lastEventId");
	/* ... obj@idx ... value/undefined */
	if (!duk_is_undefined(ctx, -1)) {
		/* Note, this throws a duk_error if it's not a string */
		ret = duk_require_string(ctx, -1);
	}
	duk_pop(ctx);
	return ret;
}
Ejemplo n.º 27
0
DUK_EXTERNAL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key) {
	duk_hthread *thr = (duk_hthread *) ctx;
	duk_bool_t ret;

	DUK_ASSERT_CTX_VALID(ctx);
	DUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);

	/* XXX: direct implementation */

	duk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]);
	ret = duk_get_prop_string(ctx, -1, key);
	duk_remove(ctx, -2);
	return ret;
}
Ejemplo n.º 28
0
    void * Get( duk_context * ctx, duk_idx_t index, size_t & class_index, finalizer_t & finalizer )
    {
        duk_size_t size;
        duk_get_prop_string( ctx, index, "\xFF" "Box" );
        dukbind_assert( duk_is_fixed_buffer( ctx, -1 ), "Boxing is always implemented as fixed buffer" );
        Box * box = reinterpret_cast<Box*>( duk_to_buffer( ctx, -1, &size ) );
        duk_pop( ctx );

        dukbind_assert( sizeof( Box ) <= size, "Fixed buffer is not a box" );

        class_index = box->ClassIndex;
        finalizer = box->Finalizer;
        return box->ObjectPointer;
    }
Ejemplo n.º 29
0
static duk_ret_t dukky_html_embed_element_name_setter(duk_context *ctx)
{
	/* Get private data for method */
	html_embed_element_private_t *priv = NULL;
	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, dukky_magic_string_private);
	priv = duk_get_pointer(ctx, -1);
	duk_pop_2(ctx);
	if (priv == NULL) {
		return 0; /* can do? No can do. */
	}

	return 0;
}
Ejemplo n.º 30
0
static duk_ret_t dukky_video_track_kind_getter(duk_context *ctx)
{
	/* Get private data for method */
	video_track_private_t *priv = NULL;
	duk_push_this(ctx);
	duk_get_prop_string(ctx, -1, dukky_magic_string_private);
	priv = duk_get_pointer(ctx, -1);
	duk_pop_2(ctx);
	if (priv == NULL) {
		return 0; /* can do? No can do. */
	}

	return 0;
}