jobject ClassLoaderData::add_handle(Handle h) {
  MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
  if (handles() == NULL) {
    set_handles(JNIHandleBlock::allocate_block());
  }
  return handles()->allocate_handle(h());
}
void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* frame, SecurityOrigin* origin)
{
    ASSERT(isMainThread());
    v8::HandleScope handles(scriptState->isolate());
    DOMWrapperWorld& world = scriptState->world();
    debugger()->contextCreated(V8ContextInfo(scriptState->context(), contextGroupId(frame), world.isMainWorld(), origin ? origin->toRawString() : "", world.isIsolatedWorld() ? world.isolatedWorldHumanReadableName() : "", IdentifiersFactory::frameId(frame), scriptState->getExecutionContext()->isDocument()));
}
void V8ConsoleMessage::appendArguments(protocol::Console::ConsoleMessage* result, V8InspectorSessionImpl* session, bool generatePreview) const
{
    if (!m_arguments.size() || !m_contextId)
        return;
    InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId);
    if (!inspectedContext)
        return;

    v8::Isolate* isolate = inspectedContext->isolate();
    v8::HandleScope handles(isolate);
    v8::Local<v8::Context> context = inspectedContext->context();

    std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> args = protocol::Array<protocol::Runtime::RemoteObject>::create();
    if (m_type == TableMessageType && generatePreview) {
        v8::Local<v8::Value> table = m_arguments[0]->Get(isolate);
        v8::Local<v8::Value> columns = m_arguments.size() > 1 ? m_arguments[1]->Get(isolate) : v8::Local<v8::Value>();
        std::unique_ptr<protocol::Runtime::RemoteObject> wrapped = session->wrapTable(context, table, columns);
        if (wrapped)
            args->addItem(std::move(wrapped));
        else
            args = nullptr;
    } else {
        for (size_t i = 0; i < m_arguments.size(); ++i) {
            std::unique_ptr<protocol::Runtime::RemoteObject> wrapped = session->wrapObject(context, m_arguments[i]->Get(isolate), "console", generatePreview);
            if (!wrapped) {
                args = nullptr;
                break;
            }
            args->addItem(std::move(wrapped));
        }
    }
    if (args)
        result->setParameters(std::move(args));
}
Пример #4
0
std::unique_ptr<InjectedScript> InjectedScript::create(InspectedContext* inspectedContext)
{
    v8::Isolate* isolate = inspectedContext->isolate();
    v8::HandleScope handles(isolate);
    v8::Local<v8::Context> context = inspectedContext->context();
    v8::Context::Scope scope(context);

    std::unique_ptr<InjectedScriptNative> injectedScriptNative(new InjectedScriptNative(isolate));
    v8::Local<v8::Object> scriptHostWrapper = V8InjectedScriptHost::create(context, inspectedContext->inspector());
    injectedScriptNative->setOnInjectedScriptHost(scriptHostWrapper);

    // Inject javascript into the context. The compiled script is supposed to evaluate into
    // a single anonymous function(it's anonymous to avoid cluttering the global object with
    // inspector's stuff) the function is called a few lines below with InjectedScriptHost wrapper,
    // injected script id and explicit reference to the inspected global object. The function is expected
    // to create and configure InjectedScript instance that is going to be used by the inspector.
    String16 injectedScriptSource(reinterpret_cast<const char*>(InjectedScriptSource_js), sizeof(InjectedScriptSource_js));
    v8::Local<v8::Value> value;
    if (!inspectedContext->inspector()->compileAndRunInternalScript(context, toV8String(isolate, injectedScriptSource)).ToLocal(&value))
        return nullptr;
    DCHECK(value->IsFunction());
    v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
    v8::Local<v8::Object> windowGlobal = context->Global();
    v8::Local<v8::Value> info[] = { scriptHostWrapper, windowGlobal, v8::Number::New(isolate, inspectedContext->contextId()) };
    v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
    v8::Local<v8::Value> injectedScriptValue;
    if (!function->Call(context, windowGlobal, PROTOCOL_ARRAY_LENGTH(info), info).ToLocal(&injectedScriptValue))
        return nullptr;
    if (!injectedScriptValue->IsObject())
        return nullptr;
    return wrapUnique(new InjectedScript(inspectedContext, injectedScriptValue.As<v8::Object>(), std::move(injectedScriptNative)));
}
Пример #5
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";
}
void InspectorRuntimeAgent::evaluate(ErrorString* errorString,
    const String& expression,
    const Maybe<String>& objectGroup,
    const Maybe<bool>& includeCommandLineAPI,
    const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole,
    const Maybe<int>& optExecutionContextId,
    const Maybe<bool>& returnByValue,
    const Maybe<bool>& generatePreview,
    OwnPtr<protocol::Runtime::RemoteObject>* result,
    Maybe<bool>* wasThrown,
    Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
{
    int executionContextId;
    if (optExecutionContextId.isJust()) {
        executionContextId = optExecutionContextId.fromJust();
    } else {
        v8::HandleScope handles(defaultScriptState()->isolate());
        executionContextId = m_v8RuntimeAgent->ensureDefaultContextAvailable(defaultScriptState()->context());
    }
    MuteConsoleScope<InspectorRuntimeAgent> muteScope;
    if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false))
        muteScope.enter(this);
    m_v8RuntimeAgent->evaluate(errorString, expression, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, executionContextId, returnByValue, generatePreview, result, wasThrown, exceptionDetails);
    TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateCounters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data());
}
Пример #7
0
void InjectedScript::getProperties(ErrorString* errorString, v8::Local<v8::Object> object, const String16& groupName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, std::unique_ptr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
{
    v8::HandleScope handles(m_context->isolate());
    V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "getProperties");
    function.appendArgument(object);
    function.appendArgument(groupName);
    function.appendArgument(ownProperties);
    function.appendArgument(accessorPropertiesOnly);
    function.appendArgument(generatePreview);

    v8::TryCatch tryCatch(m_context->isolate());
    v8::Local<v8::Value> resultValue = function.callWithoutExceptionHandling();
    if (tryCatch.HasCaught()) {
        *exceptionDetails = createExceptionDetails(tryCatch.Message());
        // FIXME: make properties optional
        *properties = Array<PropertyDescriptor>::create();
        return;
    }

    std::unique_ptr<protocol::Value> protocolValue = toProtocolValue(m_context->context(), resultValue);
    if (hasInternalError(errorString, !protocolValue))
        return;
    protocol::ErrorSupport errors(errorString);
    std::unique_ptr<Array<PropertyDescriptor>> result = Array<PropertyDescriptor>::parse(protocolValue.get(), &errors);
    if (!hasInternalError(errorString, errors.hasErrors()))
        *properties = std::move(result);
}
void ClassLoaderData::dump(outputStream * const out) {
  ResourceMark rm;
  out->print("ClassLoaderData CLD: "PTR_FORMAT", loader: "PTR_FORMAT", loader_klass: "PTR_FORMAT" %s {",
      p2i(this), p2i((void *)class_loader()),
      p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
  if (claimed()) out->print(" claimed ");
  if (is_unloading()) out->print(" unloading ");
  out->print(" handles " INTPTR_FORMAT, p2i(handles()));
  out->cr();
  if (metaspace_or_null() != NULL) {
    out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null()));
    metaspace_or_null()->dump(out);
  } else {
    out->print_cr("metaspace: NULL");
  }

