Example #1
0
JSONElement PluginInfoArray::ToJSON() const
{
    JSONElement el = JSONElement::createObject(GetName());
    el.addProperty("disabledPlugins", m_disabledPlugins);
    
    JSONElement arr = JSONElement::createArray("installed-plugins");
    PluginInfo::PluginMap_t::const_iterator iter = m_plugins.begin();
    for( ; iter != m_plugins.end(); ++iter ) {
        arr.arrayAppend( iter->second.ToJSON() );
    }
    el.append(arr);
    return el;
}
Example #2
0
void FindReplaceData::FromJSON(const JSONElement& json)
{
    m_findString = json.namedObject("m_findString").toArrayString();
    m_replaceString = json.namedObject("m_replaceString").toArrayString();
    m_flags = json.namedObject("m_flags").toSize_t(m_flags);

    if(json.hasNamedObject("m_lookIn")) {
        m_searchPaths = json.namedObject("m_lookIn").toArrayString();
    } else {
        m_searchPaths.Add(SEARCH_IN_WORKSPACE_FOLDER);
    }

    m_encoding = json.namedObject("m_encoding").toString(m_encoding);
    m_fileMask = json.namedObject("m_fileMask").toArrayString();
    m_selectedMask = json.namedObject("m_selectedMask").toString(m_selectedMask);

    long max_value = clConfig::Get().Read(kConfigMaxItemsInFindReplaceDialog, 15);

    TruncateArray(m_searchPaths, (size_t)max_value);
    TruncateArray(m_replaceString, (size_t)max_value);
    TruncateArray(m_findString, (size_t)max_value);

    if(m_fileMask.IsEmpty()) {
        m_fileMask.Add("*.c;*.cpp;*.cxx;*.cc;*.h;*.hpp;*.inc;*.mm;*.m;*.xrc");
        m_selectedMask = m_fileMask.Item(0);
    }
}
void ColoursAndFontsManager::LoadJSON(const wxFileName& path)
{
    if(!path.FileExists()) return;

    JSONRoot root(path);
    JSONElement arr = root.toElement();
    int arrSize = arr.arraySize();
    CL_DEBUG("Loading JSON file: %s (contains %d lexers)", path.GetFullPath(), arrSize);
    for(int i = 0; i < arrSize; ++i) {
        JSONElement json = arr.arrayItem(i);
        DoAddLexer(json);
    }
    CL_DEBUG("Loading JSON file...done");
}
Example #4
0
JSONElement clTernServer::CreateFilesArray(IEditor* editor, bool forDelete)
{
    const wxString fileContent = editor->GetCtrl()->GetText();
    JSONElement files = JSONElement::createArray("files");

    JSONElement file = JSONElement::createObject();
    files.arrayAppend(file);

    wxString filename;
    if(!m_workingDirectory.IsEmpty()) {
        wxFileName fn(editor->GetFileName());
        fn.MakeRelativeTo(m_workingDirectory);
        filename = fn.GetFullPath();
    } else {
        filename = editor->GetFileName().GetFullName();
    }

    if(forDelete) {
        file.addProperty("type", wxString("delete"));
        file.addProperty("name", filename);

    } else {
        file.addProperty("type", wxString("full"));
        file.addProperty("name", filename);
        file.addProperty("text", fileContent);
    }
    return files;
}
void wxCrafterCBSettings::FromJSON(const JSONElement& json)
{
    m_wxcPath = json.namedObject(wxT("m_wxcPath")).toString(m_wxcPath);
    
    // Read the settings dialog size and pos
    wxPoint settingsDlgPt  ( wxDefaultPosition );
    wxSize  settingsDlgSize( wxDefaultSize     );
    
    if ( json.hasNamedObject(wxT("m_settingsDialogRect.size")) && json.hasNamedObject(wxT("m_settingsDialogRect.point")) ) {
        settingsDlgSize = json.namedObject(wxT("m_settingsDialogRect.size")).toSize();
        settingsDlgPt   = json.namedObject(wxT("m_settingsDialogRect.point")).toPoint();
        m_settingsDialogRect = wxRect(settingsDlgPt, settingsDlgSize);
    }
}
Example #6
0
JSONElement clTernServer::CreateLocation(wxStyledTextCtrl* ctrl, int pos)
{
    if(pos == wxNOT_FOUND) {
        pos = ctrl->GetCurrentPos();
    }
    int lineNo = ctrl->LineFromPosition(pos);
    JSONElement loc = JSONElement::createObject("end");
    loc.addProperty("line", lineNo);

    // Pass the column
    int lineStartPos = ctrl->PositionFromLine(lineNo);
    pos = pos - lineStartPos;
    loc.addProperty("ch", pos);
    return loc;
}
Example #7
0
JSONElement& JSONElement::addProperty(const wxString& name, const JSONElement::wxStringMap_t& stringMap)
{
    if(!_json) return *this;

    JSONElement arr = JSONElement::createArray(name);
    JSONElement::wxStringMap_t::const_iterator iter = stringMap.begin();
    for(; iter != stringMap.end(); ++iter) {
        JSONElement obj = JSONElement::createObject();
        obj.addProperty("key", iter->first);
        obj.addProperty("value", iter->second);
        arr.arrayAppend(obj);
    }
    append(arr);
    return *this;
}
Example #8
0
JSONElement LLDBVariable::ToJSON() const
{
    JSONElement json = JSONElement::createObject();
    json.addProperty("m_name", m_name);
    json.addProperty("m_value", m_value);
    json.addProperty("m_summary", m_summary);
    json.addProperty("m_type", m_type);
    json.addProperty("m_valueChanged", m_valueChanged);
    json.addProperty("m_lldbId", m_lldbId);
    json.addProperty("m_hasChildren", m_hasChildren);
    json.addProperty("m_isWatch", m_isWatch);
    return json;
}
Example #9
0
void clTernServer::ProcessOutput(const wxString& output, wxCodeCompletionBoxEntry::Vec_t& entries)
{
    // code completion response:
    // ================================
    // {
    // "start": 78,
    // "end": 78,
    // "isProperty": true,
    // "isObjectKey": false,
    // "completions": [
    //   {
    //     "name": "concat",
    //     "type": "fn(other: [?])",
    //     "doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s).",
    //     "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat"
    //   },
    //   {
    //     "name": "every",
    //     "type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
    //     "doc": "Tests whether all elements in the array pass the test implemented by the provided function.",
    //     "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every"
    //   }]}

    entries.clear();

    JSONRoot root(output);
    JSONElement completionsArr = root.toElement().namedObject("completions");
    for(int i = 0; i < completionsArr.arraySize(); ++i) {
        JSONElement item = completionsArr.arrayItem(i);
        wxString name = item.namedObject("name").toString();
        wxString doc = item.namedObject("doc").toString();
        wxString url = item.namedObject("url").toString();
        bool isKeyword = item.namedObject("isKeyword").toBool();
        int imgId;
        if(!isKeyword) {
            doc = this->PrepareDoc(doc, url);
            wxString type = item.namedObject("type").toString();
            wxString sig, ret;
            ProcessType(type, sig, ret, imgId);

            // Remove double quotes
            name.StartsWith("\"", &name);
            name.EndsWith("\"", &name);

            wxCodeCompletionBoxEntry::Ptr_t entry = wxCodeCompletionBoxEntry::New(name /* + sig*/, imgId);
            entry->SetComment(doc);
            entries.push_back(entry);

        } else {
            imgId = 17; // keyword
            wxCodeCompletionBoxEntry::Ptr_t entry = wxCodeCompletionBoxEntry::New(name, imgId);
            entries.push_back(entry);
        }
    }
}
Example #10
0
bool clTernServer::PostCCRequest(IEditor* editor)
{
    // Sanity
    if(m_workerThread) return false;        // another request is in progress
    if(m_port == wxNOT_FOUND) return false; // don't know tern's port
    ++m_recycleCount;

    wxStyledTextCtrl* ctrl = editor->GetCtrl();

    // Prepare the request
    JSONRoot root(cJSON_Object);
    JSONElement query = JSONElement::createObject("query");
    root.toElement().append(query);
    query.addProperty("type", wxString("completions"));
    query.addProperty("file", wxString("#0"));
    query.append(CreateLocation(ctrl));
    query.addProperty("docs", true);
    query.addProperty("urls", true);
    query.addProperty("includeKeywords", true);
    query.addProperty("types", true);

    JSONElement files = CreateFilesArray(editor);
    root.toElement().append(files);

    clTernWorkerThread::Request* req = new clTernWorkerThread::Request;
    req->jsonRequest = root.toElement().FormatRawString();
    req->filename = editor->GetFileName().GetFullPath();
    req->type = clTernWorkerThread::kCodeCompletion;

    // Create the worker thread and start the request
    m_workerThread = new clTernWorkerThread(this);
    m_workerThread->Start();
    m_workerThread->Add(req);
    return true;
}
clKeyboardBindingConfig& clKeyboardBindingConfig::Load()
{
    wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "keybindings.conf");
    fn.AppendDir("config");
    if(!fn.Exists()) return *this;

    m_bindings.clear();
    JSONRoot root(fn);

    {
        JSONElement menus = root.toElement().namedObject("menus");
        int arrSize = menus.arraySize();
        for(int i = 0; i < arrSize; ++i) {
            JSONElement item = menus.arrayItem(i);
            MenuItemData binding;
            binding.action = item.namedObject("description").toString();
            binding.accel = item.namedObject("accelerator").toString();
            binding.parentMenu = item.namedObject("parentMenu").toString();
            binding.resourceID = item.namedObject("resourceID").toString();
            if(binding.resourceID == "text_word_complete") {
                // This entry was moved from Word Completion plugin to CodeLite Edit menu entry
                binding.resourceID = "simple_word_completion";
                binding.parentMenu = "Edit";
                binding.action = "Complete Word";
            } else if(binding.resourceID == "complete_word") {
                // The "action" was changed
                binding.action = "Code Complete";
            } else if(binding.resourceID == "word_complete") {
                binding.resourceID = "complete_word";
            }
            m_bindings.insert(std::make_pair(binding.resourceID, binding));
        }
    }
    return *this;
}
Example #12
0
void GitCommandsEntries::ToJSON(JSONElement& arr) const
{
    JSONElement obj = JSONElement::createObject();
    obj.addProperty("m_commandName", m_commandName);
    obj.addProperty("m_lastUsed", m_lastUsed);

    JSONElement commandsArr = JSONElement::createArray("m_commands");
    obj.append(commandsArr);

    vGitLabelCommands_t::const_iterator iter = m_commands.begin();
    for(; iter != m_commands.end(); ++iter) {
        JSONElement e = JSONElement::createObject();
        e.addProperty("label", iter->label);
        e.addProperty("command", iter->command);
        commandsArr.arrayAppend(e);
    }
    arr.arrayAppend(obj);
}
Example #13
0
void LLDBVariable::FromJSON(const JSONElement& json)
{
    m_name = json.namedObject("m_name").toString();
    m_value = json.namedObject("m_value").toString();
    m_summary = json.namedObject("m_summary").toString();
    m_type = json.namedObject("m_type").toString();
    m_valueChanged = json.namedObject("m_valueChanged").toBool(false);
    m_lldbId = json.namedObject("m_lldbId").toInt();
    m_hasChildren = json.namedObject("m_hasChildren").toBool(false);
    m_isWatch = json.namedObject("m_isWatch").toBool(m_isWatch);
}
Example #14
0
void LLDBBreakpoint::FromJSON(const JSONElement& json)
{
    m_children.clear();
    m_id = json.namedObject("m_id").toInt(wxNOT_FOUND);
    m_type = json.namedObject("m_type").toInt(kInvalid);
    m_name = json.namedObject("m_name").toString();
    SetFilename(json.namedObject("m_filename").toString());
    m_lineNumber = json.namedObject("m_lineNumber").toInt();
    JSONElement arr = json.namedObject("m_children");
    for(int i=0; i<arr.arraySize(); ++i) {
        LLDBBreakpoint::Ptr_t bp(new LLDBBreakpoint() );
        bp->FromJSON( arr.arrayItem(i) );
        m_children.push_back( bp );
    }
}
JSONElement PHPConfigurationData::ToJSON() const
{
    JSONElement e = JSONElement::createObject(GetName());
    e.addProperty("m_includePaths", m_includePaths);
    e.addProperty("m_phpExe", m_phpExe);
    e.addProperty("m_errorReporting", m_errorReporting);
    e.addProperty("m_xdebugPort", m_xdebugPort);
    e.addProperty("m_ccIncludePath", m_ccIncludePath);
    e.addProperty("m_flags", m_flags);
    e.addProperty("m_xdebugIdeKey", m_xdebugIdeKey);
    return e;
}
wxFileName CompilationDatabase::ConvertCodeLiteCompilationDatabaseToCMake(const wxFileName& compile_file)
{
    wxFFile fp(compile_file.GetFullPath(), wxT("rb"));
    if( fp.IsOpened() ) {
        wxString content;
        fp.ReadAll(&content, wxConvUTF8);

        if( content.IsEmpty() )
            return wxFileName();
        
        JSONRoot root(cJSON_Array);
        JSONElement arr = root.toElement();
        wxArrayString lines = ::wxStringTokenize(content, "\n\r", wxTOKEN_STRTOK);
        for(size_t i=0; i<lines.GetCount(); ++i) {
            wxArrayString parts = ::wxStringTokenize(lines.Item(i), wxT("|"), wxTOKEN_STRTOK);
            if( parts.GetCount() != 3 )
                continue;

            wxString file_name = wxFileName(parts.Item(0).Trim().Trim(false)).GetFullPath();
            wxString cwd       = parts.Item(1).Trim().Trim(false);
            wxString cmp_flags = parts.Item(2).Trim().Trim(false);

            JSONElement element = JSONElement::createObject();
            element.addProperty("directory", cwd);
            element.addProperty("command",   cmp_flags);
            element.addProperty("file",      file_name);
            arr.arrayAppend( element );
        }
        
        wxFileName fn(compile_file.GetPath(), "compile_commands.json");
        root.save( fn );
        // Delete the old file
        {
            wxLogNull nl;
            fp.Close();
            if ( compile_file.Exists() ) {
                ::wxRemoveFile( compile_file.GetFullPath() );
            }
        }
        return fn;
    }
    return wxFileName();
}
Example #17
0
void NodeJSSocket::WriteRequest(JSONElement& request, NodeJSHandlerBase::Ptr_t handler)
{
    if(!IsConnected()) return;
    size_t seq = NextSequence();
    request.addProperty("seq", seq);

    wxString content, str;
    str = request.format();
    content << "Content-Length:" << str.length() << "\r\n\r\n";
    content << str;

    CL_DEBUG("CodeLite >>>> %s", content);
    m_socket.Send(content);

    // Keep the handler
    if(handler) {
        m_handlers.insert(std::make_pair(seq, handler));
    }
}
Example #18
0
void NodeJSDebuggerPane::OnUpdateCallstack(clDebugEvent& event)
{
    event.Skip();
    wxWindowUpdateLocker locker(m_dataviewLocals);
    ClearCallstack();

    JSONRoot root(event.GetString());
    JSONElement frames = root.toElement().namedObject("body").namedObject("frames");
    JSONElement refs = root.toElement().namedObject("refs");

    // Load the handlers into a map
    m_handles.clear();
    ParseRefsArray(refs);

    int count = frames.arraySize();
    for(int i = 0; i < count; ++i) {
        JSONElement frame = frames.arrayItem(i);
        int index = frame.namedObject("index").toInt();
        int funcRef = frame.namedObject("func").namedObject("ref").toInt();
        int fileRef = frame.namedObject("script").namedObject("ref").toInt();
        int line = frame.namedObject("line").toInt() + 1;

        wxVector<wxVariant> cols;
        cols.push_back(wxString() << index);
        wxString file, func;
        if(m_handles.count(funcRef)) {
            func = m_handles.find(funcRef)->second.value;
        }
        if(m_handles.count(funcRef)) {
            file = m_handles.find(fileRef)->second.value;
        }
        cols.push_back(func);
        cols.push_back(file);
        cols.push_back(wxString() << line);

        FrameData* cd = new FrameData();
        cd->file = file;
        cd->line = line;
        cd->function = func;
        cd->index = i;
        m_dvListCtrlCallstack->AppendItem(cols, (wxUIntPtr)cd);

        if(i == 0) {
            // Notify the debugger to use frame #0 for the indicator
            clDebugEvent event(wxEVT_NODEJS_DEBUGGER_MARK_LINE);
            event.SetLineNumber(line);
            event.SetFileName(file);
            EventNotifier::Get()->AddPendingEvent(event);
            BuildLocals(frame);
            BuildArguments(frame);
        }
    }
}
void ColoursAndFontsManager::Save()
{
    ColoursAndFontsManager::Map_t::const_iterator iter = m_lexersMap.begin();
    JSONRoot root(cJSON_Array);
    JSONElement element = root.toElement();
    for(; iter != m_lexersMap.end(); ++iter) {
        const ColoursAndFontsManager::Vec_t& lexers = iter->second;
        for(size_t i = 0; i < lexers.size(); ++i) {
            element.arrayAppend(lexers.at(i)->ToJSON());
        }
    }

    wxFileName lexerFiles(clStandardPaths::Get().GetUserDataDir(), "lexers.json");
    lexerFiles.AppendDir("lexers");
    root.save(lexerFiles);
    SaveGlobalSettings();

    clCommandEvent event(wxEVT_CMD_COLOURS_FONTS_UPDATED);
    EventNotifier::Get()->AddPendingEvent(event);
}
void DbConnectionInfo::FromJSON(const JSONElement& json)
{
    m_connectionName  = json.namedObject("m_connectionName").toString(m_connectionName);
    m_connectionType  = json.namedObject("m_connectionType").toInt(m_connectionType);
    m_defaultDatabase = json.namedObject("m_defaultDatabase").toString(m_defaultDatabase);
    m_password        = json.namedObject("m_password").toString(m_password);
    m_server          = json.namedObject("m_server").toString(m_server);
    m_port            = json.namedObject("m_port").toInt(m_port);
    m_username        = json.namedObject("m_username").toString(m_username);
}
void CompilationDatabase::ProcessCMakeCompilationDatabase(const wxFileName& compile_commands)
{
    JSONRoot root(compile_commands);
    JSONElement arr = root.toElement();

    try {

        wxString sql;
        sql = wxT("REPLACE INTO COMPILATION_TABLE (FILE_NAME, FILE_PATH, CWD, COMPILE_FLAGS) VALUES(?, ?, ?, ?)");
        wxSQLite3Statement st = m_db->PrepareStatement(sql);
        m_db->ExecuteUpdate("BEGIN");

        for(int i = 0; i < arr.arraySize(); ++i) {
            // Each object has 3 properties:
            // directory, command, file
            JSONElement element = arr.arrayItem(i);
            if(element.hasNamedObject("file") && element.hasNamedObject("directory") &&
               element.hasNamedObject("command")) {
                wxString cmd = element.namedObject("command").toString();
                wxString file = element.namedObject("file").toString();
                wxString path = wxFileName(file).GetPath();
                wxString cwd = element.namedObject("directory").toString();

                cwd = wxFileName(cwd, "").GetPath();
                file = wxFileName(file).GetFullPath();

                st.Bind(1, file);
                st.Bind(2, path);
                st.Bind(3, cwd);
                st.Bind(4, cmd);
                st.ExecuteUpdate();
            }
        }

        m_db->ExecuteUpdate("COMMIT");

    } catch(wxSQLite3Exception& e) {
        wxUnusedVar(e);
    }
}
Example #22
0
void JSONUtil::getDocument(const string& jsonTxt, JSONElement& root)
{
	string json(jsonTxt);
	root.setType(JSONElement::JSON_OBJECT);
	root.setName("_JSON_ROOT");
	int arrst = json.find("[");
	int objst = json.find("{");
	if(json.find("{")!=string::npos && json.find("}")!=string::npos && (objst<arrst || arrst==(int)string::npos))
	{
		root.setType(JSONElement::JSON_OBJECT);
		StringUtil::replaceFirst(json, "{", "");
		StringUtil::replaceLast(json, "}", "");
		readJSON(json,false,&root);
	}
	else if(json.find("[")!=string::npos && json.find("]")!=string::npos)
	{
		root.setType(JSONElement::JSON_ARRAY);
		StringUtil::replaceFirst(json, "[", "");
		StringUtil::replaceLast(json, "]", "");
		readJSON(json,true,&root);
	}
}
Example #23
0
size_t NetworkFile::size()
{
	using namespace string_stream;

	TempAllocator1024 alloc;
	StringStream command(alloc);

	// Request the file
	command << "{\"type\":\"filesystem\",\"filesystem\":\"size\",";
	command << "\"file\":\"" << _filename << "\"}";

	network_filesystem::send(_socket, c_str(command));

	// Wait for response
	Array<char> response(default_allocator());
	network_filesystem::read_response(_socket, response);

	JSONParser parser(array::begin(response));
	JSONElement root = parser.root();

	return (size_t) root.key("size").to_int();
}
Example #24
0
JSONElement FindReplaceData::ToJSON() const
{
    JSONElement element = JSONElement::createObject(GetName());
    element.addProperty("m_findString", m_findString);
    element.addProperty("m_replaceString", m_replaceString);
    element.addProperty("m_flags", m_flags);
    element.addProperty("m_lookIn", m_searchPaths);
    element.addProperty("m_encoding", m_encoding);
    element.addProperty("m_fileMask", m_fileMask);
    element.addProperty("m_selectedMask", m_selectedMask);
    return element;
}
void NodeJSDebugger::SetBreakpoint(const NodeJSBreakpoint& bp)
{
    // Sanity
    if(!IsConnected()) return;

    // Build the request
    JSONElement request = JSONElement::createObject();
    request.addProperty("type", "request");
    request.addProperty("command", "setbreakpoint");
    JSONElement args = JSONElement::createObject("arguments");
    request.append(args);
    args.addProperty("type", "script");
    args.addProperty("target", bp.GetFilename());
    args.addProperty("line", bp.GetLine() - 1);
    args.addProperty("column", 0);

    // Write the command
    m_socket->WriteRequest(request, new NodeJSSetBreakpointHandler(bp));
}
Example #26
0
	static void parse_textures(JSONElement root, Array<TextureData>& textures, Array<char>& names, Array<char>& dynamic)
	{
		using namespace vector;

		Vector<DynamicString> keys(default_allocator());
		root.key("textures").to_keys(keys);

		for (uint32_t i = 0; i < size(keys); i++)
		{
			TextureHandle th;
			th.sampler_handle = 0;
			th.texture_handle = 0;

			ResourceId texid = root.key("textures").key(keys[i].c_str()).to_resource_id();

			TextureData td;
			td.sampler_name_offset = array::size(names); array::push(names, keys[i].c_str(), keys[i].length()); array::push_back(names, '\0');
			td.id = texid;
			td.data_offset = reserve_dynamic_data(th, dynamic);

			array::push_back(textures, td);
		}
	}
