예제 #1
0
TEST(OpenCVEngineTest, GetPathForUnExistVersion)
{
    sp<IOpenCVEngine> Engine = InitConnect();
    EXPECT_FALSE(NULL == Engine.get());
    String16 result = Engine->GetLibPathByVersion(String16("2.5"));
    EXPECT_EQ(0, result.size());
}
예제 #2
0
void    ChatSession::Advise(const sp<IChatSessionEvents>& eventSink)
{
	int callerPid = GetCallerPID();

	_TRACE("ChatSession::Advise >>(%s,pid:%d)",DISPLAY_STRING16(m_wszSessionName),callerPid);	

	if (eventSink == NULL){
		_TRACE("ChatSession::Advise << E_INVALIDARG");
		return;
	}

	String16 userName = eventSink->GetUserName();

	if(userName.size()&& !m_bAllowAnonymousAccess){
		_TRACE("ChatSession::Advise << E_ACCESSDENIED");
		return;
	}

	 sp<IBinder> binder = eventSink->asBinder();
	 binder->linkToDeath(this);
	_TRACE("**ADD(cse:%p binder:%p) ",eventSink.get(),binder.get());

	_TRACE("add user %s",DISPLAY_STRING16(userName));
	Fire_OnNewUser(userName);
	//ChatWorker::getInstance().Defer_OnNewUser(this,userName);

	Mutex::Autolock _lock(m_csAdviseLock);
	m_Listeners.add(callerPid,binder);

	_TRACE("ChatSession::Advise << S_OK");
	return;
}
TEST(Pseudolocales, RedefineMethod) {
  Pseudolocalizer pseudo(PSEUDO_ACCENTED);
  String16 result = pseudo.text(String16(String8("Hello, ")));
  pseudo.setMethod(NO_PSEUDOLOCALIZATION);
  result.append(pseudo.text(String16(String8("world!"))));
  ASSERT_EQ(String8("Ĥéļļö, world!"), String8(result));
}
예제 #4
0
status_t ChatSession::Say(const String16& statement)
{
	HRESULT hr = S_OK;
	String16 userName;
	int callerPid = GetCallerPID();
	_TRACE("ChatSession::Say(%s) >>",DISPLAY_STRING16(statement));	
	
	{
		Mutex::Autolock _lock(m_csAdviseLock);
		sp<IBinder> binder = m_Listeners.valueFor(callerPid);
		sp<IChatSessionEvents> eventSink = interface_cast<IChatSessionEvents>(binder);
		if(eventSink != NULL){
			_TRACE("**source(cse:%p  binder:%p) ",eventSink.get(),binder.get());
			userName  =  eventSink->GetUserName();
		}
	}

	if (userName.size() && CheckAccess(userName))
	{		
		{
			Mutex::Autolock _lock(m_csStatementLock);
			m_statements.add(userName + String16("\t:\t") +statement);
		}
		//Fire_OnNewStatement(userName, statement);
		ChatWorker::getInstance().Defer_OnNewStatement(this,userName, statement);
	}
	else
		hr = E_ACCESSDENIED;

	_TRACE("ChatSession::Say() <<hr:%x",hr);
	return hr;
}
예제 #5
0
void V8ProfilerAgentImpl::consoleProfileEnd(const String16& title)
{
    if (!m_enabled)
        return;
    String16 id;
    String16 resolvedTitle;
    // Take last started profile if no title was passed.
    if (title.isEmpty()) {
        if (m_startedProfiles.empty())
            return;
        id = m_startedProfiles.back().m_id;
        resolvedTitle = m_startedProfiles.back().m_title;
        m_startedProfiles.pop_back();
    } else {
        for (size_t i = 0; i < m_startedProfiles.size(); i++) {
            if (m_startedProfiles[i].m_title == title) {
                resolvedTitle = title;
                id = m_startedProfiles[i].m_id;
                m_startedProfiles.erase(m_startedProfiles.begin() + i);
                break;
            }
        }
        if (id.isEmpty())
            return;
    }
    std::unique_ptr<protocol::Profiler::CPUProfile> profile = stopProfiling(id, true);
    if (!profile)
        return;
    std::unique_ptr<protocol::Debugger::Location> location = currentDebugLocation(m_session->debugger());
    m_frontend.consoleProfileFinished(id, std::move(location), std::move(profile), resolvedTitle);
}
예제 #6
0
TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
{
    sp<IOpenCVEngine> Engine = InitConnect();
    Starter.PackageManager->InstalledPackages.clear();
    Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_X86);
    EXPECT_FALSE(NULL == Engine.get());
    String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
    EXPECT_EQ(0, result.size());
}
예제 #7
0
TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
{
    sp<IOpenCVEngine> Engine = InitConnect();
    Starter.PackageManager->InstalledPackages.clear();
    Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv7);
    EXPECT_FALSE(NULL == Engine.get());
    String16 result = Engine->GetLibPathByVersion(String16("2.4"));
    EXPECT_EQ(0, result.size());
}
예제 #8
0
TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
{
    sp<IOpenCVEngine> Engine = InitConnect();
    Starter.PackageManager->InstalledPackages.clear();
    Starter.PackageManager->InstallVersion(2040100, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
    EXPECT_FALSE(NULL == Engine.get());
    String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
    EXPECT_EQ(0, result.size());
}
예제 #9
0
TEST(OpenCVEngineTest, GetPathFor2_4_5)
{
    sp<IOpenCVEngine> Engine = InitConnect();
    Starter.PackageManager->InstalledPackages.clear();
    Starter.PackageManager->InstallVersion(2040500, PLATFORM_UNKNOWN, ARCH_ARMv7);
    EXPECT_FALSE(NULL == Engine.get());
    String16 result = Engine->GetLibPathByVersion(String16("2.4.5"));
    EXPECT_EQ(0, result.size()); // 2.4.5 is not published yet
}
예제 #10
0
ssize_t StringPool::add(const String16& ident, const String16& value,
                        bool mergeDuplicates)
{
    if (ident.size() > 0) {
        ssize_t idx = mIdents.valueFor(ident);
        if (idx >= 0) {
            fprintf(stderr, "ERROR: Duplicate string identifier %s\n",
                    String8(mEntries[idx].value).string());
            return UNKNOWN_ERROR;
        }
    }

    ssize_t vidx = mValues.indexOfKey(value);
    ssize_t pos = vidx >= 0 ? mValues.valueAt(vidx) : -1;
    ssize_t eidx = pos >= 0 ? mEntryArray.itemAt(pos) : -1;
    if (eidx < 0) {
        eidx = mEntries.add(entry(value));
        if (eidx < 0) {
            fprintf(stderr, "Failure adding string %s\n", String8(value).string());
            return eidx;
        }
    }

    const bool first = vidx < 0;
    if (first || !mergeDuplicates) {
        pos = mEntryArray.add(eidx);
        if (first) {
            vidx = mValues.add(value, pos);
            const size_t N = mEntryArrayToValues.size();
            for (size_t i=0; i<N; i++) {
                size_t& e = mEntryArrayToValues.editItemAt(i);
                if ((ssize_t)e >= vidx) {
                    e++;
                }
            }
        }
        mEntryArrayToValues.add(vidx);
        if (!mSorted) {
            entry& ent = mEntries.editItemAt(eidx);
            ent.indices.add(pos);
        }
    }

    if (ident.size() > 0) {
        mIdents.add(ident, vidx);
    }

    NOISY(printf("Adding string %s to pool: pos=%d eidx=%d vidx=%d\n",
            String8(value).string(), pos, eidx, vidx));
    
    return pos;
}
예제 #11
0
파일: buffer.cpp 프로젝트: tehme/mcprotocol
size_t Buffer::writeString16(String16 _src, size_t _offset)
{
	if(_offset != npos)
		_pf_writeOffset = _offset;
	else
		_pf_writeOffset = _pf_buffer.size();

	writeInt16(_src.size(), _pf_writeOffset);
	for(int i = 0; i < _src.size(); ++i)
		writeInt16(_src[i], _offset);

	return _pf_writeOffset;
}
예제 #12
0
int V8Regex::match(const String16& string, int startFrom, int* matchLength) const
{
    if (matchLength)
        *matchLength = 0;

    if (m_regex.IsEmpty() || string.isEmpty())
        return -1;

    // v8 strings are limited to int.
    if (string.length() > INT_MAX)
        return -1;

    v8::Isolate* isolate = m_debugger->isolate();
    v8::HandleScope handleScope(isolate);
    v8::Local<v8::Context> context = m_debugger->regexContext();
    v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
    v8::TryCatch tryCatch(isolate);

    v8::Local<v8::RegExp> regex = m_regex.Get(isolate);
    v8::Local<v8::Value> exec;
    if (!regex->Get(context, toV8StringInternalized(isolate, "exec")).ToLocal(&exec))
        return -1;
    v8::Local<v8::Value> argv[] = { toV8String(isolate, string.substring(startFrom)) };
    v8::Local<v8::Value> returnValue;
    if (!exec.As<v8::Function>()->Call(context, regex, WTF_ARRAY_LENGTH(argv), argv).ToLocal(&returnValue))
        return -1;

    // RegExp#exec returns null if there's no match, otherwise it returns an
    // Array of strings with the first being the whole match string and others
    // being subgroups. The Array also has some random properties tacked on like
    // "index" which is the offset of the match.
    //
    // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec

    ASSERT(!returnValue.IsEmpty());
    if (!returnValue->IsArray())
        return -1;

    v8::Local<v8::Array> result = returnValue.As<v8::Array>();
    v8::Local<v8::Value> matchOffset;
    if (!result->Get(context, toV8StringInternalized(isolate, "index")).ToLocal(&matchOffset))
        return -1;
    if (matchLength) {
        v8::Local<v8::Value> match;
        if (!result->Get(context, 0).ToLocal(&match))
            return -1;
        *matchLength = match.As<v8::String>()->Length();
    }

    return matchOffset.As<v8::Int32>()->Value() + startFrom;
}
예제 #13
0
NativeString*
AssetManagerGlue::getResourceName(int resid)
{
	ResTable::resource_name name;
	if (!getResources().getResourceName(resid, &name)) {
		return NULL;
	}

	String16 str;
	if (name.package != NULL) {
		str.setTo(name.package, name.packageLen);
	}
	if (name.type != NULL) {
		if (str.size() > 0) {
			char16_t div = ':';
			str.append(&div, 1);
		}
		str.append(name.type, name.typeLen);
	}
	if (name.name != NULL) {
		if (str.size() > 0) {
			char16_t div = '/';
			str.append(&div, 1);
		}
		str.append(name.name, name.nameLen);
	}

	return new NativeString(str);
}
예제 #14
0
SensorManager& SensorManager::getInstanceForPackage(const String16& packageName) {
    Mutex::Autolock _l(sLock);
    SensorManager* sensorManager;
    std::map<String16, SensorManager*>::iterator iterator =
        sPackageInstances.find(packageName);

    if (iterator != sPackageInstances.end()) {
        sensorManager = iterator->second;
    } else {
        String16 opPackageName = packageName;

        // It is possible that the calling code has no access to the package name.
        // In this case we will get the packages for the calling UID and pick the
        // first one for attributing the app op. This will work correctly for
        // runtime permissions as for legacy apps we will toggle the app op for
        // all packages in the UID. The caveat is that the operation may be attributed
        // to the wrong package and stats based on app ops may be slightly off.
        if (opPackageName.size() <= 0) {
            sp<IBinder> binder = defaultServiceManager()->getService(String16("permission"));
            if (binder != 0) {
                const uid_t uid = IPCThreadState::self()->getCallingUid();
                Vector<String16> packages;
                interface_cast<IPermissionController>(binder)->getPackagesForUid(uid, packages);
                if (!packages.isEmpty()) {
                    opPackageName = packages[0];
                } else {
                    ALOGE("No packages for calling UID");
                }
            } else {
                ALOGE("Cannot get permission service");
            }
        }

        sensorManager = new SensorManager(opPackageName);

        // If we had no package name, we looked it up from the UID and the sensor
        // manager instance we created should also be mapped to the empty package
        // name, to avoid looking up the packages for a UID and get the same result.
        if (packageName.size() <= 0) {
            sPackageInstances.insert(std::make_pair(String16(), sensorManager));
        }

        // Stash the per package sensor manager.
        sPackageInstances.insert(std::make_pair(opPackageName, sensorManager));
    }

    return *sensorManager;
}
예제 #15
0
void V8HeapProfilerAgentImpl::getObjectByHeapObjectId(ErrorString* error, const String16& heapSnapshotObjectId, const protocol::Maybe<String16>& objectGroup, std::unique_ptr<protocol::Runtime::RemoteObject>* result)
{
    bool ok;
    int id = heapSnapshotObjectId.toInt(&ok);
    if (!ok) {
        *error = "Invalid heap snapshot object id";
        return;
    }

    v8::HandleScope handles(m_isolate);
    v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id);
    if (heapObject.IsEmpty()) {
        *error = "Object is not available";
        return;
    }

    if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) {
        *error = "Object is not available";
        return;
    }

    *result = m_session->wrapObject(heapObject->CreationContext(), heapObject, objectGroup.fromMaybe(""), false);
    if (!result)
        *error = "Object is not available";
}
예제 #16
0
파일: buffer.cpp 프로젝트: tehme/mcprotocol
size_t Buffer::readString16(String16& _dst, size_t _offset)
{
	if(_offset != npos)
		_pf_readOffset = _offset;

	int16_t strLen;

	_pm_checkIfEnoughBytesToRead(sizeof(strLen), _pf_readOffset);
	readInt16(strLen, _offset); // <-- readOffset += 2;

	// Штука спорной нужности, так как откатывать всё это придётся ловцу исключения.
	// Но на всякий случай сделаем так.
	if(!_pm_checkIfEnoughBytesToRead_noEx(strLen, _pf_readOffset))
	{
		_pf_readOffset -= sizeof(strLen);
		throw Exception_NotEnoughDataToRead();
	}

	int16_t ch;
	for(int i = 0; i < strLen; ++i)
	{
		readInt16(ch);
		_dst.push_back(ch);
	}

	return _pf_readOffset;

}
예제 #17
0
/* BnHelloWorld */
status_t BnHelloWorld::onTransact(uint32_t code,
                                                const Parcel &data,
                                                Parcel *reply,
                                                uint32_t flags)
{
        LOGE("OnTransact(%u,%u)", code, flags);
        CHECK_INTERFACE(IHelloWorld, data, reply);
        switch(code) {
        case HW_HELLOTHERE: {
                /**
                 * Checking permissions is always a good idea.
                 *
                 * Note that the native client will also be granted these permissions in two cases
                 * 1) you run the client code as root or system user.
                 * 2) you run the client code as user who was granted this permission.
                 * @see http://github.com/keesj/gomo/wiki/AndroidSecurity for more information
                 **/
                if (checkCallingPermission(String16("org.credil.helloworldservice.permissions.CALL_HELLOTHERE")) == false){
                    return   PERMISSION_DENIED;
                }
                String16 str = data.readString16();
                hellothere(String8(str).string());
                ///reply->writeString16(str);
                return NO_ERROR;
        } break;
		case RETURN_INT_SHANQUAN:{
                if (checkCallingPermission(String16("org.credil.helloworldservice.permissions.CALL_HELLOTHERE")) == false){
                    return   PERMISSION_DENIED;
                }
                String16 str = data.readString16();
                helloint(String8(str).string());
				int tmp= str.size();
				printf("servie str.size():%i\n",tmp);
				status_t status = reply->writeInt32(tmp);
				if( status == NO_ERROR)
					printf("file:%s,line:%i,no error\n",__FILE__,__LINE__);
				else
					printf("file:%s,line:%i, error\n",__FILE__,__LINE__);
                return NO_ERROR;
		} break;
        default:
                return BBinder::onTransact(code, data, reply, flags);
        }
        return NO_ERROR;
}
// Send a command to the supplicant, and return the reply as a String.
static jstring doStringCommand(JNIEnv* env, jstring javaCommand) {
    char reply[REPLY_BUF_SIZE];
    ScopedUtfChars command(env, javaCommand);
    if (!doCommand(env, javaCommand, reply, sizeof(reply))) {
        return NULL;
    }
    if (DBG) ALOGD("cmd = %s, reply: %s", command.c_str(), reply);
    String16 str;
    if (strstr(command.c_str(),"BSS RANGE=")) {
        parseScanResults(str,reply);
    } else if (strstr(command.c_str(),"GET_NETWORK") &&
              strstr(command.c_str(),"ssid") && !strstr(command.c_str(),"bssid")
              && !strstr(command.c_str(),"scan_ssid")){
        constructSsid(str, reply);
    } else {
        str += String16((char *)reply);
    }
    return env->NewString((const jchar *)str.string(), str.size());
}
void InjectedScriptNative::releaseObjectGroup(const String16& groupName)
{
    if (groupName.isEmpty())
        return;
    NameToObjectGroup::iterator groupIt = m_nameToObjectGroup.find(groupName);
    if (groupIt == m_nameToObjectGroup.end())
        return;
    for (int id : *groupIt->second)
        unbind(id);
    m_nameToObjectGroup.remove(groupName);
}
예제 #20
0
status_t String16::setTo(const String16& other, size_t len, size_t begin)
{
    const size_t N = other.size();
    if (begin >= N) {
        SharedBuffer::bufferFromData(mString)->release();
        mString = getEmptyString();
        return NO_ERROR;
    }
    if ((begin+len) > N) len = N-begin;
    if (begin == 0 && len == N) {
        setTo(other);
        return NO_ERROR;
    }

    if (&other == this) {
        LOG_ALWAYS_FATAL("Not implemented");
    }

    return setTo(other.string()+begin, len);
}
예제 #21
0
파일: XMLNode.cpp 프로젝트: bincker/Webkey
String16 getNamespaceResourcePackage(String16 namespaceUri, bool* outIsPublic)
{
    //printf("%s starts with %s?\n", String8(namespaceUri).string(),
    //       String8(RESOURCES_PREFIX).string());
    size_t prefixSize;
    bool isPublic = true;
    if (namespaceUri.startsWith(RESOURCES_PREFIX)) {
        prefixSize = RESOURCES_PREFIX.size();
    } else if (namespaceUri.startsWith(RESOURCES_PRV_PREFIX)) {
        isPublic = false;
        prefixSize = RESOURCES_PRV_PREFIX.size();
    } else {
        if (outIsPublic) *outIsPublic = isPublic; // = true
        return String16();
    }

    //printf("YES!\n");
    //printf("namespace: %s\n", String8(String16(namespaceUri, namespaceUri.size()-prefixSize, prefixSize)).string());
    if (outIsPublic) *outIsPublic = isPublic;
    return String16(namespaceUri, namespaceUri.size()-prefixSize, prefixSize);
}
예제 #22
0
static String8 good_old_string(const String16& src)
{
    String8 name8;
    char ch8[2];
    ch8[1] = 0;
    for (unsigned j = 0; j < src.size(); j++) {
        char16_t ch = src[j];
        if (ch < 128) ch8[0] = (char)ch;
        name8.append(ch8);
    }
    return name8;
}
void InjectedScriptNative::addObjectToGroup(int objectId, const String16& groupName)
{
    if (groupName.isEmpty())
        return;
    if (objectId <= 0)
        return;
    m_idToObjectGroupName.set(objectId, groupName);
    auto it = m_nameToObjectGroup.find(groupName);
    if (it == m_nameToObjectGroup.end()) {
        m_nameToObjectGroup.set(groupName, protocol::Vector<int>());
        it = m_nameToObjectGroup.find(groupName);
    }
    it->second->append(objectId);
}
예제 #24
0
status_t ChatSession::Unadvise()
{
	String16 userName;
	int callerPid = GetCallerPID();

	_TRACE("ChatSession::Unadvise(%s,pid:%d)",DISPLAY_STRING16(m_wszSessionName),callerPid);
	
	{
		Mutex::Autolock _lock(m_csAdviseLock);
		sp<IBinder> binder = m_Listeners.valueFor(callerPid);
		sp<IChatSessionEvents> eventSink = interface_cast<IChatSessionEvents>(binder);
		if(eventSink != NULL){
			m_Listeners.removeItem(callerPid);
			userName  =  eventSink->GetUserName();
			_TRACE("**MOV(cse:%p binder:%p) ",eventSink.get(),binder.get());
		}
	}

	if(userName.size()){
		//ChatWorker::getInstance().Defer_OnUserLeft(this,userName);
		Fire_OnUserLeft(userName);
	}
	return NO_ERROR;
}
예제 #25
0
// static
std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(double timestampMS, MessageType type, MessageLevel level, const String16& messageText, std::vector<v8::Local<v8::Value>>* arguments, std::unique_ptr<V8StackTrace> stackTrace, InspectedContext* context)
{
    v8::Isolate* isolate = context->isolate();
    int contextId = context->contextId();
    int contextGroupId = context->contextGroupId();
    V8DebuggerImpl* debugger = context->debugger();

    String16 url;
    unsigned lineNumber = 0;
    unsigned columnNumber = 0;
    if (stackTrace && !stackTrace->isEmpty()) {
        url = stackTrace->topSourceURL();
        lineNumber = stackTrace->topLineNumber();
        columnNumber = stackTrace->topColumnNumber();
    }

    String16 actualMessage = messageText;

    Arguments messageArguments;
    if (arguments && arguments->size()) {
        for (size_t i = 0; i < arguments->size(); ++i)
            messageArguments.push_back(wrapUnique(new v8::Global<v8::Value>(isolate, arguments->at(i))));
        if (actualMessage.isEmpty())
            actualMessage = V8ValueStringBuilder::toString(messageArguments.at(0)->Get(isolate), isolate);
    }

    std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(timestampMS, ConsoleAPIMessageSource, level, actualMessage, url, lineNumber, columnNumber, std::move(stackTrace), 0 /* scriptId */, String16() /* requestIdentifier */));
    message->m_type = type;
    if (messageArguments.size()) {
        message->m_contextId = contextId;
        message->m_arguments.swap(messageArguments);
    }

    debugger->client()->messageAddedToConsole(contextGroupId, message->m_source, message->m_level, message->m_message, message->m_url, message->m_lineNumber, message->m_columnNumber, message->m_stackTrace.get());
    return message;
}
예제 #26
0
String16
pseudobidi_string(const String16& source)
{
    const char16_t* s = source.string();
    String16 result;
    result += k_rlm;
    result += k_rlo;
    for (size_t i=0; i<source.size(); i++) {
        char16_t c = s[i];
        switch(c) {
            case ' ': result += k_pdf;
                      result += k_rlm;
                      result.append(&c, 1);
                      result += k_rlm;
                      result += k_rlo;
                      break;
            default: result.append(&c, 1);
                     break;
        }
    }
    result += k_pdf;
    result += k_rlm;
    return result;
}
예제 #27
0
status_t String16::append(const String16& other)
{
    const size_t myLen = size();
    const size_t otherLen = other.size();
    if (myLen == 0) {
        setTo(other);
        return NO_ERROR;
    } else if (otherLen == 0) {
        return NO_ERROR;
    }
    
    SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
        ->editResize((myLen+otherLen+1)*sizeof(char16_t));
    if (buf) {
        char16_t* str = (char16_t*)buf->data();
        memcpy(str+myLen, other, (otherLen+1)*sizeof(char16_t));
        mString = str;
        return NO_ERROR;
    }
    return NO_MEMORY;
}
예제 #28
0
void V8HeapProfilerAgentImpl::addInspectedHeapObject(ErrorString* errorString, const String16& inspectedHeapObjectId)
{
    bool ok;
    int id = inspectedHeapObjectId.toInt(&ok);
    if (!ok) {
        *errorString = "Invalid heap snapshot object id";
        return;
    }

    v8::HandleScope handles(m_isolate);
    v8::Local<v8::Object> heapObject = objectByHeapObjectId(m_isolate, id);
    if (heapObject.IsEmpty()) {
        *errorString = "Object is not available";
        return;
    }

    if (!m_session->inspector()->client()->isInspectableHeapObject(heapObject)) {
        *errorString = "Object is not available";
        return;
    }

    m_session->addInspectedObject(wrapUnique(new InspectableHeapObject(id)));
}
예제 #29
0
String16
pseudo_generate_expansion(const unsigned int length) {
    String16 result = k_expansion_string;
    const char16_t* s = result.string();
    if (result.size() < length) {
        result += String16(" ");
        result += pseudo_generate_expansion(length - result.size());
    } else {
        int ext = 0;
        // Should contain only whole words, so looking for a space
        for (unsigned int i = length + 1; i < result.size(); ++i) {
          ++ext;
          if (s[i] == ' ') {
            break;
          }
        }
        result.remove(length + ext, 0);
    }
    return result;
}
예제 #30
0
bool String16::startsWith(const String16& prefix) const
{
    const size_t ps = prefix.size();
    if (ps > size()) return false;
    return strzcmp16(mString, ps, prefix.string(), ps) == 0;
}