#ifdef CLD_DUMP_KLASSES
  if (Verbose) {
    ResourceMark rm;
    Klass* k = _klasses;
    while (k != NULL) {
      out->print_cr("klass "PTR_FORMAT", %s, CT: %d, MUT: %d", k, k->name()->as_C_string(),
          k->has_modified_oops(), k->has_accumulated_modified_oops());
      assert(k != k->next_link(), "no loops!");
      k = k->next_link();
    }
  }
#endif  // CLD_DUMP_KLASSES
#undef CLD_DUMP_KLASSES
  if (_jmethod_ids != NULL) {
    Method::print_jmethod_ids(this, out);
  }
  out->print_cr("}");
}
Пример #9
0
void MainThreadDebugger::contextCreated(ScriptState* scriptState,
                                        LocalFrame* frame,
                                        SecurityOrigin* origin) {
  ASSERT(isMainThread());
  v8::HandleScope handles(scriptState->isolate());
  DOMWrapperWorld& world = scriptState->world();
  std::unique_ptr<protocol::DictionaryValue> auxDataValue =
      protocol::DictionaryValue::create();
  auxDataValue->setBoolean("isDefault", world.isMainWorld());
  auxDataValue->setString("frameId", IdentifiersFactory::frameId(frame));
  String auxData = auxDataValue->toJSONString();
  String humanReadableName = world.isIsolatedWorld()
                                 ? world.isolatedWorldHumanReadableName()
                                 : String();
  String originString = origin ? origin->toRawString() : String();
  v8_inspector::V8ContextInfo contextInfo(
      scriptState->context(), contextGroupId(frame),
      toV8InspectorStringView(humanReadableName));
  contextInfo.origin = toV8InspectorStringView(originString);
  contextInfo.auxData = toV8InspectorStringView(auxData);
  contextInfo.hasMemoryOnConsole =
      scriptState->getExecutionContext() &&
      scriptState->getExecutionContext()->isDocument();
  v8Inspector()->contextCreated(contextInfo);
}
Пример #10
0
	bool CallSuccess()
	{
		HandleSecurity sec(ident_, g_pCoreIdent);

		// Allocate all the handles for calling the success callback.
		Handle_t dbh = CreateLocalHandle(g_DBMan.GetDatabaseType(), db_, &sec);
		if (dbh == BAD_HANDLE)
		{
			error_ = "unable to allocate handle";
			return false;
		}

		// Add an extra refcount for the handle.
		db_->AddRef();

		assert(results_.length() == txn_->entries.length());

		ke::AutoArray<cell_t> data(new cell_t[results_.length()]);
		ke::AutoArray<cell_t> handles(new cell_t[results_.length()]);
		for (size_t i = 0; i < results_.length(); i++)
		{
			CombinedQuery *obj = new CombinedQuery(results_[i], db_);
			Handle_t rh = CreateLocalHandle(hCombinedQueryType, obj, &sec);
			if (rh == BAD_HANDLE)
			{
				// Messy - free handles up to what we've allocated, and then
				// manually destroy any remaining result sets.
				delete obj;
				for (size_t iter = 0; iter < i; iter++)
					handlesys->FreeHandle(handles[iter], &sec);
				for (size_t iter = i; iter < results_.length(); iter++)
					results_[iter]->Destroy();
				handlesys->FreeHandle(dbh, &sec);
				results_.clear();

				error_ = "unable to allocate handle";
				return false;
			}
			handles[i] = rh;
			data[i] = txn_->entries[i].data;
		}

		success_->PushCell(dbh);
		success_->PushCell(data_);
		success_->PushCell(txn_->entries.length());
		success_->PushArray(handles, results_.length());
		success_->PushArray(data, results_.length());
		success_->Execute(NULL);

		// Cleanup. Note we clear results_, since freeing their handles will
		// call Destroy(), and we don't want to double-free in ~TTransactOp.
		for (size_t i = 0; i < results_.length(); i++)
			handlesys->FreeHandle(handles[i], &sec);
		handlesys->FreeHandle(dbh, &sec);
		results_.clear();

		return true;
	}