Example #27
0
JSONElement LLDBBreakpoint::ToJSON() const
{
    JSONElement json = JSONElement::createObject();
    json.addProperty("m_id", m_id);
    json.addProperty("m_type", m_type);
    json.addProperty("m_name", m_name);
    json.addProperty("m_filename", m_filename);
    json.addProperty("m_lineNumber", m_lineNumber);

    JSONElement arr = JSONElement::createArray("m_children");
    json.append( arr );
    for(size_t i=0; i<m_children.size(); ++i) {
        arr.arrayAppend( m_children.at(i)->ToJSON() );
    }
    return json;
}
Example #28
0
void JSONElement::arrayAppend(const JSONElement& element) 
{
    if(!_json) {
       return;
    }

    cJSON* p = NULL;
    switch(element.getType()) {
    case cJSON_False:
        p = cJSON_CreateFalse();
        break;

    case cJSON_True:
        p = cJSON_CreateTrue();
        break;

    case cJSON_NULL:
        p = cJSON_CreateNull();
        break;

    case cJSON_Number:
        p = cJSON_CreateNumber(element.getValue().GetDouble());
        break;

    case cJSON_String:
        p = cJSON_CreateString(element.getValue().GetString().mb_str(wxConvUTF8).data());
        break;
    case cJSON_Array:
    case cJSON_Object:
        p = element._json;
        break;
    }
    if(p) {
        cJSON_AddItemToArray(_json, p);

    }
}
	void parse_animations(JSONElement e, Array<SpriteAnimationName>& names, Array<SpriteAnimationData>& anim_data, Array<uint32_t>& frames)
	{
		const uint32_t num = e.key("animations").size();
		for (uint32_t i = 0; i < num; i++)
		{
			JSONElement anim(e.key("animations")[i]);

			SpriteAnimationName san;
			san.id = anim.key("name").to_string_id();

			const uint32_t num_frames = anim.key("frames").size();
			SpriteAnimationData sad;
			sad.num_frames = num_frames;
			sad.first_frame = array::size(frames);
			sad.time = anim.key("time").to_float();

			// Read frames
			for (uint32_t ff = 0; ff < num_frames; ff++)
				array::push_back(frames, (uint32_t) anim.key("frames")[ff].to_int());

			array::push_back(names, san);
			array::push_back(anim_data, sad);
		}
	}
