Jump to content

Info on Interpreter


photo

Recommended Posts

Hi,

 

i add in the GLESAppTablet.cpp many method for ios

 

Unigine::Interpreter::addExternFunction("engine.tablet.showKeyboard",Unigine::MakeExternFunction(&engine_tablet_show_keyboard));

Unigine::Interpreter::addExternFunction("engine.tablet.hideKeyboard",Unigine::MakeExternFunction(&engine_tablet_hide_keyboard));

Unigine::Interpreter::addExternFunction("engine.tablet.getAccelerometerAngle",Unigine::MakeExternFunction(&engine_tablet_get_accelerometer_angle));

Unigine::Interpreter::addExternFunction("engine.tablet.getAccelerometerX",Unigine::MakeExternFunction(&engine_tablet_get_accelerometer_x));

Unigine::Interpreter::addExternFunction("engine.tablet.getAccelerometerY",Unigine::MakeExternFunction(&engine_tablet_get_accelerometer_y));

Unigine::Interpreter::addExternFunction("engine.tablet.getAccelerometerZ",Unigine::MakeExternFunction(&engine_tablet_get_accelerometer_z));

 

I show your network plugin, and in the shutdown method you delete every function added, but in the GLESAppTablet, you don't do it.

 

delete or not delete ??? that is the question.

 

It's necessary to delete every externFunction in all cases, or just because network is a plugin ???

Link to comment

In once time running application we can discard destruction of external resources.

 

But applications with multiple Engine::init()/Engine::shutdown() sequences should delete external resources:

delete Interpreter::removeExternClass("MyClass");
delete Interlreter::removeExternFunction("MyFunction");

 

External App can be an exception:

// initialize the App and create externals
GLESAppTablet app;

// initialize the Engine with external App
Engine::init(&app);
Engine::shutdown();

// initialize the Engine with external App
Engine::init(&app);
Engine::shutdown();

In this case GLESAppTablet exports externals in constructor.

After that engine has access to App externals.

On application exit we can discard destruction of App externals.

 

But if we want to recreate App each time:

{
GLESAppTablet app;
Engine::init(&app);
Engine::shutdown();
}
{
GLESAppTablet app;
Engine::init(&app);
Engine::shutdown();
}

We will have memory leaks and bunch of errors in log about multiple registrations of same external resource.

In this case destruction of external resources are required.

Link to comment
×
×
  • Create New...