Пример #11
0
void InjectedScript::setCustomObjectFormatterEnabled(bool enabled)
{
    v8::HandleScope handles(m_context->isolate());
    V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "setCustomObjectFormatterEnabled");
    function.appendArgument(enabled);
    bool hadException = false;
    function.call(hadException);
    DCHECK(!hadException);
}
Пример #12
0
bool mi::EventFilterChain::handles(const MirEvent &event)
{
    for (auto it = filters.begin(); it != filters.end(); it++)
    {
        auto filter = *it;
        if (filter->handles(event)) return true;
    }
    return false;
}
Пример #13
0
TSemaphoreSet::TLock::TLock(ulong msgMask, const TSemaphoreSet& set,
                            TWaitWhat wait, ulong timeOut)
{
  TAPointer<THandle> handles(newHandles(set));

  if (InitLock(set.Count, wait,
               ::MsgWaitForMultipleObjects(set.Count, handles, wait, timeOut, msgMask)))
    Set = &set;
}
void SkelSmoothTerm::buildA()
{
    Solver::DeformPetal& deform_petal = Solver::deform_petals_[petal_id_];
    Solver::HandleMatrix& handle_matrix = deform_petal._handle_matrix;
    Solver::BranchList& branch_list = deform_petal._branch_list;
    int handle_number = handle_matrix.rows();
    A_.resize(3);

    // biharmonic weights for handles themselves
    Eigen::MatrixXd weight_matrix(handle_number, handle_number);
    weight_matrix.setIdentity();

    // handle coordinates
    Eigen::MatrixXd handles(handle_number, 4);
    handles.setOnes();
    handles.block(0, 0, handle_number, 3) = handle_matrix;

    // M(convert affine) for handles
    Eigen::MatrixXd M(handle_number, 4*handle_number);
    for (size_t j = 0, j_end = handle_number; j < j_end; ++ j)
    {
        M.block(0, 4*j, handle_number, 4) = weight_matrix.col(j).asDiagonal() * handles;
    }

    // A for relationship between neighbor handles
    int a_cols = handle_number;
    int a_rows = 0;
    for (size_t i = 0; i < branch_list.size(); ++ i)
    {
        a_rows += (branch_list[i].size() - 2);
    }

    Eigen::MatrixXd A(a_rows, a_cols);
    A.setZero();
    int row_count = 0;
    for (size_t i = 0, i_end = branch_list.size(); i < i_end; ++ i)
    {
        std::vector<int> branch = branch_list[i];
        for (size_t j = 1, j_end = branch.size()-1; j < j_end; ++ j)
        {
            A(row_count, branch[j]) = -2;
            A(row_count, branch[j-1]) = 1;
            A(row_count, branch[j+1]) = 1;
            row_count++;
        }
    }
   
    // lambda_skel_smooth matrix
    Eigen::MatrixXd lambda_ss(a_rows, a_rows);
    lambda_ss.setIdentity();
    lambda_ss = Solver::lambda_skel_smooth_ * lambda_ss;

    A_[0] = 2 * M.transpose() * A.transpose() * lambda_ss * A * M;
    A_[1] = 2 * M.transpose() * A.transpose() * lambda_ss * A * M;
    A_[2] = 2 * M.transpose() * A.transpose() * lambda_ss * A * M;
}
Пример #15
0
void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const String16& objectId, String16* heapSnapshotObjectId)
{
    v8::HandleScope handles(m_isolate);
    v8::Local<v8::Value> value = m_session->findObject(errorString, objectId);
    if (value.IsEmpty() || value->IsUndefined())
        return;

    v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value);
    *heapSnapshotObjectId = String16::fromInteger(id);
}
Пример #16
0
bool MyExportCommand::write_connectivity(std::ofstream& output_file,MeshExportInterface *iface)
{
  output_file << " List of Elements" << std::endl;
  output_file << " Element Type, ID, Block, Connectivity" << std::endl;

  // Get the list of blocks
  std::vector<BlockHandle> blocks;
  iface->get_block_list(blocks);

  // Test for get_block_size
  int num_elements = 0;
  for (size_t i = 0; i < blocks.size(); i++)
  {
    int nelems;
    bool status = iface->get_block_size(blocks[i], nelems);
    if (status)
      num_elements += nelems;
  }

  // Get a batch of elements in an initialized block
  int buf_size = 100;
  std::vector<ElementType>   element_type(buf_size);
  std::vector<ElementHandle> handles(buf_size);

  // Elements in a buffer set will be of the same element type and in the same block
  for (size_t i = 0; i < blocks.size(); i++)
  {
    int num_elems;
    int start_index = 0;
    BlockHandle block = blocks[i];
    while( (num_elems = iface->get_block_elements(start_index, buf_size, block, element_type, handles)) > 0)
    {
      // Get ids for the element handles
      std::vector<int> ids(num_elems);
      iface->get_element_ids(num_elems, handles, ids);

      int block_id = iface->id_from_handle(block);

      // Write out the connectivity
      for (int i = 0; i < num_elems; i++)
      {
        std::vector<int> conn(27);
        int num_nodes = iface->get_connectivity(handles[i], conn);

        output_file << (int) element_type[i] << " " << ids[i] << " " << block_id << " ";
        for (int j = 0; j < num_nodes; j++)
          output_file << conn[j] << " ";
        output_file << std::endl;
      }
      start_index += num_elems;
    }
  }

  return true;
}
EXPORT_C CMemSpyEngineChunkList* CMemSpyEngineHelperChunk::ListForProcessL( TProcessId aPid )
    {
    RArray<TAny*> handles( 128 );
    CleanupClosePushL( handles );
    //
    GetChunkHandlesL( handles, EProcess, aPid );
    CMemSpyEngineChunkList* list = CreateListFromHandlesL( handles );
    //
    CleanupStack::PopAndDestroy( &handles );
    return list;
    }
