static JSValueRef setValueAndClosePopupCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef*) { JSValueRef jsRetVal = JSValueMakeUndefined(context); if (argumentCount <= 0) return jsRetVal; JSStringRef string = JSValueToStringCopy(context, arguments[0], 0); size_t sizeUTF8 = JSStringGetMaximumUTF8CStringSize(string); Vector<char> strArgs(sizeUTF8 + 1); strArgs[sizeUTF8] = 0; JSStringGetUTF8CString(string, strArgs.data(), sizeUTF8); JSStringRelease(string); JSObjectRef popUpObject = JSValueToObject(context, arguments[argumentCount - 1], 0); PagePopupBlackBerry::SharedClientPointer* client = reinterpret_cast<PagePopupBlackBerry::SharedClientPointer*>(JSObjectGetPrivate(popUpObject)); // Check the weak pointer as the owner page may have destroyed the popup. if (client->get()) client->get()->setValueAndClosePopup(0, strArgs.data()); return jsRetVal; }
//++ ------------------------------------------------------------------------------------ // Details: Check the arguments given on the command line. The main purpose of this // function is to check for the presence of the --interpreter option. Having // this option present tells *this manager to set the CMIDriver to do work. If // not use the LLDB driver. The following are options that are only handled by // the CMIDriverMgr are: // --help or -h // --interpreter // --version // --versionLong // --noLog // --executable // The above arguments are not handled by any driver object except for --executable. // The options --interpreter and --executable in code act very similar. The // --executable is necessary to differentiate whither the MI Driver is being using // by a client i.e. Eclipse or from the command line. Eclipse issues the option // --interpreter and also passes additional arguments which can be interpreted as an // executable if called from the command line. Using --executable tells the MI // Driver is being called the command line and that the executable argument is indeed // a specified executable an so actions commands to set up the executable for a // debug session. Using --interpreter on the commnd line does not action additional // commands to initialise a debug session and so be able to launch the process. // Type: Method. // Args: argc - (R) An integer that contains the count of arguments that follow in // argv. The argc parameter is always greater than or equal to 1. // argv - (R) An array of null-terminated strings representing command-line // arguments entered by the user of the program. By convention, // argv[0] is the command with which the program is invoked. // vwbExiting - (W) True = *this want to exit, Reasons: help, invalid arg(s), // version information only. // False = Continue to work, start debugger i.e. Command // interpreter. // Return: lldb::SBError - LLDB current error status. // Throws: None. //-- bool CMIDriverMgr::ParseArgs( const int argc, const char * argv[], bool & vwbExiting ) { bool bOk = MIstatus::success; vwbExiting = false; // Print MI application path to the Log file const CMIUtilString appPath( CMIUtilString::Format( MIRSRC( IDS_MI_APP_FILEPATHNAME ), argv[ 0 ] ) ); bOk = m_pLog->Write( appPath, CMICmnLog::eLogVerbosity_Log ); // Print application arguments to the Log file const bool bHaveArgs( argc >= 2 ); CMIUtilString strArgs( MIRSRC( IDS_MI_APP_ARGS ) ); if( !bHaveArgs ) { strArgs += MIRSRC( IDS_WORD_NONE ); bOk = bOk && m_pLog->Write( strArgs, CMICmnLog::eLogVerbosity_Log ); } else { for( MIint i = 1; i < argc; i++ ) { strArgs += CMIUtilString::Format( "%d:'%s' ", i, argv[ i ] ); } bOk = bOk && m_pLog->Write( strArgs, CMICmnLog::eLogVerbosity_Log ); } // Look for the command line options bool bHaveArgInterpret = false; bool bHaveArgVersion = false; bool bHaveArgVersionLong = false; bool bHaveArgNoLog = false; bool bHaveArgHelp = false; // Hardcode the use of the MI driver #if MICONFIG_DEFAULT_TO_MI_DRIVER bHaveArgInterpret = true; #endif // MICONFIG_DEFAULT_TO_MI_DRIVER if( bHaveArgs ) { // CODETAG_MIDRIVE_CMD_LINE_ARG_HANDLING for( MIint i = 1; i < argc; i++ ) { // *** Add args to help in GetHelpOnCmdLineArgOptions() *** const CMIUtilString strArg( argv[ i ] ); // Argument "--executable" is also check for in CMIDriver::ParseArgs() if( (0 == strArg.compare( "--interpreter" )) || // Given by the client such as Eclipse (0 == strArg.compare( "--executable" )) ) // Used to specify that there is executable argument also on the command line { // See fn description. bHaveArgInterpret = true; } if( 0 == strArg.compare( "--version" ) ) { bHaveArgVersion = true; } if( 0 == strArg.compare( "--versionLong" ) ) { bHaveArgVersionLong = true; } if( 0 == strArg.compare( "--noLog" ) ) { bHaveArgNoLog = true; } if( (0 == strArg.compare( "--help" )) || (0 == strArg.compare( "-h" )) ) { bHaveArgHelp = true; } } } if( bHaveArgNoLog ) { CMICmnLog::Instance().SetEnabled( false ); } // Todo: Remove this output when MI is finished. It is temporary to persuade Ecllipse plugin to work. // Eclipse reads this literally and will not work unless it gets this exact version text. // Handle --version option (ignore the --interpreter option if present) if( bHaveArgVersion ) { vwbExiting = true; bOk = bOk && CMICmnStreamStdout::Instance().WriteMIResponse( MIRSRC( IDE_MI_VERSION_GDB ) ); return bOk; } // Todo: Make this the --version when the the above --version version is removed // Handle --versionlong option (ignore the --interpreter option if present) if( bHaveArgVersionLong ) { vwbExiting = true; bOk = bOk && CMICmnStreamStdout::Instance().WriteMIResponse( GetAppVersion() ); return bOk; } // Both '--help' and '--intepreter' means give help for MI only. Without // '--interpreter' help the LLDB driver is working and so help is for that. if( bHaveArgHelp && bHaveArgInterpret ) { vwbExiting = true; bOk = bOk && CMICmnStreamStdout::Instance().WriteMIResponse( GetHelpOnCmdLineArgOptions() ); return bOk; } // This makes the assumption that there is at least one MI compatible // driver registered and one LLDB driver registerd and the CMIDriver // is the first one found. // ToDo: Implement a better solution that handle any order, any number // of drivers. Or this 'feature' may be removed if deemed not required. IDriver * pLldbDriver = GetFirstNonMIDriver(); IDriver * pMi2Driver = GetFirstMIDriver(); if( bHaveArgInterpret && (pMi2Driver != nullptr) ) bOk = bOk && SetUseThisDriverToDoWork( *pMi2Driver ); else if( pLldbDriver != nullptr ) bOk = bOk && SetUseThisDriverToDoWork( *pLldbDriver ); else { if( bOk ) { vwbExiting = true; const CMIUtilString msg( MIRSRC( IDS_DRIVER_ERR_NON_REGISTERED ) ); bOk = bOk && CMICmnStreamStdout::Instance().WriteMIResponse( msg ); } } return bOk; }