Esempio n. 1
0
void Expose_Light(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Light_StaticFunctions);
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "PointLight");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "Spotlight");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "DirectionalLight");
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Light_Functions);
    DefineProperty(ctx, "ComponentNameChanged", Light_Get_ComponentNameChanged, nullptr);
    DefineProperty(ctx, "ParentEntitySet", Light_Get_ParentEntitySet, nullptr);
    DefineProperty(ctx, "ParentEntityAboutToBeDetached", Light_Get_ParentEntityAboutToBeDetached, nullptr);
    DefineProperty(ctx, "typeName", Light_TypeName, nullptr);
    DefineProperty(ctx, "typeId", Light_TypeId, nullptr);
    DefineProperty(ctx, "name", Light_Name, Light_SetName_String);
    DefineProperty(ctx, "replicated", Light_IsReplicated, Light_SetReplicated_bool);
    DefineProperty(ctx, "local", Light_IsLocal, nullptr);
    DefineProperty(ctx, "unacked", Light_IsUnacked, nullptr);
    DefineProperty(ctx, "updateMode", Light_UpdateMode, Light_SetUpdateMode_AttributeChange__Type);
    DefineProperty(ctx, "id", Light_Id, nullptr);
    DefineProperty(ctx, "temporary", Light_IsTemporary, Light_SetTemporary_bool);
    DefineProperty(ctx, "viewEnabled", Light_ViewEnabled, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, Light_ID);
}
Esempio n. 2
0
void Expose_Line(duk_context* ctx)
{
    duk_push_c_function(ctx, Line_Ctor_Selector, DUK_VARARGS);
    duk_put_function_list(ctx, -1, Line_StaticFunctions);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Line_Functions);
    DefineProperty(ctx, "pos", Line_Get_pos, Line_Set_pos);
    DefineProperty(ctx, "dir", Line_Get_dir, Line_Set_dir);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, Line_ID);
}
Esempio n. 3
0
duk_ret_t
mn_bi_readline(duk_context *ctx) {
	duk_push_object(ctx);
	duk_put_function_list(ctx, -1, mn_bi_readline_funcs);
	duk_put_number_list(ctx, -1, mn_bi_readline_consts);
	return 1;
}
Esempio n. 4
0
duk_ret_t
mn_bi_cluster(duk_context *ctx) {
	duk_push_object(ctx);
	duk_put_function_list(ctx, -1, mn_bi_cluster_funcs);
	duk_put_number_list(ctx, -1, mn_bi_cluster_consts);
	return 1;
}
Esempio n. 5
0
void
_gum_duk_process_init (GumDukProcess * self,
                       GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  self->core = core;

  duk_push_c_function (ctx, gumjs_process_construct, 0);
  duk_push_object (ctx);
  duk_put_function_list (ctx, -1, gumjs_process_functions);
  duk_push_string (ctx, GUM_SCRIPT_ARCH);
  duk_put_prop_string (ctx, -2, "arch");
  duk_push_string (ctx, GUM_SCRIPT_PLATFORM);
  duk_put_prop_string (ctx, -2, "platform");
  duk_push_uint (ctx, gum_query_page_size ());
  duk_put_prop_string (ctx, -2, "pageSize");
  duk_push_uint (ctx, GLIB_SIZEOF_VOID_P);
  duk_put_prop_string (ctx, -2, "pointerSize");
  duk_put_prop_string (ctx, -2, "prototype");
  duk_new (ctx, 0);
  _gum_duk_put_data (ctx, -1, self);
  duk_put_global_string (ctx, "Process");
}
Esempio n. 6
0
void fileio_register(duk_context *ctx) {
	/* Set global 'FileIo'. */
	duk_push_global_object(ctx);
	duk_push_object(ctx);
	duk_put_function_list(ctx, -1, fileio_funcs);
	duk_put_prop_string(ctx, -2, "FileIo");
	duk_pop(ctx);
}
Esempio n. 7
0
File: _io.c Progetto: cjihrig/sjs
DUK_EXTERNAL duk_ret_t sjs_mod_init(duk_context* ctx) {
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, module_funcs);
    duk_push_object(ctx);
    duk_put_number_list(ctx, -1, module_consts);
    duk_put_prop_string(ctx, -2, "c");
    return 1;
}
Esempio n. 8
0
File: duv.c Progetto: Comojs/dukluv
duk_ret_t dukopen_uv(duk_context *ctx) {

  duv_ref_setup(ctx);

  // Create a uv table on the global
  duk_push_object(ctx);
  duk_put_function_list(ctx, -1, duv_funcs);
  return 1;
}
void Expose_EntityReference(duk_context* ctx)
{
    duk_push_c_function(ctx, EntityReference_Ctor_Selector, DUK_VARARGS);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, EntityReference_Functions);
    DefineProperty(ctx, "ref", EntityReference_Get_ref, EntityReference_Set_ref);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, EntityReference_ID);
}
Esempio n. 10
0
duk_ret_t dukopen_nsp_texture(duk_context *ctx) {
    duk_idx_t idx = duk_push_object(ctx);
    duk_idx_t stats_constr = duk_push_c_function(ctx, nsp_texture_constructor, DUK_VARARGS);
    duk_idx_t stats_prot = duk_push_object(ctx);
    duk_put_function_list(ctx, stats_prot, nsp_texture_methods);
    duk_put_prop_string(ctx, stats_constr, "prototype");
    duk_put_prop_string(ctx, idx, "Texture");
    return 1;
}
Esempio n. 11
0
static int init_binding_worker(duk_context *ctx) {
    duk_push_global_stash(ctx);
    duk_push_object(ctx);
    duk_put_prop_string(ctx, -2, "comoWorkersCallBack");
    duk_pop(ctx);

    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, como_worker_funcs);
    return 1;
}
void Expose_AssetReferenceList(duk_context* ctx)
{
    duk_push_c_function(ctx, AssetReferenceList_Ctor_Selector, DUK_VARARGS);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, AssetReferenceList_Functions);
    DefineProperty(ctx, "refs", AssetReferenceList_Get_refs, AssetReferenceList_Set_refs);
    DefineProperty(ctx, "type", AssetReferenceList_Get_type, AssetReferenceList_Set_type);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, AssetReferenceList_ID);
}
Esempio n. 13
0
void SetupProxy(duk_context* ctx, const duk_function_list_entry* funcs)
{
    duk_push_global_object(ctx);
    duk_get_prop_string(ctx, -1, "Proxy");
    duk_dup(ctx, -3); // Duplicate target at stack top
    duk_remove(ctx, -4); // Remove original target
    duk_push_object(ctx); // Handler
    duk_put_function_list(ctx, -1, funcs);
    duk_new(ctx, 2); // Create proxy
    duk_remove(ctx, -2); // Remove global object
}
Esempio n. 14
0
static duk_ret_t do_callback(duk_context *ctx)
{
  printf("%s %d\n", __PRETTY_FUNCTION__, __LINE__);

  duk_push_this(ctx);
  duk_push_number(ctx, 10);
  duk_put_prop_string(ctx, -2, "hello");
  duk_put_function_list(ctx, -1, test_testobj_callback_funcs);

  return 0;
}
Esempio n. 15
0
static int dukzip_core(duk_context *ctx) {
	int mod = duk_push_object(ctx);

	/* create readable archive prototype */
	duk_push_object(ctx);
	duk_push_c_function(ctx, dukzip_unz_finalizer, 1);
	duk_set_finalizer(ctx, -2);
	duk_put_function_list(ctx, -1, dukzip_unz_prototype);
	duk_put_global_string(ctx, DUKZIP_UNZ_PROTOTYPE);

	/* create writable archive prototype */
	duk_push_object(ctx);
	duk_push_c_function(ctx, dukzip_zip_finalizer, 1);
	duk_set_finalizer(ctx, -2);
	duk_put_function_list(ctx, -1, dukzip_zip_prototype);
	duk_put_global_string(ctx, DUKZIP_ZIP_PROTOTYPE);

	duk_put_function_list(ctx, -1, dukzip_module);
	return mod;
}
Esempio n. 16
0
duk_ret_t dukopen_logger(duk_context *ctx) noexcept
{
	dukx_assert_begin(ctx);
	duk_push_object(ctx);
	duk_push_object(ctx);
	duk_put_function_list(ctx, -1, loggerFunctions);
	duk_put_prop_string(ctx, -2, "Logger");
	dukx_assert_end(ctx, 1);

	return 1;
}
void Expose_RigidBody(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, RigidBody_StaticFunctions);
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "Box");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "Sphere");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "Cylinder");
    duk_push_number(ctx, 3);
    duk_put_prop_string(ctx, -2, "Capsule");
    duk_push_number(ctx, 4);
    duk_put_prop_string(ctx, -2, "TriMesh");
    duk_push_number(ctx, 5);
    duk_put_prop_string(ctx, -2, "HeightField");
    duk_push_number(ctx, 6);
    duk_put_prop_string(ctx, -2, "ConvexHull");
    duk_push_number(ctx, 7);
    duk_put_prop_string(ctx, -2, "Cone");
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, RigidBody_Functions);
    DefineProperty(ctx, "PhysicsCollision", RigidBody_Get_PhysicsCollision, nullptr);
    DefineProperty(ctx, "NewPhysicsCollision", RigidBody_Get_NewPhysicsCollision, nullptr);
    DefineProperty(ctx, "ComponentNameChanged", RigidBody_Get_ComponentNameChanged, nullptr);
    DefineProperty(ctx, "ParentEntitySet", RigidBody_Get_ParentEntitySet, nullptr);
    DefineProperty(ctx, "ParentEntityAboutToBeDetached", RigidBody_Get_ParentEntityAboutToBeDetached, nullptr);
    DefineProperty(ctx, "typeName", RigidBody_TypeName, nullptr);
    DefineProperty(ctx, "typeId", RigidBody_TypeId, nullptr);
    DefineProperty(ctx, "name", RigidBody_Name, RigidBody_SetName_String);
    DefineProperty(ctx, "replicated", RigidBody_IsReplicated, RigidBody_SetReplicated_bool);
    DefineProperty(ctx, "local", RigidBody_IsLocal, nullptr);
    DefineProperty(ctx, "unacked", RigidBody_IsUnacked, nullptr);
    DefineProperty(ctx, "updateMode", RigidBody_UpdateMode, RigidBody_SetUpdateMode_AttributeChange__Type);
    DefineProperty(ctx, "id", RigidBody_Id, nullptr);
    DefineProperty(ctx, "temporary", RigidBody_IsTemporary, RigidBody_SetTemporary_bool);
    DefineProperty(ctx, "viewEnabled", RigidBody_ViewEnabled, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, RigidBody_ID);
}
void Expose_IAssetStorage(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, IAssetStorage_StaticFunctions);
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "AssetCreate");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "AssetModify");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "AssetDelete");
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "StorageUntrusted");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "StorageTrusted");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "StorageAskTrust");
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, IAssetStorage_Functions);
    DefineProperty(ctx, "AssetChanged", IAssetStorage_Get_AssetChanged, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, IAssetStorage_ID);
}
Esempio n. 19
0
void Expose_Avatar(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Avatar_StaticFunctions);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Avatar_Functions);
    DefineProperty(ctx, "ComponentNameChanged", Avatar_Get_ComponentNameChanged, nullptr);
    DefineProperty(ctx, "ParentEntitySet", Avatar_Get_ParentEntitySet, nullptr);
    DefineProperty(ctx, "ParentEntityAboutToBeDetached", Avatar_Get_ParentEntityAboutToBeDetached, nullptr);
    DefineProperty(ctx, "typeName", Avatar_TypeName, nullptr);
    DefineProperty(ctx, "typeId", Avatar_TypeId, nullptr);
    DefineProperty(ctx, "name", Avatar_Name, Avatar_SetName_String);
    DefineProperty(ctx, "replicated", Avatar_IsReplicated, Avatar_SetReplicated_bool);
    DefineProperty(ctx, "local", Avatar_IsLocal, nullptr);
    DefineProperty(ctx, "unacked", Avatar_IsUnacked, nullptr);
    DefineProperty(ctx, "updateMode", Avatar_UpdateMode, Avatar_SetUpdateMode_AttributeChange__Type);
    DefineProperty(ctx, "id", Avatar_Id, nullptr);
    DefineProperty(ctx, "temporary", Avatar_IsTemporary, Avatar_SetTemporary_bool);
    DefineProperty(ctx, "viewEnabled", Avatar_ViewEnabled, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, Avatar_ID);
}
Esempio n. 20
0
    duk_ret_t js_register_LocalStorage(duk_context *ctx)
    {
        duk_push_global_object(ctx); /* global */
        duk_get_prop_string(ctx, -1, MURAL_JS_NAMESPACE); /* global, __MURAL__ */
        
        duk_push_c_function(ctx, w_LocalStorage_constructor, 0); /* global, __MURAL__, constructor */
        duk_push_object(ctx); /* global, __MURAL__, constructor, prototype */
        duk_put_function_list(ctx, -1, methods_of_LocalStorage);
        duk_put_prop_string(ctx, -2, "prototype"); /* global, __MURAL__, constructor */
        
        duk_put_prop_string(ctx, -2, "LocalStorage"); /* global, __MURAL__ */
        duk_pop_2(ctx);

        return 0;
    }