Пример #18
0
TSemaphoreSet::TLock::TLock(const TSemaphoreSet& set, TWaitWhat wait,
                            ulong timeOut, bool alertable)
:
  Set(0)
{
  TAPointer<THandle> handles(newHandles(set));

  if (InitLock(set.Count, wait,
               ::WaitForMultipleObjectsEx(set.Count, handles, wait, timeOut, alertable)))
    Set = &set;
}
Пример #19
0
void V8HeapProfilerAgentImpl::getHeapObjectId(ErrorString* errorString, const String16& objectId, String16* heapSnapshotObjectId)
{
    v8::HandleScope handles(m_isolate);
    v8::Local<v8::Value> value;
    v8::Local<v8::Context> context;
    String16 objectGroup;
    if (!m_session->unwrapObject(errorString, objectId, &value, &context, &objectGroup) || value->IsUndefined())
        return;

    v8::SnapshotObjectId id = m_isolate->GetHeapProfiler()->GetObjectId(value);
    *heapSnapshotObjectId = String16::fromInteger(id);
}
Пример #20
0
std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(ErrorString* errorString, v8::Local<v8::Value> value, const String16& groupName, bool forceValueType, bool generatePreview) const
{
    v8::HandleScope handles(m_context->isolate());
    v8::Local<v8::Value> wrappedObject;
    if (!wrapValue(errorString, value, groupName, forceValueType, generatePreview).ToLocal(&wrappedObject))
        return nullptr;
    protocol::ErrorSupport errors;
    std::unique_ptr<protocol::Runtime::RemoteObject> remoteObject = protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->context(), wrappedObject).get(), &errors);
    if (!remoteObject)
        *errorString = "Object has too long reference chain";
    return remoteObject;
}
void GetAllWindowHandlesCommandHandler::ExecuteInternal(
    const IECommandExecutor& executor,
    const ParametersMap& command_parameters,
    Response* response) {
  Json::Value handles(Json::arrayValue);
  std::vector<std::string> handle_list;
  executor.GetManagedBrowserHandles(&handle_list);
  for (unsigned int i = 0; i < handle_list.size(); ++i) {
    handles.append(handle_list[i]);
  }

  response->SetSuccessResponse(handles);
}
CMemSpyEngineCodeSegList* CMemSpyEngineHelperCodeSegment::CodeSegmentListRamLoadedL()
    {
    RArray<TAny*> handles( 16 );
    CleanupClosePushL( handles );

    // Get just RAM-loaded
    GetCodeSegmentHandlesL( handles, NULL, ETrue );
    CMemSpyEngineCodeSegList* list = ListFromHandlesLC( handles );
    //
    CleanupStack::Pop( list );
    CleanupStack::PopAndDestroy( &handles );
    //
    return list;
    }
