bool xplayerGMPPlayer::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { XPLAYER_LOG_INVOKE (aIndex, xplayerGMPPlayer); switch (Methods (aIndex)) { case eNewPlaylist: /* xplayerIGMPPlaylist newPlaylist (in AUTF8String name, in AUTF8String URL); */ XPLAYER_WARN_INVOKE_UNIMPLEMENTED (aIndex, xplayerGMPPlayer); return NullVariant (_result); case eClose: /* void close (); */ case eNewMedia: /* xplayerIGMPMedia newMedia (in AUTF8String URL); */ case eOpenPlayer: /* void openPlayer (in AUTF8String URL); */ case eLaunchURL: /* void launchURL (in AUTF8String URL); */ return ThrowSecurityError (); } return false; }
bool xplayerCone::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { XPLAYER_LOG_INVOKE (aIndex, xplayerCone); switch (Methods (aIndex)) { case eversionInfo: return GetPropertyByIndex (eVersionInfo, _result); } return false; }
bool totemConePlaylistItems::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { TOTEM_LOG_INVOKE (aIndex, totemConePlaylistItems); switch (Methods (aIndex)) { case eClear: Plugin()->ClearPlaylist (); return VoidVariant (_result); } return false; }
int main(int argc, char* argv[]) { double time = std::atof(argv[1]); //time in seconds double dx = 1./100; //delta x double dt = (dx*dx)/2.; //delta t /* run functions */ Methods meth = Methods(time, dt, dx); //object meth from class Methods std::string method = argv[2]; //method of choice //if-tests for which method to run if(method == "EE") meth.explicitEuler(); if(method == "IE") meth.implicitEuler(); if(method == "CN") meth.implicitCrankNicolson(); return 0; }
bool idolConeAudio::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { IDOL_LOG_INVOKE (aIndex, idolConeAudio); switch (Methods (aIndex)) { case eToggleMute: { /* FIXMEchpe this sucks */ NPVariant mute; BOOLEAN_TO_NPVARIANT (!mMute, mute); return SetPropertyByIndex (eMute, &mute); } } return false; }
bool xplayerConeVideo::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { XPLAYER_LOG_INVOKE (aIndex, xplayerConeVideo); switch (Methods (aIndex)) { case eToggleFullscreen: { /* FIXMEchpe this sucks */ NPVariant fullscreen; BOOLEAN_TO_NPVARIANT (!Plugin()->IsFullscreen(), fullscreen); return SetPropertyByIndex (eFullscreen, &fullscreen); } case eToggleTeletext: XPLAYER_WARN_INVOKE_UNIMPLEMENTED (aIndex, xplayerConeVideo); return VoidVariant (_result); } return false; }
///////////////////////////////////////////////////////////////////// Class #define JB_CURRENT_CLASS Class JB_DEFINE_WRAPPER_CLASS( "java/lang/Class" , NoFields , Methods ( GetName, "getName", "()Ljava/lang/String;" ) ( ForName, "+forName", "(Ljava/lang/String;)Ljava/lang/Class;" ) ) Class::Class(const jni::LObject& clazz): java::Object(clazz) { } PString Class::GetName() const { return PString::Wrap(JB_CALL_THIS(ObjectMethod,GetName)); }
BEGIN_NAMESPACE(jni) ///////////////////////////////////////////////////////////////////// helpers ///////////////////////////////////////////////// ThrowRuntimeException #define JB_CURRENT_CLASS RuntimeException JB_DEFINE_ACCESSOR( "java/lang/RuntimeException" , NoFields , Methods ( Constructor, "<init>","(Ljava/lang/String;)V" ) ) static void ThrowRuntimeException(const char* message) { Throw(JB_NEW(Constructor,java::PString::New(message))); } #undef JB_CURRENT_CLASS ///////////////////////////////////////////////////////////////////// LObject LObject::LObject() { Construct(0,false); }
#define JB_CURRENT_CLASS Callee JB_DEFINE_ACCESSOR( "com/itoa/jnipp/test/Callee" , NoFields , Methods (Constructor,"<init>","()V") (GetBoolean,"getBoolean","()Z")(SetBoolean,"setBoolean","(Z)V") (GetByte,"getByte","()B")(SetByte,"setByte","(B)V") (GetChar,"getChar","()C")(SetChar,"setChar","(C)V") (GetShort,"getShort","()S")(SetShort,"setShort","(S)V") (GetInt,"getInt","()I")(SetInt,"setInt","(I)V") (GetLong,"getLong","()J")(SetLong,"setLong","(J)V") (GetFloat,"getFloat","()F")(SetFloat,"setFloat","(F)V") (GetDouble,"getDouble","()D")(SetDouble,"setDouble","(D)V") (GetStaticBoolean,"+getStaticBoolean","()Z")(SetStaticBoolean,"+setStaticBoolean","(Z)V") (GetStaticByte,"+getStaticByte","()B")(SetStaticByte,"+setStaticByte","(B)V") (GetStaticChar,"+getStaticChar","()C")(SetStaticChar,"+setStaticChar","(C)V") (GetStaticShort,"+getStaticShort","()S")(SetStaticShort,"+setStaticShort","(S)V") (GetStaticInt,"+getStaticInt","()I")(SetStaticInt,"+setStaticInt","(I)V") (GetStaticLong,"+getStaticLong","()J")(SetStaticLong,"+setStaticLong","(J)V") (GetStaticFloat,"+getStaticFloat","()F")(SetStaticFloat,"+setStaticFloat","(F)V") (GetStaticDouble,"+getStaticDouble","()D")(SetStaticDouble,"+setStaticDouble","(D)V") ) static jni::LObject CreateTestObject() { return JB_NEW(Constructor); } #define GENERATE_GETSET(MethodType,ReturnType,CType,PrinfFormatter) \
///////////////////////////////////////////////// JavaExit #define JB_CURRENT_CLASS JavaExit JB_DEFINE_ACCESSOR( "java/lang/System" , NoFields , Methods ( RunFinalizersOnExit, "+runFinalizersOnExit", "(Z)V" ) ( Exit, "+exit", "(I)V" ) ) static void JavaExit(int32_t exitCode) { JB_CALL_STATIC(VoidMethod,RunFinalizersOnExit,true); JB_CALL_STATIC(VoidMethod,Exit,exitCode); } #undef JB_CURRENT_CLASS ///////////////////////////////////////////////////////////////////// Activity:: classes
hy_error* ErrorCode(hy_error_code *retval) { return Methods()->error_code(Self(), retval); }
hy_error* ErrorMessage(const char **retval) { return Methods()->error_message(Self(), retval); }
bool xplayerGMPControls::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { XPLAYER_LOG_INVOKE (aIndex, xplayerGMPControls); switch (Methods (aIndex)) { case ePause: /* void pause (); */ Plugin()->Command (XPLAYER_COMMAND_PAUSE); return VoidVariant (_result); case ePlay: /* void play (); */ Plugin()->Command (XPLAYER_COMMAND_PLAY); return VoidVariant (_result); case eStop: /* void stop (); */ Plugin()->Command (XPLAYER_COMMAND_PAUSE); return VoidVariant (_result); case eGetAudioLanguageDescription: /* AUTF8String getAudioLanguageDescription (in long index); */ XPLAYER_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,xplayerGMPControls); return StringVariant (_result, "English"); case eGetLanguageName: /* AUTF8String getLanguageName (in long LCID); */ XPLAYER_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,xplayerGMPControls); return StringVariant (_result, "English"); case eIsAvailable: /* boolean isAvailable (in ACString name); */ NPString name; if (!GetNPStringFromArguments (argv, argc, 0, name)) return false; if (g_ascii_strncasecmp (name.UTF8Characters, "currentItem", name.UTF8Length) == 0 || g_ascii_strncasecmp (name.UTF8Characters, "next", name.UTF8Length) == 0 || g_ascii_strncasecmp (name.UTF8Characters, "pause", name.UTF8Length) == 0 || g_ascii_strncasecmp (name.UTF8Characters, "play", name.UTF8Length) == 0 || g_ascii_strncasecmp (name.UTF8Characters, "previous", name.UTF8Length) == 0 || g_ascii_strncasecmp (name.UTF8Characters, "stop", name.UTF8Length) == 0) return BoolVariant (_result, true); return BoolVariant (_result, false); case eFastForward: /* void fastForward (); */ case eFastReverse: /* void fastReverse (); */ case eGetAudioLanguageID: /* long getAudioLanguageID (in long index); */ case eNext: /* void next (); */ case ePlayItem: /* void playItem (in xplayerIGMPMedia theMediaItem); */ case ePrevious: /* void previous (); */ case eStep: /* void step (in long frameCount); */ XPLAYER_WARN_INVOKE_UNIMPLEMENTED (aIndex,xplayerGMPControls); return VoidVariant (_result); } return false; }
/* Implementation of the WeakReference functions using * java.lang.ref.WeakReference class. */ #define JB_CURRENT_CLASS WeakReference JB_DEFINE_ACCESSOR( "java/lang/ref/WeakReference" , NoFields , Methods ( Constructor, "<init>","(Ljava/lang/Object;)V" ) ( Get, "get","()Ljava/lang/Object;" ) ) static jobject LocalToGlobalRef(jobject object) { if (!object) { return 0; } jobject globalObject=jni::GetEnv()->NewGlobalRef(object); jni::GetEnv()->DeleteLocalRef(object); return globalObject; }
bool xplayerMullYPlayer::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { XPLAYER_LOG_INVOKE (aIndex, xplayerMullYPlayer); switch (Methods (aIndex)) { case eGetVersion: return StringVariant (_result, XPLAYER_MULLY_VERSION); case ePlay: Plugin()->Command (XPLAYER_COMMAND_PLAY); return VoidVariant (_result); case ePause: Plugin()->Command (XPLAYER_COMMAND_PAUSE); return VoidVariant (_result); case eStop: Plugin()->Command (XPLAYER_COMMAND_STOP); return VoidVariant (_result); case eSetVolume: { // FIXMEchpe where's getVolume? break; } case eMute: Plugin()->SetMute (true); return VoidVariant (_result); case eUnMute: Plugin()->SetMute (false); return VoidVariant (_result); case eSetMinVersion: case eSetMode: case eSetAllowContextMenu: case eSetAutoPlay: case eSetLoop: case eSetBufferingMode: case eSetBannerEnabled: case eSetMovieTitle: case eSetPreviewImage: case eSetPreviewMessage: case eSetPreviewMessageFontSize: case eOpen: case eStepForward: case eStepBackward: case eFF: case eRW: case eSeek: case eResize: case eGetTotalTime: case eGetVideoWidth: case eGetVideoHeight: case eGetTotalVideoFrames: case eGetVideoFramerate: case eGetNumberOfAudioTracks: case eGetNumberOfSubtitleTracks: case eGetAudioTrackLanguage: case eGetSubtitleTrackLanguage: case eGetAudioTrackName: case eGetSubtitleTrackName: case eGetCurrentAudioTrack: case eGetCurrentSubtitleTrack: case eSetCurrentAudioTrack: case eSetCurrentSubtitleTrack: XPLAYER_WARN_INVOKE_UNIMPLEMENTED (aIndex, xplayerMullYPlayer); return VoidVariant (_result); case eGoEmbedded: case eGoWindowed: case eGoFullscreen: case eAbout: case eShowPreferences: case eShowContextMenu: /* We don't allow the page's JS to do this. Don't throw though, just silently do nothing. */ return VoidVariant (_result); } return false; }
///////////////////////////////////////////////// FreeLayoutParams #define JB_CURRENT_CLASS FreeLayoutParams JB_DEFINE_WRAPPER_CLASS( "com/itoa/FreeLayout$LayoutParams" , Fields ( Matrix, "matrix","Landroid/graphics/Matrix;" ) , Methods ( Constructor, "<init>", "(IILandroid/graphics/Matrix;)V" ) ) FreeLayoutParams::FreeLayoutParams(): ViewLayoutParams(JB_NEW(Constructor,0,0,0)) { } FreeLayoutParams::FreeLayoutParams(int32_t width,int32_t height,android::PMatrix matrix): ViewLayoutParams(JB_NEW(Constructor,width,height,matrix)) { } FreeLayoutParams::FreeLayoutParams(const jni::LObject& object):
int main(int argc, char* argv[]) { double sun_mass = 1.00000000e-00; //mass sun double mercury_mass = 1.65956463e-07; //mass mercury double venus_mass = 2.44699613e-06; //mass venus double earth_mass = 3.00245840e-06; //mass earth double mars_mass = 3.00245840e-07; //mass mars double jupiter_mass = 9.54265748e-04; //mass jupiter double saturn_mass = 2.85716656e-04; //mass saturn double uranus_mass = 4.36430044e-05; //mass uranus double neptune_mass = 5.14855965e-05; //mass neptune double pluto_mass = 6.58086572e-09; //mass pluto arma::vec mercury_position = {0.466697,0.,0.}; arma::vec mercury_velocity = {0.,9.99077808,0.}; arma::vec venus_position = {0.728213,0.,0.}; arma::vec venus_velocity = {0.,7.38729464,0.}; arma::vec earth_position = {1.,0,0.}; //initial position earth arma::vec earth_velocity = {0.,6.28194273,0.}; //initial velocity earth arma::vec mars_position {1.6660,0.,0.}; arma::vec mars_velocity {0.,5.07892327,0.}; arma::vec jupiter_position = {5.458104,0.,0.}; arma::vec jupiter_velocity = {0.,2.75705142,0.}; arma::vec saturn_position = {10.11595804,0.,0.}; arma::vec saturn_velocity = {0.,2.04405725,0.}; arma::vec uranus_position = {20.095371,0.,0.}; arma::vec uranus_velocity = {0.,1.43442614,0.}; arma::vec neptune_position = {30.331855,0.,0.}; arma::vec neptune_velocity = {0.,1.14543146,0.}; arma::vec pluto_position = {39.264,0.,0.}; arma::vec pluto_velocity = {0.,0.991441599,0.}; arma::vec velocities[9] = {mercury_velocity, venus_velocity, earth_velocity, mars_velocity, jupiter_velocity, saturn_velocity, neptune_velocity, uranus_velocity, pluto_velocity}; double masses[9] = {mercury_mass, venus_mass, earth_mass, mars_mass, jupiter_mass, saturn_mass, uranus_mass, neptune_mass, pluto_mass}; double s_vel = 0; for(int i=0; i<9 ;i++) { s_vel += masses[i]*arma::norm(velocities[i]); } arma::vec sun_position = {0.,0.,0.}; //initial position sun arma::vec sun_velocity = {0.,s_vel,0.}; //initial position sun Solarsystem mySolarsystem; //initialize solarsystem Body sun (sun_position, sun_velocity, sun_mass); //create sun Body mercury(mercury_position, mercury_velocity, mercury_mass); //create mercury Body venus (venus_position, venus_velocity, venus_mass); //create venus Body earth (earth_position, earth_velocity, earth_mass); //create earth Body mars (mars_position, mars_velocity, mars_mass); //create mars Body jupiter(jupiter_position, jupiter_velocity, jupiter_mass); //create jupiter Body saturn (saturn_position, saturn_velocity, saturn_mass); //create saturn Body uranus (uranus_position, uranus_velocity, uranus_mass); //create uranus Body neptune(neptune_position, neptune_velocity, neptune_mass); //create neptune Body pluto (pluto_position, pluto_velocity, pluto_mass); //create pluto mySolarsystem.addBody(sun); //add sun to system mySolarsystem.addBody(mercury); //add mercury to system mySolarsystem.addBody(venus); //add venus to system mySolarsystem.addBody(earth); //add earth to system mySolarsystem.addBody(mars); //add mars to system mySolarsystem.addBody(jupiter); //add jupiter to system mySolarsystem.addBody(saturn); //add saturn to system mySolarsystem.addBody(uranus); //add uranus to system mySolarsystem.addBody(neptune); //add neptune to system mySolarsystem.addBody(pluto); //add pluto to system Methods methods = Methods(); //initialize methods double T = std::atof(argv[1]); //total time double dt = std::atof(argv[2]); //time-step std::string method = argv[3]; //method choice if(method == "verlet") { /* run verlet */ methods.verlet_integrate(mySolarsystem, T, dt); //call integrator with made solarsystem } else if(method == "rk4") { /* run rk4 */ methods.rk4_integrate(mySolarsystem, T, dt); } else { /* standard */ std::cout << "Specify method" << std::endl; } return 0; }
bool totemConePlaylist::InvokeByIndex (int aIndex, const NPVariant *argv, uint32_t argc, NPVariant *_result) { TOTEM_LOG_INVOKE (aIndex, totemConePlaylist); switch (Methods (aIndex)) { case eAdd: { /* long add (in AUTF8String MRL, [in AUTF8String name, in AUTF8String options]); */ if (!CheckArgc (argc, 1, 3)) return false; NPString mrl; if (!GetNPStringFromArguments (argv, argc, 0, mrl)) return false; NPString title; if (argc != 3 || !GetNPStringFromArguments (argv, argc, 1, title)) title.UTF8Characters = NULL; NPString options; if (argc != 3 || !GetNPStringFromArguments (argv, argc, 2, options)) options.UTF8Characters = NULL; //FIXME handle options as array //http://wiki.videolan.org/Documentation:WebPlugin#Playlist_object char *subtitle = NULL; if (options.UTF8Characters && options.UTF8Length) { char *str, **items; guint i; str = g_strndup (options.UTF8Characters, options.UTF8Length); items = g_strsplit (str, " ", -1); g_free (str); for (i = 0; items[i] != NULL; i++) { if (g_str_has_prefix (items[i], ":sub-file=")) { subtitle = g_strdup (items[i] + strlen (":sub-file=")); break; } } g_strfreev (items); } Plugin()->AddItem (mrl, title, subtitle); g_free (subtitle); //FIXME we're supposed to return a unique number here return Int32Variant (_result, 1); } case ePlay: Plugin()->Command (TOTEM_COMMAND_PLAY); return VoidVariant (_result); case eStop: Plugin()->Command (TOTEM_COMMAND_STOP); return VoidVariant (_result); case eTogglePause: if (Plugin()->State() == TOTEM_STATE_PLAYING) { Plugin()->Command (TOTEM_COMMAND_PAUSE); } else if (Plugin()->State() == TOTEM_STATE_PAUSED) { Plugin()->Command (TOTEM_COMMAND_PLAY); } return VoidVariant (_result); case eNext: case ePlayItem: case ePrev: case eRemoveItem: TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex, totemConePlaylist); return VoidVariant (_result); } return false; }