Esempio n. 21
0
char *initPlugin(pluginHandler *_ph){
    slog(DEBUG,DEBUG,"Plugin "PLUGIN_SCOPE" initializing.");
    ph=_ph;
    ctx = ph->ctx;

    wally_put_function_list(ph,c_watchdogMethods);

    duk_push_c_function(ctx, js_watchdog_ctor, 7 );
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, watchdogMethods);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, JS_SCOPE);

    return PLUGIN_SCOPE;
}
Esempio n. 22
0
char *initPlugin(pluginHandler *_ph){
    slog(DEBUG,FULLDEBUG,"Plugin "PLUGIN_SCOPE" initializing.");
    ph=_ph;
    ctx = ph->ctx;

    wally_put_function(PLUGIN_SCOPE"::info", WFUNC_SYNC, myPluginInfo, 0);

    duk_push_c_function(ctx, js_myPlugin_ctor, 1 );
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, myPluginMethods);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, "myPlugin");  /* -> stack: [ ] */

    return PLUGIN_SCOPE;
}
void Expose_IAssetTransfer(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, IAssetTransfer_Functions);
    DefineProperty(ctx, "asset", IAssetTransfer_Get_asset, IAssetTransfer_Set_asset);
    DefineProperty(ctx, "source", IAssetTransfer_Get_source, IAssetTransfer_Set_source);
    DefineProperty(ctx, "assetType", IAssetTransfer_Get_assetType, IAssetTransfer_Set_assetType);
    DefineProperty(ctx, "internalResourceName", IAssetTransfer_Get_internalResourceName, IAssetTransfer_Set_internalResourceName);
    DefineProperty(ctx, "Downloaded", IAssetTransfer_Get_Downloaded, nullptr);
    DefineProperty(ctx, "Succeeded", IAssetTransfer_Get_Succeeded, nullptr);
    DefineProperty(ctx, "Failed", IAssetTransfer_Get_Failed, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, IAssetTransfer_ID);
}
Esempio n. 24
0
/**
 * Install the I2C module in the duktape interpreter.
 * @param ctx the duktape context to register the module in.
 */