EXPORT_C CMemSpyEngineCodeSegList* CMemSpyEngineHelperCodeSegment::CodeSegmentListL()
    {
    RArray<TAny*> handles( 16 );
    CleanupClosePushL( handles );

    // Get everything
    GetCodeSegmentHandlesL( handles, NULL, EFalse );
    CMemSpyEngineCodeSegList* list = ListFromHandlesLC( handles );
    //
    CleanupStack::Pop( list );
    CleanupStack::PopAndDestroy( &handles );
    //
    return list;
    }
Пример #24
0
double traverse(std::string name) {
  double ret=0;
  RMF::FileConstHandle rh= RMF::open_rmf_file_read_only(name);
  RMF::Categories kcs= rh.get_categories<1>();
  ret+=show_xml(rh.get_root_node(), kcs);
  RMF::NodePairConstHandles ps= rh.get_node_sets<2>();
  for (unsigned int i=0; i< ps.size(); ++i) {
    std::pair< RMF::NodeConstHandle, RMF::NodeConstHandle> handles
        (ps[i].get_node(0),ps[i].get_node(1));
    ret+=handles.first.get_id().get_index();
    ret+=handles.second.get_id().get_index();
  }
  return ret;
}
Пример #25
0
std::unique_ptr<protocol::Runtime::RemoteObject> V8ConsoleMessage::wrapException(V8InspectorSessionImpl* session, bool generatePreview) const
{
    if (!m_arguments.size() || !m_contextId)
        return nullptr;
    DCHECK_EQ(1u, m_arguments.size());
    InspectedContext* inspectedContext = session->debugger()->getContext(session->contextGroupId(), m_contextId);
    if (!inspectedContext)
        return nullptr;

    v8::Isolate* isolate = inspectedContext->isolate();
    v8::HandleScope handles(isolate);
    // TODO(dgozman): should we use different object group?
    return session->wrapObject(inspectedContext->context(), m_arguments[0]->Get(isolate), "console", generatePreview);
}
EXPORT_C CMemSpyEngineCodeSegList* CMemSpyEngineHelperCodeSegment::CodeSegmentListL( TProcessId aProcess )
    {
    TUint processId = aProcess;
    //
    RArray<TAny*> handles( 16 );
    CleanupClosePushL( handles );
    
    // Get process-specific list
    GetCodeSegmentHandlesL( handles, &processId, EFalse );
    CMemSpyEngineCodeSegList* list = ListFromHandlesLC( handles );
    //
    CleanupStack::Pop( list );
    CleanupStack::PopAndDestroy( &handles );
    //
    return list;
    }