Example #30
0
bool clTernServer::PostFunctionTipRequest(IEditor* editor, int pos)
{
    // Sanity
    if(m_workerThread) return false;        // another request is in progress
    if(m_port == wxNOT_FOUND) return false; // don't know tern's port
    ++m_recycleCount;

    wxStyledTextCtrl* ctrl = editor->GetCtrl();

    // Write the modified buffer into a file
    // wxFileName tmpFileName = wxFileName::CreateTempFileName("tern");
    // if(!FileUtils::WriteFileContent(tmpFileName, ctrl->GetText())) return false;

    // Prepare the request
    JSONRoot root(cJSON_Object);
    JSONElement query = JSONElement::createObject("query");
    root.toElement().append(query);
    query.addProperty("type", wxString("type"));
    query.addProperty("file", wxString("#0"));
    query.append(CreateLocation(ctrl, pos));

    // Creae the files array
    JSONElement files = CreateFilesArray(editor);
    root.toElement().append(files);

    clTernWorkerThread::Request* req = new clTernWorkerThread::Request;
    req->jsonRequest = root.toElement().FormatRawString();
    req->filename = editor->GetFileName().GetFullPath();
    req->type = clTernWorkerThread::kFunctionTip;

    // Create the worker thread and start the request
    m_workerThread = new clTernWorkerThread(this);
    m_workerThread->Start();
    m_workerThread->Add(req);
    return true;
}