void i2c_install_dpt_module(duk_context *ctx)
{
    const duk_function_list_entry i2c_module_functions[] = {
        { "enable_device", i2c_enable_device, DUK_VARARGS },
        { "open_bus", i2c_open_bus, DUK_VARARGS },
        { "set_device", i2c_set_device, DUK_VARARGS },
        { "write_byte", i2c_write_byte, DUK_VARARGS },
        { NULL, NULL, 0 }
    };

    duk_push_global_object(ctx);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, i2c_module_functions);
    duk_put_prop_string(ctx, -2, "I2CModule");
    duk_pop(ctx);
}
Esempio n. 25
0
File: sys1.c Progetto: jelaas/sys
int sys1_load(duk_context *ctx, int n, struct prg *prg)
{
	int i;
	
	duk_put_function_list(ctx, n, sys1_funcs);
	duk_put_number_list(ctx, n, sys1_consts);
	
	for(i=1;i<prg->argc;i++) {
		duk_push_string(ctx, prg->argv[i]);
		duk_put_prop_index(ctx, n, i-1);
	}
	duk_push_number(ctx, prg->argc-1);
	duk_put_prop_string(ctx, n, "argc");
	
	return 0;
}
Esempio n. 26
0
void
_gum_duk_kernel_init (GumDukKernel * self,
                      GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  self->core = core;

  duk_push_object (ctx);
  duk_push_uint (ctx, gum_kernel_query_page_size ());
  duk_put_prop_string (ctx, -2, "pageSize");
  _gum_duk_add_properties_to_class_by_heapptr (ctx,
      duk_require_heapptr (ctx, -1), gumjs_kernel_values);
  duk_put_function_list (ctx, -1, gumjs_kernel_functions);
  duk_put_global_string (ctx, "Kernel");
}
Esempio n. 27
0
void js_client_init(duk_context *ctx) {
   slog(DEBUG,DEBUG,"Constructing cloud object");
  
#ifndef WITH_SEADUK 
   duv_ref_setup(ctx);
#endif

   duk_push_c_function(ctx, js_client_ctor, 5 );

   /* Push Client.prototype object. */
   duk_push_object(ctx);

   duk_put_function_list(ctx, -1, clientMethods);
   duk_put_prop_string(ctx, -2, "prototype");
   /* Finally, register Client to the global object */
   duk_put_global_string(ctx, "CloudClient");  /* -> stack: [ ] */
}
Esempio n. 28
0
void Context::registerClass(index_t idx,
                            const char* id,
                            Function ctorFunc, int ctorNargs,
                            const FunctionEntry* methods,
                            const PropertyEntry* props)
{
    ASSERT(ctorFunc);
    duk_push_c_function(m_handle, ctorFunc, ctorNargs);

    duk_push_object(m_handle); // Prototype object
    if (methods)
        duk_put_function_list(m_handle, -1, (const duk_function_list_entry*)methods);
    if (props)
        registerProps(-1, props);

    duk_set_prototype(m_handle, -2);
    duk_put_prop_string(m_handle, idx-1, id);
}
void Expose_PhysicsWorld(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, PhysicsWorld_Functions);
    DefineProperty(ctx, "PhysicsCollision", PhysicsWorld_Get_PhysicsCollision, nullptr);
    DefineProperty(ctx, "NewPhysicsCollision", PhysicsWorld_Get_NewPhysicsCollision, nullptr);
    DefineProperty(ctx, "AboutToUpdate", PhysicsWorld_Get_AboutToUpdate, nullptr);
    DefineProperty(ctx, "Updated", PhysicsWorld_Get_Updated, nullptr);
    DefineProperty(ctx, "physicsUpdatePeriod", PhysicsWorld_PhysicsUpdatePeriod, PhysicsWorld_SetPhysicsUpdatePeriod_float);
    DefineProperty(ctx, "maxSubSteps", PhysicsWorld_MaxSubSteps, PhysicsWorld_SetMaxSubSteps_int);
    DefineProperty(ctx, "gravity", PhysicsWorld_Gravity, PhysicsWorld_SetGravity_float3);
    DefineProperty(ctx, "debugGeometryEnabled", PhysicsWorld_IsDebugGeometryEnabled, PhysicsWorld_SetDebugGeometryEnabled_bool);
    DefineProperty(ctx, "running", PhysicsWorld_IsRunning, PhysicsWorld_SetRunning_bool);
    DefineProperty(ctx, "client", PhysicsWorld_IsClient, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, PhysicsWorld_ID);
}
Esempio n. 30
0
void Expose_IAsset(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "Original");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "Cached");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "Programmatic");
    duk_push_number(ctx, 3);
    duk_put_prop_string(ctx, -2, "Bundle");
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, IAsset_Functions);
    DefineProperty(ctx, "Unloaded", IAsset_Get_Unloaded, nullptr);
    DefineProperty(ctx, "Loaded", IAsset_Get_Loaded, nullptr);
    DefineProperty(ctx, "PropertyStatusChanged", IAsset_Get_PropertyStatusChanged, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, IAsset_ID);
}