Пример #27
0
std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local<v8::Value> table, v8::Local<v8::Value> columns) const
{
    v8::HandleScope handles(m_context->isolate());
    V8FunctionCall function(m_context->inspector(), m_context->context(), v8Value(), "wrapTable");
    function.appendArgument(table);
    if (columns.IsEmpty())
        function.appendArgument(false);
    else
        function.appendArgument(columns);
    bool hadException = false;
    v8::Local<v8::Value>  r = function.call(hadException);
    if (hadException)
        return nullptr;
    protocol::ErrorSupport errors;
    return protocol::Runtime::RemoteObject::parse(toProtocolValue(m_context->context(), r).get(), &errors);
}
Пример #28
0
void StarShape::moveHandleAction(int handleId, const QPointF & point, Qt::KeyboardModifiers modifiers)
{
    if (modifiers & Qt::ShiftModifier) {
        QPointF handle = handles()[handleId];
        QPointF tangentVector = point - handle;
        qreal distance = sqrt(tangentVector.x()*tangentVector.x() + tangentVector.y()*tangentVector.y());
        QPointF radialVector = handle - m_center;
        // cross product to determine in which direction the user is dragging
        qreal moveDirection = radialVector.x()*tangentVector.y() - radialVector.y()*tangentVector.x();
        // make the roundness stick to zero if distance is under a certain value
        float snapDistance = 3.0;
        if (distance >= 0.0)
            distance = distance < snapDistance ? 0.0 : distance-snapDistance;
        else
            distance = distance > -snapDistance ? 0.0 : distance+snapDistance;
        // control changes roundness on both handles, else only the actual handle roundness is changed
        if (modifiers & Qt::ControlModifier)
            m_roundness[handleId] = moveDirection < 0.0f ? distance : -distance;
        else
            m_roundness[base] = m_roundness[tip] = moveDirection < 0.0f ? distance : -distance;
    }
    else {
        QPointF distVector = point - m_center;
        // unapply scaling
        distVector.rx() /= m_zoomX;
        distVector.ry() /= m_zoomY;
        m_radius[handleId] = sqrt(distVector.x()*distVector.x() + distVector.y()*distVector.y());

        qreal angle = atan2(distVector.y(), distVector.x());
        if (angle < 0.0)
            angle += 2.0*M_PI;
        qreal diffAngle = angle-m_angles[handleId];
        qreal radianStep = M_PI / static_cast<qreal>(m_cornerCount);
        if (handleId == tip) {
            m_angles[tip] += diffAngle-radianStep;
            m_angles[base] += diffAngle-radianStep;
        } else {
            // control make the base point move freely
            if (modifiers & Qt::ControlModifier)
                m_angles[base] += diffAngle-2*radianStep;
            else
                m_angles[base] = m_angles[tip];
        }
    }
}
void CMemSpyEngineHelperChunk::DoOutputChunkInfoForObjectL( TUint aId, TDes& aLineBuffer, TType aType )
    {
    TFullName ownerName;
	//
    RArray<TAny*> handles( 128 );
    CleanupClosePushL( handles );
    //
    GetChunkHandlesL( handles, aType, aId );
    CMemSpyEngineChunkList* list = CreateListFromHandlesL( handles );
    //
    CleanupStack::PopAndDestroy( &handles );
    CleanupStack::PushL( list );
    //
    const TInt count = list->Count();
    for (TInt i=0; i<count; i++)
    	{
        const CMemSpyEngineChunkEntry& entry = list->At( i );
        //
        _LIT(KLine1, "Name");
        iEngine.Sink().OutputItemAndValueL( KLine1, entry.Name() );
        //
        _LIT(KLine2, "Owner");
        entry.OwnerName( ownerName );
        iEngine.Sink().OutputItemAndValueL( KLine2, ownerName );
        //
        _LIT(KLine3, "Address");
        _LIT(KLine3Format, "0x%08x - 0x%08x");
        aLineBuffer.Format(KLine3Format, entry.BaseAddress(), entry.UpperAddress() );
        iEngine.Sink().OutputItemAndValueL( KLine3, aLineBuffer );
        //
        _LIT(KLine4, "Size (max)");
        _LIT(KLine4Format, "%d (%d)");
        aLineBuffer.Format(KLine4Format, entry.Size(), entry.MaxSize());
        iEngine.Sink().OutputItemAndValueL( KLine4, aLineBuffer );
        //
        if  ( i < count - 1 )
            {
            iEngine.Sink().OutputBlankLineL();
    		}
        }
    //
    CleanupStack::PopAndDestroy( list );
    }
