Esempio n. 1
0
//Регистрация библиотеки работы с плейлистами
void bind_playlist_library (Environment& environment)
{
  InvokerRegistry lib = environment.CreateLibrary (MEDIA_PLAYLIST_LIBRARY);

    //регистрация функций создания

  lib.Register ("Create", make_invoker (&create_playlist));

    //регистрация операций

  lib.Register ("get_Capacity", make_invoker (&Playlist::Capacity));
  lib.Register ("get_Empty",    make_invoker (&Playlist::IsEmpty));
  lib.Register ("get_Id",       make_invoker (&Playlist::Id));
  lib.Register ("get_Size",     make_invoker (&Playlist::Size));

  lib.Register ("AddSource",    make_invoker (&Playlist::AddSource));
  lib.Register ("Clear",        make_invoker (&Playlist::Clear));
  lib.Register ("Clone",        make_invoker (&Playlist::Clone));
  lib.Register ("Item",         make_invoker (&Playlist::Item));
  lib.Register ("RemoveSource", make_invoker (make_invoker (implicit_cast<void (Playlist::*) (const char*)> (&Playlist::RemoveSource)),
                                              make_invoker (implicit_cast<void (Playlist::*) (unsigned int)> (&Playlist::RemoveSource))));
  lib.Register ("Reserve",      make_invoker (&Playlist::Reserve));

  environment.RegisterType<Playlist> (MEDIA_PLAYLIST_LIBRARY);
}
Esempio n. 2
0
//Регистрация библиотеки работы с проигрывателями
void bind_media_player_library (Environment& environment)
{
  InvokerRegistry lib = environment.CreateLibrary (MEDIA_PLAYER_LIBRARY);

    //регистрация статических переменных
  bind_static_media_player_library (environment);

    //регистрация функций создания

  lib.Register ("Create", make_invoker (make_invoker (&create_player_with_target_and_playlist),
                                        make_invoker (&create_player_with_target_and_stream),
                                        make_invoker (&create_player_with_target),
                                        make_invoker (&create_player)));

  //регистрация операций

  lib.Register ("get_CurrentPlaybackDuration", make_invoker (implicit_cast<float (MediaPlayer::*) () const> (&MediaPlayer::Duration)));
  lib.Register ("get_IsPaused",                make_invoker (&MediaPlayer::IsPaused));
  lib.Register ("get_IsPlaying",               make_invoker (&MediaPlayer::IsPlaying));
  lib.Register ("get_IsStopped",               make_invoker (&MediaPlayer::IsStopped));
  lib.Register ("get_Mute",                    make_invoker (&MediaPlayer::IsMuted));
  lib.Register ("get_Name",                    make_invoker (&MediaPlayer::Name));
  lib.Register ("get_NextPlayTrack",           make_invoker (&MediaPlayer::NextPlayTrack));
  lib.Register ("get_Playlist",                make_invoker (&MediaPlayer::Playlist));
  lib.Register ("get_Position",                make_invoker (&MediaPlayer::Position));
  lib.Register ("get_RepeatMode",              make_invoker (&MediaPlayer::RepeatMode));
  lib.Register ("get_Source",                  make_invoker (implicit_cast<const char* (MediaPlayer::*) () const> (&MediaPlayer::Source)));
  lib.Register ("get_State",                   make_invoker (&MediaPlayer::State));
  lib.Register ("get_Target",                  make_invoker (&MediaPlayer::Target));
  lib.Register ("get_Track",                   make_invoker (&MediaPlayer::Track));
  lib.Register ("get_TracksCount",             make_invoker (&MediaPlayer::TracksCount));
  lib.Register ("get_Volume",                  make_invoker (&MediaPlayer::Volume));
  lib.Register ("set_Mute",                    make_invoker (&MediaPlayer::SetMute));
  lib.Register ("set_Name",                    make_invoker (&MediaPlayer::SetName));
  lib.Register ("set_NextPlayTrack",           make_invoker (&MediaPlayer::SetNextPlayTrack));
  lib.Register ("set_Position",                make_invoker (&MediaPlayer::SetPosition));
  lib.Register ("set_RepeatMode",              make_invoker (&MediaPlayer::SetRepeatMode));
  lib.Register ("set_Target",                  make_invoker (&MediaPlayer::SetTarget));
  lib.Register ("set_Track",                   make_invoker (&MediaPlayer::SetTrack));
  lib.Register ("set_Volume",                  make_invoker (&MediaPlayer::SetVolume));

  lib.Register ("Close",          make_invoker (&MediaPlayer::Close));
  lib.Register ("Duration",       make_invoker (implicit_cast<float (MediaPlayer::*) (unsigned int) const> (&MediaPlayer::Duration)));
  lib.Register ("NextTrack",      make_invoker (&MediaPlayer::NextTrack));
  lib.Register ("Open",           make_invoker (make_invoker (implicit_cast<void (MediaPlayer::*) (const char*)> (&MediaPlayer::Open)),
                                                make_invoker (implicit_cast<void (MediaPlayer::*) (const Playlist&)> (&MediaPlayer::Open))));
  lib.Register ("UpdatePlaylist", make_invoker (&MediaPlayer::UpdatePlaylist));
  lib.Register ("Pause",          make_invoker (&MediaPlayer::Pause));
  lib.Register ("Play",           make_invoker (&MediaPlayer::Play));
  lib.Register ("PrevTrack",      make_invoker (&MediaPlayer::PrevTrack));
  lib.Register ("Source",         make_invoker (implicit_cast<const char* (MediaPlayer::*) (unsigned int) const> (&MediaPlayer::Source)));
  lib.Register ("Stop",           make_invoker (&MediaPlayer::Stop));

  lib.Register ("CreateEventHandler",   make_callback_invoker<MediaPlayerEventHandler::signature_type> ());
  lib.Register ("RegisterEventHandler", make_invoker (&player_register_event_handler));

  environment.RegisterType<MediaPlayer> (MEDIA_PLAYER_LIBRARY);
}
Esempio n. 3
0
//Регистрация статических переменных
void bind_static_media_player_library (Environment& environment)
{
  InvokerRegistry player_state_lib       = environment.CreateLibrary (MEDIA_STATIC_PLAYER_STATE_LIBRARY);
  InvokerRegistry player_repeat_mode_lib = environment.CreateLibrary (MEDIA_STATIC_PLAYER_REPEAT_MODE_LIBRARY);
  InvokerRegistry player_event_lib       = environment.CreateLibrary (MEDIA_STATIC_PLAYER_EVENT_LIBRARY);

  player_state_lib.Register       ("get_Stopped",            make_const (MediaPlayerState_Stopped));
  player_state_lib.Register       ("get_Playing",            make_const (MediaPlayerState_Playing));
  player_state_lib.Register       ("get_Paused",             make_const (MediaPlayerState_Paused));
  player_repeat_mode_lib.Register ("get_Off",                make_const (MediaPlayerRepeatMode_Off));
  player_repeat_mode_lib.Register ("get_Last",               make_const (MediaPlayerRepeatMode_Last));
  player_repeat_mode_lib.Register ("get_All",                make_const (MediaPlayerRepeatMode_All));
  player_event_lib.Register       ("get_OnChangeName",       make_const (MediaPlayerEvent_OnChangeName));
  player_event_lib.Register       ("get_OnChangeTarget",     make_const (MediaPlayerEvent_OnChangeTarget));
  player_event_lib.Register       ("get_OnChangePlaylist",   make_const (MediaPlayerEvent_OnChangePlaylist));
  player_event_lib.Register       ("get_OnChangeTrack",      make_const (MediaPlayerEvent_OnChangeTrack));
  player_event_lib.Register       ("get_OnChangePlayback",   make_const (MediaPlayerEvent_OnChangePlayback));
  player_event_lib.Register       ("get_OnChangeVolume",     make_const (MediaPlayerEvent_OnChangeVolume));
  player_event_lib.Register       ("get_OnChangeRepeatMode", make_const (MediaPlayerEvent_OnChangeRepeatMode));
}
Esempio n. 4
0
void bind_static_axis_aligned_box_library (Environment& environment)
{
  InvokerRegistry aabox_box_corner_lib = environment.CreateLibrary (BV_STATIC_AXIS_ALIGNED_BOX_CORNER_LIBRARY);

  aabox_box_corner_lib.Register ("get_nxnynz", make_const (box_corner_nxnynz));
  aabox_box_corner_lib.Register ("get_pxnynz", make_const (box_corner_pxnynz));
  aabox_box_corner_lib.Register ("get_nxpynz", make_const (box_corner_nxpynz));
  aabox_box_corner_lib.Register ("get_pxpynz", make_const (box_corner_pxpynz));
  aabox_box_corner_lib.Register ("get_nxnypz", make_const (box_corner_nxnypz));
  aabox_box_corner_lib.Register ("get_pxnypz", make_const (box_corner_pxnypz));
  aabox_box_corner_lib.Register ("get_nxpypz", make_const (box_corner_nxpypz));
  aabox_box_corner_lib.Register ("get_pxpypz", make_const (box_corner_pxpypz));
}  
void bind_linear_acceleration_evaluator_library (Environment& environment)
{
  InvokerRegistry lib = environment.CreateLibrary (SCENE_LINEAR_ACCELERATION_EVALUATOR_LIBRARY);

    //регистрация функций создания

  lib.Register ("Create", make_invoker (&create_linear_acceleration_evaluator));

    //регистрация операций

  lib.Register ("set_Acceleration", make_invoker (&LinearAccelerationEvaluator::SetAcceleration));
  lib.Register ("set_Deceleration", make_invoker (&LinearAccelerationEvaluator::SetDeceleration));
  lib.Register ("set_MaxSpeed",     make_invoker (&LinearAccelerationEvaluator::SetMaxSpeed));
  lib.Register ("get_Acceleration", make_invoker (&LinearAccelerationEvaluator::Acceleration));
  lib.Register ("get_Deceleration", make_invoker (&LinearAccelerationEvaluator::Deceleration));
  lib.Register ("get_MaxSpeed",     make_invoker (&LinearAccelerationEvaluator::MaxSpeed));

    //регистрация типа данных

  environment.RegisterType<LinearAccelerationEvaluator> (SCENE_LINEAR_ACCELERATION_EVALUATOR_LIBRARY);
}
Esempio n. 6
0
int main ()
{
  printf ("Results of common_string_tree_test:\n");
  
  try
  {
    common::LogFilter filter ("script.binds.*", &log_handler);

    Environment env;
    
    InvokerRegistry lib = env.CreateLibrary ("Utils");

    lib.Register ("PrintIndent", make_invoker (&print_indent));

    Shell shell ("lua", env);

    xtl::com_ptr<IInterpreter> script (shell.Interpreter ());                

    env.BindLibraries ("Common");

    load_script (*script, SCRIPT_FILE_NAME);
    
    printf ("Test library:\n");

    invoke<void> (*script, "test");
  }
  catch (xtl::bad_any_cast& exception)
  {
    printf ("%s: %s -> %s\n", exception.what (), exception.source_type ().name (), exception.target_type ().name ());
  }    
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
Esempio n. 7
0
void bind_axis_aligned_box_library (Environment& environment)
{
  typedef axis_aligned_box<T>         box_type;
  typedef typename box_type::vec_type vec_type;  

  InvokerRegistry lib        = environment.CreateLibrary (BV_AXIS_ALIGNED_BOX_LIBRARY);
  InvokerRegistry global_lib = environment.Library ("global");
  
    //регистрация функций создания

  lib.Register ("Create", make_invoker (
                            make_invoker ((box_type (*)(T, T, T, T, T, T))&create_axis_aligned_box<T>),
                            make_invoker ((box_type (*)(const vec_type&, const vec_type&))&create_axis_aligned_box<T>),
                            make_invoker ((box_type (*)())&create_axis_aligned_box<T>)
                          ));
  global_lib.Register ("AABB", lib, "Create");

    //регистрация статических переменных

  bind_static_axis_aligned_box_library (environment);

    //регистрация операций

  lib.Register ("set_Minimum", make_invoker (implicit_cast<void (axis_aligned_box<T>::*) (const typename axis_aligned_box<T>::vec_type&)> 
                                            (&box_type::set_minimum)));
  lib.Register ("set_Maximum", make_invoker (implicit_cast<void (box_type::*) (const typename box_type::vec_type&)> 
                                            (&box_type::set_maximum)));
  lib.Register ("get_Minimum", make_invoker (&box_type::minimum));
  lib.Register ("get_Maximum", make_invoker (&box_type::maximum));

  lib.Register ("get_Center", make_invoker (&box_type::center));
  lib.Register ("get_Size",   make_invoker (&box_type::size));
  lib.Register ("get_Radius", make_invoker (&box_type::radius));
  lib.Register ("get_Empty",  make_invoker (&box_type::empty));

  lib.Register ("SetExtents", make_invoker (implicit_cast<void (box_type::*)
               (const typename box_type::vec_type&, const typename box_type::vec_type&)> (&box_type::set_extents)));

  lib.Register ("Corner", make_invoker (&box_type::corner));

  lib.Register ("Reset", make_invoker (&box_type::reset));

  lib.Register ("__add", make_invoker (implicit_cast<box_type (box_type::*) 
                                      (const box_type&) const> (&box_type::operator +)));
  lib.Register ("__mul", make_invoker (
    make_invoker (implicit_cast<box_type (box_type::*) (const matrix<T, 4>&) const> (&box_type::operator *)),
    make_invoker (implicit_cast<box_type (box_type::*) (const quat<T>&) const> (&box_type::operator *))
  ));
//  lib.Register ("__eq",  make_invoker (&box_type::operator ==));

  lib.Register ("get_Volume", make_invoker (&bound_volumes::volume<T>));
  lib.Register ("Equal", make_invoker (xtl::implicit_cast<bool (*)(const box_type&, const box_type&, const T& eps)> (&bound_volumes::equal<T>)));
  lib.Register ("Intersects", make_invoker (implicit_cast<bool (*) (const box_type&, const box_type&)> (&bound_volumes::intersects)));
  lib.Register ("Contains", make_invoker (
    make_invoker (implicit_cast<bool (*) (const box_type&, const box_type&)> (&bound_volumes::contains)),
    make_invoker (implicit_cast<bool (*) (const box_type&, const math::vector<T, 3>&)> (&bound_volumes::contains))
  ));
  lib.Register ("Intersection", make_invoker (implicit_cast<box_type (*) (const box_type&, const box_type&)> (&bound_volumes::intersection)));

    //регистрация типов данных

  environment.RegisterType<box_type> (BV_AXIS_ALIGNED_BOX_LIBRARY);
}