Пример #30
0
// Compute MatchData array for lossy compression.
static void
compute_matchdata_lossy(JB2Image *jimg, MatchData *lib,
                        int dpi, mdjvu_matcher_options_t options)
{
  int i;
  int nshapes = jimg->get_shape_count();
  // Prepare MatchData
  GTArray<mdjvu_pattern_t> handles(nshapes);
  for (i=0; i<nshapes; i++)
    {
      JB2Shape &jshp = jimg->get_shape(i);
      lib[i].bits = 0;
      lib[i].area = 0;
      lib[i].match = -1;
      handles[i] = 0;
      if (! jshp.bits) continue;
      if (jshp.userdata & JB2SHAPE_SPECIAL) continue;
      lib[i].bits = jshp.bits;
      lib[i].area = compute_area(jshp.bits);
      handles[i] = compute_comparable_image(jshp.bits);
    }
  // Run Ilya's pattern matcher.
  GTArray<int> tags(nshapes);  
  int maxtag = mdjvu_classify_patterns(handles, tags, nshapes, dpi, options);
  // Extract substitutions
  GTArray<int> reps(maxtag);
  for (i=0; i<=maxtag; i++)
    reps[i] = -1;
  for (i=0; i<nshapes; i++)
    if (handles[i])
      {
        int r = reps[tags[i]];
        lib[i].match = r;
        if (r < 0) 
          reps[tags[i]] = i;
      }
  // Free Ilya's data structures.
  for (i=0; i<nshapes; i++)
    if (handles[i])
      mdjvu_pattern_destroy(handles[i]);
}