# Brazilian Portuguese translation for gnome-devel-docs. # Copyright (C) 2017 gnome-devel-docs's COPYRIGHT HOLDER # This file is distributed under the same license as the gnome-devel-docs package. # Rafael Fontenelle , 2017. msgid "" msgstr "" "Project-Id-Version: gnome-devel-docs master\n" "POT-Creation-Date: 2017-03-21 01:53+0000\n" "PO-Revision-Date: 2017-03-22 18:22-0200\n" "Last-Translator: Rafael Fontenelle \n" "Language-Team: Brazilian Portuguese \n" "Language: pt_BR\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Generator: Virtaal 1.0.0-beta1\n" "X-Project-Style: gnome\n" #. Put one translator per line, in the form NAME , YEAR1, YEAR2 msgctxt "_" msgid "translator-credits" msgstr "Rafael Fontenelle , 2017" #. (itstool) path: credit/name #: C/additional-materials.page:10 C/c-coding-style.page:10 #: C/documentation.page:11 C/index.page:8 C/writing-good-code.page:10 msgid "Federico Mena-Quintero" msgstr "Federico Mena-Quintero" #. (itstool) path: credit/years #: C/additional-materials.page:12 C/c-coding-style.page:12 #: C/documentation.page:13 C/index.page:10 C/writing-good-code.page:12 msgid "2013" msgstr "2013" #. (itstool) path: info/desc #: C/additional-materials.page:17 msgid "Other style guides and books about organizing free software projects" msgstr "" "Outros guias de estilo e livros sobre organização de projetos de software " "livre" #. (itstool) path: page/title #: C/additional-materials.page:21 msgid "Additional Materials" msgstr "Materiais adicionais" #. (itstool) path: page/p #: C/additional-materials.page:23 msgid "" "Here we give you links to other materials that you may want to read. These " "will teach you a lot about how to work on large distributed teams of free " "software developers, and about good programming style in general." msgstr "" "Aqui nós fornecemos links para outros materiais que você pode querer ler. " "Eles o ensinarão muito sobre como trabalhar em equipes grandes e " "distribuídas de desenvolvedores de software livre, e sobre bom estilo de " "programação em geral." #. (itstool) path: item/p #: C/additional-materials.page:32 msgid "" "Producing Open Source Software, by Karl Fogel. This is a truly excellent book of good practices that " "free software projects should follow. This is about social aspects " "of the project: how to treat contributors, how to organize and moderate " "communication, how to deal with non-profit foundations. If you ask yourself " "at any time, \"how should I deal with $human_situation in the project?\", " "this book may provide the answer." msgstr "" "Producing Open Source Software (Produzindo Software de Código Aberto), por Karl Fogel. Esse é " "realmente um excelente livro para boas práticas que projetos de software " "livre devem seguir. Trata sobre aspectos sociais do projeto: como " "tratar contribuidores, como organizar e moderar comunicação, como lidar com " "fundações sem fins lucrativos. Se você em algum momento se perguntar “como " "eu deveria lidar com $situação_humana no projeto?”, este livro pode lhe " "fornecer a resposta." #. (itstool) path: item/p #: C/additional-materials.page:46 msgid "" "GNU Coding Standards. This is an old document, but it still has lots of excellent advice. " "It talks about C coding style, issues when dealing with plug-in systems, " "common option names for command-line programs, conventions for Makefiles, " "and some very GNU-ish details like using Texinfo for documentation." msgstr "" "GNU Coding Standards (Padrões de codificação GNU). Esse é um documento antigo, mas ele " "ainda possui muitos excelentes conselhos. Ele fala sobre estilo de " "codificação C, questões ao lidar com sistemas de plug-in, nomes comuns de " "opções para programas de linha de comando, convenções para Makefiles e " "alguns detalhes bem relacionados só GNU, como o uso de Texinfo para " "documentação" #. (itstool) path: item/p #: C/additional-materials.page:57 msgid "" " Linux Kernel Coding Style. Explains the rationale for \"big " "indentation\", brace placement, concise but unambiguous naming, and " "centralized exit of functions." msgstr "" " Linux Kernel Coding Style (Estilo de Codificação do Kernel " "Linux). Explica a fundamentação para o “recuo grande”, posicionamento de " "chaves, nomenclatura concisa sem ser ambígua e saída centralizada de funções." #. (itstool) path: credit/name #: C/api-stability.page:10 C/databases.page:11 C/documentation.page:16 #: C/file-system.page:11 C/gerror.page:11 C/glist.page:11 C/index.page:21 #: C/introspection.page:10 C/logging.page:11 C/main-contexts.page:11 #: C/memory-management.page:10 C/namespacing.page:10 #: C/parallel-installability.page:18 C/preconditions.page:11 #: C/threading.page:11 C/tooling.page:10 C/unit-testing.page:10 #: C/version-control.page:10 C/versioning.page:10 msgid "Philip Withnall" msgstr "Philip Withnall" #. (itstool) path: credit/years #: C/api-stability.page:12 C/databases.page:13 C/documentation.page:18 #: C/file-system.page:13 C/gerror.page:13 C/glist.page:13 C/index.page:23 #: C/introspection.page:12 C/logging.page:13 C/memory-management.page:12 #: C/parallel-installability.page:20 C/preconditions.page:13 #: C/threading.page:13 C/tooling.page:12 C/unit-testing.page:12 #: C/version-control.page:12 C/versioning.page:12 msgid "2015" msgstr "2015" #. (itstool) path: info/desc #: C/api-stability.page:17 msgid "Backwards compatibility in APIs" msgstr "Compatibilidade reversa nas APIs" #. (itstool) path: page/title #: C/api-stability.page:20 msgid "API stability" msgstr "Estabilidade de API" #. (itstool) path: synopsis/title #: C/api-stability.page:23 C/databases.page:24 C/documentation.page:32 #: C/file-system.page:24 C/introspection.page:23 C/logging.page:26 #: C/main-contexts.page:27 C/memory-management.page:65 C/namespacing.page:25 #: C/parallel-installability.page:33 C/threading.page:24 C/tooling.page:45 #: C/unit-testing.page:23 C/version-control.page:23 C/versioning.page:23 msgid "Summary" msgstr "Resumo" #. (itstool) path: item/p #: C/api-stability.page:26 msgid "" "Define API stability guarantees for your project. ()" msgstr "" "Defina garantias de estabilidade de API para seu projeto. ()" #. (itstool) path: item/p #: C/api-stability.page:30 msgid "" "Ensure version numbers are changed as appropriate when API changes. ()" msgstr "" "Certifique-se de que números de versão sejam alterados conforme apropriado " "quando a API é alterada. ()" #. (itstool) path: section/title #: C/api-stability.page:38 msgid "API and ABI" msgstr "API e ABI" #. (itstool) path: section/p #: C/api-stability.page:40 msgid "" "At a high level, an API – Application Programming Interface – is " "the boundary between two components when developing against them. It is " "closely related to an ABI – Application Binary Interface – which is " "the boundary at runtime. It defines the possible ways in which other " "components can interact with a component. More concretely, this normally " "means the C headers of a library form its API, and compiled library symbols " "its ABI. The difference between an API and ABI is given by compilation of " "the code: there are certain things in a C header, such as #defines, which can cause a library’s API to change without changing its ABI. " "But these differences are mostly academic, and for all practical purposes, " "API and ABI can be treated interchangeably." msgstr "" "Em um nível alto, uma API – Application Programming Interface ou " "interface de programação de aplicação – é o limite entre dois componentes " "quando se está desenvolvendo para eles. Ela está intimamente relacionada a " "uma ABI – Application Binary Interface ou interface binária de " "aplicação – que é o limite em tempo real. Ela define as formas possíveis nas " "quais outros componentes podem interagir com um componente. Mais " "concretamente, ela normalmente significa que os cabeçalhos C de uma " "biblioteca formam sua API, e biblioteca compilada simboliza sua ABI. A " "diferença entre uma API e uma ABI é dada pela compilação do código: há " "certas coisas em um cabeçalho C, tal como #defines, que podem " "fazer com que uma API da biblioteca seja alterada sem alterar sua ABI. Mas " "essas diferenças são em sua maioria acadêmicas e, para todos os propósitos " "práticos, API e ABI podem ser tratados de forma intercambiável." #. (itstool) path: section/p #: C/api-stability.page:54 msgid "" "Examples of API-incompatible changes to a C function would be to add a new " "parameter, change the function’s return type, or remove a parameter." msgstr "" "Exemplos de alterações incompatíveis com API para uma função C seria " "adicionar um novo parâmetro, alterar o tipo de retorno da função ou remover " "um parâmetro." #. (itstool) path: section/p #: C/api-stability.page:59 msgid "" "However, many other parts of a project can form an API. If a daemon exposes " "itself on D-Bus, the interfaces exported there form an API. Similarly, if a " "C API is exposed in higher level languages by use of GIR, the GIR file forms " "another API — if it changes, any higher level code using it must also change." msgstr "" "Porém, muitas outras partes de um projeto podem formar uma API. Se um daemon " "se expõe no D-Bus, as interfaces exportadas lá formam uma API. Similarmente, " "se uma API C é exposta em linguagens de alto nível pelo uso de GIR, o " "arquivo GIR forma uma outra API — se ela é alterada, qualquer código de alto " "nível usando-a também é alterado." #. (itstool) path: section/p #: C/api-stability.page:67 msgid "" "Other examples of more unusual APIs are configuration file locations and " "formats, and GSettings schemas. Any changes to these could require code " "using your library to change." msgstr "" "Outros exemplos de APIs mais incomuns são locais e formatos de arquivos de " "configuração, e esquemas de GSettings. Quaisquer alterações nestes poderia " "exigir que o código usando sua biblioteca seja alterado." #. (itstool) path: section/title #: C/api-stability.page:75 msgid "Stability" msgstr "Estabilidade" #. (itstool) path: section/p #: C/api-stability.page:77 msgid "" "API stability refers to some level of guarantee from a project that its API " "will only change in defined ways in the future, or will not change at all. " "Generally, an API is considered ‘stable’ if it commits to backwards-" "compatibility (defined below); but APIs could also commit to being unstable " "or even forwards-compatible. The purpose of API stability guarantees is to " "allow people to use your project from their own code without worrying about " "constantly updating their code to keep up with API changes. Typical API " "stability guarantees mean that code which is compiled against one version of " "a library will run without problems against all future versions of that " "library with the same major version number — or similarly that code which " "runs against a daemon will continue to run against all future versions of " "that daemon with the same major version number." msgstr "" "Estabilidade da API se refere a algum nível de garantia de um projeto que " "sua API será alterada apenas em formas definidas no futuro, ou jamais será " "alterada. Geralmente, um API é considerada ‘estável’ se ela se compromete em " "manter compatibilidade com versões anteriores (definido abaixo); mas APIs " "pode também se comprometer em ser instáveis ou até mesmo compatíveis com " "versões posteriores. O propósito das garantias de estabilidade de API é " "permitir que as pessoas usem seu projeto para seus próprios código se " "preocupar em atualizar constantemente seu código para se manter em dia com " "as alterações da API. Garantias comuns de estabilidade de API significa que " "o código que é compilado com uma versão de uma biblioteca vai funcionar sem " "problemas contra todas versões futuras daquela biblioteca com o mesmo número " "de versão maior — ou similarmente àquele código que funciona com um daemon " "vai continuar a funcionar em todas as versões futuras daquele daemon com o " "mesmo número de versão maior." #. (itstool) path: section/p #: C/api-stability.page:93 msgid "" "It is possible to apply different levels of API stability to components " "within a project. For example, the core functions in a library could be " "stable, and hence their API left unchanged in future; while the newer, less " "core functions could be left unstable and allowed to change wildly until the " "right design is found, at which point they could be marked as stable." msgstr "" "É possível aplicar diferentes níveis de estabilidade de API a componentes " "dentro de um projeto. Por exemplo, as funções centrais em uma biblioteca " "poderiam ser estáveis e, consequentemente, sua API mantida inalterada no " "futuro; enquanto as funções mais novas e menos centrais serem mantidas " "instáveis e poderem ser alteradas descontroladamente até que o design certo " "seja encontrado, ponto no qual elas poderiam ser marcadas como estáveis." #. (itstool) path: section/p #: C/api-stability.page:102 msgid "Several types of stability commonly considered:" msgstr "Vários tipos de estabilidade comumente considerados:" #. (itstool) path: item/title #: C/api-stability.page:107 msgid "Unstable" msgstr "Instável (unstable)" #. (itstool) path: item/p #: C/api-stability.page:108 msgid "The API could change or be removed in future." msgstr "A API poderia alterar ou ser removida no futuro." #. (itstool) path: item/title #: C/api-stability.page:111 msgid "Backwards compatible" msgstr "Compatibilidade com versões anteriores" #. (itstool) path: item/p #: C/api-stability.page:112 msgid "" "Only changes which permit code compiled against the unmodified API to " "continue running against the modified API are allowed (for example, " "functions cannot be removed)." msgstr "" "Apenas alterações que permitem código compilado com a API não modificada " "para continuar funcionando com a API modificada são permitidos (por exemplo, " "funções não podem ser removidas)." #. (itstool) path: item/title #: C/api-stability.page:119 msgid "Forwards compatible" msgstr "Compatibilidade com versões posteriores" #. (itstool) path: item/p #: C/api-stability.page:120 msgid "" "Only changes which permit code compiled against the modified API to run " "against the unmodified API are allowed (for example, functions cannot be " "added)." msgstr "" "Apenas alterações que permitem código compilado com a API modificada para " "funcionar com a API modificada são permitidos (por exemplo, funções não " "podem ser adicionadas)." #. (itstool) path: item/title #: C/api-stability.page:127 msgid "Totally stable" msgstr "Totalmente estável" #. (itstool) path: item/p #: C/api-stability.page:128 msgid "No changes are allowed to the API, only to the implementation." msgstr "Nenhuma alteração é permitida à API, apenas para a implementação." #. (itstool) path: section/p #: C/api-stability.page:132 msgid "" "Typically, projects commit to backwards-compatibility when they say an API " "is ‘stable’. Very few projects commit to total stability because it would " "prevent almost all further development of the project." msgstr "" "Geralmente, projetos se comprometem com compatibilidade reversa quando eles " "dizem que uma API é ‘estável’. Muito poucos projetos se comprometem à total " "estabilidade por impediria quase que todos os desenvolvimentos posteriores " "do projeto." #. (itstool) path: section/title #. (itstool) path: page/title #: C/api-stability.page:140 C/versioning.page:20 msgid "Versioning" msgstr "Versionamento" #. (itstool) path: section/p #: C/api-stability.page:142 msgid "" "API stability guarantees are strongly linked to project versioning; both " "package versioning and libtool versioning. Libtool versioning exists " "entirely for the purpose of tracking ABI stability, and is explained in " "detail on the Autotools Mythbuster or ." msgstr "" "Garantias de estabilidade de API estão fortemente vinculadas a versionamento " "do projeto; tanto versionamento de pacote e versionamento do libtool. " "Versionamento do libtool existe totalmente para o propósito de rastrear a " "estabilidade da ABI e é explicado em detalhes em Autotools Mythbuster (Caçador de " "mitos de autotools) ou ." #. (itstool) path: section/p #: C/api-stability.page:151 msgid "" "Package versioning (major.minor.micro) is strongly linked to API " "stability: typically, the major version number is incremented when backwards-" "incompatible changes are made (for example, when functions are renamed, " "parameters are changed, or functions are removed). The minor version number " "is incremented when forwards-incompatible changes are made (for example, " "when new public API is added). The micro version number is incremented when " "code changes are made without modifying API. See " "for more information." msgstr "" "Versionamento de pacote (maior.menor.micro) está fortemente " "vinculado à estabilidade da API: geralmente, o número da versão maior é " "incrementado quando alterações incompatíveis com versões anteriores são " "feitas (por exemplo, quando funções são renomeadas, parâmetros são " "alterados, ou funções são removidas). O número da versão menor é " "incrementada quando alterações incompatíveis com versões posteriores são " "feitas (por exemplo, quando uma nova API pública é adicionada). O número da " "versão micro é incrementada quando as alterações no código são feitas sem " "modificar a API. Veja para mais informações." #. (itstool) path: section/p #: C/api-stability.page:162 msgid "" "API versioning is just as important for D-Bus APIs and GSettings schemas (if " "they are likely to change) as for C APIs. See the documentation on D-" "Bus API versioning for details." msgstr "" "Versionamento de API é tão importante para APIs de D-Bus e esquemas de " "GSettings (se eles são suscetíveis de alterações) quanto é para APIs C. Veja " "a documentação sobre versionamento de API de D-Bus para " "detalhes." #. (itstool) path: section/p #: C/api-stability.page:169 msgid "" "For GIR APIs, their stability typically follows the C API stability, as they " "are generated from the C API. One complexity is that their stability " "additionally depends on the version of gobject-introspection used in " "generating the GIR, but recent versions have not changed much so this is not " "a major concern." msgstr "" "Para APIs GIR, sua estabilidade geralmente segue a estabilidade da API C, " "como elas são geradas a partir da API C. Uma complexidade é que sua " "estabilidade depende adicionalmente na versão do gobject-introspection usada " "na geração do GIR, mas versões recentes não foram muito alteradas, de forma " "que isso não é uma grande preocupação." #. (itstool) path: section/title #: C/api-stability.page:179 C/unit-testing.page:272 C/version-control.page:161 msgid "External Links" msgstr "Links externos" #. (itstool) path: section/p #: C/api-stability.page:181 msgid "The topic of API stability is covered in the following articles:" msgstr "" "O tópico de estabilidade de API é coberto nos seguintes artigos (em inglês):" #. (itstool) path: item/p #: C/api-stability.page:185 msgid "" "Wikipedia page on APIs" msgstr "" "Página do Wikipédia sobre APIs" #. (itstool) path: item/p #: C/api-stability.page:189 msgid "" "Wikipedia page on ABIs" msgstr "" "Página do Wikipédia sobre ABIs" #. (itstool) path: item/p #: C/api-stability.page:193 msgid "" "D-Bus API versioning documentation" msgstr "" "Documentação de versionamento de API D-Bus" #. (itstool) path: credit/name #: C/c-coding-style.page:15 C/documentation.page:21 msgid "The GTK+ Team" msgstr "A equipe do GTK+" #. (itstool) path: info/desc #: C/c-coding-style.page:20 msgid "Our guidelines for C code in GNOME" msgstr "Nossas diretrizes para código C no GNOME" #. (itstool) path: page/title #: C/c-coding-style.page:23 msgid "C Coding Style" msgstr "Estilo de codificação C" #. (itstool) path: page/p #: C/c-coding-style.page:25 msgid "" "This document presents the preferred coding style for C programs in GNOME. " "While coding style is very much a matter of taste, in GNOME we favor a " "coding style that promotes consistency, readability, and maintainability." msgstr "" "Esse documento apresenta o estilo de codificação preferido para programas C " "no GNOME. Enquanto o estilo de codificação é muito uma questão de gosto, no " "GNOME somos a favor de um estilo de codificação que promove consistência, " "legibilidade e manutenção." #. (itstool) path: page/p #: C/c-coding-style.page:32 msgid "" "We present examples of good coding style as well as examples of bad style " "that is not acceptable in GNOME. Please try to submit patches that conform " "to GNOME’s coding style; this indicates that you have done your homework to " "respect the project’s goal of long-term maintainability. Patches with " "GNOME’s coding style will also be easier to review!" msgstr "" "Nós apresentamos exemplos de bom estilo de codificação, bem como exemplos de " "estilo ruim que não é aceitável no GNOME. Por favor, tente enviar patches " "que estejam em conformidade com o estilo de codificação do GNOME; isso " "indica que você fez seu dever de casa para respeitar o objetivo do projeto " "de manutenção a longo prazo. Patches com o estilo de codificação do GNOME " "também serão mais fáceis de revisar!" #. (itstool) path: note/p #: C/c-coding-style.page:42 msgid "" "This document is for C code. For other languages, check the main page of the GNOME Programming Guidelines." msgstr "" "Esse documento é para código C. Para outras linguagens, veja a página principal das Diretrizes de programação do GNOME." #. (itstool) path: page/p #: C/c-coding-style.page:49 msgid "" "These guidelines are heavily inspired by GTK’s CODING-STYLE document, the " "Linux Kernel’s CodingStyle, and the GNU Coding Standards. These are slight " "variations of each other, with particular modifications for each project’s " "particular needs and culture, and GNOME’s version is no different." msgstr "" "Essas diretrizes são fortemente inspiradas no documento “CODING-STYLE” do " "GTK, no “CodingStyle” do Kernel Linux e no “GNU Coding Standards”. Essas são " "pequenas variações entre si, com modificações particulares para cada " "culturas e necessidades em particular do projeto, e a versão do GNOME não é " "diferente." #. (itstool) path: section/title #: C/c-coding-style.page:58 msgid "The Single Most Important Rule" msgstr "A regra mais importante" #. (itstool) path: section/p #: C/c-coding-style.page:60 msgid "" "The single most important rule when writing code is this: check the " "surrounding code and try to imitate it." msgstr "" "A regra mais importante quando se está escrevendo código é essa: veja o " "código ao redor e tente imitá-lo." #. (itstool) path: section/p #: C/c-coding-style.page:65 msgid "" "As a maintainer it is dismaying to receive a patch that is obviously in a " "different coding style to the surrounding code. This is disrespectful, like " "someone tromping into a spotlessly-clean house with muddy shoes." msgstr "" "Como um mantenedor, é assustador receber um patch que obviamente está em um " "estilo de codificação diferente do código ao redor. Isso é desrespeitoso, " "como alguém pisando em uma casa impecavelmente limpa com sapatos cheios de " "lama." #. (itstool) path: section/p #: C/c-coding-style.page:72 msgid "" "So, whatever this document recommends, if there is already written code and " "you are patching it, keep its current style consistent even if it is not " "your favorite style." msgstr "" "Então, independente do que este documenta recomenda, se há código escrito e " "você está fazendo um patch para ele, mantenha a consistência do seu estilo " "atual ainda que não seja seu estilo favorito." #. (itstool) path: section/title #: C/c-coding-style.page:80 msgid "Line Width" msgstr "Largura da linha" #. (itstool) path: section/p #: C/c-coding-style.page:82 msgid "" "Try to use lines of code between 80 and 120 characters long. This amount of " "text is easy to fit in most monitors with a decent font size. Lines longer " "than that become hard to read, and they mean that you should probably " "restructure your code. If you have too many levels of indentation, it means " "that you should fix your code anyway." msgstr "" "Tente usar linhas de códigos entre 80 e 120 caracteres. Essa quantidade de " "texto é fácil de ajustar na maioria dos monitores com um tamanho de fonte " "decente. Linhas maiores que isso se tornam difíceis de ler, e isso pode " "significar que você provavelmente deveria restruturar seu código. Se você " "tiver um número grande de níveis de recuo, isso significa que você " "provavelmente deveria corrigir seu código de qualquer maneira." #. (itstool) path: section/title #: C/c-coding-style.page:93 msgid "Indentation" msgstr "Recuo" #. (itstool) path: section/p #: C/c-coding-style.page:95 msgid "" "In general there are two preferred indentation styles for code in GNOME." msgstr "Em geral, há dois estilos de recuo preferidos para código no GNOME." #. (itstool) path: item/p #: C/c-coding-style.page:102 msgid "" "Linux Kernel style. Tabs with a length of 8 characters are used for the " "indentation, with K&R brace placement:" msgstr "" "Estilo do Kernel Linux. Tabulações com um comprimento de 8 caracteres são " "usados para recuo, com colocação de chaves de K&R:" #. (itstool) path: item/code #: C/c-coding-style.page:107 #, no-wrap msgid "" "\n" "for (i = 0; i < num_elements; i++) {\n" "\tfoo[i] = foo[i] + 42;\n" "\n" "\tif (foo[i] < 35) {\n" "\t\tprintf (\"Foo!\");\n" "\t\tfoo[i]--;\n" "\t} else {\n" "\t\tprintf (\"Bar!\");\n" "\t\tfoo[i]++;\n" "\t}\n" "}" msgstr "" "\n" "for (i = 0; i < num_elements; i++) {\n" "\tfoo[i] = foo[i] + 42;\n" "\n" "\tif (foo[i] < 35) {\n" "\t\tprintf (\"Foo!\");\n" "\t\tfoo[i]--;\n" "\t} else {\n" "\t\tprintf (\"Bar!\");\n" "\t\tfoo[i]++;\n" "\t}\n" "}" #. (itstool) path: item/p #: C/c-coding-style.page:122 msgid "" "GNU style. Each new level is indented by 2 spaces, braces go on a line by " "themselves, and they are indented as well." msgstr "" "Estilo GNU. Cada novo nível possui recuo de 2 espaços, aspas vai em uma " "linha própria e elas também possuem recuo." #. (itstool) path: item/code #: C/c-coding-style.page:128 #, no-wrap msgid "" "\n" "for (i = 0; i < num_elements; i++)\n" " {\n" " foo[i] = foo[i] + 42;\n" "\n" " if (foo[i] < 35)\n" " {\n" " printf (\"Foo!\");\n" " foo[i]--;\n" " }\n" " else\n" " {\n" " printf (\"Bar!\");\n" " foo[i]++;\n" " }\n" " }" msgstr "" "\n" "for (i = 0; i < num_elements; i++)\n" " {\n" " foo[i] = foo[i] + 42;\n" "\n" " if (foo[i] < 35)\n" " {\n" " printf (\"Foo!\");\n" " foo[i]--;\n" " }\n" " else\n" " {\n" " printf (\"Bar!\");\n" " foo[i]++;\n" " }\n" " }" #. (itstool) path: section/p #: C/c-coding-style.page:148 msgid "" "Both styles have their pros and cons. The most important things is to be " "consistent with the surrounding code. For example, the GTK+ library, " "which is GNOME’s widget toolkit, is written with the GNU style. Nautilus, " "GNOME’s file manager, is written in Linux kernel style. Both styles are " "perfectly readable and consistent when you get used to them." msgstr "" "Ambos estilos têm suas vantagens e desvantagens. O mais importante é ser " "consistente com o código ao redor. Por exemplo, a biblioteca GTK+, que " "é uma caixa de ferramentas de widgets do GNOME, é escrito com o estilo GNU. " "Nautilus, o gerenciador de arquivos do GNOME, é escrito no estilo Kernel " "Linux. Ambos estilos são perfeitamente legíveis e consistentes quando você " "se acostuma com eles." #. (itstool) path: section/p #: C/c-coding-style.page:157 msgid "" "Your first feeling when having to study or work on a piece of code that " "doesn’t have your preferred indentation style may be, how shall we put it, " "gut-wrenching. You should resist your inclination to reindent everything, or " "to use an inconsistent style for your patch. Remember the first rule: be " "consistent and respectful of that code’s customs, and your patches will " "have a much higher chance of being accepted without a lot of arguing about " "the right indentation style." msgstr "" "Seu primeiro sentimento ao ter que estudar ou trabalhar em um pedaço de " "código que não seja seu preferido em estilo de recuo pode ser, como vamos " "colocá-lo, desconfortável. Você deve resistir sua inclinação em ajustar o " "recuo de tudo, ou usar um estilo inconsistente para seu patch. Lembre-se da " "primeira regra: ser consistente e respeitoso com os costumes do " "código, e seus patches terão uma chance muito mais alta de serem aceitos sem " "muita argumentação sobre o estilo de recuo correto." #. (itstool) path: section/title #: C/c-coding-style.page:170 msgid "Tab Characters" msgstr "Caracteres de tabulações" #. (itstool) path: section/p #: C/c-coding-style.page:172 msgid "" "Do not ever change the size of tabs in your editor; leave them as 8 " "spaces. Changing the size of tabs means that code that you didn’t write " "yourself will be perpetually misaligned." msgstr "" "Não altere o tamanho dos tabs em seu editor; deixe-os como 8 " "espaços. Alterar o tamanho dos tabs naquele código que você não escreveu " "estará perpetuamente desalinhada." #. (itstool) path: section/p #: C/c-coding-style.page:178 msgid "" "Instead, set the indentation size as appropriate for the code you " "are editing. When writing in something other than Linux kernel style, you " "may even want to tell your editor to automatically convert all tabs to 8 " "spaces, so that there is no ambiguity about the intended amount of space." msgstr "" "Em vez disso, defina o tamanho do recuo conforme apropriado para o " "código que você está editando. Quando se está escrevendo em algo diferente " "do estilo Kernel Linux, você pode está querer dizer ao seu editor para " "converter todas os tabs para 8 espaços, de forma que não haja ambiguidade " "sobre a quantidade de espaços." #. (itstool) path: section/title #: C/c-coding-style.page:188 msgid "Braces" msgstr "Chaves" #. (itstool) path: section/p #: C/c-coding-style.page:190 msgid "Curly braces should not be used for single statement blocks:" msgstr "Chaves não devem ser usadas para blocos de instrução singular:" #. (itstool) path: section/code #: C/c-coding-style.page:194 #, no-wrap msgid "" "\n" "/* valid */\n" "if (condition)\n" "\tsingle_statement ();\n" "else\n" "\tanother_single_statement (arg1);" msgstr "" "\n" "/* válido */\n" "if (condição)\n" "\tsingle_statement ();\n" "else\n" "\tanother_single_statement (arg1);" #. (itstool) path: section/p #: C/c-coding-style.page:201 msgid "The “no block for single statements” rule has only four exceptions:" msgstr "" "A regra de “nenhum bloco para instruções singulares” possui apenas quatro " "exceções:" #. (itstool) path: item/p #: C/c-coding-style.page:208 msgid "" "In GNU style, if either side of an if-else statement has braces, both sides " "should, to match up indentation:" msgstr "" "No estilo GNU, se qualquer um dos lados de uma instrução if-else possui " "chaves, ambos lados deveriam ter, para corresponder o recuo:" #. (itstool) path: item/code #: C/c-coding-style.page:213 #, no-wrap msgid "" "\n" "/* valid GNU style */\n" "if (condition)\n" " {\n" " foo ();\n" " bar ();\n" " }\n" "else\n" " {\n" " baz ();\n" " }" msgstr "" "\n" "/* estilo GNU válido */\n" "if (condição)\n" " {\n" " foo ();\n" " bar ();\n" " }\n" "else\n" " {\n" " baz ();\n" " }" #. (itstool) path: item/code #: C/c-coding-style.page:225 #, no-wrap msgid "" "\n" "/* invalid */\n" "if (condition)\n" " {\n" " foo ();\n" " bar ();\n" " }\n" "else\n" " baz ();" msgstr "" "\n" "/* inválido */\n" "if (condição)\n" " {\n" " foo ();\n" " bar ();\n" " }\n" "else\n" " baz ();" #. (itstool) path: item/p #: C/c-coding-style.page:237 msgid "" "If the single statement covers multiple lines, e.g. for functions with many " "arguments, and it is followed by else or else if:" msgstr "" "Se a instrução singular cobre múltiplas linhas (ex.: para funções com muitos " "argumentos) e é seguido por else ou eles if:" #. (itstool) path: item/code #: C/c-coding-style.page:243 #, no-wrap msgid "" "\n" "/* valid Linux kernel style */\n" "if (condition) {\n" "\ta_single_statement_with_many_arguments (some_lengthy_argument,\n" "\t\t\t\t\t\tanother_lengthy_argument,\n" "\t\t\t\t\t\tand_another_one,\n" "\t\t\t\t\t\tplus_one);\n" "} else\n" "\tanother_single_statement (arg1, arg2);\n" "\n" "/* valid GNU style */\n" "if (condition)\n" " {\n" " a_single_statement_with_many_arguments (some_lengthy_argument,\n" " another_lengthy_argument,\n" " and_another_one,\n" " plus_one);\n" " }\n" "else\n" " {\n" " another_single_statement (arg1, arg2);\n" " }" msgstr "" "\n" "/* estilo Kernel Linux válido */\n" "if (condição) {\n" "\tuma_instrução_singular_com_muitos_args (algum_argumento_comprido,\n" "\t\t\t\t\t\toutro_argumento_comprido,\n" "\t\t\t\t\t\te_mais_um_outro,\n" "\t\t\t\t\t\tmais_um);\n" "} else\n" "\toutro_arg_singular (arg1, arg2);\n" "\n" "/* estilo GNU válido */\n" "if (condição)\n" " {\n" " uma_instrução_singular_com_muitos_args (algum_argumento_comprido,\n" " outro_argumento_comprido,\n" " e_mais_um_outro,\n" " mais_um);\n" " }\n" "else\n" " {\n" " outro_arg_singular (arg1, arg2);\n" " }" #. (itstool) path: item/p #: C/c-coding-style.page:268 msgid "If the condition is composed of many lines:" msgstr "Se a condição for composta de muitas linhas:" #. (itstool) path: item/code #: C/c-coding-style.page:272 #, no-wrap msgid "" "\n" "/* valid Linux kernel style */\n" "if (condition1 ||\n" " (condition2 && condition3) ||\n" " condition4 ||\n" " (condition5 && (condition6 || condition7))) {\n" "\ta_single_statement ();\n" "}\n" "\n" "/* valid GNU style */\n" "if (condition1 ||\n" " (condition2 && condition3) ||\n" " condition4 ||\n" " (condition5 && (condition6 || condition7)))\n" " {\n" " a_single_statement ();\n" " }" msgstr "" "\n" "/* estilo Kernel Linux válido */\n" "if (condição1 ||\n" " (condição2 && condição3) ||\n" " condição4 ||\n" " (condição5 && (condição6 || condição7))) {\n" "\tuma_instrução_singular ();\n" "}\n" "\n" "/* estilo GNU válido */\n" "if (condição1 ||\n" " (condição2 && condição3) ||\n" " condição4 ||\n" " (condição5 && (condição6 || condição7)))\n" " {\n" " uma_instrução_singular ();\n" " }" #. (itstool) path: item/p #: C/c-coding-style.page:290 msgid "" "Note that such long conditions are usually hard to understand. A good " "practice is to set the condition to a boolean variable, with a good name for " "that variable. Another way is to move the long condition to a function." msgstr "" "Note que tais condições longas são geralmente difíceis de entender. Uma boa " "prática é definir essa condição para uma variável booleana, com um bom nome " "para aquela variável. Uma outra forma é mover a condição longa para uma " "função." #. (itstool) path: item/p #: C/c-coding-style.page:299 msgid "" "Nested ifs, in which case the block should be placed on the " "outermost if:" msgstr "" "ifs aninhados, caso em que o bloco deve ser colocado if mais extremo:" #. (itstool) path: item/code #: C/c-coding-style.page:304 #, no-wrap msgid "" "\n" "/* valid Linux kernel style */\n" "if (condition) {\n" "\tif (another_condition)\n" "\t\tsingle_statement ();\n" "\telse\n" "\t\tanother_single_statement ();\n" "}\n" "\n" "/* valid GNU style */\n" "if (condition)\n" " {\n" " if (another_condition)\n" " single_statement ();\n" " else\n" " another_single_statement ();\n" " }" msgstr "" "\n" "/* estilo Kernel Linux válido */\n" "if (condição) {\n" "\tif (outra_condição)\n" "\t\tinstrução_singular ();\n" "\telse\n" "\t\toutra_instrução_singular ();\n" "}\n" "\n" "/* estilo GNU válido */\n" "if (condição)\n" " {\n" " if (outra_condição)\n" " instrução_singular ();\n" " else\n" " outra_instrução_singular ();\n" " }" #. (itstool) path: item/code #: C/c-coding-style.page:322 #, no-wrap msgid "" "\n" "/* invalid */\n" "if (condition)\n" "\tif (another_condition)\n" "\t\tsingle_statement ();\n" "\telse if (yet_another_condition)\n" "\t\tanother_single_statement ();" msgstr "" "\n" "/* inválido */\n" "if (condição)\n" "\tif (outra_condição)\n" "\t\tinstrução_singular ();\n" "\telse if (mais_uma_condição)\n" "\t\toutra_instrução_singular ();" #. (itstool) path: section/p #: C/c-coding-style.page:332 msgid "" "In general, new blocks should be placed on a new indentation level, like " "this:" msgstr "" "Em geral, novos blocos devem ser colocados em um novo nível de recuo, como " "este:" #. (itstool) path: section/code #: C/c-coding-style.page:337 #, no-wrap msgid "" "\n" "int retval = 0;\n" "\n" "statement_1 ();\n" "statement_2 ();\n" "\n" "{\n" "\tint var1 = 42;\n" "\tgboolean res = FALSE;\n" "\n" "\tres = statement_3 (var1);\n" "\n" "\tretval = res ? -1 : 1;\n" "}" msgstr "" "\n" "int retval = 0;\n" "\n" "instrucao_1 ();\n" "instrucao_2 ();\n" "\n" "{\n" "\tint var1 = 42;\n" "\tgboolean res = FALSE;\n" "\n" "\tres = instrucao_3 (var1);\n" "\n" "\tretval = res ? -1 : 1;\n" "}" #. (itstool) path: section/p #: C/c-coding-style.page:352 msgid "" "While curly braces for function definitions should rest on a new line they " "should not add an indentation level:" msgstr "" "Enquanto chaves para definições de função devem ficar em uma nova linha, " "elas não devem adicionar um novo nível de recuo:" #. (itstool) path: section/code #: C/c-coding-style.page:357 #, no-wrap msgid "" "\n" "/* valid Linux kernel style*/\n" "static void\n" "my_function (int argument)\n" "{\n" "\tdo_my_things ();\n" "}\n" "\n" "/* valid GNU style*/\n" "static void\n" "my_function (int argument)\n" "{\n" " do_my_things ();\n" "}" msgstr "" "\n" "/* estilo Kernel Linux válido */\n" "static void\n" "minha_funcao (int argumento)\n" "{\n" "\tfaz_minhas_coisas ();\n" "}\n" "\n" "/* estilo GNU válido */\n" "static void\n" "minha_funcao (int argumento)\n" "{\n" " faz_minhas_coisas ();\n" "}" #. (itstool) path: section/code #: C/c-coding-style.page:372 #, no-wrap msgid "" "\n" "/* invalid */\n" "static void\n" "my_function (int argument) {\n" "\tdo_my_things ();\n" "}\n" "\n" "/* invalid */\n" "static void\n" "my_function (int argument)\n" " {\n" " do_my_things ();\n" " }" msgstr "" "\n" "/* inválido */\n" "static void\n" "minha_funcao (int argumento) {\n" "\tfaz_minhas_coisas ();\n" "}\n" "\n" "/* inválido */\n" "static void\n" "minha_funcao (int argumento)\n" " {\n" " faz_minhas_coisas ();\n" " }" #. (itstool) path: section/title #: C/c-coding-style.page:388 msgid "Conditions" msgstr "Condições" #. (itstool) path: section/p #: C/c-coding-style.page:390 msgid "" "Do not check boolean values for equality. By using implicit comparisons, the " "resulting code can be read more like conversational English. Another " "rationale is that a ‘true’ value may not be necessarily equal to whatever " "the TRUE macro uses. For example:" msgstr "" "Não verifique valores booleanos por igualdade. Ao usar comparações " "implícitas, o código resultante pode ser mais parecido com o inglês " "conversacional. Um outro fundamento é que um valor ‘verdadeiro’ não " "necessariamente será igual a macro TRUE usada. Por exemplo:" #. (itstool) path: section/code #: C/c-coding-style.page:397 #, no-wrap msgid "" "\n" "/* invalid */\n" "if (found == TRUE)\n" "\tdo_foo ();\n" "\n" "/* invalid */\n" "if (found == FALSE)\n" "\tdo_bar ();" msgstr "" "\n" "/* inválido */\n" "if (localizado == TRUE)\n" "\tfazer_foo ();\n" "\n" "/* inválido */\n" "if (localizado == FALSE)\n" "\tfazer_bar ();" #. (itstool) path: section/code #: C/c-coding-style.page:406 #, no-wrap msgid "" "\n" "/* valid */\n" "if (found)\n" "\tdo_foo ();\n" "\n" "/* valid */\n" "if (!found)\n" "\tdo_bar ();" msgstr "" "\n" "/* válido */\n" "if (localizado)\n" "\tfazer_foo ();\n" "\n" "/* válido */\n" "if (!localizado)\n" "\tfazer_bar ();" #. (itstool) path: section/p #: C/c-coding-style.page:415 msgid "" "The C language uses the value 0 for many purposes. As a numeric value, the " "end of a string, a null pointer and the FALSE boolean. To make " "the code clearer, you should write code that highlights the specific way 0 " "is used. So when reading a comparison, it is possible to know the variable " "type. For boolean variables, an implicit comparison is appropriate because " "it’s already a logical expression. Other variable types are not logical " "expressions by themselves, so an explicit comparison is better:" msgstr "" "A linguagem C usa o valor 0 para muitos propósitos. Como um valor numérico, " "o fim de uma string, um ponteiro nulo e o booleano FALSE. Para " "tornar o código mais limpo, você deveria escrever código que realça a forma " "específica que 0 é usado. Então, ao ler uma comparação, é possível saber o " "tipo de variável. Para variáveis booleanas, uma comparação implícita é " "apropriado porque já é uma expressão lógica. Outros tipos de variáveis que " "não são expressões lógicas por si só, então uma comparação explícita é " "melhor:" #. (itstool) path: section/code #: C/c-coding-style.page:426 #, no-wrap msgid "" "\n" "/* valid */\n" "if (some_pointer == NULL)\n" "\tdo_blah ();\n" "\n" "/* valid */\n" "if (number == 0)\n" "\tdo_foo ();\n" "\n" "/* valid */\n" "if (str != NULL && *str != '\\0')\n" "\tdo_bar ();" msgstr "" "\n" "/* válido */\n" "if (algum_ponteiro == NULL)\n" "\tfazer_blá ();\n" "\n" "/* válido */\n" "if (número == 0)\n" "\tfazer_foo ();\n" "\n" "/* válido */\n" "if (str != NULL && *str != '\\0')\n" "\tfazer_bar ();" #. (itstool) path: section/code #: C/c-coding-style.page:439 #, no-wrap msgid "" "\n" "/* invalid */\n" "if (!some_pointer)\n" "\tdo_blah ();\n" "\n" "/* invalid */\n" "if (!number)\n" "\tdo_foo ();\n" "\n" "/* invalid */\n" "if (str && *str)\n" "\tdo_bar ();" msgstr "" "\n" "/* inválido */\n" "if (!algum_ponteiro)\n" "\tfazer_blá ();\n" "\n" "/* inválido */\n" "if (!número)\n" "\tfazer_foo ();\n" "\n" "/* inválido */\n" "if (str && *str)\n" "\tfazer_bar ();" #. (itstool) path: section/title #: C/c-coding-style.page:454 msgid "Functions" msgstr "Funções" #. (itstool) path: section/p #: C/c-coding-style.page:456 msgid "" "Functions should be declared by placing the returned value on a separate " "line from the function name:" msgstr "" "Funções devem ser declaradas colocando o valor de retorno em uma linha " "separada do nome da função:" #. (itstool) path: section/code #: C/c-coding-style.page:461 #, no-wrap msgid "" "\n" "void\n" "my_function (void)\n" "{\n" " …\n" "}" msgstr "" "\n" "void\n" "minha_funcao (void)\n" "{\n" " …\n" "}" #. (itstool) path: section/p #: C/c-coding-style.page:468 msgid "" "The argument list must be broken into a new line for each argument, with the " "argument names right aligned, taking into account pointers:" msgstr "" "A lista de argumentos deve estar quebrada em nova linha para cada argumento, " "com os nomes dos argumentos alinhados à direita, levando em consideração os " "ponteiros:" #. (itstool) path: section/code #: C/c-coding-style.page:474 #, no-wrap msgid "" "\n" "void\n" "my_function (some_type_t type,\n" " another_type_t *a_pointer,\n" " double_ptr_t **double_pointer,\n" " final_type_t another_type)\n" "{\n" " …\n" "}" msgstr "" "\n" "void\n" "minha_funcao (algum_tipo_t tipo,\n" " outro_tipo_t *um_ponteiro,\n" " double_ptr_t **ponteiro_duplo,\n" " tipo_final_t outro_tipo)\n" "{\n" " …\n" "}" #. (itstool) path: section/p #: C/c-coding-style.page:484 msgid "" "If you use Emacs, you can use M-x align to do this kind of " "alignment automatically. Just put the point and mark around the function’s " "prototype, and invoke that command." msgstr "" "Se você usa Emacs, você pode usar M-x align para fazer esse " "tipo de alinhamento automaticamente. Basca colocar o ponteiro e marcar em " "volta do protótipo da função e invocar aquele comando." #. (itstool) path: section/p #: C/c-coding-style.page:490 msgid "" "The alignment also holds when invoking a function without breaking the line " "length limit:" msgstr "" "O alinhamento também se mantém ao invocar uma função sem quebrar o limite de " "comprimento da linha:" #. (itstool) path: section/code #: C/c-coding-style.page:495 #, no-wrap msgid "" "\n" "align_function_arguments (first_argument,\n" " second_argument,\n" " third_argument);" msgstr "" "\n" "alinha_args_de_funcoes (primeiro_argumento,\n" " segundo_argumento,\n" " terceiro_argumento);" #. (itstool) path: section/title #: C/c-coding-style.page:502 msgid "Whitespace" msgstr "Espaço em branco" #. (itstool) path: section/p #: C/c-coding-style.page:504 msgid "Always put a space before an opening parenthesis but never after:" msgstr "Sempre coloque espaço antes de abrir parênteses, mas nunca após:" # "switch", assim como "if", é uma instrução de programação; não traduzir -- Rafael #. (itstool) path: section/code #: C/c-coding-style.page:508 #, no-wrap msgid "" "\n" "/* valid */\n" "if (condition)\n" "\tdo_my_things ();\n" "\n" "/* valid */\n" "switch (condition) {\n" "}" msgstr "" "\n" "/* válido */\n" "if (condição)\n" "\tfaz_minhas_coisas ();\n" "\n" "/* válido */\n" "switch (condição) {\n" "}" #. (itstool) path: section/code #: C/c-coding-style.page:517 #, no-wrap msgid "" "\n" "/* invalid */\n" "if(condition)\n" "\tdo_my_things();\n" "\n" "/* invalid */\n" "if ( condition )\n" "\tdo_my_things ( );" msgstr "" "\n" "/* inválido */\n" "if(condição)\n" "\tfaz_minhas_coisas();\n" "\n" "/* inválido */\n" "if ( condição )\n" "\tfaz_minhas_coisas ( );" #. (itstool) path: section/p #: C/c-coding-style.page:526 msgid "" "When declaring a structure type use newlines to separate logical sections of " "the structure:" msgstr "" "Ao declarar um tipo de estrutura, use novas linhas para separar seções " "lógicas da estrutura:" #. (itstool) path: section/code #: C/c-coding-style.page:531 #, no-wrap msgid "" "\n" "struct _GtkWrapBoxPrivate\n" "{\n" "\tGtkOrientation orientation;\n" "\tGtkWrapAllocationMode mode;\n" "\n" "\tGtkWrapBoxSpreading horizontal_spreading;\n" "\tGtkWrapBoxSpreading vertical_spreading;\n" "\n" "\tguint16 vertical_spacing;\n" "\tguint16 horizontal_spacing;\n" "\n" "\tguint16 minimum_line_children;\n" "\tguint16 natural_line_children;\n" "\n" "\tGList *children;\n" "};" msgstr "" "\n" "struct _GtkWrapBoxPrivate\n" "{\n" "\tGtkOrientation orientation;\n" "\tGtkWrapAllocationMode mode;\n" "\n" "\tGtkWrapBoxSpreading horizontal_spreading;\n" "\tGtkWrapBoxSpreading vertical_spreading;\n" "\n" "\tguint16 vertical_spacing;\n" "\tguint16 horizontal_spacing;\n" "\n" "\tguint16 minimum_line_children;\n" "\tguint16 natural_line_children;\n" "\n" "\tGList *children;\n" "};" #. (itstool) path: section/p #: C/c-coding-style.page:549 msgid "" "Do not eliminate whitespace and newlines just because something would fit on " "a single line:" msgstr "" "Não elimine espaços em branco e novas linhas apenas por que alguma coisa " "caberia em uma única linha:" #. (itstool) path: section/code #: C/c-coding-style.page:554 #, no-wrap msgid "" "\n" "/* invalid */\n" "if (condition) foo (); else bar ();" msgstr "" "\n" "/* inválido */\n" "if (condição) foo (); else bar ();" #. (itstool) path: section/p #: C/c-coding-style.page:558 msgid "" "Do eliminate trailing whitespace on any line, preferably as a separate patch " "or commit. Never use empty lines at the beginning or at the end of a file." msgstr "" "Elimine espaços em branco de qualquer linha, preferivelmente como um patch " "ou commit separado. Nunca use linhas vazias no começo ou no fim de um " "arquivo." #. (itstool) path: section/p #: C/c-coding-style.page:564 msgid "" "This is a little Emacs function that you can use to clean up lines with " "trailing whitespace:" msgstr "" "Essa é uma pequena função de Emacs que você pode usar para limpar linhas " "terminando com espaço em branco:" # Quase toda essa mensagem é código; traduzir apenas texto de 'message' -- Rafael #. (itstool) path: section/code #: C/c-coding-style.page:569 #, no-wrap msgid "" "\n" "(defun clean-line-ends ()\n" " (interactive)\n" " (if (not buffer-read-only)\n" " (save-excursion\n" "\t(goto-char (point-min))\n" "\t(let ((count 0))\n" "\t (while (re-search-forward \"[ \t]+$\" nil t)\n" "\t (setq count (+ count 1))\n" "\t (replace-match \"\" t t))\n" "\t (message \"Cleaned %d lines\" count)))))" msgstr "" "\n" "(defun clean-line-ends ()\n" " (interactive)\n" " (if (not buffer-read-only)\n" " (save-excursion\n" "\t(goto-char (point-min))\n" "\t(let ((count 0))\n" "\t (while (re-search-forward \"[ \t]+$\" nil t)\n" "\t (setq count (+ count 1))\n" "\t (replace-match \"\" t t))\n" "\t (message \"Limpadas %d linhas\" count)))))" #. (itstool) path: section/title #: C/c-coding-style.page:583 msgid "The switch Statement" msgstr "A instrução switch" # tag adicionada intencionalmente; case não deve ser traduzida -- Rafael #. (itstool) path: section/p #: C/c-coding-style.page:585 msgid "" "A switch should open a block on a new indentation level, and " "each case should start on the same indentation level as the " "curly braces, with the case block on a new indentation level:" msgstr "" "Um switch deve abrir um bloco em um novo nível de recuo, e cada " "case deve iniciar no mesmo nível de recuo que as chaves, com o " "bloco de case em um novo nível de recuo:" #. (itstool) path: section/code #: C/c-coding-style.page:592 #, no-wrap msgid "" "\n" "/* valid Linux kernel style */\n" "switch (condition) {\n" "case FOO:\n" "\tdo_foo ();\n" "\tbreak;\n" "\n" "case BAR:\n" "\tdo_bar ();\n" "\tbreak;\n" "}\n" "\n" "/* valid GNU style */\n" "switch (condition)\n" " {\n" " case FOO:\n" " do_foo ();\n" " break;\n" "\n" " case BAR:\n" " do_bar ();\n" " break;\n" " }" msgstr "" "\n" "/* estilo Kernel Linux válido */\n" "switch (condição) {\n" "case FOO:\n" "\tfazer_foo ();\n" "\tbreak;\n" "\n" "case BAR:\n" "\tfazer_bar ();\n" "\tbreak;\n" "}\n" "\n" "/* estilo GNU válido */\n" "switch (condição)\n" " {\n" " case FOO:\n" " fazer_foo ();\n" " break;\n" "\n" " case BAR:\n" " fazer_bar ();\n" " break;\n" " }" #. (itstool) path: section/code #: C/c-coding-style.page:616 #, no-wrap msgid "" "\n" "/* invalid */\n" "switch (condition) {\n" " case FOO: do_foo (); break;\n" " case BAR: do_bar (); break;\n" "}\n" "\n" "/* invalid */\n" "switch (condition)\n" " {\n" " case FOO: do_foo ();\n" " break;\n" " case BAR: do_bar ();\n" " break;\n" " }\n" "\n" "/* invalid */\n" "switch (condition)\n" " {\n" " case FOO:\n" " do_foo ();\n" " break;\n" " case BAR:\n" " do_bar ();\n" " break;\n" " }" msgstr "" "\n" "/* inválido */\n" "switch (condição) {\n" " case FOO: fazer_foo (); break;\n" " case BAR: fazer_bar (); break;\n" "}\n" "\n" "/* inválido */\n" "switch (condição)\n" " {\n" " case FOO: fazer_foo ();\n" " break;\n" " case BAR: fazer_bar ();\n" " break;\n" " }\n" "\n" "/* inválido */\n" "switch (condição)\n" " {\n" " case FOO:\n" " fazer_foo ();\n" " break;\n" " case BAR:\n" " fazer_bar ();\n" " break;\n" " }" #. (itstool) path: section/p #: C/c-coding-style.page:643 msgid "" "It is preferable, though not mandatory, to separate the various cases with a " "newline:" msgstr "" "É preferível, apesar de não ser obrigatório, separar os vários cases com uma " "nova linha:" #. (itstool) path: section/code #: C/c-coding-style.page:648 #, no-wrap msgid "" "\n" "switch (condition) {\n" "case FOO:\n" "\tdo_foo ();\n" "\tbreak;\n" "\n" "case BAR:\n" "\tdo_bar ();\n" "\tbreak;\n" "\n" "default:\n" "\tdo_default ();\n" "}" msgstr "" "\n" "switch (condição) {\n" "case FOO:\n" "\tfazer_foo ();\n" "\tbreak;\n" "\n" "case BAR:\n" "\tfazer_foo ();\n" "\tbreak;\n" "\n" "default:\n" "\tfazer_padrão ();\n" "}" #. (itstool) path: section/p #: C/c-coding-style.page:662 msgid "" "The break statement for the default case is not " "mandatory." msgstr "" "A instrução break para o caso default não é " "obrigatório." #. (itstool) path: section/p #: C/c-coding-style.page:667 msgid "" "If switching over an enumerated type, a case statement must " "exist for every member of the enumerated type. For members you do not want " "to handle, alias their case statements to default:" msgstr "" "Se alternando sobre um tipo enumerado, uma instrução case deve " "existir para cada novo membro do tipo enumerado. Para membros que você não " "deseja tratar, apelide suas instruções case para default:" #. (itstool) path: section/code #: C/c-coding-style.page:674 #, no-wrap msgid "" "\n" "switch (enumerated_condition) {\n" "case HANDLED_1:\n" "\tdo_foo ();\n" "\tbreak;\n" "\n" "case HANDLED_2:\n" "\tdo_bar ();\n" "\tbreak;\n" "\n" "case IGNORED_1:\n" "case IGNORED_2:\n" "default:\n" "\tdo_default ();\n" "}" msgstr "" "\n" "switch (condição_enumerada) {\n" "case TRATADA_1:\n" "\tfazer_foo ();\n" "\tbreak;\n" "\n" "case TRATADA_2:\n" "\tfazer_bar ();\n" "\tbreak;\n" "\n" "case IGNORADA_1:\n" "case IGNORADA_2:\n" "default:\n" "\tfazer_padrão ();\n" "}" #. (itstool) path: section/p #: C/c-coding-style.page:690 msgid "" "If most members of the enumerated type should not be handled, consider using " "an if statement instead of a switch." msgstr "" "Se a maioria dos membros do tipo enumerado não deve ser tratada, considere " "usar uma instrução if em vez de um switch." #. (itstool) path: section/p #: C/c-coding-style.page:695 msgid "" "If a case block needs to declare new variables, the same rules " "as the inner blocks apply (see above); the break statement " "should be placed outside of the inner block:" msgstr "" "Se um bloco case precisa declarar novas variáveis, as mesmas " "regras que os blocos internos se aplicam (veja acima); a instrução " "break deve ser colocada fora do bloco interno:" #. (itstool) path: section/code #: C/c-coding-style.page:701 #, no-wrap msgid "" "\n" "/* valid GNU style */\n" "switch (condition)\n" " {\n" " case FOO:\n" " {\n" " int foo;\n" "\n" " foo = do_foo ();\n" " }\n" " break;\n" "\n" " …\n" " }" msgstr "" "\n" "/* estilo GNU válido */\n" "switch (condição)\n" " {\n" " case FOO:\n" " {\n" " int foo;\n" "\n" " foo = fazer_foo ();\n" " }\n" " break;\n" "\n" " …\n" " }" #. (itstool) path: section/title #: C/c-coding-style.page:718 msgid "Header Files" msgstr "Arquivos de cabeçalho" #. (itstool) path: section/p #: C/c-coding-style.page:720 msgid "" "The only major rule for headers is that the function definitions should be " "vertically aligned in three columns:" msgstr "" "A única regra importante para cabeçalhos é que as definições de funções " "devem estar alinhados verticalmente em três colunas:" #. (itstool) path: section/code #: C/c-coding-style.page:725 #, no-wrap msgid "" "\n" "return_type function_name (type argument,\n" " type argument,\n" " type argument);" msgstr "" "\n" "tipo_retorno nome_funcao (tipo argumento,\n" " tipo argumento,\n" " tipo argumento);" #. (itstool) path: section/p #: C/c-coding-style.page:730 msgid "" "The maximum width of each column is given by the longest element in the " "column:" msgstr "" "A largura máxima de cada coluna é dada pelo elemento mais longo na coluna:" #. (itstool) path: section/code #: C/c-coding-style.page:735 #, no-wrap msgid "" "\n" "void gtk_type_set_property (GtkType *type,\n" " const gchar *value,\n" " GError **error);\n" "const gchar *gtk_type_get_property (GtkType *type);" msgstr "" "\n" "void gtk_type_set_property (GtkType *type,\n" " const gchar *value,\n" " GError **error);\n" "const gchar *gtk_type_get_property (GtkType *type);" #. (itstool) path: section/p #: C/c-coding-style.page:741 msgid "It is also possible to align the columns to the next tab:" msgstr "Também é possível alinhar as colunas à próxima tabulação:" #. (itstool) path: section/code #: C/c-coding-style.page:745 #, no-wrap msgid "" "\n" "void gtk_type_set_prop (GtkType *type,\n" " gfloat value);\n" "gfloat gtk_type_get_prop (GtkType *type);\n" "gint gtk_type_update_foobar (GtkType *type);" msgstr "" "\n" "void gtk_type_set_prop (GtkType *type,\n" " gfloat value);\n" "gfloat gtk_type_get_prop (GtkType *type);\n" "gint gtk_type_update_foobar (GtkType *type);" #. (itstool) path: section/p #: C/c-coding-style.page:751 msgid "" "As before, you can use M-x align in Emacs to do this " "automatically." msgstr "" "Como anteriormente, você pode usar M-x align no Emacs para " "fazer isso automaticamente." #. (itstool) path: section/p #: C/c-coding-style.page:756 msgid "" "If you are creating a public library, try to export a single public header " "file that in turn includes all the smaller header files into it. This is so " "that public headers are never included directly; rather a single include is " "used in applications. For example, GTK+ uses the following in its header " "files that should not be included directly by applications:" msgstr "" "Se você está criando uma biblioteca pública, tente exportar um único arquivo " "de cabeçalho público que, por sua vez, inclua todos os arquivos de " "cabeçalhos menores nele. Isto é para que cabeçalhos públicos nunca seja " "incluídos diretamente; em vez disso, uma única inclusão é usada nos " "aplicativos. Por exemplo, GTK+ usa o seguinte em seus arquivos de cabeçalhos " "que não devem ser incluídos diretamente por aplicativos:" #. (itstool) path: section/code #: C/c-coding-style.page:766 #, no-wrap msgid "" "\n" "#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)\n" "#error \"Only <gtk/gtk.h> can be included directly.\"\n" "#endif" msgstr "" "\n" "#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)\n" "#error \"Only <gtk/gtk.h> can be included directly.\"\n" "#endif" #. (itstool) path: section/p #: C/c-coding-style.page:771 msgid "" "For libraries, all headers should have inclusion guards (for internal usage) " "and C++ guards. These provide the extern \"C\" magic that C++ " "requires to include plain C headers:" msgstr "" "Para bibliotecas, todos cabeçalhos devem ter proteções de inclusão (para uso " "interno) e proteções de C++ ou, em inglês, #include guards e C+" "+ guards. Estas fornece a mágica extern \"C\" que C++ " "requer para incluir cabeçalhos de C simples:" #. (itstool) path: section/code #: C/c-coding-style.page:777 #, no-wrap msgid "" "\n" "#ifndef MYLIB_FOO_H_\n" "#define MYLIB_FOO_H_\n" "\n" "#include <gtk/gtk.h>\n" "\n" "G_BEGIN_DECLS\n" "\n" "…\n" "\n" "G_END_DECLS\n" "\n" "#endif /* MYLIB_FOO_H_ */" msgstr "" "\n" "#ifndef MYLIB_FOO_H_\n" "#define MYLIB_FOO_H_\n" "\n" "#include <gtk/gtk.h>\n" "\n" "G_BEGIN_DECLS\n" "\n" "…\n" "\n" "G_END_DECLS\n" "\n" "#endif /* MYLIB_FOO_H_ */" #. (itstool) path: section/title #: C/c-coding-style.page:793 msgid "GObject Classes" msgstr "Classes de GObject" #. (itstool) path: section/p #: C/c-coding-style.page:795 msgid "" "GObject class definitions and implementations require some additional coding " "style notices, and should always be correctly namespaced." msgstr "" "Definições e implementações de classe GObject exigem algumas notas " "adicionais de estilo de codificação, e devem sempre estar sob espaço de nome correto." #. (itstool) path: section/p #: C/c-coding-style.page:801 msgid "Typedef declarations should be placed at the beginning of the file:" msgstr "" "Declarações Typedef devem ser colocadas no começo do arquivo:" #. (itstool) path: section/code #: C/c-coding-style.page:805 #, no-wrap msgid "" "\n" "typedef struct _GtkBoxedStruct GtkBoxedStruct;\n" "typedef struct _GtkMoreBoxedStruct GtkMoreBoxedStruct;" msgstr "" "\n" "typedef struct _GtkBoxedStruct GtkBoxedStruct;\n" "typedef struct _GtkMoreBoxedStruct GtkMoreBoxedStruct;" #. (itstool) path: section/p #: C/c-coding-style.page:809 msgid "This includes enumeration types:" msgstr "Isso inclui tipos de enumeração:" #. (itstool) path: section/code #: C/c-coding-style.page:813 #, no-wrap msgid "" "\n" "typedef enum\n" "{\n" " GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT,\n" " GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH\n" "} GtkSizeRequestMode;" msgstr "" "\n" "typedef enum\n" "{\n" " GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT,\n" " GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH\n" "} GtkSizeRequestMode;" #. (itstool) path: section/p #: C/c-coding-style.page:820 msgid "And callback types:" msgstr "A tipos de retorno de chamada (callback):" #. (itstool) path: section/code #: C/c-coding-style.page:824 #, no-wrap msgid "" "\n" "typedef void (* GtkCallback) (GtkWidget *widget,\n" " gpointer user_data);" msgstr "" "\n" "typedef void (* GtkCallback) (GtkWidget *widget,\n" " gpointer user_data);" #. (itstool) path: section/p #: C/c-coding-style.page:828 msgid "" "Instance structures should be declared using G_DECLARE_FINAL_TYPE or G_DECLARE_DERIVABLE_TYPE:" msgstr "" "Estruturas de instâncias devem ser declaradas usando " "G_DECLARE_FINAL_TYPE ou G_DECLARE_DERIVABLE_TYPE:" #. (itstool) path: section/code #: C/c-coding-style.page:834 #, no-wrap msgid "" "\n" "#define GTK_TYPE_FOO (gtk_foo_get_type ())\n" "G_DECLARE_FINAL_TYPE (GtkFoo, gtk_foo, GTK, FOO, GtkWidget)" msgstr "" "\n" "#define GTK_TYPE_FOO (gtk_foo_get_type ())\n" "G_DECLARE_FINAL_TYPE (GtkFoo, gtk_foo, GTK, FOO, GtkWidget)" #. (itstool) path: section/p #: C/c-coding-style.page:838 msgid "" "For final types, private data can be stored in the object struct, which " "should be defined in the C file:" msgstr "" "Para tipos finais, dados privados podem ser armazenados em um objeto " "struct, o qual deve ser definido no arquivo C:" #. (itstool) path: section/code #: C/c-coding-style.page:843 #, no-wrap msgid "" "\n" "struct _GtkFoo\n" "{\n" " GObject parent_instance;\n" "\n" " guint private_data;\n" " gpointer more_private_data;\n" "};" msgstr "" "\n" "struct _GtkFoo\n" "{\n" " GObject instancia_pai;\n" "\n" " guint dados_privados;\n" " gpointer mais_dados_privados;\n" "};" #. (itstool) path: section/p #: C/c-coding-style.page:852 msgid "" "For derivable types, private data must be stored in a private struct in the " "C file, configured using G_DEFINE_TYPE_WITH_PRIVATE() and " "accessed using a _get_instance_private() function:" msgstr "" "Para tipos deriváveis, dados privados devem estar armazenados em um struct " "privado no arquivo C, configurado usando G_DEFINE_TYPE_WITH_PRIVATE() e acessado usando uma função _get_instance_private():" #. (itstool) path: section/code #: C/c-coding-style.page:858 #, no-wrap msgid "" "\n" "#define GTK_TYPE_FOO gtk_foo_get_type ()\n" "G_DECLARE_DERIVABLE_TYPE (GtkFoo, gtk_foo, GTK, FOO, GtkWidget)\n" "\n" "struct _GtkFooClass\n" "{\n" " GtkWidgetClass parent_class;\n" "\n" " void (* handle_frob) (GtkFrobber *frobber,\n" " guint n_frobs);\n" "\n" " gpointer padding[12];\n" "};" msgstr "" "\n" "#define GTK_TYPE_FOO gtk_foo_get_type ()\n" "G_DECLARE_DERIVABLE_TYPE (GtkFoo, gtk_foo, GTK, FOO, GtkWidget)\n" "\n" "struct _GtkFooClass\n" "{\n" " GtkWidgetClass parent_class;\n" "\n" " void (* handle_frob) (GtkFrobber *frobber,\n" " guint n_frobs);\n" "\n" " gpointer padding[12];\n" "};" #. (itstool) path: section/p #: C/c-coding-style.page:872 msgid "" "Always use the G_DEFINE_TYPE(), " "G_DEFINE_TYPE_WITH_PRIVATE(), and " "G_DEFINE_TYPE_WITH_CODE() macros, or their abstract variants " "G_DEFINE_ABSTRACT_TYPE(), " "G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(), and " "G_DEFINE_ABSTRACT_TYPE_WITH_CODE(); also, use the similar " "macros for defining interfaces and boxed types." msgstr "" "Sempre use as macros G_DEFINE_TYPE(), " "G_DEFINE_TYPE_WITH_PRIVATE() e G_DEFINE_TYPE_WITH_CODE() ou suas variantes abstratas G_DEFINE_ABSTRACT_TYPE(), " "G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE() e " "G_DEFINE_ABSTRACT_TYPE_WITH_CODE(); também, use as macros " "similares para definir interfaces e tipos “boxed”." #. (itstool) path: section/p #: C/c-coding-style.page:882 msgid "Interface types should always have the dummy typedef for cast purposes:" msgstr "" "Tipos de interfaces devem sempre ter um typedef dummy visando as chamadas:" #. (itstool) path: section/code #: C/c-coding-style.page:887 #, no-wrap msgid "" "\n" "typedef struct _GtkFooable GtkFooable;" msgstr "" "\n" "typedef struct _GtkFooable GtkFooable;" #. (itstool) path: section/p #: C/c-coding-style.page:890 msgid "" "The interface structure should have ‘Interface’ postfixed to the dummy " "typedef:" msgstr "" "A estrutura da interface deve ter ‘Interface’ pós-fixado ao typedef dummy:" #. (itstool) path: section/code #: C/c-coding-style.page:895 #, no-wrap msgid "" "\n" "typedef struct _GtkFooableInterface GtkFooableInterface;" msgstr "" "\n" "typedef struct _GtkFooableInterface GtkFooableInterface;" #. (itstool) path: section/p #: C/c-coding-style.page:898 msgid "Interfaces must have the following macros:" msgstr "Interfaces devem ter as seguintes macros:" #. (itstool) path: td/p #: C/c-coding-style.page:905 msgid "Macro" msgstr "Macro" #. (itstool) path: td/p #: C/c-coding-style.page:906 msgid "Expands to" msgstr "Expande para" #. (itstool) path: td/p #: C/c-coding-style.page:911 msgid "GTK_TYPE_iface_name" msgstr "GTK_TYPE_iface_name" #. (itstool) path: td/p #: C/c-coding-style.page:912 msgid "iface_name_get_type" msgstr "iface_name_get_type" #. (itstool) path: td/p #: C/c-coding-style.page:915 msgid "GTK_iface_name" msgstr "GTK_iface_name" #. (itstool) path: td/p #: C/c-coding-style.page:916 msgid "G_TYPE_CHECK_INSTANCE_CAST" msgstr "G_TYPE_CHECK_INSTANCE_CAST" #. (itstool) path: td/p #: C/c-coding-style.page:919 msgid "GTK_IS_iface_name" msgstr "GTK_IS_iface_name" #. (itstool) path: td/p #: C/c-coding-style.page:920 msgid "G_TYPE_CHECK_INSTANCE_TYPE" msgstr "G_TYPE_CHECK_INSTANCE_TYPE" #. (itstool) path: td/p #: C/c-coding-style.page:923 msgid "GTK_iface_name_GET_IFACE" msgstr "GTK_iface_name_GET_IFACE" #. (itstool) path: td/p #: C/c-coding-style.page:924 msgid "G_TYPE_INSTANCE_GET_INTERFACE" msgstr "G_TYPE_INSTANCE_GET_INTERFACE" #. (itstool) path: section/title #: C/c-coding-style.page:932 msgid "Memory Allocation" msgstr "Alocação de memória" #. (itstool) path: section/p #: C/c-coding-style.page:934 msgid "When dynamically allocating data on the heap use g_new()." msgstr "" "Quando se estiver alocando dados em uma pilha, use g_new()." #. (itstool) path: section/p #: C/c-coding-style.page:938 msgid "" "Public structure types should always be returned after being zero-ed, either " "explicitly for each member, or by using g_new0()." msgstr "" "Tipos de estrutura pública devem sempre ser retornados após serem zerados, " "seja explicitamente para cada membro, seja usando g_new0()." #. (itstool) path: section/p #: C/c-coding-style.page:944 msgid "See for more details." msgstr "Veja para mais detalhes." #. (itstool) path: section/title #: C/c-coding-style.page:950 msgid "Macros" msgstr "Macros" #. (itstool) path: section/p #: C/c-coding-style.page:952 msgid "" "Try to avoid private macros unless strictly necessary. Remember to " "#undef them at the end of a block or a series of functions " "needing them." msgstr "" "Tente evitar macros privadas, a menos que seja estritamente necessário. " "Lembre-se de usar #undef nelas no final de um bloco ou uma " "série de funções que precisem delas." #. (itstool) path: section/p #: C/c-coding-style.page:958 msgid "Inline functions are usually preferable to private macros." msgstr "Funções em linha são geralmente preferíveis a macros privadas." #. (itstool) path: section/p #: C/c-coding-style.page:962 msgid "Public macros should not be used unless they evaluate to a constant." msgstr "" "Macros públicas não devem ser usadas a menos que elas sejam avaliadas para " "uma constante." #. (itstool) path: section/title #: C/c-coding-style.page:969 msgid "Public API" msgstr "API pública" #. (itstool) path: section/p #: C/c-coding-style.page:971 msgid "" "Avoid exporting variables as public API, since this is cumbersome on some " "platforms. It is always preferable to add getters and setters instead. Also, " "beware global variables in general." msgstr "" "Evite exportar variáveis como API pública, já que isso pode ser pesado " "demais para algumas plataformas. Em vez disso, é sempre preferível adicionar " "“gets” e “sets”. Também, cuidado com variáveis globais em geral." #. (itstool) path: section/title #: C/c-coding-style.page:980 msgid "Private API" msgstr "API privada" #. (itstool) path: section/p #: C/c-coding-style.page:982 msgid "" "Non-exported functions that are needed in more than one source file should " "be prefixed with an underscore (‘_’), and declared in a private header file. " "For example, _mylib_internal_foo()." msgstr "" "Funções não exportadas que são necessárias em mais de um arquivo fonte devem " "ser prefixadas com um sublinhado (‘_’) e declarados em um arquivo de " "cabeçalho privado. Por exemplo, _minhalib_foo_interno()." #. (itstool) path: section/p #: C/c-coding-style.page:988 msgid "Underscore-prefixed functions are never exported." msgstr "Funções prefixadas com sublinhado nunca são exportadas." #. (itstool) path: section/p #: C/c-coding-style.page:992 msgid "" "Non-exported functions that are only needed in one source file should be " "declared static." msgstr "" "Funções não exportadas que são necessárias apenas em um arquivo fonte devem " "ser declaradas com estáticas." #. (itstool) path: p/link #: C/cc-by-sa-3-0.xml:4 msgid "Creative Commons Attribution-Share Alike 3.0 United States License" msgstr "" "Licença Creative Commons Atribuição-Compartilhada Igual 3.0, dos Estados " "Unidos" #. (itstool) path: license/p #: C/cc-by-sa-3-0.xml:3 msgid "This work is licensed under a <_:link-1/>." msgstr "Este trabalho está licenciado sob uma <_:link-1/>." #. (itstool) path: license/p #: C/cc-by-sa-3-0.xml:6 msgid "" "As a special exception, the copyright holders give you permission to copy, " "modify, and distribute the example code contained in this document under the " "terms of your choosing, without restriction." msgstr "" "Como uma exceção especial, os detentores do copyright dão a você permissão " "para copiar, modificar e distribuir o código exemplo contido nesta " "documentação sob os termos de sua escolha, sem restrição." #. (itstool) path: info/desc #: C/databases.page:18 msgid "Simple persistent object stores" msgstr "Armazenamentos simples de objetos persistentes" #. (itstool) path: page/title #: C/databases.page:21 msgid "Databases" msgstr "Bancos de dados" #. (itstool) path: item/p #: C/databases.page:27 msgid "" "Use databases for appropriate use cases: not configuration data (use " "GSettings). ()" msgstr "" "Use bancos de dados para casos de uso apropriados: não para dados de " "configuração (use GSettings). ()" #. (itstool) path: item/p #: C/databases.page:31 msgid "" "Choose between GOM and GVDB based on whether indexing is required. ()" msgstr "" "Escolha entre GOM e GVDB com base em se indexação é necessária. ()" #. (itstool) path: item/p #: C/databases.page:35 msgid "" "Consider your vacuuming policy before committing to using GOM. ()" msgstr "" "Considere sua política de vacuuming antes de usar GOM. ()" #. (itstool) path: item/p #: C/databases.page:39 msgid "" "Avoid SQL injection vulnerabilities by using prepared statements. ()" msgstr "" "Evite vulnerabilidades de injeção SQL usando as instruções preparadas. " "()" #. (itstool) path: section/title #: C/databases.page:47 msgid "When to Use Databases" msgstr "Quando usar bancos de dados" #. (itstool) path: section/p #: C/databases.page:49 msgid "" "Configuration data should be stored in GSettings. As a rule of thumb, if " "some data needs to be persistent and affects how an application behaves, it " "is configuration data. If it could potentially be subject to policies " "imposed by the system administrator (such as proxy or lockdown settings), it " "is configuration data. If it contains user created content, it is not " "configuration data, and should not be stored in GSettings." msgstr "" "Dados de configuração devem ser armazenados em GSettings. Como uma " "regra de ouro, se alguns dados precisam ser persistentes e afetam como um " "aplicativo se comporta, eles são dados de configuração. Se eles estão " "potencialmente sujeitos a políticas impostas pelo administrador do sistema " "(tal como configurações de proxy e bloqueio), são dados de configuração. Se " "eles contêm conteúdo criado por usuários, não são dados de configuração e " "não devem ser armazenados em GSettings." #. (itstool) path: section/p #: C/databases.page:60 msgid "" "For such situations where user data is highly structured, storing it in a " "database is sensible. There are two main databases suggested for use within " "GNOME: GOM and GVDB. GOM is a wrapper around SQLite, and hence implements " "indexing of fields and SQL-style queries. GVDB is a much simpler object " "store, supporting fast serialization of a dictionary of objects to disk." msgstr "" "Para tais situações nas quais dados de usuário estejam altamente " "estruturado, armazená-los em um banco de dados é sensível. Há dois bancos de " "dados principais sugeridos para usar com GNOME: GOM e GVDB. GOM é um " "interfaceador do SQLite e, portanto, implementa indexação de campos e " "consultas no tipo SQL. GVDB é um armazenamento de objeto muito mais simples, " "oferecendo suporte a serialização rápida de um dicionário de objetos para " "disco." #. (itstool) path: section/p #: C/databases.page:69 msgid "" "GOM should be used if you need advanced features, especially indexing. GVDB " "should be used otherwise." msgstr "" "GOM deve ser usado se você precisa de recursos avançados, especialmente " "indexação. Do contrário, GVDB deve ser usado." #. (itstool) path: section/p #: C/databases.page:74 msgid "" "Before deciding to use GOM (and hence SQLite), you must consider a vacuuming " "policy for the database, and whether your use case will interact well with " "SQLite’s vacuuming system. Vacuuming is effectively SQLite’s term for " "defragmenting the database — if a database is not vacuumed appropriately, " "performance will degrade and the database size will increase indefinitely. " "Read this article on vacuuming for more information; " "please consider it before choosing to use GOM." msgstr "" "Antes de decidir por usar o GOM (e, portanto, SQLite), você deveria " "considerar uma política de vacuuming para o banco de dados e se seu " "caso de uso vai interagir bem com o sistema de vácuo do SQLite. " "Vaccuming é, efetivamente, o termo para desfragmentação do banco de " "dados — se um banco de dados não for adequadamente aspirado, o desempenho " "será degradado e seu tamanho vai aumentar indefinidamente. Leia este artigo sobre vacuuming para mais informações; " "considere-o antes de escolher usar GOM." #. (itstool) path: section/p #: C/databases.page:86 msgid "" "GNOME has another database library: GNOME Data Access (GDA). This is " "targeted at abstracting access to various types of relational database, for " "use in a database utility program or office program, for example. It is not " "suitable for storing user settings." msgstr "" "GNOME possui uma outra biblioteca de banco de dados: GNOME Data Access " "(GDA). Ela visa abstrair o acesso a vários tipos de banco de dados " "relacionais, para uso em um programa utilitário de banco de dados ou " "programa de escritório, por exemplo. Ela não é adequado para armazenar configurações " "de usuários." #. (itstool) path: section/title #: C/databases.page:97 msgid "Using GOM" msgstr "Usando o GOM" #. (itstool) path: section/p #: C/databases.page:99 msgid "" "Providing a GOM tutorial is beyond the scope of this document, but a reference manual is available." msgstr "" "Fornecer um tutorial do GOM vai além do escopo deste documento, mas um manual de referência está " "disponível." #. (itstool) path: section/title #: C/databases.page:113 msgid "SQL Injection" msgstr "Injeção de SQL" # Desconheço tradução para o termo técnico "prepared statement" e "value binding" --Rafael # Utilizada a URL do Wikipédia em português para Injeção de SQL --Rafael #. (itstool) path: section/p #: C/databases.page:115 msgid "" "GOM does allow access to the lower level SQLite query APIs. When using them, " "queries must be constructed using SQLite’s prepared statement " "and value " "binding API, rather than by constructing SQL strings then passing " "them to SQLite to parse. Constructing strings makes SQL injection vulnerabilities very " "likely, which can give attackers access to arbitrary user data from the " "database." msgstr "" "GOM não permite acesso às APIs de consulta de baixo de nível do SQLite. Ao " "usá-las, as consultas devem ser construídas usando " "a API de prepared " "statement (instrução preparada) e value binding (associação de valor) do SQLite, " "em vez de construir strings SQL e, então, passá-las para o SQLite " "interpretar. Construir strings possibilita as vulnerabilidades da injeção de SQL, o que pode fornecer acesso aos atacantes a dados de usuários a partir " "do banco de dados." #. (itstool) path: section/title #: C/databases.page:131 msgid "Using GVDB" msgstr "Usando o GVDB" #. (itstool) path: section/p #: C/databases.page:133 msgid "" "GVDB has a simple API which mirrors a conventional hash table. Presently, " "GVDB is only available as a copy-and-paste library; fetch the most recent " "copy of the code from GVDB " "git and copy it into your project. It is licenced under LGPLv2.1+." msgstr "" "GVDB possui uma API simples que espelha a tabela de hash convencional. " "Atualmente, GVDB está disponível apenas como uma biblioteca de " "copiar-e-colar; obtenha a cópia mais recente do código de GVDB git e copie-o para seu " "projeto. Ele está licenciado sob LGPLv2.1+." #. (itstool) path: section/p #: C/databases.page:141 msgid "A full GVDB tutorial is beyond the scope of this document." msgstr "Um tutorial completo do GVDB vai além do escopo deste documento." #. (itstool) path: info/desc #: C/documentation.page:26 msgid "Adding documentation to libraries and APIs" msgstr "Adicionando documentação a bibliotecas e APIs" #. (itstool) path: page/title #. (itstool) path: section/title #: C/documentation.page:29 C/memory-management.page:473 msgid "Documentation" msgstr "Documentação" #. (itstool) path: item/p #: C/documentation.page:35 msgid "" "Use gtk-doc with up-to-date settings for API documentation. ()" msgstr "" "Use gtk_doc com configurações atualizadas para documentação de API. ()" #. (itstool) path: item/p #: C/documentation.page:39 msgid "" "Use XML entities for including external symbols into the documentation. " "()" msgstr "" "Use entidades XML para inclusão de símbolos externos à documentação. ()" #. (itstool) path: item/p #: C/documentation.page:43 msgid "" "Use a consistent, standard, table of contents for all API documentation to " "maintain familiarity. ()" msgstr "" "Use uma tabela de conteúdos consistente e padrão para toda documentação de " "API para manter a familiaridade. ()" #. (itstool) path: item/p #: C/documentation.page:47 msgid "" "Use gdbus-codegen to generate D-Bus API documentation to include " "in the gtk-doc build. ()" msgstr "" "Use gdbus-codegen para gerar documentação de API do D-Bus para " "incluir na compilação de gtk-doc. ()" #. (itstool) path: item/p #: C/documentation.page:51 msgid "" "Add introspection annotations to all API documentation. ()" msgstr "" "Adicione anotações de introspecção a toda documentação de API. ()" #. (itstool) path: item/p #: C/documentation.page:55 msgid "" "Add Since lines to all API documentation. ()" msgstr "" "Adicione linhas Since para toda documentação de API. ()" #. (itstool) path: item/p #: C/documentation.page:59 msgid "Enable gtk-doc tests. ()" msgstr "Habilite testes de gtk-doc. ()" #. (itstool) path: section/title #: C/documentation.page:66 msgid "gtk-doc" msgstr "gtk-doc" #. (itstool) path: section/p #: C/documentation.page:68 msgid "" "The preferred documentation system for GNOME libraries is gtk-doc, which extracts inline " "comments from the code to let you build a DocBook document and collection of HTML pages. These can then be " "read in Devhelp. A " "lot of GNOME’s infrastructure is built to handle with documentation written " "using gtk-doc." msgstr "" "O sistema de documentação preferido para bibliotecas do GNOME é o gtk-doc, o qual extrai comentários em " "linha do código e permite que você compile um documento DocBook e coleção de páginas HTML. Esses podem ser " "lidos em Devhelp. " "Muito da infraestrutura do GNOME é construído para lidar com documentação " "escrita usando gtk-doc." #. (itstool) path: section/title #: C/documentation.page:81 msgid "Build System" msgstr "Sistema de compilação" #. (itstool) path: section/p #: C/documentation.page:83 msgid "" "To integrate gtk-doc into a project’s build system, follow the " "instructions in the gtk-doc manual. Note that while the " "sections.txt file is automatically generated the first time gtk-" "doc is run, it is not generated subsequently, and should be kept up to date " "manually. It should also be in version control." msgstr "" "Para integrar gtk-doc a um sistema de compilação do projeto, siga as instruções no manual do gtk-doc. Note que enquanto o arquivo " "sections.txt é gerado automaticamente na primeira vez que o gtk-" "doc é executado, ele não é gerado subsequentemente, e deve ser mantido " "atualizado. Ele também deve estar no controle de versão." #. (itstool) path: section/p #: C/documentation.page:94 msgid "" "gtk-doc’s no-tmpl flavour should be used, and XML mode should " "be used instead of SGML. (tmpl mode and SGML are both outdated and slower " "than XML.)" msgstr "" "A opção --flavour no-tmpl do gtk-doc deve ser usada, e o modo " "XML deve ser usado no lugar do SGML. (modo tmpl e SGML estão ambos " "desatualizados e são mais lentos que XML.)" #. (itstool) path: section/p #: C/documentation.page:106 msgid "" "If the package version is needed to be substituted into the documentation, " "create a file named docs/version.xml.in, containing:" msgstr "" "Se a versão do pacote for necessária para ser substituída na documentação, " "crie um arquivo chamado docs/version.xml.in, contendo:" #. (itstool) path: section/code #: C/documentation.page:110 #, no-wrap msgid "@PACKAGE_VERSION@" msgstr "@PACKAGE_VERSION@" #. (itstool) path: section/p #: C/documentation.page:111 msgid "" "Add it to AC_CONFIG_FILES in configure.ac, then " "include it into the main documentation file (*-docs.xml) using: " "<!ENTITY version SYSTEM \"version.xml\"> in the " "DOCTYPE at the top of the document. The package version can " "then be used inline as &version;." msgstr "" "Adicione-o a AC_CONFIG_FILES no configure.ac, " "então inclua-o ao arquivo central da documentação (*-docs.xml) " "usando: <!ENTITY version SYSTEM \"version.xml\"> no " "DOCTYPE sobre o documento. A versão do pacote pode ser usada em " "linha como &version;." #. (itstool) path: section/title #: C/documentation.page:121 msgid "Standard Layout" msgstr "Layout padrão" #. (itstool) path: section/p #: C/documentation.page:123 msgid "" "Using a standard layout for the table of contents, sections, appendices, " "etc. means the same project-name-docs.xml template " "can be reused with few changes between projects. It also means the " "documentation layout is similar across all projects, making it more familiar " "to developers." msgstr "" "Usar um layout padrão para a tabela de conteúdos, seções, apêndices etc. " "significa que o mesmo modelo de nome-do-projeto-docs.xml pode ser reusado com algumas alterações entre projetos. Ele também " "significa que o layout da documentação é similar por todos os projetos, " "fazendo dele mais familiar para os desenvolvedores." #. (itstool) path: section/p #: C/documentation.page:131 msgid "The following layout is suggested:" msgstr "O layout a seguir é sugerido:" #. (itstool) path: listing/title #: C/documentation.page:135 msgid "project-name-docs.xml" msgstr "nome-do-projeto-docs.xml" #. (itstool) path: listing/desc #: C/documentation.page:136 msgid "A template top-level gtk-doc file for a project" msgstr "Um arquivo de modelo de nível superior do gtk-doc para um projeto" #. (itstool) path: section/title #: C/documentation.page:142 msgid "Licensing" msgstr "Licenciamento" #. (itstool) path: section/p #: C/documentation.page:150 msgid "" "It is important to make the license used for API references clear, " "especially if they contain code examples which could be copied around." msgstr "" "É importante tornar a licença usada para referências de API bem clara, " "especialmente se elas contiverem exemplos de código que poderia ser copiado." #. (itstool) path: section/p #: C/documentation.page:155 msgid "" "Typically, projects use the same license for their API reference as for the " "project’s code itself, to avoid confusion. Some other projects use CC-BY-SA " "3.0 for all their reference documentation. The choice is yours." msgstr "" "Geralmente, projetos usam a mesma licença para sua referência de API que " "para o código do projeto em si, para evitar confusão. Alguns projetos usam " "CC-BY-SA 3.0 para toda documentação de referência. A escolha é sua." #. (itstool) path: section/p #: C/documentation.page:161 msgid "" "As shown in the Standard Layout you " "should include a license.xml in the top-level gtk-doc DocBook " "file which gives the full text of your documentation license." msgstr "" "Como mostrado no Layout padrão, você " "deve incluir um license.xml no arquivo DocBook de nível " "superior do gtk-doc, o qual fornece o texto completo para sua licença de " "documentação." #. (itstool) path: section/title #: C/documentation.page:169 msgid "Public APIs" msgstr "API pública" #. (itstool) path: section/p #: C/documentation.page:171 msgid "" "All public APIs must have gtk-doc comments. For functions, these should be " "placed in the source file, directly above the function." msgstr "" "Todas APIs públicas devem ter comentários de gtk-doc. Para funções, essas " "devem ser colocadas no arquivo fonte, diretamente sobre a função." #. (itstool) path: section/code #: C/documentation.page:176 #, no-wrap msgid "" "/**\n" " * gtk_get_flow:\n" " * @widget: a #GtkWidget\n" " *\n" " * Gets the flow of a widget.\n" " *\n" " * Note that flows may be laminar or turbulent...\n" " *\n" " * Returns: (transfer none): the flow of @widget\n" " */\n" "GtkFlow *\n" "gtk_get_flow (GtkWidget *widget)\n" "{\n" "\n" " ...\n" "\n" "}" msgstr "" "/**\n" " * gtk_get_flow:\n" " * @widget: a #GtkWidget\n" " *\n" " * Gets the flow of a widget.\n" " *\n" " * Note that flows may be laminar or turbulent...\n" " *\n" " * Returns: (transfer none): the flow of @widget\n" " */\n" "GtkFlow *\n" "gtk_get_flow (GtkWidget *widget)\n" "{\n" "\n" " ...\n" "\n" "}" #. (itstool) path: section/p #: C/documentation.page:194 msgid "" "Documentation comments for macros, function types, class structs, etc. " "should be placed next to the definitions, typically in header files." msgstr "" "Comentários de documentação para macros, tipos de função, structs de classe, " "etc. devem ser colocados próximo às definições, geralmente em arquivos de " "cabeçalhos." #. (itstool) path: section/p #: C/documentation.page:200 msgid "" "Section introductions should be placed in the source file they describe, " "after the license header:" msgstr "" "Introduções de seção devem ser colocadas no arquivo fonte que elas " "descrevem, após o cabeçalho de licença:" #. (itstool) path: section/code #: C/documentation.page:205 #, no-wrap msgid "" "/**\n" " * SECTION:gtksizerequest\n" " * @Short_Description: Height-for-width geometry management\n" " * @Title: GtkSizeRequest\n" " *\n" " * The GtkSizeRequest interface is GTK+'s height-for-width (and\n" " * width-for-height) geometry management system.\n" " * ...\n" " */" msgstr "" "/**\n" " * SECTION:gtksizerequest\n" " * @Short_Description: Height-for-width geometry management\n" " * @Title: GtkSizeRequest\n" " *\n" " * The GtkSizeRequest interface is GTK+'s height-for-width (and\n" " * width-for-height) geometry management system.\n" " * ...\n" " */" #. (itstool) path: section/p #: C/documentation.page:215 msgid "" "Keep in mind that in order to include a function, macro, function type, or " "struct type, it needs to be listed in your documentation’s modulename-" "sections.txt file." msgstr "" "Tenha em mente que para incluir uma função, macro, tipo de função ou tipo de " "struct, ele precisa ser listado no arquivo de nomemodulo-sections.txt da documentação." #. (itstool) path: section/p #: C/documentation.page:221 msgid "" "To properly document a new class, it needs to be given its own section in " "modulename-sections.txt, needs to be included in your toplevel " "modulename-docs.sgml, and the get_type() function " "for your class needs to be listed in your modulename.types." msgstr "" "Para documentação adequadamente uma nova classe, ele precisa ser dado em sua " "própria seção no nomemodulo-sections.txt e a função " "get_type() para sua classe precisa ser listada em seu " "nomemodulo.types." #. (itstool) path: section/title #: C/documentation.page:231 msgid "Introspection Annotations" msgstr "Anotações de introspecção" #. (itstool) path: section/p #: C/documentation.page:233 msgid "" "Each gtk-doc comment should have appropriate GObject introspection " "annotations. These are useful for two reasons:" msgstr "" "Cada comentário gtk-doc deve ter as anotações de introspeção de " "GObject adequada. Essa são úteis por dois motivos:" #. (itstool) path: item/p #: C/documentation.page:240 msgid "" "They add important information about parameter types, nullability and memory " "management to the C API documentation generated by gtk-doc." msgstr "" "Elas adicionam informações importantes sobre tipos de parâmetros, " "anulabilidade e gerenciamento de memória para a documentação de API C gerada " "pelo gtk-doc." #. (itstool) path: item/p #: C/documentation.page:244 msgid "" "They allow public APIs to be automatically bound in other languages, such as " "Python or JavaScript." msgstr "" "Elas permitem que APIs públicas sejam automaticamente vinculadas a outras " "linguagens, tais como Python ou JavaScript." #. (itstool) path: section/p #: C/documentation.page:250 msgid "" "Introspection annotations add information to APIs (functions, function " "parameters, function return values, structures, GObject properties, GObject " "signals) which is otherwise not present in the machine readable C API and " "only exists in the form of human readable documentation or convention. They " "are very important." msgstr "" "Anotações de introspecção adicionam informações às APIs (funções, parâmetros " "de função, valor de retorno de função, estruturas, propriedades de GObject, " "sinais de GObject) nas quais, do contrário, não está presente na API C " "legível por máquina e existe apenas na forma de documentação legível por " "humano ou convenção. Elas são muito importantes." #. (itstool) path: section/p #: C/documentation.page:258 msgid "" "In gtk-doc comments, annotations should be preferred over human-readable " "equivalents. For example, when documenting a function parameter which may be " "NULL, use the (nullable) annotation rather than " "some text:" msgstr "" "Em comentários de gtk-doc, anotações devem ser preferidos a equivalentes " "legíveis por humanos, Por exemplo, ao documentar o parâmetro de uma função " "que pode ser NULL, use a anotação (nullable) e, " "vez de algum texto:" #. (itstool) path: section/code #: C/documentation.page:264 #, no-wrap msgid "" "/**\n" " * my_function:\n" " * @parameter: (nullable): some parameter which affects something\n" " *\n" " * Body of the function documentation.\n" " */" msgstr "" "/**\n" " * my_function:\n" " * @parameter: (nullable): some parameter which affects something\n" " *\n" " * Body of the function documentation.\n" " */" #. (itstool) path: section/p #: C/documentation.page:271 msgid "Instead of:" msgstr "Em vez de:" #. (itstool) path: section/code #: C/documentation.page:274 #, no-wrap msgid "" "/**\n" " * my_bad_function:\n" " * @parameter: some parameter which affects something, or %NULL to ignore\n" " *\n" " * Bad body of the function documentation.\n" " */" msgstr "" "/**\n" " * my_bad_function:\n" " * @parameter: some parameter which affects something, or %NULL to ignore\n" " *\n" " * Bad body of the function documentation.\n" " */" #. (itstool) path: section/p #: C/documentation.page:281 msgid "" "For more information on introspection, see the introspection guidelines." msgstr "" "Para mais informação sobre introspecção, veja as diretrizes de introspecção." #. (itstool) path: section/title #: C/documentation.page:288 msgid "Symbol Versioning" msgstr "Versionamento de símbolo" #. (itstool) path: section/p #: C/documentation.page:290 msgid "" "Whenever a symbol is added to the public API, it should have a documentation " "comment added. This comment should always contain a Since line " "with the package version number of the release which will first contain the " "new API. This should be the number currently in configure.ac if " "post-release version incrementing is being used." msgstr "" "Quando um símbolo é adicionado à API pública, ele deve ter um comentário de " "documentação adicionado. Esse comentário deve sempre conter uma linha " "Since com o número da versão de pacote do lançamento que " "primeiro conterá a nova API. Isso deve ser o número que está no " "configure.in seincrementação de versão pós-lançamento estiver sendo usado." #. (itstool) path: section/p #. (itstool) path: example/p #: C/documentation.page:300 C/memory-management.page:494 C/threading.page:79 msgid "For example:" msgstr "Por exemplo:" #. (itstool) path: section/code #: C/documentation.page:303 #, no-wrap msgid "" "/**\n" " * my_function:\n" " * @param: some parameter\n" " *\n" " * Body of the function documentation.\n" " *\n" " * Since: 0.5.0\n" " */" msgstr "" "/**\n" " * my_function:\n" " * @param: some parameter\n" " *\n" " * Body of the function documentation.\n" " *\n" " * Since: 0.5.0\n" " */" #. (itstool) path: section/p #: C/documentation.page:312 msgid "" "gtk-doc uses this information to generate indexes of the APIs added in each " "release. These should be added to the main *-docs.xml as an " "appendix:" msgstr "" "gtk-doc usa essa informação para gerar índices das APIs adicionadas em cada " "lançamento. Essas devem ser adicionadas ao *-docs.xml principal " "como um apêndice:" #. (itstool) path: section/code #: C/documentation.page:317 #, no-wrap msgid "" "<part>\n" "\t<title>Appendices</title>\n" "\t<index id=\"api-index-full\">\n" "\t\t<title>API Index</title>\n" "\t\t<xi:include href=\"xml/api-index-full.xml\"><xi:fallback/></xi:include>\n" "\t</index>\n" "\t<index id=\"api-index-deprecated\">\n" "\t\t<title>Index of deprecated symbols</title>\n" "\t\t<xi:include href=\"xml/api-index-deprecated.xml\"><xi:fallback/></xi:include>\n" "\t</index>\n" "\t<index role=\"0.1.0\">\n" "\t\t<title>Index of new symbols in 0.1.0</title>\n" "\t\t<xi:include href=\"xml/api-index-0.1.0.xml\"><xi:fallback/></xi:include>\n" "\t</index>\n" "\t<!-- More versions here. -->\n" "\t<xi:include href=\"xml/annotation-glossary.xml\"><xi:fallback /></xi:include>\n" "</part>" msgstr "" "<part>\n" "\t<title>Appendices</title>\n" "\t<index id=\"api-index-full\">\n" "\t\t<title>API Index</title>\n" "\t\t<xi:include href=\"xml/api-index-full.xml\"><xi:fallback/></xi:include>\n" "\t</index>\n" "\t<index id=\"api-index-deprecated\">\n" "\t\t<title>Index of deprecated symbols</title>\n" "\t\t<xi:include href=\"xml/api-index-deprecated.xml\"><xi:fallback/></xi:include>\n" "\t</index>\n" "\t<index role=\"0.1.0\">\n" "\t\t<title>Index of new symbols in 0.1.0</title>\n" "\t\t<xi:include href=\"xml/api-index-0.1.0.xml\"><xi:fallback/></xi:include>\n" "\t</index>\n" "\t<!-- More versions here. -->\n" "\t<xi:include href=\"xml/annotation-glossary.xml\"><xi:fallback /></xi:include>\n" "</part>" #. (itstool) path: section/title #: C/documentation.page:337 msgid "D-Bus APIs" msgstr "APIs de D-Bus" #. (itstool) path: section/p #: C/documentation.page:339 msgid "" "D-Bus interface descriptions contain documentation comments, and these can " "be extracted from the XML using gdbus-codegen, and turned into " "DocBook files to be included by gtk-doc." msgstr "" "Descrições de interface D-Bus contêm comentários de documentação, e podem " "ser extraídas do XML usando gdbus-codegen e transformadas em " "arquivos DocBook para serem incluídas pelo gtk-doc." #. (itstool) path: section/p #: C/documentation.page:352 msgid "" "The DocBook files can be included in the main *-docs.xml file " "using:" msgstr "" "Os arquivos DocBook podem ser incluídos no arquivo *-docs.xml " "principal usando:" #. (itstool) path: section/code #: C/documentation.page:356 #, no-wrap msgid "" "<chapter>\n" " <title>C Interfaces</title>\n" " <partintro>\n" " <para>C wrappers for the D-Bus interfaces.</para>\n" " </partintro>\n" "\n" " <xi:include href=\"xml/SomeDBusService.xml\"/>\n" " <xi:include href=\"xml/SomeOtherService.xml\"/>\n" "</chapter>" msgstr "" "<chapter>\n" " <title>C Interfaces</title>\n" " <partintro>\n" " <para>C wrappers for the D-Bus interfaces.</para>\n" " </partintro>\n" "\n" " <xi:include href=\"xml/SomeDBusService.xml\"/>\n" " <xi:include href=\"xml/SomeOtherService.xml\"/>\n" "</chapter>" #. (itstool) path: section/p #: C/documentation.page:366 msgid "" "The generated XML files must be included in the content_files " "variable in your gtk-doc Makefile.am, otherwise the build will " "fail. (This is to fix situations where the builddir does not " "equal the srcdir.)" msgstr "" "Os arquivos XML gerados devem ser incluídos na variável content_files em seu Makefile.am de gtk-doc, do contrário a compilação " "vai falhar. (Isso é para corrigir situações nas quais builddir " "não é igual a srcdir.)" #. (itstool) path: section/title #: C/documentation.page:375 msgid "Keeping Documentation Up to Date" msgstr "Mantendo a documentação atualizada" #. (itstool) path: section/p #: C/documentation.page:377 msgid "" "gtk-doc comes with support for checking the documentation with some basic " "tests. These check that all version indexes are included in the main *-" "docs.xml file and that all symbols are documented, amongst other " "things." msgstr "" "gtk-doc vem com suporte a verificação da documentação com alguns testes " "básicos. Essas verificações que toda versão indexa são incluídas ao arquivo " "*-docs.xml principal e que todos símbolos são documentados, " "além de outras coisas." #. (itstool) path: section/p #: C/documentation.page:384 msgid "" "These tests should always be enabled, by adding the following to your gtk-" "doc Makefile.am:" msgstr "" "Esses testes devem sempre estar habilitados, adicionando o seguinte para seu " "Makefile.am de gtk-doc:" #. (itstool) path: section/code #: C/documentation.page:388 #, no-wrap msgid "TESTS = $(GTKDOC_CHECK)" msgstr "TESTS = $(GTKDOC_CHECK)" #. (itstool) path: section/p #: C/documentation.page:390 msgid "They will then be run as part of make check." msgstr "Eles serão, então, executados como parte do make check." #. (itstool) path: info/desc #: C/file-system.page:18 msgid "Accessing the file system" msgstr "Acessando o sistema de arquivos" #. (itstool) path: page/title #: C/file-system.page:21 msgid "File System Access" msgstr "Acesso ao sistema de arquivos" #. (itstool) path: synopsis/p #: C/file-system.page:26 msgid "" "There are a few anti-patterns to consider when accessing the file system. " "This article assumes knowledge of the standard GFile, GInputStream and GOutputStream APIs." msgstr "" "Há alguns antipadrões a serem considerados ao acessar o sistema de arquivos. " "Esse artigo presume conhecimento das APIs GFile, GInputStream e GOutputStream " "padrões." #. (itstool) path: item/p #: C/file-system.page:37 msgid "" "Use asynchronous I/O for file access. ()" msgstr "" "Use E/S assíncrona para acesso de arquivo. ()" #. (itstool) path: item/p #: C/file-system.page:41 msgid "" "Always use appropriate functions to construct file names and paths. ()" msgstr "" "Sempre use funções adequadas para construir nomes e caminhos de arquivos . " "()" #. (itstool) path: item/p #: C/file-system.page:45 msgid "" "Validate file paths are in the expected directories before using them. " "()" msgstr "" "Valide caminhos de arquivos que estão em diretórios esperados antes de usá-" "los. ()" #. (itstool) path: item/p #: C/file-system.page:49 msgid "" "Use mandatory access control profiles to enforce constraints on file access. " "()" msgstr "" "Use perfis obrigatórios de controle de acesso para reforçar restrições de " "acesso de arquivos. ()" #. (itstool) path: section/title #: C/file-system.page:58 msgid "Asynchronous I/O" msgstr "E/S assíncrona" #. (itstool) path: section/p #: C/file-system.page:60 msgid "" "Almost all I/O should be performed asynchronously. That is, without blocking " "the GLib main context. This can be achieved by always using " "the *_async() and *_finish() variants of each I/O " "function." msgstr "" "Quase toda E/S deve ser feita assincronamente, ou seja, sem bloqueio do " "contexto principal do GLib. Isso pode ser alcançado por " "sempre usar as variantes *_async() e *_finish() de " "cada função de E/S." #. (itstool) path: example/p #: C/file-system.page:70 msgid "" "For example, g_input_stream_read_async() rather than g_input_stream_read()." msgstr "" "Por exemplo, g_input_stream_read_async() em vez de g_input_stream_read()." #. (itstool) path: section/p #: C/file-system.page:78 msgid "" "Synchronous I/O blocks the main loop, which means that other events, such as " "user input, incoming networking packets, timeouts and idle callbacks, are " "not handled until the blocking function returns." msgstr "" "E/S síncrona bloqueia o loop principal, o que significa que outros eventos, " "tal como entrada de usuário, chegada de pacotes de rede, expiração de tempo " "limite e retorno de chamada ocioso, não são tratados até que a função " "bloqueadora retorne." #. (itstool) path: section/p #: C/file-system.page:84 msgid "" "Synchronous I/O is acceptable in certain circumstances where the overheads " "of scheduling an asynchronous operation exceed the costs of local " "synchronous I/O on Linux. For example, making a small read from a local " "file, or from a virtual file system such as /proc. For such " "reads, the low level functions g_open(), read() " "and g_close() should be used rather than GIO." msgstr "" "E/S síncrona é aceitável em certas circunstâncias nas quais a sobrecarga de " "agendar uma operação assíncrona excede o custo de E/S síncrona local no " "Linux. Por exemplo, fazer uma leitura pequena de um arquivo local, ou de um " "sistema de arquivos virtual tal como /proc. Para tais leituras, " "as funções de baixo nível g_open(), read() e " "g_close() devem ser usadas, em vez do GIO." #. (itstool) path: section/p #: C/file-system.page:93 msgid "" "Files in the user’s home directory do not count as local, as they " "could be on a networked file system." msgstr "" "Arquivos no diretório pessoal do usuário não contam como locais, " "pois eles podem estar em um sistema de arquivos de rede." #. (itstool) path: section/p #: C/file-system.page:98 msgid "" "Note that the alternative – running synchronous I/O in a separate thread – " "is highly discouraged; see the threading guidelines for more information." msgstr "" "Note que a alternativa – executar E/S síncrona em uma thread separada – é " "altamente desencorajada; veja as diretrizes de thread para mais informações." #. (itstool) path: section/title #: C/file-system.page:107 msgid "File Path Construction" msgstr "Construção de caminho de arquivo" #. (itstool) path: section/p #: C/file-system.page:109 msgid "" "File names and paths are not normal strings: on some systems, they can use a " "character encoding other than UTF-8, while normal strings in GLib are " "guaranteed to always use UTF-8. For this reason, special functions should be " "used to build and handle file names and paths. (Modern Linux systems almost " "universally use UTF-8 for filename encoding, so this is not an issue in " "practice, but the file path functions should still be used for compatibility " "with systems such as Windows, which use UTF-16 filenames.)" msgstr "" "Nomes e caminhos de arquivos não são strings normais: em alguns sistemas, " "eles podem usar uma codificação de caracteres diferente de UTF-8, enquanto " "strings normais no GLib têm a garantia de sempre usar UTF-8. Por este " "motivo, funções especiais devem ser usadas para compilar e tratar nomes e " "caminhos de arquivos. (Sistemas Linux modernos quase que universalmente usam " "UTF-8 para codificação de nome de arquivo, então isso não é um problema na " "prática, mas as funções de caminho de arquivo ainda devem ser usadas para " "compatibilidade com sistemas como o Windows, que usam nomes de arquivos " "UTF-16.)" #. (itstool) path: example/p #: C/file-system.page:120 msgid "" "For example, file paths should be built using g_build_filename() rather than g_strconcat()." msgstr "" "Por exemplo, caminhos de arquivos devem ser construídos usando g_build_filename() em " "vez de g_strconcat()." #. (itstool) path: section/p #: C/file-system.page:128 msgid "" "Doing so makes it clearer what the code is meant to do, and also eliminates " "duplicate directory separators, so the returned path is canonical (though " "not necessarily absolute)." msgstr "" "Fazer isso deixa mais claro qual é a intenção do código e também elimina " "separadores duplicados de diretórios, de forma que o caminho retornado é " "canonical (apesar de não necessariamente absoluto)." #. (itstool) path: example/p #: C/file-system.page:135 msgid "" "As another example, paths should be disassembled using g_path_get_basename() and g_path_get_dirname() " "rather than g_strrstr() and other " "manual searching functions." msgstr "" "Como um outro exemplo, caminhos devem ser desmembrados usando g_path_get_basename() e g_path_get_dirname() em vez de g_strrstr() e outras funções manuais de pesquisa." #. (itstool) path: section/title #: C/file-system.page:148 msgid "Path Validation and Sandboxing" msgstr "Validação de caminho e sandboxing" #. (itstool) path: section/p #: C/file-system.page:150 msgid "" "If a filename or path comes from external input, such as a web page or user " "input, it should be validated to ensure that putting it into a file path " "will not produce an arbitrary path. For example if a filename is constructed " "from the constant string ~/ plus some user input, if the user " "inputs ../../etc/passwd, they can (potentially) gain access to " "sensitive account information, depending on which user the program is " "running as, and what it does with data loaded from the constructed path." msgstr "" "Se um nome ou caminho de arquivo vem com uma entrada externa, tal como uma " "página web ou entrada de usuário, ele deve ser validado para garantir que " "colocá-lo em um caminho de arquivo não produzirá um caminho arbitrário. Por " "exemplo, se um nome de arquivo é construído a partir de uma string constante " "~/ junto com alguma entrada de usuário, se o usuário insere " "./../etc/passwd, eles podem (potencialmente) ganhar acesso a " "informação sensível de contas, dependendo de com qual usuário o programa " "está sendo executado e o que ele faz com os dados carregados a partir do " "caminho construído." #. (itstool) path: section/p #: C/file-system.page:161 msgid "" "This can be avoided by validating constructed paths before using them, using " "g_file_resolve_relative_path() " "to convert any relative paths to absolute ones, and then validating that the " "path is beneath a given root sandboxing directory appropriate for the " "operation. For example, if code downloads a file, it could validate that all " "paths are beneath ~/Downloads, using g_file_has_parent()." msgstr "" "Isso pode ser evitado por meio de uma validação dos caminhos construídos " "antes de usá-los usando g_file_resolve_relative_path() para converter " "quaisquer caminhos relativos para absolutos e, então, validar se aqueles " "caminhos estão dentro de um diretório raiz de sandbox apropriado " "para a operação. Por exemplo, se um código baixa um arquivo, ele poderia " "validar se aqueles caminhos estejam dentro de ~/Downloads, " "usando g_file_has_parent()." #. (itstool) path: section/p #: C/file-system.page:172 msgid "" "As a second line of defence, all projects which access the file system " "should consider providing a mandatory access control profile, using a system " "such as AppArmor or SELinux, which limits the directories " "and files they can read from and write to." msgstr "" "Como uma segunda linha de defesa, todos os projetos que acessam o sistema de " "arquivos devem considerar fornecer um perfil obrigatório de controle de " "acesso, usando um sistema tal como AppArmor ou SELinux que limita os diretórios e arquivos nos quais eles podem ler de ou " "escrever em." #. (itstool) path: info/desc #: C/gerror.page:18 msgid "Runtime error handling and reporting" msgstr "Tratamento e relatório de erro em tempo de execução" #. (itstool) path: page/title #: C/gerror.page:21 msgid "GError" msgstr "GError" #. (itstool) path: section/title #: C/gerror.page:24 msgid "GError Usage" msgstr "Uso do GError" #. (itstool) path: section/p #: C/gerror.page:26 msgid "" "GError is the standard error reporting mechanism " "for GLib-using code, and can be thought of as a C implementation of an exception." msgstr "" "GError é o mecanismo padrão de relatório de erro " "para códigos usando GLib e pode ser pensado como uma implementação C de uma <" "link href=\"http://en.wikipedia.org/wiki/Exception_handling\">exceção." #. (itstool) path: section/p #: C/gerror.page:33 msgid "" "Any kind of runtime failure (anything which is not a programmer error) must be handled by including a " "GError** parameter in the function, and setting a useful and " "relevant GError describing the failure, before returning from the function. " "Programmer errors must not be handled using GError: use assertions, pre-" "conditions or post-conditions instead." msgstr "" "Qualquer tipo de falha em tempo de execução (qualquer coisa que não seja um <" "link xref=\"preconditions\">erro de programação) deve ser tratado com " "a inclusão de um parâmetro GError** na função e definição de um " "GError útil e relevante que descreva a falha, antes de retornar a função. Os " "erros de programação não devem ser tratados usando GError: use asserções, " "pré-condições ou pós-condições." #. (itstool) path: section/p #: C/gerror.page:42 msgid "" "GError should be used in preference to a simple return code, as it can " "convey more information, and is also supported by all GLib tools. For " "example, introspecting an API will " "automatically detect all GError parameters so that they can be converted to " "exceptions in other languages." msgstr "" "O GError deve ser usado como preferência a um código de retorno simples, " "pois ele pode transmitir mais informações e também tem suporte em todas as " "ferramentas em GLib. Por exemplo, introspecção " "de uma API detectará automaticamente todos os parâmetros de GError de " "forma que eles possam ser convertidos para exceções em outros idiomas." #. (itstool) path: section/p #: C/gerror.page:50 msgid "" "Printing warnings to the console must not be done in library code: use a " "GError, and the calling code can propagate it further upwards, decide to " "handle it, or decide to print it to the console. Ideally, the only code " "which prints to the console will be top-level application code, and not " "library code." msgstr "" "A impressão de avisos para o console não deve ser feita no código da " "biblioteca: use um GError e o código de chamada pode propagá-lo mais para " "cima, decidir tratá-lo ou decidir imprimi-lo para o console. Idealmente, o " "único código que imprime para o console será um código de aplicativo topo de " "nível, e não um código de biblioteca." #. (itstool) path: section/p #: C/gerror.page:58 msgid "" "Any function call which can take a GError**, should " "take such a parameter, and the returned GError should be handled " "appropriately. There are very few situations where ignoring a potential " "error by passing NULL to a GError** parameter is " "acceptable." msgstr "" "Qualquer chamada de função que possa levar um GError**, " "deve levar tal parâmetro e o GError retornado deve ser tratado " "apropriadamente. Há muito poucas situações nas quais ignorar um erro em " "potencial passando NULL para um parâmetro GError** " "é aceitável." #. (itstool) path: section/p #: C/gerror.page:66 msgid "" "The GLib API documentation contains a full tutorial for using GError." msgstr "" "A documentação de API do GLib contém um tutorial completo sobre o uso de GError." #. (itstool) path: info/desc #: C/glist.page:18 msgid "Linked lists and container types" msgstr "Listas vinculadas e tipos contêineres" #. (itstool) path: page/title #: C/glist.page:21 msgid "GList" msgstr "GList" #. (itstool) path: section/title #: C/glist.page:24 msgid "GList Usage" msgstr "Uso do GList" #. (itstool) path: section/p #: C/glist.page:26 msgid "" "GLib provides several container types for sets of data: GList, GSList, GPtrArray and GArray." msgstr "" "GLib fornece vários tipos contêineres para conjuntos de dados: GList, GSList, GPtrArray e GArray." #. (itstool) path: section/p #: C/glist.page:34 msgid "" "It has been common practice in the past to use GList in all situations where " "a sequence or set of data needs to be stored. This is inadvisable — in most " "situations, a GPtrArray should be used instead. It has lower memory overhead " "(a third to a half of an equivalent list), better cache locality, and the " "same or lower algorithmic complexity for all common operations. The only " "typical situation where a GList may be more appropriate is when dealing with " "ordered data, which requires expensive insertions at arbitrary indexes in " "the array." msgstr "" "Foi uma prática comum no passado usar GList e, todas situações nas quais uma " "sequência ou conjunto de dados precisa ser armazenada(o). Isso não é " "recomendável — na maioria das situações, um GPtrArray deve ser usado. Ele " "faz menor uso de memória (um terço a metade de uma lista equivalente), " "melhora localidade de cache e a mesma ou menor complexidade algorítmica para " "todas as operações comuns. A única situação típica na qual um GList pode ser " "mais apropriado é ao lidar com dados ordenados, que requer inserções " "custosas em índices arbitrários no vetor." #. (itstool) path: section/p #: C/glist.page:45 msgid "" "If linked lists are used, be careful to keep the complexity of operations on " "them low, using standard CS complexity analysis. Any operation which uses " "g_list_nth() or g_list_nth_data() is almost certainly wrong. For " "example, iteration over a GList should be implemented using the linking " "pointers, rather than a incrementing index:" msgstr "" "Se listas vinculadas forem usadas, tenha o cuidado de manter baixa a " "complexidade das operações nelas, usando análise padrão de complexidade CS. " "Qualquer operação que usa g_list_nth() " "ou g_list_nth_data() está " "quase certamente errada. Por exemplo, interação por um GList deve ser " "implementada usando os ponteiros vinculantes, em vez de um índice " "incremental:" #. (itstool) path: section/code #: C/glist.page:54 #, no-wrap msgid "" "GList *some_list, *l;\n" "\n" "for (l = some_list; l != NULL; l = l->next)\n" " {\n" " gpointer element_data = l->data;\n" "\n" " /* Do something with @element_data. */\n" " }" msgstr "" "GList *some_list, *l;\n" "\n" "for (l = some_list; l != NULL; l = l->next)\n" " {\n" " gpointer element_data = l->data;\n" "\n" " /* Faz alguma coisa com @element_data. */\n" " }" #. (itstool) path: section/p #: C/glist.page:63 msgid "" "Using an incrementing index instead results in a quadratic decrease in " "performance (O(N^2) rather than O(N)):" msgstr "" "Usar um índice incremental pode resultar em um decréscimo quadrático no " "desempenho (O(N^2) em vez de O(N)):" #. (itstool) path: section/code #: C/glist.page:67 #, no-wrap msgid "" "GList *some_list;\n" "guint i;\n" "\n" "/* This code is inefficient and should not be used in production. */\n" "for (i = 0; i < g_list_length (some_list); i++)\n" " {\n" " gpointer element_data = g_list_nth_data (some_list, i);\n" "\n" " /* Do something with @element_data. */\n" " }" msgstr "" "GList *some_list;\n" "guint i;\n" "\n" "/* Esse código é ineficiente e não deve ser usado em produção. */\n" "for (i = 0; i < g_list_length (some_list); i++)\n" " {\n" " gpointer element_data = g_list_nth_data (some_list, i);\n" "\n" " /* Faz alguma coisa com @element_data. */\n" " }" #. (itstool) path: section/p #: C/glist.page:78 msgid "" "The performance penalty comes from g_list_length() and " "g_list_nth_data() which both traverse the list (O(N)) " "to perform their operations." msgstr "" "A penalidade no desempenho vem de g_list_length() e de " "g_list_nth_data(), os quais percorrem a lista (O(N)) " "para realizar suas operações." #. (itstool) path: section/p #: C/glist.page:84 msgid "" "Implementing the above with a GPtrArray has the same complexity as the first " "(correct) GList implementation, but better cache locality and lower memory " "consumption, so will perform better for large numbers of elements:" msgstr "" "Implementar o código acima com um GPtrArray tem a mesma complexidade que a " "primeira (correta) implementação de GList, mas com melhor localidade de " "cache e menor consumo de memória, de forma a executar melhor para grandes " "números de elementos:" #. (itstool) path: section/code #: C/glist.page:89 #, no-wrap msgid "" "GPtrArray *some_array;\n" "guint i;\n" "\n" "for (i = 0; i < some_array->len; i++)\n" " {\n" " gpointer element_data = some_array->pdata[i];\n" "\n" " /* Do something with @element_data. */\n" " }" msgstr "" "GPtrArray *some_array;\n" "guint i;\n" "\n" "for (i = 0; i < some_array->len; i++)\n" " {\n" " gpointer element_data = some_array->pdata[i];\n" "\n" " /* Faz alguma coisa com @element_data. */\n" " }" #. (itstool) path: credit/name #: C/index.page:13 C/writing-good-code.page:15 msgid "Miguel de Icaza" msgstr "Miguel de Icaza" #. (itstool) path: credit/name #: C/index.page:17 C/writing-good-code.page:19 msgid "Morten Welinder" msgstr "Morten Welinder" #. (itstool) path: credit/name #: C/index.page:26 msgid "GNOME Foundation" msgstr "A Fundação GNOME" #. (itstool) path: credit/page #: C/index.page:27 msgid "http://foundation.gnome.org/" msgstr "http://foundation.gnome.org/" #. (itstool) path: info/desc #. (itstool) path: page/title #: C/index.page:32 C/index.page:37 msgid "GNOME Programming Guidelines" msgstr "Diretrizes de programação do GNOME" #. (itstool) path: info/title #: C/index.page:34 msgctxt "link:trail" msgid "Programming Guidelines" msgstr "Diretrizes de programação" #. (itstool) path: page/p #: C/index.page:39 msgid "" "This article contains several guidelines and suggestions for programmers " "working in and with the GNOME stack. This is intended for programmers to " "know about the development processes, conventions and philosophies behind " "GNOME applications and the stack of libraries supporting them. By knowing " "“the way things are done” in the GNOME ecosystem, it is hoped that " "programmers will find use of GNOME APIs and development of new applications " "easier and more natural, and will produce code which is legible and " "maintainable over a long period of time by a diverse team of programmers." msgstr "" "Esse artigo contém várias diretrizes e sugestões para programadores que " "estejam trabalhando em e com recursos do GNOME. Ele é direcionado para " "programadores saberem sobre os processos de desenvolvimento, convenções e " "filosofias por trás dos aplicativos do GNOME e a pilha de bibliotecas por " "trás destes. Sabendo “a forma como as coisas são feitas” no ecossistema do " "GNOME, espera-se que programadores encontrem uso nas APIs do GNOME e um " "desenvolvimento de novos aplicativos mais fácil e mais natural, e produzirão " "código que seja legível e sustentável por um longo período de tempo por uma " "equipe diversa de programadores." #. (itstool) path: page/p #: C/index.page:50 msgid "This guide has a two-fold purpose:" msgstr "Esse guia tem um propósito duplo:" #. (itstool) path: item/p #: C/index.page:56 msgid "" "To give you good suggestions on how to write code for GNOME or using GNOME " "technologies. This will help you write code that is consistent with best " "practices, and that will be accepted by the community. This will also lead " "to code that is a pleasure to work on." msgstr "" "Fornecer boas sugestões sobre como escrever código para GNOME e usar " "tecnologias do GNOME. Isso lhe ajudará a escrever código que é consistente " "com as melhores práticas, e que serão aceitas pela comunidade. Isso também " "levará a um código no qual seja agradável de trabalhar." #. (itstool) path: item/p #: C/index.page:65 msgid "" "To transmit the knowledge we have gotten over the years on how to keep the " "GNOME project sustainable, even when people’s contributions increase or " "decrease." msgstr "" "Transmitir o conhecimento que nós obtivemos pelos anos sobre como manter o " "projeto GNOME sustentável, mesmo quando as contribuições das pessoas " "aumentaram ou diminuírem." #. (itstool) path: info/title #: C/index.page:75 msgctxt "link:trail" msgid "General Guidelines" msgstr "Diretrizes gerais" #. (itstool) path: section/title #: C/index.page:77 msgid "General Guidelines" msgstr "Diretrizes gerais" #. (itstool) path: info/title #: C/index.page:83 msgctxt "link:trail" msgid "Maintainer Guidelines" msgstr "Diretrizes de manutenção" #. (itstool) path: section/title #: C/index.page:85 msgid "Maintainer Guidelines" msgstr "Diretrizes de manutenção" #. (itstool) path: info/title #: C/index.page:91 msgctxt "link:trail" msgid "Specific How-Tos" msgstr "“Como fazer” específicos" #. (itstool) path: section/title #: C/index.page:93 msgid "Specific How-Tos" msgstr "“Como fazer” específicos" #. (itstool) path: info/title #: C/index.page:99 msgctxt "link:trail" msgid "References" msgstr "Referências" #. (itstool) path: section/title #: C/index.page:101 msgid "References" msgstr "Referências" #. (itstool) path: info/desc #: C/introspection.page:17 msgid "GObject Introspection support in library code" msgstr "Suporte a GObject Introspection em código de biblioteca" #. (itstool) path: page/title #: C/introspection.page:20 msgid "Introspection" msgstr "Introspection" #. (itstool) path: synopsis/p #: C/introspection.page:25 msgid "" " GObject " "introspection (abbreviated ‘GIR’) is a system which extracts APIs " "from C code and produces binary type libraries which can be used by non-C " "language bindings, and other tools, to introspect or wrap the original C libraries. " "It uses a system of annotations in documentation comments in the C code to " "expose extra information about the APIs which is not machine readable from " "the code itself." msgstr "" " GObject " "introspection (abreviado para ‘GIR’) é um sistema que extrai APIs de " "código C e produz bibliotecas de tipo binário que podem ser usadas por " "ligações de linguagem não C, e outras ferramentas, para examinar ou interfacear as " "bibliotecas C originais. Ele usa um sistema de anotações em comentários de " "documentação no código C para expor informações extras sobre as APIs que não " "sejam legíveis por máquina a partir do próprio código." #. (itstool) path: synopsis/p #: C/introspection.page:37 msgid "" "It should be enabled for all public APIs: so all libraries. It cannot be " "enabled for programs, since they expose no APIs. However, it is still " "recommended to add " "introspection annotations to documentation comments in program code, " "as they clarify the documentation." msgstr "" #. (itstool) path: item/p #: C/introspection.page:46 msgid "" "Enable introspection for all libraries. ()" msgstr "" #. (itstool) path: item/p #: C/introspection.page:50 msgid "" "Pay attention to warnings from g-ir-scanner and " "introspectable=\"0\" attributes in GIR files. ()" msgstr "" #. (itstool) path: item/p #: C/introspection.page:55 msgid "" "Add introspection annotations to all documentation comments. ()" msgstr "" #. (itstool) path: item/p #: C/introspection.page:59 msgid "" "Design APIs to be introspectable from the start. ()" msgstr "" #. (itstool) path: section/title #: C/introspection.page:67 msgid "Using Introspection" msgstr "Usando a introspecção" #. (itstool) path: section/p #: C/introspection.page:69 msgid "" "The first step for using introspection is to add it to the build system, " "following the instructions here, following method 1. This should be done early " "in the life of a project, as introspectability affects API design." msgstr "" #. (itstool) path: section/p #: C/introspection.page:77 msgid "" "This should result in a .gir and .typelib file " "being generated for the project. The .gir file is human " "readable, and can be inspected manually to see if the API has been " "introspected correctly (although the GIR compilation process will print " "error messages and warnings for any missing annotations or other problems). " "APIs with introspectable=\"0\" will not be exposed to language " "bindings as they are missing annotations or are otherwise not representable " "in the GIR file." msgstr "" #. (itstool) path: section/p #: C/introspection.page:88 msgid "" "The next step is to add annotations to the documentation comments for every piece of public " "API. If a particular piece of API should not be exposed in the GIR " "file, use the (skip) annotation. Documentation on the available " "annotations is here." msgstr "" #. (itstool) path: section/p #: C/introspection.page:98 msgid "" "If annotating the code for a program, a good approach is to split the bulk " "of the code out into an internal, private convenience library. An internal " "API reference manual can be built from its documentation comments (see ). The library is then not installed, but is linked " "in to the program which is itself installed. This approach for generating " "internal API documentation is especially useful for large projects where the " "internal code may be large and hard to navigate." msgstr "" #. (itstool) path: section/p #: C/introspection.page:108 msgid "" "Annotations do not have to be added exhaustively: GIR has a set of default " "annotations which it applies based on various conventions (see ). For example, a const gchar* parameter does " "not need an explicit (transfer none) annotation, because the " "const modifier implies this already. Learning the defaults for " "annotations is a matter of practice." msgstr "" #. (itstool) path: section/title #: C/introspection.page:119 msgid "API Design" msgstr "Design de API" #. (itstool) path: section/p #: C/introspection.page:121 msgid "" "In order to be introspectable without too many annotations, APIs must follow " "certain conventions, such as the standard GObject naming conventions, and the conventions for bindable APIs. This is necessary because of the flexibility of C: code can be " "written to behave in any way imaginable, but higher level languages don’t " "allow this kind of freedom. So in order for a C API to be representable in a " "higher level language, it has to conform to the behaviors supported by that " "language." msgstr "" #. (itstool) path: section/p #: C/introspection.page:134 msgid "" "For example, GIR expects that if a function can fail, it will have a " "GError** parameter, which will always be its final parameter. " "The GIR scanner detects this and automatically converts that parameter to an " "exception attribute on the method in the GIR file. It cannot do this if the " "GError* is returned directly, or is not the final function " "parameter, for example." msgstr "" #. (itstool) path: section/p #: C/introspection.page:143 msgid "" "Therefore, APIs must be designed to be introspectable, and the GIR file " "should be checked as the APIs are being written. If the GIR doesn’t match " "what you expect for a new API, the API may need extra annotations, or even " "for its C declaration to be changed (as in the case of va_list)." msgstr "" #. (itstool) path: section/p #: C/introspection.page:151 msgid "" "g-ir-scanner emits warnings when it encounters code it does not " "understand. By passing --warn-error as well as --warn-all in INTROSPECTION_SCANNER_ARGS in Makefile.am, " "compilation will fail when unintrospectable APIs are encountered. This will " "ensure all new APIs are introspectable, and is highly recommended." msgstr "" #. (itstool) path: info/desc #: C/logging.page:18 msgid "Logging debug and information output from libraries and programs" msgstr "" "Registrando saída de depuração e de informação de bibliotecas e programas" #. (itstool) path: page/title #: C/logging.page:23 msgid "Logging" msgstr "Logging" #. (itstool) path: synopsis/p #: C/logging.page:28 msgid "" "Logging debug and informational output from libraries and programs is an " "open problem, and there are various methods for converting multiple streams " "of log output into the customary stdout and stderr streams. Below are some " "suggestions for how to implement logging. However, the most important thing " "is to ensure that logging is consistent, so that log data can be accessed " "and searched with a minimum of effort, since that’s what it’s used for. " "Using different logging mechanisms and formats in different projects is not " "the right approach." msgstr "" #. (itstool) path: item/p #: C/logging.page:40 msgid "" "Use the GLib logging framework instead of logging directly to stderr and " "stdout. ()" msgstr "" #. (itstool) path: item/p #: C/logging.page:44 msgid "" "If systemd can be a dependency of the project, consider logging directly to " "the journal. ()" msgstr "" #. (itstool) path: item/p #: C/logging.page:48 msgid "" "Do not implement log rotation and deletion; leave that to system services. " "()" msgstr "" #. (itstool) path: section/title #: C/logging.page:56 msgid "GLib Logging Framework" msgstr "Framework de registro de Glib" #. (itstool) path: section/p #: C/logging.page:58 msgid "" "GLib provides a logging framework based around the g_log() function, with convenience wrappers g_debug(), g_message(), g_warning() and g_error(). The GLib logging framework has a few " "useful features:" msgstr "" #. (itstool) path: item/p #: C/logging.page:72 msgid "" "Programmatic redirection of log messages using g_log_set_handler()." msgstr "" #. (itstool) path: item/p #: C/logging.page:76 msgid "Multiple logging domains, which can be processed separately." msgstr "" #. (itstool) path: item/p #: C/logging.page:79 msgid "" "Multiple log levels, which can be processed separately. For example, this " "allows debug messages to be turned on and off at runtime." msgstr "" #. (itstool) path: item/p #: C/logging.page:83 msgid "Support for automatically aborting a program on ‘fatal’ messages." msgstr "" #. (itstool) path: section/p #: C/logging.page:88 msgid "" "These should be used in preference to functions like printf(), " "g_print() and g_printerr(), due to their enhanced " "flexibility. The logging functions allow log processing to be done in code, " "rather than by external shell scripting, which simplifies everything." msgstr "" #. (itstool) path: section/p #: C/logging.page:99 msgid "" "A key reason to use the logging framework is that it is used in GLib and " "other related libraries already; by using it, all log messages are then " "going through the same system and can be processed similarly." msgstr "" #. (itstool) path: section/p #: C/logging.page:105 msgid "" "To use the GLib logging framework, define G_LOG_DOMAIN for the project so it’s unique from all " "other projects. Call g_debug(\"Message\") to log a debug " "message." msgstr "" #. (itstool) path: section/p #: C/logging.page:112 msgid "" "If the default GLib log handlers are not sufficient, for example if log " "messages need to be in a custom format or journald integration is needed, set up a log handler with the " "following code:" msgstr "" #. (itstool) path: section/code #: C/logging.page:118 #, no-wrap msgid "" "\n" "static const gchar *\n" "log_level_to_string (GLogLevelFlags level)\n" "{\n" " switch (level)\n" " {\n" " case G_LOG_LEVEL_ERROR: return \"ERROR\";\n" " case G_LOG_LEVEL_CRITICAL: return \"CRITICAL\";\n" " case G_LOG_LEVEL_WARNING: return \"WARNING\";\n" " case G_LOG_LEVEL_MESSAGE: return \"MESSAGE\";\n" " case G_LOG_LEVEL_INFO: return \"INFO\";\n" " case G_LOG_LEVEL_DEBUG: return \"DEBUG\";\n" " default: return \"UNKNOWN\";\n" " }\n" "}\n" "\n" "static void\n" "log_handler_cb (const gchar *log_domain,\n" " GLogLevelFlags log_level,\n" " const gchar *message,\n" " gpointer user_data)\n" "{\n" " const gchar *log_level_str;\n" "\n" " /* Ignore debug messages if disabled. */\n" " if (!debug_enabled && (log_level & G_LOG_LEVEL_DEBUG))\n" " {\n" " return;\n" " }\n" "\n" " log_level_str = log_level_to_string (log_level & G_LOG_LEVEL_MASK);\n" "\n" " /* Use g_printerr() for warnings and g_print() otherwise. */\n" " if (flags <= G_LOG_LEVEL_WARNING)\n" " {\n" " g_printerr (\"%s: %s: %s\\n\", log_domain, log_level_str, message);\n" " }\n" " else\n" " {\n" " g_print (\"%s: %s: %s\\n\", log_domain, log_level_str, message);\n" " }\n" "}\n" "\n" "g_log_set_handler (\"log-domain\",\n" " G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,\n" " log_handler_cb, NULL);" msgstr "" #. (itstool) path: section/title #: C/logging.page:166 msgid "Exceptions" msgstr "Exceções" #. (itstool) path: item/p #: C/logging.page:169 msgid "" "Do not use g_message() in normal code to print output. Printing " "output should be done at the top level of an application, using " "g_print(), and should be quite rare; i.e. only done in command " "line applications." msgstr "" #. (itstool) path: item/p #: C/logging.page:175 msgid "" "Do not use g_warning() in library code. Use GErrors instead." msgstr "" #. (itstool) path: item/p #: C/logging.page:179 msgid "" "Similarly, do not set up log handlers in library code. Log messages should " "propagate through library code and be handled in a log handler at the top " "level of an application." msgstr "" #. (itstool) path: section/title #: C/logging.page:189 msgid "journald Integration" msgstr "Integração com journald" #. (itstool) path: section/p #: C/logging.page:191 msgid "" "Compared to conventional syslog-style logs, journald supports storage of " "structured logging data, which can make post-hoc analysis of logs much " "easier. If it’s possible to add systemd-journal as a dependency " "to a project, the project’s log handling function could be extended to use " "sd_journal_print() and sd_journal_send() " "instead of g_print() and g_printerr()." msgstr "" #. (itstool) path: section/p #: C/logging.page:202 msgid "" "For more information, see this article on logging to the journal." msgstr "" #. (itstool) path: section/title #: C/logging.page:210 msgid "Log Rotation" msgstr "Rotação de registro" #. (itstool) path: section/p #: C/logging.page:212 msgid "" "Log file rotation is one feature which is out of scope of the GLib logging " "system. It should be handled by the normal system logging mechanisms, such " "as logrotate or systemd-journald." msgstr "" #. (itstool) path: credit/years #: C/main-contexts.page:13 msgid "2014–2015" msgstr "2014–2015" #. (itstool) path: info/desc #: C/main-contexts.page:18 msgid "" "GLib main contexts, invoking functions in other threads, and the event loop" msgstr "" "Contextos centrais de GLib, invocando funções em outras threads e loop de " "eventos" #. (itstool) path: page/title #: C/main-contexts.page:24 msgid "GLib Main Contexts" msgstr "Contextos centrais de GLib" #. (itstool) path: item/p #: C/main-contexts.page:30 msgid "" "Use g_main_context_invoke_full() to invoke functions in other threads, assuming every thread has " "a thread default main context which runs throughout the lifetime of that " "thread ()" msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:37 msgid "" "Use GTask to run a function in the background without " "caring about the specific thread used ()" msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:43 msgid "" "Liberally use assertions to check which context executes each function, and " "add these assertions when first writing the code ()" msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:48 msgid "" "Explicitly document contexts a function is expected to be called in, a " "callback will be invoked in, or a signal will be emitted in ()" msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:53 msgid "" "Beware of g_idle_add() and similar functions which implicitly " "use the global-default main context ()" msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:62 msgid "What is GMainContext?" msgstr "O que é GMainContext?" #. (itstool) path: section/p #: C/main-contexts.page:64 msgid "" "GMainContext is a generalized " "implementation of an event loop, useful for implementing polled file I/O or event-based " "widget systems (such as GTK+). It is at the core of almost every GLib " "application. To understand GMainContext requires understanding " "poll() and polled I/O." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:74 msgid "" "A GMainContext has a set of GSources which are ‘attached’ to it, each of which can be thought of as " "an expected event with an associated callback function which will be invoked " "when that event is received; or equivalently as a set of file descriptors " "(FDs) to check. An event could be a timeout or data being received on a " "socket, for example. One iteration of the event loop will:" msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:84 msgid "" "Prepare sources, determining if any of them are ready to dispatch " "immediately." msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:88 msgid "" "Poll the sources, blocking the current thread until an event is received for " "one of the sources." msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:92 msgid "Check which of the sources received an event (several could have)." msgstr "" #. (itstool) path: item/p #: C/main-contexts.page:95 msgid "Dispatch callbacks from those sources." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:100 msgid "" "This is explained very well in the GLib documentation." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:108 msgid "" "At its core, GMainContext is just a poll() loop, " "with the preparation, check and dispatch stages of the loop corresponding to " "the normal preamble and postamble in a typical poll() loop " "implementation, such as listing 1 from this article. Typically, some complexity is needed in non-" "trivial poll()-using applications to track the lists of FDs " "which are being polled. Additionally, GMainContext adds a lot " "of useful functionality which vanilla poll() doesn’t support. " "Most importantly, it adds thread safety." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:121 msgid "" "GMainContext is completely thread safe, meaning that a " "GSource can be created in one thread and attached to a " "GMainContext running in another thread. (See also: .) A typical use for this might be to allow worker threads to " "control which sockets are being listened to by a GMainContext " "in a central I/O thread. Each GMainContext is ‘acquired’ by a " "thread for each iteration it’s put through. Other threads cannot iterate a " "GMainContext without acquiring it, which guarantees that a " "GSource and its FDs will only be polled by one thread at once " "(since each GSource is attached to at most one " "GMainContext). A GMainContext can be swapped " "between threads across iterations, but this is expensive." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:137 msgid "" "GMainContext is used instead of poll() mostly for " "convenience, as it transparently handles dynamically managing the array of " "FDs to pass to poll(), especially when operating over multiple " "threads. This is done by encapsulating FDs in GSources, which " "decide whether those FDs should be passed to the poll() call on " "each ‘prepare’ stage of the main context iteration." msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:149 msgid "What is GMainLoop?" msgstr "O que é GMainLoop?" #. (itstool) path: section/p #: C/main-contexts.page:151 msgid "" "GMainLoop is essentially the " "following few lines of code, once reference counting and locking have been " "removed (from g_main_loop_run()):" msgstr "" #. (itstool) path: section/code #: C/main-contexts.page:157 #, no-wrap msgid "" "loop->is_running = TRUE;\n" "while (loop->is_running)\n" " {\n" " g_main_context_iteration (context, TRUE);\n" " }" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:163 msgid "" "Plus a fourth line in g_main_loop_quit() which sets loop->is_running = FALSE and which " "will cause the loop to terminate once the current main context iteration " "ends." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:170 msgid "" "Hence, GMainLoop is a convenient, thread-safe way of running a " "GMainContext to process events until a desired exit condition " "is met, at which point g_main_loop_quit() should be called. " "Typically, in a UI program, this will be the user clicking ‘exit’. In a " "socket handling program, this might be the final socket closing." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:178 msgid "" "It is important not to confuse main contexts with main loops. Main contexts " "do the bulk of the work: preparing source lists, waiting for events, and " "dispatching callbacks. A main loop simply iterates a context." msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:186 msgid "Default Contexts" msgstr "Contextos padrões" #. (itstool) path: section/p #: C/main-contexts.page:188 msgid "" "One of the important features of GMainContext is its support " "for ‘default’ contexts. There are two levels of default context: the thread-" "default, and the global-default. The global-default (accessed using " "g_main_context_default()) is run by GTK+ when gtk_main() is called. It’s also used for timeouts (g_timeout_add()) " "and idle callbacks (g_idle_add()) — these won’t be dispatched " "unless the default context is running! (See: .)" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:200 msgid "" "Thread-default contexts are a later addition to GLib (since version 2.22), " "and are generally used for I/O operations which need to run and dispatch " "callbacks in a thread. By calling " "g_main_context_push_thread_default() before starting an I/O " "operation, the thread-default context is set and the I/O operation can add " "its sources to that context. The context can then be run in a new main loop " "in an I/O thread, causing the callbacks to be dispatched on that thread’s " "stack rather than on the stack of the thread running the global-default main " "context. This allows I/O operations to be run entirely in a separate thread " "without explicitly passing a specific GMainContext pointer " "around everywhere." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:214 msgid "" "Conversely, by starting a long-running operation with a specific thread-" "default context set, the calling code can guarantee that the operation’s " "callbacks will be emitted in that context, even if the operation itself runs " "in a worker thread. This is the principle behind GTask: when " "a new GTask is created, it stores a reference to the current " "thread-default context, and dispatches its completion callback in that " "context, even if the task itself is run using g_task_run_in_thread()." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:227 msgid "" "For example, the code below will run a GTask which performs two " "writes in parallel from a thread. The callbacks for the writes will be " "dispatched in the worker thread, whereas the callback from the task as a " "whole will be dispatched in the interesting_context." msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:234 #, no-wrap msgid "" "\n" "typedef struct {\n" " GMainLoop *main_loop;\n" " guint n_remaining;\n" "} WriteData;\n" "\n" "/* This is always called in the same thread as thread_cb() because\n" " * it’s always dispatched in the @worker_context. */\n" "static void\n" "write_cb (GObject *source_object,\n" " GAsyncResult *result,\n" " gpointer user_data)\n" "{\n" " WriteData *data = user_data;\n" " GOutputStream *stream = G_OUTPUT_STREAM (source_object);\n" " GError *error = NULL;\n" " gssize len;\n" "\n" " /* Finish the write. */\n" " len = g_output_stream_write_finish (stream, result, &error);\n" " if (error != NULL)\n" " {\n" " g_error (\"Error: %s\", error->message);\n" " g_error_free (error);\n" " }\n" "\n" " /* Check whether all parallel operations have finished. */\n" " write_data->n_remaining--;\n" "\n" " if (write_data->n_remaining == 0)\n" " {\n" " g_main_loop_quit (write_data->main_loop);\n" " }\n" "}\n" "\n" "/* This is called in a new thread. */\n" "static void\n" "thread_cb (GTask *task,\n" " gpointer source_object,\n" " gpointer task_data,\n" " GCancellable *cancellable)\n" "{\n" " /* These streams come from somewhere else in the program: */\n" " GOutputStream *output_stream1, *output_stream;\n" " GMainContext *worker_context;\n" " GBytes *data;\n" " const guint8 *buf;\n" " gsize len;\n" "\n" " /* Set up a worker context for the writes’ callbacks. */\n" " worker_context = g_main_context_new ();\n" " g_main_context_push_thread_default (worker_context);\n" "\n" " /* Set up the writes. */\n" " write_data.n_remaining = 2;\n" " write_data.main_loop = g_main_loop_new (worker_context, FALSE);\n" "\n" " data = g_task_get_task_data (task);\n" " buf = g_bytes_get_data (data, &len);\n" "\n" " g_output_stream_write_async (output_stream1, buf, len,\n" " G_PRIORITY_DEFAULT, NULL, write_cb,\n" " &write_data);\n" " g_output_stream_write_async (output_stream2, buf, len,\n" " G_PRIORITY_DEFAULT, NULL, write_cb,\n" " &write_data);\n" "\n" " /* Run the main loop until both writes have finished. */\n" " g_main_loop_run (write_data.main_loop);\n" " g_task_return_boolean (task, TRUE); /* ignore errors */\n" "\n" " g_main_loop_unref (write_data.main_loop);\n" "\n" " g_main_context_pop_thread_default (worker_context);\n" " g_main_context_unref (worker_context);\n" "}\n" "\n" "/* This can be called from any thread. Its @callback will always be\n" " * dispatched in the thread which currently owns\n" " * @interesting_context. */\n" "void\n" "parallel_writes_async (GBytes *data,\n" " GMainContext *interesting_context,\n" " GCancellable *cancellable,\n" " GAsyncReadyCallback callback,\n" " gpointer user_data)\n" "{\n" " GTask *task;\n" "\n" " g_main_context_push_thread_default (interesting_context);\n" "\n" " task = g_task_new (NULL, cancellable, callback, user_data);\n" " g_task_set_task_data (task, data,\n" " (GDestroyNotify) g_bytes_unref);\n" " g_task_run_in_thread (task, thread_cb);\n" " g_object_unref (task);\n" "\n" " g_main_context_pop_thread_default (interesting_context);\n" "}" msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:336 msgid "Implicit Use of the Global-Default Main Context" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:338 msgid "" "Several functions implicitly add sources to the global-default main context. " "They should not be used in threaded code. Instead, use " "g_source_attach() with the GSource created by the " "replacement function from the table below." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:345 msgid "" "Implicit use of the global-default main context means the callback functions " "are invoked in the main thread, typically resulting in work being brought " "back from a worker thread into the main thread." msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:356 msgid "Do not use" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:357 msgid "Use instead" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:362 msgid "g_timeout_add()" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:363 msgid "g_timeout_source_new()" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:366 msgid "g_idle_add()" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:367 msgid "g_idle_source_new()" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:370 msgid "g_child_watch_add()" msgstr "" #. (itstool) path: td/p #: C/main-contexts.page:371 msgid "g_child_watch_source_new()" msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:377 msgid "" "So to delay some computation in a worker thread, use the following code:" msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:381 #, no-wrap msgid "" "\n" "static guint\n" "schedule_computation (guint delay_seconds)\n" "{\n" " GSource *source = NULL;\n" " GMainContext *context;\n" " guint id;\n" "\n" " /* Get the calling context. */\n" " context = g_main_context_get_thread_default ();\n" "\n" " source = g_timeout_source_new_seconds (delay_seconds);\n" " g_source_set_callback (source, do_computation, NULL, NULL);\n" " id = g_source_attach (source, context);\n" " g_source_unref (source);\n" "\n" " /* The ID can be used with the same @context to\n" " * cancel the scheduled computation if needed. */\n" " return id;\n" "}\n" "\n" "static void\n" "do_computation (gpointer user_data)\n" "{\n" " /* … */\n" "}" msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:412 msgid "Using GMainContext in a Library" msgstr "Usando GMainContext em uma biblioteca" #. (itstool) path: section/p #: C/main-contexts.page:414 msgid "" "At a high level, library code must not make changes to main contexts which " "could affect the execution of an application using the library, for example " "by changing when the application’s GSources are dispatched. " "There are various best practices which can be followed to aid this." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:422 msgid "" "Never iterate a context created outside the library, including the global-" "default or thread-default contexts. Otherwise, GSources created " "in the application may be dispatched when the application is not expecting " "it, causing re-entrancy problems for the application code." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:431 msgid "" "Always remove GSources from a main context before dropping the " "library’s last reference to the context, especially if it may have been " "exposed to the application (for example, as a thread-default). Otherwise the " "application may keep a reference to the main context and continue iterating " "it after the library has returned, potentially causing unexpected source " "dispatches in the library. This is equivalent to not assuming that dropping " "the library’s last reference to a main context will finalize that context." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:442 msgid "" "If the library is designed to be used from multiple threads, or in a context-" "aware fashion, always document which context each callback will be " "dispatched in. For example, “callbacks will always be dispatched in the " "context which is the thread-default at the time of the object’s " "construction”. Developers using the library’s API need to know this " "information." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:451 msgid "" "Use g_main_context_invoke() to ensure callbacks are dispatched " "in the right context. It’s much easier than manually using " "g_idle_source_new() to transfer work between contexts. (See: " ".)" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:458 msgid "" "Libraries should never use g_main_context_default() (or, " "equivalently, pass NULL to a GMainContext-typed " "parameter). Always store and explicitly use a specific GMainContext, even if it often points to some default context. This makes the code " "easier to split out into threads in future, if needed, without causing hard-" "to-debug problems caused by callbacks being invoked in the wrong context." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:468 msgid "" "Always write things asynchronously internally (using GTask where appropriate), and keep synchronous " "wrappers at the very top level of an API, where they can be implemented by " "calling g_main_context_iteration() on a specific " "GMainContext. Again, this makes future refactoring easier. This " "is demonstrated in the above example: the thread uses " "g_output_stream_write_async() rather than " "g_output_stream_write()." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:479 msgid "" "Always match pushes and pops of the thread-default main context: " "g_main_context_push_thread_default() and " "g_main_context_pop_thread_default()." msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:487 msgid "Ensuring Functions are Called in the Right Context" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:489 msgid "" "The ‘right context’ is the thread-default main context of the thread the " "function should be executing in. This assumes the typical case that " "every thread has a single main context running in a main loop. A " "main context effectively provides a work or message queue for the thread — something " "which the thread can periodically check to determine if there is work " "pending from another thread. Putting a message on this queue – invoking a " "function in another main context – will result in it eventually being " "dispatched in that thread." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:503 msgid "" "For example, if an application does a long and CPU-intensive computation it " "should schedule this in a background thread so that UI updates in the main " "thread are not blocked. The results of the computation, however, might need " "to be displayed in the UI, so some UI update function must be called in the " "main thread once the computation’s complete." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:511 msgid "" "Furthermore, if the computation function can be limited to a single thread, " "it becomes easy to eliminate the need for locking a lot of the data it " "accesses. This assumes that other threads are implemented similarly and " "hence most data is only accessed by a single thread, with threads " "communicating by message passing. This allows each thread to update its data at its " "leisure, which significantly simplifies locking." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:523 msgid "" "For some functions, there might be no reason to care which context they’re " "executed in, perhaps because they’re asynchronous and hence do not block the " "context. However, it is still advisable to be explicit about which context " "is used, since those functions may emit signals or invoke callbacks, and for " "reasons of thread safety it’s necessary to know which threads those signal " "handlers or callbacks are going to be invoked in." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:533 msgid "" "For example, the progress callback in g_file_copy_async() is documented as being called in the thread-default main " "context at the time of the initial call." msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:542 msgid "Principles of Invocation" msgstr "Princípios da invocação" #. (itstool) path: section/p #: C/main-contexts.page:544 msgid "" "The core principle of invoking a function in a specific context is simple, " "and is walked through below to explain the concepts. In practice the convenience method, " "g_main_context_invoke_full() should be used instead." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:551 msgid "" "A GSource has to be added to the " "target GMainContext, which will invoke the function when it’s " "dispatched. This GSource should almost always be an idle source " "created with g_idle_source_new(), but this doesn’t have to be the case. It could be a timeout source so " "that the function is executed after a delay, for example." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:562 msgid "" "The GSource will be dispatched as soon as it’s ready, calling the function on the " "thread’s stack. In the case of an idle source, this will be as soon as all " "sources at a higher priority have been dispatched — this can be tweaked " "using the idle source’s priority parameter with g_source_set_priority(). The source will " "typically then be destroyed so the function is only executed once (though " "again, this doesn’t have to be the case)." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:574 msgid "" "Data can be passed between threads as the user_data passed to " "the GSource’s callback. This is set on the source using g_source_set_callback(), " "along with the callback function to invoke. Only a single pointer is " "provided, so if multiple data fields need passing, they must be wrapped in " "an allocated structure." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:584 msgid "" "The example below demonstrates the underlying principles, but there are " "convenience methods explained below which simplify things." msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:589 #, no-wrap msgid "" "\n" "/* Main function for the background thread, thread1. */\n" "static gpointer\n" "thread1_main (gpointer user_data)\n" "{\n" " GMainContext *thread1_main_context = user_data;\n" " GMainLoop *main_loop;\n" "\n" " /* Set up the thread’s context and run it forever. */\n" " g_main_context_push_thread_default (thread1_main_context);\n" "\n" " main_loop = g_main_loop_new (thread1_main_context, FALSE);\n" " g_main_loop_run (main_loop);\n" " g_main_loop_unref (main_loop);\n" "\n" " g_main_context_pop_thread_default (thread1_main_context);\n" " g_main_context_unref (thread1_main_context);\n" "\n" " return NULL;\n" "}\n" "\n" "/* A data closure structure to carry multiple variables between\n" " * threads. */\n" "typedef struct {\n" " gchar *some_string; /* owned */\n" " guint some_int;\n" " GObject *some_object; /* owned */\n" "} MyFuncData;\n" "\n" "static void\n" "my_func_data_free (MyFuncData *data)\n" "{\n" " g_free (data->some_string);\n" " g_clear_object (&data->some_object);\n" " g_free (data);\n" "}\n" "\n" "static void\n" "my_func (const gchar *some_string,\n" " guint some_int,\n" " GObject *some_object)\n" "{\n" " /* Do something long and CPU intensive! */\n" "}\n" "\n" "/* Convert an idle callback into a call to my_func(). */\n" "static gboolean\n" "my_func_idle (gpointer user_data)\n" "{\n" " MyFuncData *data = user_data;\n" "\n" " my_func (data->some_string, data->some_int, data->some_object);\n" "\n" " return G_SOURCE_REMOVE;\n" "}\n" "\n" "/* Function to be called in the main thread to schedule a call to\n" " * my_func() in thread1, passing the given parameters along. */\n" "static void\n" "invoke_my_func (GMainContext *thread1_main_context,\n" " const gchar *some_string,\n" " guint some_int,\n" " GObject *some_object)\n" "{\n" " GSource *idle_source;\n" " MyFuncData *data;\n" "\n" " /* Create a data closure to pass all the desired variables\n" " * between threads. */\n" " data = g_new0 (MyFuncData, 1);\n" " data->some_string = g_strdup (some_string);\n" " data->some_int = some_int;\n" " data->some_object = g_object_ref (some_object);\n" "\n" " /* Create a new idle source, set my_func() as the callback with\n" " * some data to be passed between threads, bump up the priority\n" " * and schedule it by attaching it to thread1’s context. */\n" " idle_source = g_idle_source_new ();\n" " g_source_set_callback (idle_source, my_func_idle, data,\n" " (GDestroyNotify) my_func_data_free);\n" " g_source_set_priority (idle_source, G_PRIORITY_DEFAULT);\n" " g_source_attach (idle_source, thread1_main_context);\n" " g_source_unref (idle_source);\n" "}\n" "\n" "/* Main function for the main thread. */\n" "static void\n" "main (void)\n" "{\n" " GThread *thread1;\n" " GMainContext *thread1_main_context;\n" "\n" " /* Spawn a background thread and pass it a reference to its\n" " * GMainContext. Retain a reference for use in this thread\n" " * too. */\n" " thread1_main_context = g_main_context_new ();\n" " g_thread_new (\"thread1\", thread1_main,\n" " g_main_context_ref (thread1_main_context));\n" "\n" " /* Maybe set up your UI here, for example. */\n" "\n" " /* Invoke my_func() in the other thread. */\n" " invoke_my_func (thread1_main_context,\n" " \"some data which needs passing between threads\",\n" " 123456, some_object);\n" "\n" " /* Continue doing other work. */\n" "}" msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:698 msgid "" "This invocation is uni-directional: it calls " "my_func() in thread1, but there’s no way to return " "a value to the main thread. To do that, the same principle needs to be used " "again, invoking a callback function in the main thread. It’s a " "straightforward extension which isn’t covered here." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:706 msgid "" "To maintain thread safety, data which is potentially accessed by multiple " "threads must make those accesses mutually exclusive using a mutex. Data " "potentially accessed by multiple threads: thread1_main_context, " "passed in the fork call to thread1_main; and some_object, a reference to which is passed in the data closure. Critically, GLib " "guarantees that GMainContext is thread safe, so sharing " "thread1_main_context between threads is safe. The example " "assumes that other code accessing some_object is thread safe." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:720 msgid "" "Note that some_string and some_int cannot be " "accessed from both threads, because copies of them are passed to " "thread1, rather than the originals. This is a standard " "technique for making cross-thread calls thread safe without requiring " "locking. It also avoids the problem of synchronizing freeing " "some_string." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:729 msgid "" "Similarly, a reference to some_object is transferred to " "thread1, which works around the issue of synchronizing " "destruction of the object (see )." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:735 msgid "" "g_idle_source_new() is used rather than the simpler " "g_idle_add() so the GMainContext to attach to can " "be specified." msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:744 msgid "Convenience Method: g_main_context_invoke_full()" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:748 msgid "" "This is simplified greatly by the convenience method, g_main_context_invoke_full(). It invokes a " "callback so that the specified GMainContext is owned during the " "invocation. Owning a main context is almost always equivalent to running it, " "and hence the function is invoked in the thread for which the specified " "context is the thread-default." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:757 msgid "" "g_main_context_invoke() can be used instead if the user data " "does not need to be freed by a GDestroyNotify callback after " "the invocation returns." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:764 msgid "" "Modifying the earlier example, the invoke_my_func() function " "can be replaced by the following:" msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:769 #, no-wrap msgid "" "\n" "static void\n" "invoke_my_func (GMainContext *thread1_main_context,\n" " const gchar *some_string,\n" " guint some_int,\n" " GObject *some_object)\n" "{\n" " MyFuncData *data;\n" "\n" " /* Create a data closure to pass all the desired variables\n" " * between threads. */\n" " data = g_new0 (MyFuncData, 1);\n" " data->some_string = g_strdup (some_string);\n" " data->some_int = some_int;\n" " data->some_object = g_object_ref (some_object);\n" "\n" " /* Invoke the function. */\n" " g_main_context_invoke_full (thread1_main_context,\n" " G_PRIORITY_DEFAULT, my_func_idle,\n" " data,\n" " (GDestroyNotify) my_func_data_free);\n" "}" msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:792 msgid "" "Consider what happens if invoke_my_func() were called from " "thread1, rather than from the main thread. With the original " "implementation, the idle source would be added to thread1’s " "context and dispatched on the context’s next iteration (assuming no pending " "dispatches with higher priorities). With the improved implementation, " "g_main_context_invoke_full() will notice that the specified " "context is already owned by the thread (or ownership can be acquired by it), " "and will call my_func_idle() directly, rather than attaching a " "source to the context and delaying the invocation to the next context " "iteration." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:806 msgid "" "This subtle behavior difference doesn’t matter in most cases, but is worth " "bearing in mind since it can affect blocking behavior " "(invoke_my_func() would go from taking negligible time, to " "taking the same amount of time as my_func() before returning)." msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:818 msgid "Checking Threading" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:820 msgid "" "It is useful to document which thread each function should be called in, in " "the form of an assertion:" msgstr "" #. (itstool) path: section/code #: C/main-contexts.page:824 #, no-wrap msgid "" "\n" "g_assert (g_main_context_is_owner (expected_main_context));" msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:827 msgid "" "If that’s put at the top of each function, any assertion failure will " "highlight a case where a function has been called from the wrong thread. It " "is much easier to write these assertions when initially developing code, " "rather than debuging race conditions which can easily result from a function " "being called in the wrong thread." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:835 msgid "" "This technique can also be applied to signal emissions and callbacks, " "improving type safety as well as asserting the right context is used. Note " "that signal emission via g_signal_emit() is synchronous, and doesn’t involve a main context at all." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:844 msgid "For example, instead of using the following when emitting a signal:" msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:847 #, no-wrap msgid "" "\n" "guint param1; /* arbitrary example parameters */\n" "gchar *param2;\n" "guint retval = 0;\n" "\n" "g_signal_emit_by_name (my_object, \"some-signal\",\n" " param1, param2, &retval);" msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:855 msgid "The following can be used:" msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:858 #, no-wrap msgid "" "\n" "static guint\n" "emit_some_signal (GObject *my_object,\n" " guint param1,\n" " const gchar *param2)\n" "{\n" " guint retval = 0;\n" "\n" " g_assert (g_main_context_is_owner (expected_main_context));\n" "\n" " g_signal_emit_by_name (my_object, \"some-signal\",\n" " param1, param2, &retval);\n" "\n" " return retval;\n" "}" msgstr "" #. (itstool) path: section/title #: C/main-contexts.page:877 msgid "GTask" msgstr "GTask" #. (itstool) path: section/p #: C/main-contexts.page:879 msgid "" "GTask provides a slightly different approach to " "invoking functions in other threads, which is more suited to the case where " "a function should be executed in some background thread, but not a " "specific one." msgstr "" #. (itstool) path: section/p #: C/main-contexts.page:886 msgid "" "GTask takes a data closure and a function to execute, and " "provides ways to return the result from this function. It handles everything " "necessary to run that function in an arbitrary thread belonging to some " "thread pool internal to GLib." msgstr "" #. (itstool) path: example/p #: C/main-contexts.page:894 msgid "" "By combining g_main_context_invoke_full() and GTask, " "it is possible to run a task in a specific context and effortlessly return " "its result to the current context:" msgstr "" #. (itstool) path: example/code #: C/main-contexts.page:900 #, no-wrap msgid "" "\n" "/* This will be invoked in thread1. */\n" "static gboolean\n" "my_func_idle (gpointer user_data)\n" "{\n" " GTask *task = G_TASK (user_data);\n" " MyFuncData *data;\n" " gboolean retval;\n" "\n" " /* Call my_func() and propagate its returned boolean to\n" " * the main thread. */\n" " data = g_task_get_task_data (task);\n" " retval = my_func (data->some_string, data->some_int,\n" " data->some_object);\n" " g_task_return_boolean (task, retval);\n" "\n" " return G_SOURCE_REMOVE;\n" "}\n" "\n" "/* Whichever thread this is invoked in, the @callback will be\n" " * invoked in, once my_func() has finished and returned a result. */\n" "static void\n" "invoke_my_func_with_result (GMainContext *thread1_main_context,\n" " const gchar *some_string,\n" " guint some_int,\n" " GObject *some_object,\n" " GAsyncReadyCallback callback,\n" " gpointer user_data)\n" "{\n" " MyFuncData *data;\n" "\n" " /* Create a data closure to pass all the desired variables\n" " * between threads. */\n" " data = g_new0 (MyFuncData, 1);\n" " data->some_string = g_strdup (some_string);\n" " data->some_int = some_int;\n" " data->some_object = g_object_ref (some_object);\n" "\n" " /* Create a GTask to handle returning the result to the current\n" " * thread-default main context. */\n" " task = g_task_new (NULL, NULL, callback, user_data);\n" " g_task_set_task_data (task, data,\n" " (GDestroyNotify) my_func_data_free);\n" "\n" " /* Invoke the function. */\n" " g_main_context_invoke_full (thread1_main_context,\n" " G_PRIORITY_DEFAULT, my_func_idle,\n" " task,\n" " (GDestroyNotify) g_object_unref);\n" "}" msgstr "" #. (itstool) path: info/desc #: C/memory-management.page:17 msgid "Managing memory allocation and deallocation in C" msgstr "Gerindo alocação e desalocação de memória no C" #. (itstool) path: page/title #: C/memory-management.page:20 msgid "Memory Management" msgstr "Gerenciamento de memória" #. (itstool) path: page/p #: C/memory-management.page:50 msgid "" "The GNOME stack is predominantly written in C, so dynamically allocated " "memory has to be managed manually. Through use of GLib convenience APIs, " "memory management can be trivial, but programmers always need to keep memory " "in mind when writing code." msgstr "" #. (itstool) path: page/p #: C/memory-management.page:57 msgid "" "It is assumed that the reader is familiar with the idea of heap allocation " "of memory using malloc() and free(), and knows of " "the paired GLib equivalents, g_malloc() and g_free()." msgstr "" #. (itstool) path: synopsis/p #: C/memory-management.page:67 msgid "There are three situations to avoid, in order of descending importance:" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:72 msgid "Using memory after freeing it (use-after-free)." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:73 msgid "Using memory before allocating it." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:74 msgid "Not freeing memory after allocating it (leaking)." msgstr "" #. (itstool) path: synopsis/p #: C/memory-management.page:77 msgid "Key principles, in no particular order:" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:82 msgid "" "Determine and document whether each variable is owned or unowned. They must " "never change from one to the other at runtime. ()" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:87 msgid "" "Determine and document the ownership transfers at function boundaries. " "()" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:91 msgid "" "Ensure that each assignment, function call and function return respects the " "relevant ownership transfers. (, , )" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:96 msgid "" "Use reference counting rather than explicit finalization where possible. " "()" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:100 msgid "" "Use GLib convenience functions like g_clear_object() where possible. ()" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:105 msgid "" "Do not split memory management across code paths. ()" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:109 msgid "" "Use the single-path cleanup pattern for large or complex functions. ()" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:113 msgid "" "Leaks should be checked for using Valgrind or the address sanitizer. ()" msgstr "" #. (itstool) path: section/title #: C/memory-management.page:121 msgid "Principles of Memory Management" msgstr "Princípios do gerenciamento de memória" #. (itstool) path: section/p #: C/memory-management.page:123 msgid "" "The normal approach to memory management is for the programmer to keep track " "of which variables point to allocated memory, and to manually free them when " "they are no longer needed. This is correct, but can be clarified by " "introducing the concept of ownership, which is the piece of code " "(such as a function, struct or object) which is responsible for freeing a " "piece of allocated memory (an allocation). Each allocation has " "exactly one owner; this owner may change as the program runs, by " "transferring ownership to another piece of code. Each variable is " "owned or unowned, according to whether the scope " "containing it is always its owner. Each function parameter and return type " "either transfers ownership of the values passed to it, or it doesn’t. If " "code which owns some memory doesn’t deallocate that memory, that’s a memory " "leak. If code which doesn’t own some memory frees it, that’s a double-free. " "Both are bad." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:140 msgid "" "By statically calculating which variables are owned, memory management " "becomes a simple task of unconditionally freeing the owned variables before " "they leave their scope, and not freeing the unowned variables (see " "). The key question to answer for all " "memory is: which code has ownership of this memory?" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:149 msgid "" "There is an important restriction here: variables must never change from owned to unowned (or vice-versa) at runtime. This " "restriction is key to simplifying memory management." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:155 msgid "For example, consider the functions:" msgstr "Por exemplo, considere as funções:" #. (itstool) path: section/code #: C/memory-management.page:159 #, no-wrap msgid "" "gchar *generate_string (const gchar *template);\n" "void print_string (const gchar *str);" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:162 msgid "" "The following code has been annotated to note where the ownership transfers " "happen:" msgstr "" #. (itstool) path: section/code #: C/memory-management.page:167 #, no-wrap msgid "" "gchar *my_str = NULL; /* owned */\n" "const gchar *template; /* unowned */\n" "GValue value = G_VALUE_INIT; /* owned */\n" "g_value_init (&value, G_TYPE_STRING);\n" "\n" "/* Transfers ownership of a string from the function to the variable. */\n" "template = \"XXXXXX\";\n" "my_str = generate_string (template);\n" "\n" "/* No ownership transfer. */\n" "print_string (my_str);\n" "\n" "/* Transfer ownership. We no longer have to free @my_str. */\n" "g_value_take_string (&value, my_str);\n" "\n" "/* We still have ownership of @value, so free it before it goes out of scope. */\n" "g_value_unset (&value);" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:185 msgid "" "There are a few points here: Firstly, the ‘owned’ comments by the variable " "declarations denote that those variables are owned by the local scope, and " "hence need to be freed before they go out of scope. The alternative is " "‘unowned’, which means the local scope does not have ownership, and " "must not free the variables before going out of scope. Similarly, " "ownership must not be transferred to them on assignment." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:195 msgid "" "Secondly, the variable type modifiers reflect whether they transfer " "ownership: because my_str is owned by the local scope, it has " "type gchar, whereas template is const " "to denote it is unowned. Similarly, the template parameter of " "generate_string() and the str parameter of " "print_string() are const because no ownership is " "transferred when those functions are called. As ownership is " "transferred for the string parameter of g_value_take_string(), " "we can expect its type to be gchar." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:208 msgid "" "(Note that this is not the case for GObjects and subclasses, which can never be const. It is only the " "case for strings and simple structs.)" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:216 msgid "" "Finally, a few libraries use a function naming convention to indicate " "ownership transfer, for example using ‘take’ in a function name to indicate " "full transfer of parameters, as with g_value_take_string(). " "Note that different libraries use different conventions, as shown below:" msgstr "" #. (itstool) path: td/p #: C/memory-management.page:229 #, fuzzy msgid "Function name" msgstr "the \"$name\" function requires exactly one argument" #. (itstool) path: td/p #: C/memory-management.page:230 #, fuzzy msgid "Convention 1 (standard)" msgstr "Prefixos não coincidem no uso da convenção TO." #. (itstool) path: td/p #: C/memory-management.page:231 #, fuzzy msgid "Convention 2 (alternate)" msgstr "Alternativo:" #. (itstool) path: td/p #: C/memory-management.page:232 msgid "Convention 3 (gdbus-codegen)" msgstr "" #. (itstool) path: td/p #: C/memory-management.page:237 #, fuzzy msgid "get" msgstr "Obter tíquete" #. (itstool) path: td/p #: C/memory-management.page:238 C/memory-management.page:254 #: C/memory-management.page:259 C/memory-management.page:260 #: C/memory-management.page:261 #, fuzzy msgid "No transfer" msgstr "Transferir chamada" #. (itstool) path: td/p #: C/memory-management.page:239 #, fuzzy msgid "Any transfer" msgstr "_Cancelar a transferência" #. (itstool) path: td/p #: C/memory-management.page:240 C/memory-management.page:245 #: C/memory-management.page:266 C/memory-management.page:273 #: C/memory-management.page:274 C/memory-management.page:275 #, fuzzy msgid "Full transfer" msgstr "Completo" #. (itstool) path: td/p #: C/memory-management.page:244 #, fuzzy msgid "dup" msgstr "D_uplicar Linha / Seleção" #. (itstool) path: td/p #: C/memory-management.page:246 C/memory-management.page:247 #: C/memory-management.page:252 C/memory-management.page:253 #: C/memory-management.page:267 C/memory-management.page:268 msgid "Unused" msgstr "Não utilizado" #. (itstool) path: td/p #: C/memory-management.page:251 #, fuzzy msgid "peek" msgstr "ERRO INTERNO: Erro na pilha de entrada em peek_input ()" #. (itstool) path: td/p #: C/memory-management.page:258 #, fuzzy msgid "set" msgstr "set" #. (itstool) path: td/p #: C/memory-management.page:265 #, fuzzy msgid "take" msgstr "Pegar foco" #. (itstool) path: td/p #: C/memory-management.page:272 #, fuzzy msgid "steal" msgstr "" "Este não parece ser o %s real. Atacantes podem estar tentando roubar " "ou alterar informações indo para ou vindo deste site (por exemplo, mensagens " "privadas, informações de cartões de crédito ou senhas)." #. (itstool) path: section/p #: C/memory-management.page:280 msgid "" "Ideally, all functions have a (transfer) introspection annotation for all relevant " "parameters and the return value. Failing that, here is a set of guidelines " "to use to determine whether ownership of a return value is transferred:" msgstr "" #. (itstool) path: item/p #: C/memory-management.page:288 msgid "" "If the type has an introspection (transfer) annotation, look at " "that." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:292 msgid "Otherwise, if the type is const, there is no transfer." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:295 msgid "" "Otherwise, if the function documentation explicitly specifies the return " "value must be freed, there is full or container transfer." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:299 msgid "" "Otherwise, if the function is named ‘dup’, ‘take’ or ‘steal’, there is full " "or container transfer." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:303 msgid "Otherwise, if the function is named ‘peek’, there is no transfer." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:306 msgid "" "Otherwise, you need to look at the function’s code to determine whether it " "intends ownership to be transferred. Then file a bug against the " "documentation for that function, and ask for an introspection annotation to " "be added." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:314 msgid "" "Given this ownership and transfer infrastructure, the correct approach to " "memory allocation can be mechanically determined for each situation. In each " "case, the copy() function must be appropriate to the data type, " "for example g_strdup() for strings, or g_object_ref() for GObjects." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:322 msgid "" "When thinking about ownership transfer, malloc()/free() and reference counting are equivalent: in the former case, a newly " "allocated piece of heap memory is transferred; in the latter, a newly " "incremented reference. See ." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:331 #, fuzzy msgid "Assignments" msgstr "Porque a FSF recebe o copyright de seus colaboradores" #. (itstool) path: td/p #: C/memory-management.page:338 #, fuzzy msgid "Assignment from/to" msgstr "Operadores de atribuição" #. (itstool) path: td/p #: C/memory-management.page:339 #, fuzzy msgid "Owned destination" msgstr "Propriedade do usuário" #. (itstool) path: td/p #: C/memory-management.page:340 #, fuzzy msgid "Unowned destination" msgstr "_Destino:" #. (itstool) path: td/p #: C/memory-management.page:346 C/memory-management.page:394 #: C/memory-management.page:441 #, fuzzy msgid "Owned source" msgstr "Propriedade do usuário" #. (itstool) path: td/p #: C/memory-management.page:348 #, fuzzy msgid "Copy or move the source to the destination." msgstr "Selecionar destino da movimentação" #. (itstool) path: td/code #: C/memory-management.page:351 #, no-wrap msgid "owned_dest = copy (owned_src)" msgstr "" #. (itstool) path: td/code #: C/memory-management.page:352 #, no-wrap msgid "owned_dest = owned_src; owned_src = NULL" msgstr "" #. (itstool) path: td/p #: C/memory-management.page:355 msgid "" "Pure assignment, assuming the unowned variable is not used after the owned " "one is freed." msgstr "" #. (itstool) path: td/code #: C/memory-management.page:359 #, fuzzy, no-wrap msgid "unowned_dest = owned_src" msgstr "" "Uso: sln fonte destino|arquivo\n" "\n" #. (itstool) path: td/p #: C/memory-management.page:364 C/memory-management.page:411 #: C/memory-management.page:457 #, fuzzy msgid "Unowned source" msgstr "Não existe a fonte" #. (itstool) path: td/p #: C/memory-management.page:366 #, fuzzy msgid "Copy the source to the destination." msgstr "Caminhos Fonte/Destino:" #. (itstool) path: td/code #: C/memory-management.page:367 #, no-wrap msgid "owned_dest = copy (unowned_src)" msgstr "" #. (itstool) path: td/p #: C/memory-management.page:370 #, fuzzy msgid "Pure assignment." msgstr "supressão de atribuição" #. (itstool) path: td/code #: C/memory-management.page:371 #, fuzzy, no-wrap msgid "unowned_dest = unowned_src" msgstr "" "Uso: sln fonte destino|arquivo\n" "\n" #. (itstool) path: section/title #: C/memory-management.page:379 #, fuzzy msgid "Function Calls" msgstr "" "Melhorias ao PyGObject no 3.20 incluem suporte estendido a GError e melhorias de desempenho para chamadas e encerramentos de funções. A " "referência de API do " "PyGObject também foi melhorada no 3.20:" #. (itstool) path: td/p #: C/memory-management.page:386 #, fuzzy msgid "Call from/to" msgstr "Recebendo chamada de vídeo de %s" #. (itstool) path: td/p #: C/memory-management.page:387 #, fuzzy msgid "Transfer full parameter" msgstr "Completo" #. (itstool) path: td/p #: C/memory-management.page:388 #, fuzzy msgid "Transfer none parameter" msgstr " (nenhum)" #. (itstool) path: td/p #: C/memory-management.page:396 #, fuzzy msgid "Copy or move the source for the parameter." msgstr "Copiar parâmetro" #. (itstool) path: td/code #: C/memory-management.page:399 #, no-wrap msgid "function_call (copy (owned_src))" msgstr "" #. (itstool) path: td/code #: C/memory-management.page:400 #, no-wrap msgid "function_call (owned_src); owned_src = NULL" msgstr "" #. (itstool) path: td/p #: C/memory-management.page:403 C/memory-management.page:417 #, fuzzy msgid "Pure parameter passing." msgstr "Parâmetros: " #. (itstool) path: td/code #: C/memory-management.page:406 #, fuzzy, no-wrap msgid "function_call (owned_src)" msgstr "Chamar uma função:" #. (itstool) path: td/p #: C/memory-management.page:413 #, fuzzy msgid "Copy the source for the parameter." msgstr "Copiar parâmetro" #. (itstool) path: td/code #: C/memory-management.page:414 #, no-wrap msgid "function_call (copy (unowned_src))" msgstr "" #. (itstool) path: td/code #: C/memory-management.page:418 #, fuzzy, no-wrap msgid "function_call (unowned_src)" msgstr "" "\n" "\t# Pilha de Chamadas de Função:\n" "\n" #. (itstool) path: section/title #: C/memory-management.page:426 #, fuzzy msgid "Function Returns" msgstr "" "Esta função retorna a função densidade de probabilidade da distribuição Beta." #. (itstool) path: td/p #: C/memory-management.page:433 #, fuzzy msgid "Return from/to" msgstr "ASN.1 resposta ruim da gmtime" #. (itstool) path: td/p #: C/memory-management.page:434 #, fuzzy msgid "Transfer full return" msgstr "Enter" #. (itstool) path: td/p #: C/memory-management.page:435 #, fuzzy msgid "Transfer none return" msgstr " (nenhum)" #. (itstool) path: td/p #: C/memory-management.page:443 #, fuzzy msgid "Pure variable return." msgstr "Definir uma variável para retornar valor." #. (itstool) path: td/code #: C/memory-management.page:446 #, fuzzy, no-wrap msgid "return owned_src" msgstr "Propriedade do _grupo" #. (itstool) path: td/p #: C/memory-management.page:449 msgid "" "Invalid. The source needs to be freed, so the return value would use freed " "memory — a use-after-free error." msgstr "" #. (itstool) path: td/p #: C/memory-management.page:459 #, fuzzy msgid "Copy the source for the return." msgstr "copying change source files" #. (itstool) path: td/code #: C/memory-management.page:460 #, no-wrap msgid "return copy (unowned_src)" msgstr "" #. (itstool) path: td/p #: C/memory-management.page:463 #, fuzzy msgid "Pure variable passing." msgstr "Passando opções na linha de comando" #. (itstool) path: td/code #: C/memory-management.page:464 #, fuzzy, no-wrap msgid "return unowned_src" msgstr "" "Uso: sln fonte destino|arquivo\n" "\n" #. (itstool) path: section/p #: C/memory-management.page:475 msgid "" "Documenting the ownership transfer for each function parameter and return, " "and the ownership for each variable, is important. While they may be clear " "when writing the code, they are not clear a few months later; and may never " "be clear to users of an API. They should always be documented." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:482 msgid "" "The best way to document ownership transfer is to use the (transfer) annotation introduced by gobject-" "introspection. Include this in the API documentation comment for each " "function parameter and return type. If a function is not public API, write a " "documentation comment for it anyway and include the (transfer) " "annotations. By doing so, the introspection tools can also read the " "annotations and use them to correctly introspect the API." msgstr "" #. (itstool) path: section/code #: C/memory-management.page:497 #, no-wrap msgid "" "/**\n" " * g_value_take_string:\n" " * @value: (transfer none): an initialized #GValue\n" " * @str: (transfer full): string to set it to\n" " *\n" " * Function documentation goes here.\n" " */\n" "\n" "/**\n" " * generate_string:\n" " * @template: (transfer none): a template to follow when generating the string\n" " *\n" " * Function documentation goes here.\n" " *\n" " * Returns: (transfer full): a newly generated string\n" " */" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:514 msgid "" "Ownership for variables can be documented using inline comments. These are " "non-standard, and not read by any tools, but can form a convention if used " "consistently." msgstr "" #. (itstool) path: section/code #: C/memory-management.page:519 #, no-wrap msgid "" "GObject *some_owned_object = NULL; /* owned */\n" "GObject *some_unowned_object; /* unowned */" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:522 msgid "" "The documentation for is similarly only a " "convention; it includes the type of the contained elements too:" msgstr "" #. (itstool) path: section/code #: C/memory-management.page:526 #, no-wrap msgid "" "GPtrArray/*<owned gchar*>*/ *some_unowned_string_array; /* unowned */\n" "GPtrArray/*<owned gchar*>*/ *some_owned_string_array = NULL; /* owned */\n" "GPtrArray/*<unowned GObject*>*/ *some_owned_object_array = NULL; /* owned */" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:530 msgid "" "Note also that owned variables should always be initialized so that freeing " "them is more convenient. See ." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:536 msgid "" "Also note that some types, for example basic C types like strings, can have " "the const modifier added if they are unowned, to take advantage " "of compiler warnings resulting from assigning those variables to owned " "variables (which must not use the const modifier). If " "so, the /* unowned */ comment may be omitted." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:546 msgid "Reference Counting" msgstr "Contagem de referência" #. (itstool) path: section/p #: C/memory-management.page:548 msgid "" "As well as conventional malloc()/free()-style " "types, GLib has various reference counted types — " "GObject being a prime example." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:555 msgid "" "The concepts of ownership and transfer apply just as well to reference " "counted types as they do to allocated types. A scope owns a " "reference counted type if it holds a strong reference to the instance (for " "example by calling g_object_ref()). An instance can be ‘copied’ by calling g_object_ref() again. Ownership can be freed with " "g_object_unref() — even though this may not actually " "finalize the instance, it frees the current scope’s ownership of that " "instance." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:569 msgid "" "See for a convenient way of handling " "GObject references." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:574 msgid "" "There are other reference counted types in GLib, such as " "GHashTable (using " "g_hash_table_ref() and " "g_hash_table_unref()), or GVariant " "( g_variant_ref(), " "g_variant_unref()). Some types, like GHashTable, support both reference counting and explicit finalization. Reference " "counting should always be used in preference, because it allows instances to " "be easily shared between multiple scopes (each holding their own reference) " "without having to allocate multiple copies of the instance. This saves " "memory." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:596 msgid "Floating References" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:598 msgid "" "Classes which are derived from GInitiallyUnowned, as opposed to GObject have an initial reference which is " "floating, meaning that no code owns the reference. As soon as g_object_ref_sink() is " "called on the object, the floating reference is converted to a strong " "reference, and the calling code assumes ownership of the object." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:610 msgid "" "Floating references are a convenience for use in C in APIs, such as GTK+, " "where large numbers of objects must be created and organized into a " "hierarchy. In these cases, calling g_object_unref() to drop all " "the strong references would result in a lot of code." msgstr "" #. (itstool) path: example/p #: C/memory-management.page:618 msgid "Floating references allow the following code to be simplified:" msgstr "" #. (itstool) path: example/code #: C/memory-management.page:621 #, no-wrap msgid "" "GtkWidget *new_widget;\n" "\n" "new_widget = gtk_some_widget_new ();\n" "gtk_container_add (some_container, new_widget);\n" "g_object_unref (new_widget);" msgstr "" #. (itstool) path: example/p #: C/memory-management.page:627 msgid "" "Instead, the following code can be used, with the GtkContainer " "assuming ownership of the floating reference:" msgstr "" #. (itstool) path: example/code #: C/memory-management.page:632 #, no-wrap msgid "" "\n" "gtk_container_add (some_container, gtk_some_widget_new ());" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:636 msgid "" "Floating references are only used by a few APIs — in particular, " "GtkWidget and all its subclasses. You must learn which APIs " "support it, and which APIs consume floating references, and only use them " "together." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:643 msgid "" "Note that g_object_ref_sink() is equivalent to " "g_object_ref() when called on a non-floating reference, making " "gtk_container_add() no different from any other function in " "such cases." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:650 msgid "" "See the GObject manual for more " "information on floating references." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:658 msgid "Convenience Functions" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:660 msgid "" "GLib provides various convenience functions for memory management, " "especially for GObjects. Three will be covered here, but others exist — " "check the GLib API documentation for more. They typically follow similar " "naming schemas to these three (using ‘_full’ suffixes, or the verb ‘clear’ " "in the function name)." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:669 msgid "g_clear_object()" msgstr "g_clear_object()" #. (itstool) path: section/p #: C/memory-management.page:671 msgid "" " g_clear_object() is a " "version of g_object_unref() which unrefs a GObject and then clears the pointer to it to " "NULL." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:679 msgid "" "This makes it easier to implement code that guarantees a GObject pointer is " "always either NULL, or has ownership of a GObject (but which " "never points to a GObject it no longer owns)." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:685 msgid "" "By initialising all owned GObject pointers to NULL, freeing " "them at the end of the scope is as simple as calling g_clear_object() without any checks, as discussed in :" msgstr "" #. (itstool) path: section/code #: C/memory-management.page:691 #, no-wrap msgid "" "void\n" "my_function (void)\n" "{\n" " GObject *some_object = NULL; /* owned */\n" "\n" " if (rand ())\n" " {\n" " some_object = create_new_object ();\n" " /* do something with the object */\n" " }\n" "\n" " g_clear_object (&some_object);\n" "}" msgstr "" #. (itstool) path: section/title #: C/memory-management.page:707 msgid "g_list_free_full()" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:709 msgid "" " g_list_free_full() frees " "all the elements in a linked list, and all their data. It is much " "more convenient than iterating through the list to free all the elements’ " "data, then calling g_list_free() to " "free the GList elements themselves." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:721 msgid "g_hash_table_new_full()" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:723 msgid "" " g_hash_table_new_full() is a " "newer version of g_hash_table_new() " "which allows setting functions to destroy each key and value in the hash " "table when they are removed. These functions are then automatically called " "for all keys and values when the hash table is destroyed, or when an entry " "is removed using g_hash_table_remove()." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:734 msgid "" "Essentially, it simplifies memory management of keys and values to the " "question of whether they are present in the hash table. See for a discussion on ownership of elements within " "container types." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:741 msgid "" "A similar function exists for GPtrArray: g_ptr_array_new_with_free_func()." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:750 #, fuzzy msgid "Container Types" msgstr "O contêiner não existe" #. (itstool) path: section/p #: C/memory-management.page:752 msgid "" "When using container types, such as GPtrArray or GList, an additional level of ownership is introduced: as well as the " "ownership of the container instance, each element in the container is either " "owned or unowned too. By nesting containers, multiple levels of ownership " "must be tracked. Ownership of owned elements belongs to the container; " "ownership of the container belongs to the scope it’s in (which may be " "another container)." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:762 msgid "" "A key principle for simplifying this is to ensure that all elements in a " "container have the same ownership: they are either all owned, or all " "unowned. This happens automatically if the normal are used for types like GPtrArray and " "GHashTable." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:770 msgid "" "If elements in a container are owned, adding them to the container " "is essentially an ownership transfer. For example, for an array of strings, " "if the elements are owned, the definition of g_ptr_array_add() " "is effectively:" msgstr "" #. (itstool) path: section/code #: C/memory-management.page:776 #, no-wrap msgid "" "/**\n" " * g_ptr_array_add:\n" " * @array: a #GPtrArray\n" " * @str: (transfer full): string to add\n" " */\n" "void\n" "g_ptr_array_add (GPtrArray *array,\n" " gchar *str);" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:785 msgid "" "So, for example, constant (unowned) strings must be added to the array using " "g_ptr_array_add (array, g_strdup (\"constant string\"))." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:790 msgid "Whereas if the elements are unowned, the definition is effectively:" msgstr "" #. (itstool) path: section/code #: C/memory-management.page:793 #, no-wrap msgid "" "/**\n" " * g_ptr_array_add:\n" " * @array: a #GPtrArray\n" " * @str: (transfer none): string to add\n" " */\n" "void\n" "g_ptr_array_add (GPtrArray *array,\n" " const gchar *str);" msgstr "" #. (itstool) path: section/p #: C/memory-management.page:802 msgid "" "Here, constant strings can be added without copying them: " "g_ptr_array_add (array, \"constant string\")." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:807 msgid "" "See for examples of comments to add to " "variable definitions to annotate them with the element type and ownership." msgstr "" #. (itstool) path: section/title #: C/memory-management.page:814 #, fuzzy msgid "Single-Path Cleanup" msgstr "Limpeza concluída" #. (itstool) path: section/p #: C/memory-management.page:816 msgid "" "A useful design pattern for more complex functions is to have a single " "control path which cleans up (frees) allocations and returns to the caller. " "This vastly simplifies tracking of allocations, as it’s no longer necessary " "to mentally work out which allocations have been freed on each code path — " "all code paths end at the same point, so perform all the frees then. The " "benefits of this approach rapidly become greater for larger functions with " "more owned local variables; it may not make sense to apply the pattern to " "smaller functions." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:827 #, fuzzy msgid "This approach has two requirements:" msgstr "Um vetor tem dois propósitos principais:" #. (itstool) path: item/p #: C/memory-management.page:831 msgid "" "The function returns from a single point, and uses goto to " "reach that point from other paths." msgstr "" #. (itstool) path: item/p #: C/memory-management.page:835 msgid "" "All owned variables are set to NULL when initialized or when " "ownership is transferred away from them." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:841 msgid "" "The example below is for a small function (for brevity), but should " "illustrate the principles for application of the pattern to larger functions:" msgstr "" #. (itstool) path: listing/title #: C/memory-management.page:848 #, fuzzy msgid "Single-Path Cleanup Example" msgstr "Exemplo de caminho: " #. (itstool) path: listing/desc #: C/memory-management.page:849 msgid "Example of implementing single-path cleanup for a simple function" msgstr "" #. (itstool) path: listing/code #: C/memory-management.page:852 #, no-wrap msgid "" "GObject *\n" "some_function (GError **error)\n" "{\n" " gchar *some_str = NULL; /* owned */\n" " GObject *temp_object = NULL; /* owned */\n" " const gchar *temp_str;\n" " GObject *my_object = NULL; /* owned */\n" " GError *child_error = NULL; /* owned */\n" "\n" " temp_object = generate_object ();\n" " temp_str = \"example string\";\n" "\n" " if (rand ())\n" " {\n" " some_str = g_strconcat (temp_str, temp_str, NULL);\n" " }\n" " else\n" " {\n" " some_operation_which_might_fail (&child_error);\n" "\n" " if (child_error != NULL)\n" " {\n" " goto done;\n" " }\n" "\n" " my_object = generate_wrapped_object (temp_object);\n" " }\n" "\n" "done:\n" " /* Here, @some_str is either NULL or a string to be freed, so can be passed to\n" " * g_free() unconditionally.\n" " *\n" " * Similarly, @temp_object is either NULL or an object to be unreffed, so can\n" " * be passed to g_clear_object() unconditionally. */\n" " g_free (some_str);\n" " g_clear_object (&temp_object);\n" "\n" " /* The pattern can also be used to ensure that the function always returns\n" " * either an error or a return value (but never both). */\n" " if (child_error != NULL)\n" " {\n" " g_propagate_error (error, child_error);\n" " g_clear_object (&my_object);\n" " }\n" "\n" " return my_object;\n" "}" msgstr "" #. (itstool) path: section/title #: C/memory-management.page:903 #, fuzzy msgid "Verification" msgstr "Digite o código de verificação:" #. (itstool) path: section/p #: C/memory-management.page:905 msgid "" "Memory leaks can be checked for in two ways: static analysis, and runtime " "leak checking." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:910 msgid "" "Static analysis with tools like Coverity, the Clang static " "analyzer or Tartan can catch " "some leaks, but require knowledge of the ownership transfer of every " "function called in the code. Domain-specific static analyzers like Tartan " "(which knows about GLib memory allocation and transfer) can perform better " "here, but Tartan is quite a young project and still misses things (a low " "true positive rate). It is recommended that code be put through a static " "analyzer, but the primary tool for detecting leaks should be runtime leak " "checking." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:924 msgid "" "Runtime leak checking is done using Valgrind, using its memcheck tool. Any leak it detects as ‘definitely losing memory’ should be " "fixed. Many of the leaks which ‘potentially’ lose memory are not real leaks, " "and should be added to the suppression file." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:933 msgid "" "If compiling with a recent version of Clang or GCC, the address sanitizer can be enabled " "instead, and it will detect memory leaks and overflow problems at runtime, " "but without the difficulty of running Valgrind in the right environment. " "Note, however, that it is still a young tool, so may fail in some cases." msgstr "" #. (itstool) path: section/p #: C/memory-management.page:942 msgid "" "See for more information on using Valgrind." msgstr "" #. (itstool) path: credit/years #: C/namespacing.page:12 #, fuzzy msgid "2015, 2016" msgstr "2015, 2016" #. (itstool) path: info/desc #: C/namespacing.page:17 msgid "Avoiding symbol conflicts between libraries by namespacing all APIs" msgstr "" "Evite conflitos de símbolos entre bibliotecas atribuindo espaço de nomes a " "todas APIs" #. (itstool) path: page/title #: C/namespacing.page:22 msgid "Namespacing" msgstr "Espaço de nomes" #. (itstool) path: synopsis/p #: C/namespacing.page:27 msgid "" "If a library is namespaced correctly, it can define types and methods in its " "API which have the same names as those in another library, and a program can " "use both without conflicts. This is achieved by prefixing all types and " "method names with a namespace unique to the library." msgstr "" #. (itstool) path: section/title #: C/namespacing.page:36 msgid "GObject APIs" msgstr "" #. (itstool) path: section/p #: C/namespacing.page:38 msgid "" "Consistent and complete namespacing of symbols (functions and types) and " "files is important for two key reasons:" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:43 msgid "" "Establishing a convention which means developers have to learn fewer symbol " "names to use the library — they can guess them reliably instead." msgstr "" #. (itstool) path: item/p #: C/namespacing.page:47 msgid "" "Ensuring symbols from two projects do not conflict if included in the same " "file." msgstr "" #. (itstool) path: section/p #: C/namespacing.page:53 msgid "" "The second point is important — imagine what would happen if every project " "exported a function called create_object(). The headers " "defining them could not be included in the same file, and even if that were " "overcome, the programmer would not know which project each function comes " "from. Namespacing eliminates these problems by using a unique, consistent " "prefix for every symbol and filename in a project, grouping symbols into " "their projects and separating them from others." msgstr "" #. (itstool) path: section/p #: C/namespacing.page:63 msgid "" "The conventions below should be used for namespacing all symbols. They are " " used in all GLib-based projects, so should be familiar to a " "lot of developers:" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:70 msgid "Functions should use lower_case_with_underscores." msgstr "" #. (itstool) path: item/p #: C/namespacing.page:73 msgid "" "Structures, types and objects should use CamelCaseWithoutUnderscores." msgstr "" #. (itstool) path: item/p #: C/namespacing.page:77 msgid "" "Macros and constants should use UPPER_CASE_WITH_UNDERSCORES." msgstr "" #. (itstool) path: item/p #: C/namespacing.page:81 msgid "" "All symbols should be prefixed with a short (2–4 characters) version of the " "namespace. This is shortened purely for ease of typing, but should still be " "unique." msgstr "" #. (itstool) path: item/p #: C/namespacing.page:86 msgid "All methods of a class should also be prefixed with the class name." msgstr "" #. (itstool) path: section/p #: C/namespacing.page:91 msgid "" "Additionally, public headers should be included from a subdirectory, " "effectively namespacing the header files. For example, instead of " "#include <abc.h>, a project should allow its users to use " "#include <namespace/abc.h>." msgstr "" #. (itstool) path: section/p #: C/namespacing.page:98 msgid "" "Some projects namespace their headers within this subdirectory — for " "example, #include <namespace/ns-abc.h> instead of " "#include <namespace/abc.h>. This is redundant, but " "harmless." msgstr "" #. (itstool) path: section/p #: C/namespacing.page:105 msgid "" "For example, for a project called ‘Walbottle’, the short namespace ‘Wbl’ " "would be chosen. If it has a ‘schema’ class and a ‘writer’ class, it would " "install headers:" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:111 msgid "" "$(includedir)/walbottle-$API_MAJOR/walbottle/" "schema.h" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:114 msgid "" "$(includedir)/walbottle-$API_MAJOR/walbottle/" "writer.h" msgstr "" #. (itstool) path: section/p #: C/namespacing.page:119 msgid "" "(The use of $API_MAJOR above is for parallel installability.)" msgstr "" #. (itstool) path: section/p #: C/namespacing.page:124 msgid "" "For the schema class, the following symbols would be exported (amongst " "others), following GObject conventions:" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:129 #, fuzzy msgid "WblSchema structure" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/namespacing.page:130 #, fuzzy msgid "WblSchemaClass structure" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/namespacing.page:131 msgid "WBL_TYPE_SCHEMA macro" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:132 #, fuzzy msgid "WBL_IS_SCHEMA macro" msgstr "Esta macro gera o código de inicialização para a interface." #. (itstool) path: item/p #: C/namespacing.page:133 msgid "wbl_schema_get_type function" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:134 msgid "wbl_schema_new function" msgstr "" #. (itstool) path: item/p #: C/namespacing.page:135 msgid "wbl_schema_load_from_data function" msgstr "" #. (itstool) path: credit/name #: C/parallel-installability.page:10 msgid "Havoc Pennington" msgstr "Havoc Pennington" #. (itstool) path: credit/years #: C/parallel-installability.page:12 msgid "2002" msgstr "2002" #. (itstool) path: info/desc #: C/parallel-installability.page:25 msgid "Writing libraries to be future proof through parallel installation" msgstr "" "Escrevendo bibliotecas para serem a prova de futuro por meio de instalação " "paralela" #. (itstool) path: page/title #: C/parallel-installability.page:30 msgid "Parallel Installability" msgstr "Instabilidade paralela" #. (itstool) path: synopsis/p #: C/parallel-installability.page:35 msgid "" "If two packages can be parallel installed, then they have no filenames in " "common, and people developing against the package always compile against the " "version they expected. This applies to daemons, utility programs and " "configuration files as it does to header files and library binaries." msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:43 msgid "" "Ensure all versions of a library are parallel installable. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:47 msgid "Version all files installed by a library. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:51 msgid "" "Keep package version numbers separate from soname or libtool version " "numbers. Be clear which part of the package version number changes with the " "API. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:57 msgid "" "Install C header files to $(includedir)/liblibrary-version/library/. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:62 msgid "" "Install library binaries to $(libdir)/liblibrary-" "version.so.soname. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:67 msgid "" "Install pkg-config files to $(libdir)/pkgconfig/" "library-version.pc. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:72 msgid "" "Make configuration files forwards and backwards compatible, or install them " "to $(sysconfdir)/library-version/. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:78 msgid "" "Set GETTEXT_PACKAGE to library-version. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:83 msgid "" "Include a version number in all D-Bus interface names, service names and " "object paths. For example: org.domain.LibraryVersion.Interface, org.domain.LibraryVersion and /org/domain/LibraryVersion/. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:91 msgid "" "Install daemon binaries to $(libexecdir)/library-" "daemon-version. ()" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:96 msgid "" "Install utility binaries to $(bindir)/library-" "utility-version and install symbolic links to " "$(bindir)/library-utility. ()" msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:106 msgid "Justification" msgstr "Justificação" #. (itstool) path: section/p #: C/parallel-installability.page:108 msgid "" "All public libraries should be designed to be parallel installed to ease API " "breaks later in the life of the library. If a library is used by multiple " "projects, and wants to break API, either all of the projects must be ported " "to the new API in parallel, or some of them will no longer be installable at " "the same time as the others, due to depending on conflicting versions of " "this library." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:117 msgid "" "This is unmaintainable, and asking all the projects to port to a new API at " "the same time is hard to organize and demoralizing, as most API breaks do " "not bring large new features which would motivate porting." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:123 msgid "" "The solution is to ensure that all libraries are parallel installable, " "allowing the old and new versions of the API to be installed and compiled " "against at the same time, without conflicts. Building in support for this " "kind of parallel installation is much easier to do at the start of a project " "than it is to do retroactively." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:131 msgid "" "This eliminates the ‘chicken and egg’ problem of porting a collection of " "applications from one version of a library to the next, and makes breaking " "API a lot simpler for library maintainers, which can allow for more rapid " "iteration and development of new features if they desire." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:138 msgid "" "The alternative, and equally valid, solution is for the library to never " "break API — the approach taken by libc." msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:145 #, fuzzy msgid "Solution" msgstr "Solução:" #. (itstool) path: section/p #: C/parallel-installability.page:147 msgid "" "The solution to the problem is essentially to rename the library, and in " "most cases the nicest way to do so is to include the version number in the " "path of every file it installs. This means multiple versions of the library " "can be installed at the same time." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:154 msgid "" "For example, say that library Foo traditionally installs these " "files:" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:159 C/parallel-installability.page:284 #, fuzzy msgid "/usr/include/foo.h" msgstr "Incluir um arquivo - \\input" #. (itstool) path: item/p #: C/parallel-installability.page:160 msgid "/usr/include/foo-utils.h" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:161 msgid "/usr/lib/libfoo.so" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:162 msgid "/usr/lib/pkgconfig/foo.pc" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:163 msgid "/usr/share/doc/foo/foo-manual.txt" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:164 msgid "/usr/bin/foo-utility" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:167 msgid "" "You might modify Foo version 4 to install these files instead:" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:172 C/parallel-installability.page:261 msgid "/usr/include/foo-4/foo/foo.h" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:173 msgid "/usr/include/foo-4/foo/utils.h" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:174 C/parallel-installability.page:338 msgid "/usr/lib/libfoo-4.so" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:175 C/parallel-installability.page:397 msgid "/usr/lib/pkgconfig/foo-4.pc" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:176 msgid "/usr/share/doc/foo-4/foo-manual.txt" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:177 msgid "/usr/bin/foo-utility-4" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:180 msgid "It could then be parallel installed with version 5:" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:184 C/parallel-installability.page:262 msgid "/usr/include/foo-5/foo/foo.h" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:185 msgid "/usr/include/foo-5/foo/utils.h" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:186 C/parallel-installability.page:339 msgid "/usr/lib/libfoo-5.so" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:187 C/parallel-installability.page:398 msgid "/usr/lib/pkgconfig/foo-5.pc" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:188 msgid "/usr/share/doc/foo-5/foo-manual.txt" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:189 msgid "/usr/bin/foo-utility-5" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:192 msgid "" "This is easily supported using pkg-config: foo-4.pc " "would add /usr/include/foo-4 to the include path and " "libfoo-4.so to the list of libraries to link; foo-5.pc would add /usr/include/foo-5 and libfoo-5.so." msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:204 #, fuzzy msgid "Version Numbers" msgstr "" " --sort=PALAVRA ordena conforme PALAVRA:\n" " general-numeric -g (numérico geral),\n" " human-numeric -h (numérico humano),\n" " month -M (mês), numeric -n (numérico),\n" " random -R (aleatório), version -V (versão)\n" " -V, --version-sort ordem natural de números (de versão) com " "texto\n" "\n" #. (itstool) path: section/p #: C/parallel-installability.page:206 msgid "" "The version number that goes in filenames is an ABI/API version. It " "should not be the full version number of your package — just the part which " "signifies an API break. If using the standard major." "minor.micro scheme for project versioning, the " "API version is typically the major version number." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:214 msgid "" "Minor releases (typically where API is added but not changed or " "removed) and micro releases (typically bug fixes) do not affect API backwards compatibility so do not require " "moving all the files." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:221 msgid "" "The examples in the following sections assume that the API version and " "soname are exported from configure.ac using the following code:" msgstr "" #. (itstool) path: listing/title #: C/parallel-installability.page:227 #, fuzzy msgid "API Versioning in Autoconf" msgstr "Versionamento" #. (itstool) path: listing/desc #: C/parallel-installability.page:228 msgid "" "Code to export the API version and soname from configure.ac" msgstr "" #. (itstool) path: listing/code #: C/parallel-installability.page:231 #, no-wrap msgid "" "# Before making a release, the LIBRARY_LT_VERSION string should be modified.\n" "# The string is of the form c:r:a. Follow these instructions sequentially:\n" "#\n" "# 1. If the library source code has changed at all since the last update,\n" "# then increment revision (‘c:r:a’ becomes ‘c:r+1:a’).\n" "# 2. If any interfaces have been added, removed, or changed since the last update,\n" "# increment current, and set revision to 0.\n" "# 3. If any interfaces have been added since the last public release,\n" "# then increment age.\n" "# 4. If any interfaces have been removed or changed since the last public release,\n" "# then set age to 0.\n" "AC_SUBST([LIBRARY_LT_VERSION],[1:0:0])\n" "\n" "AC_SUBST([LIBRARY_API_VERSION],[4])" msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:249 #, fuzzy msgid "C Header Files" msgstr "Permuta entre o arquivo cabeçalho e o fonte" #. (itstool) path: section/p #: C/parallel-installability.page:251 msgid "" "Header files should always be installed in a versioned subdirectory that " "requires an -I flag to the C compiler. For example, if my header " "is foo.h, and applications do this:" msgstr "" #. (itstool) path: section/code #: C/parallel-installability.page:256 #, fuzzy, no-wrap msgid "#include <foo/foo.h>" msgstr "#include <gtkmm.h>" #. (itstool) path: section/p #: C/parallel-installability.page:257 #, fuzzy msgid "then I should install these files:" msgstr "então Eu deveria instalar esses arquivos:" #. (itstool) path: section/p #: C/parallel-installability.page:265 msgid "" "Applications should pass the flag -I/usr/include/foo-4 or -I/" "usr/include/foo-5 to the C compiler. Again, this is facilitated by " "using pkg-config." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:271 msgid "" "Note the extra foo/ subdirectory. This namespaces the #include to avoid file naming collisions with " "other libraries. For example, if two different libraries install headers " "called utils.h, which one gets included when you use #include <utils.h>?" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:279 msgid "" "There’s some temptation to keep one of the header files outside of any " "subdirectory:" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:285 msgid "/usr/include/foo-5/foo.h" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:288 msgid "" "The problem there is that users are always accidentally getting the wrong " "header, since -I/usr/include seems to find its way onto compile " "command lines with some regularity. If you must do this, at least add a " "check to the library that detects applications using the wrong header file " "when the library is initialized." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:296 msgid "" "Versioned header files can be installed from automake using the following " "code:" msgstr "" #. (itstool) path: listing/title #: C/parallel-installability.page:301 #, fuzzy msgid "Header Files in Automake" msgstr "Arquivos de cabeçalho" #. (itstool) path: listing/desc #: C/parallel-installability.page:302 msgid "Code to install versioned header files from Makefile.am" msgstr "" #. (itstool) path: listing/code #: C/parallel-installability.page:305 #, no-wrap msgid "" "libraryincludedir = $(includedir)/liblibrary-@LIBRARY_API_VERSION@/library\n" "library_headers = \\\n" "\tliblibrary/example1.h \\\n" "\tliblibrary/example2.h \\\n" "\t$(NULL)\n" "\n" "# The following headers are private, and shouldn't be installed:\n" "private_headers = \\\n" "\tliblibrary/example-private.h \\\n" "\t$(NULL)\n" "# The main header simply #includes all other public headers:\n" "main_header = liblibrary/library.h\n" "public_headers = \\\n" "\t$(main_header) \\\n" "\t$(library_headers) \\\n" "\t$(NULL)\n" "\n" "libraryinclude_HEADERS = $(public_headers)" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:325 msgid "" "As well as correct versioning, all APIs in installed headers should be namespaced correctly." msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:332 msgid "Libraries" msgstr "Bibliotecas" #. (itstool) path: section/p #: C/parallel-installability.page:334 msgid "Library object files should have a versioned name. For example:" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:342 msgid "" "This allows applications to get exactly the one they want at compile time, " "and ensures that versions 4 and 5 have no files in common." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:347 msgid "" "Versioned libraries can be built and installed from automake using the " "following code:" msgstr "" #. (itstool) path: listing/title #: C/parallel-installability.page:352 #, fuzzy msgid "Libraries in Automake" msgstr "Automake" #. (itstool) path: listing/desc #: C/parallel-installability.page:353 msgid "" "Code to build and install versioned libraries from Makefile.am" msgstr "" #. (itstool) path: listing/code #: C/parallel-installability.page:357 #, no-wrap msgid "" "lib_LTLIBRARIES = liblibrary/liblibrary-@LIBRARY_API_VERSION@.la\n" "\n" "liblibrary_liblibrary_@LIBRARY_API_VERSION@_la_SOURCES = \\\n" "\t$(private_headers) \\\n" "\t$(library_sources) \\\n" "\t$(NULL)\n" "liblibrary_liblibrary_@LIBRARY_API_VERSION@_la_CPPFLAGS = …\n" "liblibrary_liblibrary_@LIBRARY_API_VERSION@_la_CFLAGS = …\n" "liblibrary_liblibrary_@LIBRARY_API_VERSION@_la_LIBADD = …\n" "liblibrary_liblibrary_@LIBRARY_API_VERSION@_la_LDFLAGS = \\\n" "\t-version-info $(LIBRARY_LT_VERSION) \\\n" "\t$(AM_LDFLAGS) \\\n" "\t$(NULL)" msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:373 #, fuzzy msgid "Library sonames" msgstr "Biblioteca" #. (itstool) path: section/p #: C/parallel-installability.page:375 msgid "" "Library sonames (also known as libtool version numbers) only address the " "problem of runtime linking previously-compiled applications. They don’t " "address the issue of compiling applications that require a previous version, " "and they don’t address anything other than libraries." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:382 msgid "" "For this reason, sonames should be used, but in addition to " "versioned names for libraries. The two solutions address different problems." msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:391 msgid "pkg-config Files" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:393 msgid "pkg-config files should have a versioned name. For example:" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:401 msgid "" "Since each pkg-config file contains versioned information about the library " "name and include paths, any project which depends on the library should be " "able to switch from one version to another simply by changing their pkg-" "config check from foo-4 to foo-5 (and doing any " "necessary API porting)." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:409 msgid "" "Versioned pkg-config files can be installed from autoconf and automake using " "the following code:" msgstr "" #. (itstool) path: listing/title #: C/parallel-installability.page:414 msgid "pkg-config Files in Autoconf and Automake" msgstr "" #. (itstool) path: listing/desc #: C/parallel-installability.page:415 msgid "" "Code to install versioned pkg-config files from configure.ac " "and Makefile.am" msgstr "" #. (itstool) path: listing/code #: C/parallel-installability.page:420 #, no-wrap msgid "" "AC_CONFIG_FILES([\n" "liblibrary/library-$LIBRARY_API_VERSION.pc:liblibrary/library.pc.in\n" "],[],\n" "[LIBRARY_API_VERSION='$LIBRARY_API_VERSION'])" msgstr "" #. (itstool) path: listing/code #: C/parallel-installability.page:425 #, no-wrap msgid "" "# Note that the template file is called library.pc.in, but generates a\n" "# versioned .pc file using some magic in AC_CONFIG_FILES.\n" "pkgconfigdir = $(libdir)/pkgconfig\n" "pkgconfig_DATA = liblibrary/library-$(LIBRARY_API_VERSION).pc\n" "\n" "DISTCLEANFILES += $(pkgconfig_DATA)\n" "EXTRA_DIST += liblibrary/library.pc.in" msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:436 #, fuzzy msgid "Configuration Files" msgstr "Removendo arquivos de configuração…" #. (itstool) path: section/p #: C/parallel-installability.page:438 msgid "" "From a user standpoint, the best approach to configuration files is to keep " "the format both forward and backward " "compatible (both library versions understand exactly the same " "configuration file syntax and semantics). Then the same configuration file " "can be used for all versions of the library, and no versioning is needed on " "the configuration file itself." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:448 msgid "" "If you can’t do that, the configuration files should simply be renamed, and " "users will have to configure each version of the library separately." msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:455 #, fuzzy msgid "Gettext Translations" msgstr "Sem traduções" #. (itstool) path: section/p #: C/parallel-installability.page:457 msgid "" "If you use gettext for translations in combination with autoconf and " "automake, normally things are set up to install the translations to /" "usr/share/locale/lang/LC_MESSAGES/package. " "You’ll need to change package. The convention used in GNOME is to " "put this in configure.ac:" msgstr "" #. (itstool) path: section/code #: C/parallel-installability.page:465 #, no-wrap msgid "" "GETTEXT_PACKAGE=foo-4\n" "AC_SUBST([GETTEXT_PACKAGE])\n" "AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],[\"$GETTEXT_PACKAGE\"])" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:469 msgid "" "Then use GETTEXT_PACKAGE as the package name to pass to bindtextdomain(), textdomain(), and dgettext()." msgstr "" #. (itstool) path: section/title #: C/parallel-installability.page:482 #, fuzzy msgid "D-Bus Interfaces" msgstr "" "Fornece interfaces de D-Bus para consultar e manipular\n" "informações de conta de usuário." #. (itstool) path: section/p #: C/parallel-installability.page:484 msgid "" "A D-Bus interface is another form of API, similar to a C API except that " "resolution of the version is done at runtime rather than compile time. " "Versioning D-Bus interfaces is otherwise no different to C APIs: version " "numbers must be included in interface names, service names and object paths." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:492 msgid "" "For example, for a service org.example.Foo exposing interfaces " "A and B on objects Controller and " "Client, versions 4 and 5 of the D-Bus API would look like this:" msgstr "" #. (itstool) path: list/title #: C/parallel-installability.page:499 #, fuzzy msgid "Service Names" msgstr "Nomes:" #. (itstool) path: item/p #: C/parallel-installability.page:500 #, fuzzy msgid "org.example.Foo4" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:501 #, fuzzy msgid "org.example.Foo5" msgstr "O código {code} é inválido." #. (itstool) path: list/title #: C/parallel-installability.page:504 #, fuzzy msgid "Interface Names" msgstr "Os nomes de interface do dispositivo e a conexão não correspondem." #. (itstool) path: item/p #: C/parallel-installability.page:505 #, fuzzy msgid "org.example.Foo4.InterfaceA" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:506 #, fuzzy msgid "org.example.Foo4.InterfaceB" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:507 #, fuzzy msgid "org.example.Foo5.InterfaceA" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:508 #, fuzzy msgid "org.example.Foo5.InterfaceB" msgstr "O código {code} é inválido." #. (itstool) path: list/title #: C/parallel-installability.page:511 #, fuzzy msgid "Object Paths" msgstr "" "Uma matriz de caminho de objeto pode conter qualquer número de caminhos de " "objeto (incluindo nenhum: \"[]\").\n" "\n" "Se você não está interagindo com D-Bus, então não há motivo para fazer uso " "deste tipo." #. (itstool) path: item/p #: C/parallel-installability.page:512 #, fuzzy msgid "/org/example/Foo4/Controller" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:513 #, fuzzy msgid "/org/example/Foo4/Client" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:514 #, fuzzy msgid "/org/example/Foo5/Controller" msgstr "O código {code} é inválido." #. (itstool) path: item/p #: C/parallel-installability.page:515 #, fuzzy msgid "/org/example/Foo5/Client" msgstr "O código {code} é inválido." #. (itstool) path: section/title #: C/parallel-installability.page:527 #, fuzzy msgid "Programs, Daemons and Utilities" msgstr "_Utilidades" #. (itstool) path: section/p #: C/parallel-installability.page:529 msgid "" "Desktop applications generally do not need to be versioned, as they are not " "depended on by any other modules. Daemons and utility programs, however, " "interact with other parts of the system and hence need versioning." msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:536 #, fuzzy msgid "Given a daemon and utility program:" msgstr "Nenhum nome de programa dado\\n" #. (itstool) path: item/p #: C/parallel-installability.page:540 msgid "/usr/libexec/foo-daemon" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:541 msgid "/usr/bin/foo-lookup-utility" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:543 #, fuzzy msgid "these should be versioned as:" msgstr "Sem controle de _versão" #. (itstool) path: item/p #: C/parallel-installability.page:547 msgid "/usr/libexec/foo-daemon-4" msgstr "" #. (itstool) path: item/p #: C/parallel-installability.page:548 msgid "/usr/bin/foo-lookup-utility-4" msgstr "" #. (itstool) path: section/p #: C/parallel-installability.page:551 msgid "" "You may want to install a symbolic link from /usr/bin/foo-lookup-" "utility to the recommended versioned copy of the utility, to make it " "more convenient for users to use." msgstr "" #. (itstool) path: info/desc #: C/preconditions.page:18 msgid "Contract programming with checks on function input and output" msgstr "Contrate programação com verificações em função de entrada e saída" #. (itstool) path: page/title #. (itstool) path: section/title #: C/preconditions.page:21 C/preconditions.page:24 msgid "Pre- and Post-Conditions" msgstr "Pré e pós-condições" #. (itstool) path: section/p #: C/preconditions.page:26 msgid "" "An important part of secure coding is ensuring that incorrect data does not " "propagate far through code — the further some malicious input can propagate, " "the more code it sees, and the greater potential there is for an exploit to " "be possible." msgstr "" #. (itstool) path: section/p #: C/preconditions.page:33 msgid "" "A standard way of preventing the propagation of invalid data is to check all " "inputs to, and outputs from, all publicly visible functions in a library or " "module. There are two levels of checking:" msgstr "" #. (itstool) path: item/title #: C/preconditions.page:40 msgid "Assertions" msgstr "Asserções" #. (itstool) path: item/p #: C/preconditions.page:41 msgid "Check for programmer errors and abort the program on failure." msgstr "" #. (itstool) path: item/title #: C/preconditions.page:46 msgid "Validation" msgstr "Validação" #. (itstool) path: item/p #: C/preconditions.page:47 msgid "Check for invalid input and return an error gracefully on failure." msgstr "" #. (itstool) path: section/p #: C/preconditions.page:53 msgid "" "Validation is a complex topic, and is handled using GErrors. The remainder of this section discusses pre- and post-" "condition assertions, which are purely for catching programmer errors. A " "programmer error is where a function is called in a way which is documented " "as disallowed. For example, if NULL is passed to a parameter " "which is documented as requiring a non-NULL value to be passed; " "or if a negative value is passed to a function which requires a positive " "value. Programmer errors can happen on output too — for example, returning " "NULL when it is not documented to, or not setting a GError " "output when it fails." msgstr "" #. (itstool) path: section/p #: C/preconditions.page:67 msgid "" "Adding pre- and post-condition assertions to code is as much about ensuring " "the behavior of each function is correctly and completely documented as it " "is about adding the assertions themselves. All assertions should be " "documented, preferably by using the relevant introspection annotations, such as (nullable)." msgstr "" #. (itstool) path: section/p #: C/preconditions.page:76 msgid "" "Pre- and post-condition assertions are implemented using g_return_if_fail() and g_return_val_if_fail()." msgstr "" #. (itstool) path: section/p #: C/preconditions.page:83 msgid "" "The pre-conditions should check each parameter at the start of the function, " "before any other code is executed (even retrieving the private data " "structure from a GObject, for example, since the GObject pointer could be " "NULL). The post-conditions should check the return value and " "any output parameters at the end of the function — this requires a single " "return statement and use of goto to merge other " "control paths into it. See for an example." msgstr "" #. (itstool) path: info/desc #: C/threading.page:18 msgid "Moving computation out of the main thread into worker threads" msgstr "Movendo computação da thread principal para threads de trabalho" #. (itstool) path: page/title #: C/threading.page:21 msgid "Threading" msgstr "Threading" #. (itstool) path: item/p #: C/threading.page:27 msgid "" "Do not use threads if at all possible. ()" msgstr "" #. (itstool) path: item/p #: C/threading.page:31 msgid "" "If threads have to be used, use GTask or GThreadPool and isolate the threaded code as much as possible. ()" msgstr "" #. (itstool) path: item/p #: C/threading.page:37 msgid "" "Use g_thread_join() to avoid leaking thread resources if using " "GThread manually. ()" msgstr "" #. (itstool) path: item/p #: C/threading.page:42 msgid "" "Be careful about the GMainContext which code is executed in if " "using threads. Executing code in the wrong context can cause race " "conditions, or block the main loop. ()" msgstr "" #. (itstool) path: section/title #: C/threading.page:52 #, fuzzy msgid "When to Use Threading" msgstr "Usar encadeamento de mensagens" #. (itstool) path: section/p #: C/threading.page:54 msgid "" "When writing projects using GLib, the default approach should be to never use threads. Instead, make proper use of the " "GLib main context which, through the use " "of asynchronous operations, allows most blocking I/O operations to continue " "in the background while the main context continues to process other events. " "Analysis, review and debugging of threaded code becomes very hard, very " "quickly." msgstr "" #. (itstool) path: section/p #: C/threading.page:64 msgid "" "Threading should only be necessary when using an external library which has " "blocking functions which need to be called from GLib code. If the library " "provides a non-blocking alternative, or one which integrates with a poll() loop, that should be used in preference. If " "the blocking function really must be used, a thin wrapper should be written " "for it to convert it to the normal GAsyncResult style of " "GLib asynchronous function, running the blocking operation in a worker " "thread." msgstr "" #. (itstool) path: example/code #: C/threading.page:82 #, no-wrap msgid "" "\n" "int\n" "some_blocking_function (void *param1,\n" " void *param2);\n" msgstr "" #. (itstool) path: example/p #: C/threading.page:87 #, fuzzy msgid "Should be wrapped as:" msgstr "" "Essa opção define se linhas de texto longas demais devem ser quebradas." #. (itstool) path: example/code #: C/threading.page:90 #, no-wrap msgid "" "\n" "void\n" "some_blocking_function_async (void *param1,\n" " void *param2,\n" " GCancellable *cancellable,\n" " GAsyncReadyCallback callback,\n" " gpointer user_data);\n" "int\n" "some_blocking_function_finish (GAsyncResult *result,\n" " GError **error);\n" msgstr "" #. (itstool) path: example/p #: C/threading.page:102 #, fuzzy msgid "With an implementation something like:" msgstr "Isso faz com que ela se pareça com algo como isso:" #. (itstool) path: example/code #: C/threading.page:105 #, no-wrap msgid "" "/* Closure for the call’s parameters. */\n" "typedef struct {\n" " void *param1;\n" " void *param2;\n" "} SomeBlockingFunctionData;\n" "\n" "static void\n" "some_blocking_function_data_free (SomeBlockingFunctionData *data)\n" "{\n" " free_param (data->param1);\n" " free_param (data->param2);\n" "\n" " g_free (data);\n" "}\n" "\n" "static void\n" "some_blocking_function_thread_cb (GTask *task,\n" " gpointer source_object,\n" " gpointer task_data,\n" " GCancellable *cancellable)\n" "{\n" " SomeBlockingFunctionData *data = task_data;\n" " int retval;\n" "\n" " /* Handle cancellation. */\n" " if (g_task_return_error_if_cancelled (task))\n" " {\n" " return;\n" " }\n" "\n" " /* Run the blocking function. */\n" " retval = some_blocking_function (data->param1, data->param2);\n" " g_task_return_int (task, retval);\n" "}\n" "\n" "void\n" "some_blocking_function_async (void *param1,\n" " void *param2,\n" " GCancellable *cancellable,\n" " GAsyncReadyCallback callback,\n" " gpointer user_data)\n" "{\n" " GTask *task = NULL; /* owned */\n" " SomeBlockingFunctionData *data = NULL; /* owned */\n" "\n" " g_return_if_fail (validate_param (param1));\n" " g_return_if_fail (validate_param (param2));\n" " g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));\n" "\n" " task = g_task_new (NULL, cancellable, callback, user_data);\n" " g_task_set_source_tag (task, some_blocking_function_async);\n" "\n" " /* Cancellation should be handled manually using mechanisms specific to\n" " * some_blocking_function(). */\n" " g_task_set_return_on_cancel (task, FALSE);\n" "\n" " /* Set up a closure containing the call’s parameters. Copy them to avoid\n" " * locking issues between the calling thread and the worker thread. */\n" " data = g_new0 (SomeBlockingFunctionData, 1);\n" " data->param1 = copy_param (param1);\n" " data->param2 = copy_param (param2);\n" "\n" " g_task_set_task_data (task, data, some_blocking_function_data_free);\n" "\n" " /* Run the task in a worker thread and return immediately while that continues\n" " * in the background. When it’s done it will call @callback in the current\n" " * thread default main context. */\n" " g_task_run_in_thread (task, some_blocking_function_thread_cb);\n" "\n" " g_object_unref (task);\n" "}\n" "\n" "int\n" "some_blocking_function_finish (GAsyncResult *result,\n" " GError **error)\n" "{\n" " g_return_val_if_fail (g_task_is_valid (result,\n" " some_blocking_function_async), -1);\n" " g_return_val_if_fail (error == NULL || *error == NULL, -1);\n" "\n" " return g_task_propagate_int (G_TASK (result), error);\n" "}" msgstr "" #. (itstool) path: example/p #: C/threading.page:187 msgid "" "See the GAsyncResult documentation for more details. A simple " "way to implement the worker thread is to use GTask and g_task_run_in_thread(). (See also: .)" msgstr "" #. (itstool) path: section/title #: C/threading.page:200 #, fuzzy msgid "Using Threading" msgstr "Encadeamento _JWZ" #. (itstool) path: section/p #: C/threading.page:202 msgid "" "If GTask is not suitable for writing the worker thread, a more " "low-level approach must be used. This should be considered very carefully, " "as it is very easy to get threading code wrong in ways which will " "unpredictably cause bugs at runtime, cause deadlocks, or consume too many " "resources and terminate the program." msgstr "" #. (itstool) path: section/p #: C/threading.page:210 msgid "" "A full manual on writing threaded code is beyond the scope of this document, " "but here are a number of guidelines to follow which should reduce the " "potential for bugs in threading code. The overriding principle is to reduce " "the amount of code and data which can be affected by threading — for " "example, reducing the number of threads, the complexity of worker thread " "implementation, and the amount of data shared between threads." msgstr "" #. (itstool) path: item/p #: C/threading.page:222 msgid "" "Use GThreadPool instead of manually creating GThreads if possible. GThreadPool " "supports a work queue, limits on the number of spawned threads, and " "automatically joins finished threads so they are not leaked." msgstr "" #. (itstool) path: item/p #: C/threading.page:232 msgid "" "If it is not possible to use a GThreadPool (which is rarely the " "case):" msgstr "" #. (itstool) path: item/p #: C/threading.page:239 msgid "" "Use g_thread_try_new() to spawn threads, " "instead of g_thread_new(), so errors due to the " "system running out of threads can be handled gracefully rather than " "unconditionally aborting the program." msgstr "" #. (itstool) path: item/p #: C/threading.page:248 msgid "" "Explicitly join threads using g_thread_join() " "to avoid leaking the thread resources." msgstr "" #. (itstool) path: item/p #: C/threading.page:257 msgid "" "Use message passing to transfer data between threads, rather than manual " "locking with mutexes. GThreadPool explicitly supports this with " "g_thread_pool_push()." msgstr "" #. (itstool) path: item/p #: C/threading.page:265 #, fuzzy msgid "If mutexes must be used:" msgstr "--select deve ser usado com ao menos uma URI." #. (itstool) path: item/p #: C/threading.page:271 msgid "" "Isolate threading code as much as possible, keeping mutexes private within " "classes, and tightly bound to very specific class members." msgstr "" #. (itstool) path: item/p #: C/threading.page:278 msgid "" "All mutexes should be clearly commented beside their declaration, indicating " "which other structures or variables they protect access to. Similarly, those " "variables should be commented saying that they should only be " "accessed with that mutex held." msgstr "" #. (itstool) path: item/p #: C/threading.page:288 msgid "" "Be careful about interactions between main contexts and threads. For " "example, g_timeout_add_seconds() adds a timeout to be executed in the global default main " "context, which is being run in the main thread, not necessarily the current thread. Getting this wrong can mean that work intended for a " "worker thread accidentally ends up being executed in the main thread anyway. " "(See also: .)" msgstr "" #. (itstool) path: section/title #: C/threading.page:304 msgid "Debugging" msgstr "Depuração" #. (itstool) path: section/p #: C/threading.page:306 msgid "" "Debugging threading issues is tricky, both because they are hard to " "reproduce, and because they are hard to reason about. This is one of the big " "reasons for avoiding using threads in the first place." msgstr "" #. (itstool) path: section/p #: C/threading.page:312 msgid "" "However, if a threading issue does arise, Valgrind’s drd and helgrind tools are useful." msgstr "" #. (itstool) path: info/desc #: C/tooling.page:17 msgid "Using the right tool for various tasks" msgstr "Usando a ferramenta certa para várias tarefas" #. (itstool) path: page/title #: C/tooling.page:20 msgid "Tooling" msgstr "Ferramentas" #. (itstool) path: page/p #: C/tooling.page:22 msgid "" "Development tools are much more than just a text editor and a compiler. " "Correct use of the right tools can drastically ease debugging and tracking " "down of complex problems with memory allocation and system calls, amongst " "other things. Some of the most commonly used tools are described below; " "other tools exist for more specialized use cases, and should be used when " "appropriate." msgstr "" "Ferramentas de desenvolvimento são muito mais do que um editor de texto e um " "compilador. O uso correto das ferramentas certas pode facilitar " "drasticamente a depuração e o rastreamento de problemas complexos com " "alocação de memória e chamadas de sistema; além de outras coisas. Algumas " "das ferramentas mais comumente usadas são descritas abaixo; outras " "ferramentas existem para casos de uso mais especializados e devem ser usados " "quando apropriado." #. (itstool) path: page/p #: C/tooling.page:31 msgid "" "An overarching principle to use when developing is to always have as many " "debugging options enabled as possible, rather than keeping them disabled " "until near release time. By constantly testing code with all available debug " "tooling, bugs can be caught early on, before they become ingrained in code " "and thus harder to remove." msgstr "" "Um princípio geral a se usar quando se está desenvolvendo é sempre ter " "tantas opções de depuração habilitadas quanto possível, em vez de mantê-las " "desabilitadas até próximo da data de lançamento. Ao testar o código " "constantemente com todas as ferramentas de depuração disponível, erros podem " "ser encontrados desde cedo, antes que eles façam parte do código e, " "portanto, mais seja difícil de removê-los." #. (itstool) path: page/p #: C/tooling.page:39 msgid "" "Practically, this means having all compiler and other tool warnings enabled " "and set to fail the build process with an error if they are emitted." msgstr "" "Na prática, isso significa ter todos os avisos, do compilador e de outras " "ferramentas, habilitados e definidos para falhar no processo de compilação " "com um erro se forem emitidos." #. (itstool) path: item/p #: C/tooling.page:48 msgid "" "Compile frequently with a second compiler. ()" msgstr "" "Compile com frequência com um segundo compilador. ()" #. (itstool) path: item/p #: C/tooling.page:52 msgid "" "Enable a large selection of compiler warnings and make them fatal. ()" msgstr "" "Habilite uma seleção grande de avisos de compilador e faça-os falhar. ()" #. (itstool) path: item/p #: C/tooling.page:56 msgid "Use GDB to debug and step through code. ()" msgstr "Use GDB para depurar e passear pelo código. ()" #. (itstool) path: item/p #: C/tooling.page:59 msgid "" "Use Valgrind to analyze memory usage, memory errors, cache and CPU " "performance and threading errors. ()" msgstr "" "Use Valgrind para analisar o uso de memória, erros de memória, cache e " "desempenho da CPU e erros em threads. ()" #. (itstool) path: item/p #: C/tooling.page:63 msgid "" "Use gcov and lcov to analyze unit test coverage. ()" msgstr "" "Use gcov e lcov para analisar a cobertura de teste de unidade. ()" #. (itstool) path: item/p #: C/tooling.page:67 msgid "" "Use compiler sanitizers to analyze memory, thread and undefined behavior " "problems. ()" msgstr "" "Use sanitizadores de compilador para analisar problemas de memória, thread e " "comportamentos indefinidos. ()" #. (itstool) path: item/p #: C/tooling.page:71 msgid "" "Submit to Coverity as a cronjob and eliminate static analysis errors as they " "appear. ()" msgstr "" "Envie para Coverity como um cronjob e elimine erros de análise estática na " "medida em que eles aparecem. ()" #. (itstool) path: item/p #: C/tooling.page:75 msgid "" "Use Clang static analyzer and Tartan regularly to eliminate statically " "analysable errors locally. ()" msgstr "" "Use o analisador estático do Clang e o Tartan regularmente para eliminar " "localmente erros analisáveis estaticamente" #. (itstool) path: section/title #: C/tooling.page:83 msgid "GCC and Clang" msgstr "GCC e Clang" #. (itstool) path: section/p #: C/tooling.page:85 msgid "" "GCC is the " "standard C compiler for Linux. An alternative exists in the form of Clang, with " "comparable functionality. Choose one (probably GCC) to use as a main " "compiler, but occasionally use the other to compile the code, as the two " "detect slightly different sets of errors and warnings in code. Clang also " "comes with a static analyzer tool which can be used to detect errors in code " "without compiling or running it; see ." msgstr "" "GCC é o compilador " "C padrão para Linux. Existe uma alternativa na forma de Clang, com funcionalidade " "comparável. Escolha um (provavelmente GCC) para usar como compilador " "principal, mas ocasionalmente use o outro para compilar o código, já que os " "dois detectam um conjunto um pouco diferente de erros e avisos no código. " "Clang também vem com uma ferramenta de análise estática que pode ser usada " "para detectar erros no código sem precisar compilá-lo e executá-lo; veja " "." #. (itstool) path: section/p #: C/tooling.page:97 msgid "" "Both compilers should be used with as many warning flags enabled as " "possible. Although compiler warnings do occasionally provide false " "positives, most warnings legitimately point to problems in the code, and " "hence should be fixed rather than ignored. A development policy of enabling " "all warning flags and also specifying the -Werror flag (which " "makes all warnings fatal to compilation) promotes fixing warnings as soon as " "they are introduced. This helps code quality. The alternative of ignoring " "warnings leads to long debugging sessions to track down bugs caused by " "issues which would have been flagged up by the warnings. Similarly, ignoring " "warnings until the end of the development cycle, then spending a block of " "time enabling and fixing them all wastes time." msgstr "" "Ambos compiladores devem ser usados com tantos sinalizadores de avisos " "habilitados quanto possível. Apesar de avisos de compilador de vez em quando " "fornecerem falsos positivos, a maioria dos avisos legitimamente aponta para " "problemas no código e, portanto, devem ser corrigidos em vez de ignorados. " "Uma política de desenvolvimento de habilitar todos sinalizadores de avisos e " "também especificar o sinalizador -Werror (que torna todos os " "avisos em fatais para compilação) promove correção de avisos assim que forem " "introduzidos. Isso ajuda na qualidade do código. A alternativa de ignorar " "avisos leva a longas sessões de depuração para rastrear erros causados por " "problemas que teriam sido levantados pelos avisos. Similarmente, ignorar " "avisos até o fim do ciclo de desenvolvimento para, em um momento posterior, " "gastar um pedaço de tempo habilitando e corrigindo todos eles é uma perda de " "tempo." #. (itstool) path: section/p #: C/tooling.page:112 msgid "" "Both GCC and Clang support a wide range of compiler flags, only some of " "which are related to modern, multi-purpose code (for example, others are " "outdated or architecture-specific). Finding a reasonable set of flags to " "enable can be tricky, and hence the AX_COMPILER_FLAGS macro exists." msgstr "" "Ambos GCC e Clang oferecem suporte a um amplo alcance de sinalizadores de " "compilador, estando apenas alguns relacionados a um código moderno e " "multipropósito (por exemplo, outros estão desatualizados e são para alguma " "arquitetura específica). Encontrar um conjunto razoável de sinalizadores " "para habilitar pode ser complicado e por isto que a macro " "AX_COMPILER_FLAGS existe." #. (itstool) path: section/p #: C/tooling.page:121 msgid "" "AX_COMPILER_FLAGS enables a consistent set of compiler " "warnings, and also tests that the compiler supports each flag before " "enabling it. This accounts for differences in the set of flags supported by " "GCC and Clang. To use it, add AX_COMPILER_FLAGS to " "configure.ac. If you are using in-tree copies of autoconf-" "archive macros, copy " "ax_compiler_flags.m4 to the m4/ directory " "of your project. Note that it depends on the following autoconf-archive " "macros which are GPL-licenced so potentially cannot be copied in-tree. They " "may have to remain in autoconf-archive, with that as a build time dependency " "of the project:" msgstr "" "AX_COMPILER_FLAGS permite um conjunto consistente de avisos de " "compilador e também testa se o computador oferece suporte a cada sinalizador " "antes de habilitá-lo. Isso conta para diferenças no conjunto de " "sinalizadores aos quais GCC e Clang oferecem suporte. Para usá-lo, adicione " "AX_COMPILER_FLAGS ao configure.ac. Se você está " "usando cópias de macros autoconf-archive na árvore do projeto, copie ax_compiler_flags.m4 para o diretório m4/ deste. Note que ele depende das " "macros de autoconf-archive a seguir, as quais são licenciadas sob GPL e, " "portanto, potencialmente não podem ser copiadas para a árvore. Elas podem " "permanecer no autoconf-archive, com este como uma dependência de tempo de " "compilação do projeto:" #. (itstool) path: item/p #: C/tooling.page:136 msgid "ax_append_compile_flags.m4" msgstr "ax_append_compile_flags.m4" #. (itstool) path: item/p #: C/tooling.page:137 msgid "ax_append_flag.m4" msgstr "ax_append_flag.m4" #. (itstool) path: item/p #: C/tooling.page:138 msgid "ax_check_compile_flag.m4" msgstr "ax_check_compile_flag.m4" #. (itstool) path: item/p #: C/tooling.page:139 msgid "ax_require_defined.m4" msgstr "ax_require_defined.m4" #. (itstool) path: section/p #: C/tooling.page:142 msgid "" "AX_COMPILER_FLAGS supports disabling -Werror for " "release builds, so that releases may always be built against newer compilers " "which have introduced more warnings. Set its third parameter to ‘yes’ for " "release builds (and only release builds) to enable this functionality. " "Development and CI builds should always have -Werror enabled." msgstr "" "AX_COMPILER_FLAGS oferece suporte a desabilitar -Werror para compilações de lançamento, de forma que lançamentos sempre seja " "possível compilar com novos compiladores que podem ter introduzido mais " "avisos. Defina seu terceiro parâmetro para “yes” para compilações de " "lançamento (e apenas compilações de lançamento) para habilitar essa " "funcionalidade. Compilações de desenvolvimento e de integração contínua (em " "inglês “continuous integration” ou, abreviado, “CI”) deve sempre ter -" "Werror habilitado." #. (itstool) path: section/p #: C/tooling.page:151 msgid "" "Release builds can be detected using the AX_IS_RELEASE macro, the result of which can be passed directly to " "AX_COMPILER_FLAGS:" msgstr "" "Compilações de lançamento podem ser detectadas usando a macro AX_IS_RELEASE, podendo o seu resultado ser passado " "diretamente para AX_COMPILER_FLAGS:" #. (itstool) path: section/code #: C/tooling.page:157 #, no-wrap msgid "" "AX_IS_RELEASE([git])\n" "AX_COMPILER_FLAGS([WARN_CFLAGS],[WARN_LDFLAGS],[$ax_is_release])" msgstr "" "AX_IS_RELEASE([git])\n" "AX_COMPILER_FLAGS([WARN_CFLAGS],[WARN_LDFLAGS],[$ax_is_release])" #. (itstool) path: section/p #: C/tooling.page:160 msgid "" "The choice of release stability policy (the first argument to " "AX_IS_RELEASE) should be made per project, taking the project’s " "versioning stability into account." msgstr "" "A escolha de política de estabilidade de lançamento (o primeiro argumento " "para AX_IS_RELEASE) deve ser feita por projeto, levando em " "consideração a estabilidade de versionamento do projeto." #. (itstool) path: section/title #: C/tooling.page:169 msgid "GDB" msgstr "GDB" #. (itstool) path: section/p #: C/tooling.page:171 msgid "" "GDB is the standard debugger for C on Linux. Its most common uses are for " "debugging crashes, and for stepping through code as it executes. A full " "tutorial for using GDB is given here." msgstr "" "GDB é o depurador padrão para C no Linux. Seu uso mais comum é para depurar " "travamentos, e para analisar o código enquanto ele é executado. Um tutorial " "completo para usar GDB é fornecido aqui." #. (itstool) path: section/p #: C/tooling.page:179 msgid "" "To run GDB on a program from within the source tree, use: libtool exec " "gdb --args ./program-name --some --arguments --here" msgstr "" "Para executar GDB em um programa dentro da árvore fonte, use libtool " "exec gdb --args ./nome-do-programa --alguns --argumentos --" "aqui" #. (itstool) path: section/p #: C/tooling.page:184 msgid "" "This is necessary due to libtool wrapping each compiled binary in the source " "tree in a shell script which sets up some libtool variables. It is not " "necessary for debugging installed executables." msgstr "" "Isso é necessário porque o libtool interfaceia cada binário compilado na " "árvore fonte em um script shell que define algumas variáveis libtool. Não é " "necessário para depurar executáveis instalados." #. (itstool) path: section/p #: C/tooling.page:190 msgid "" "GDB has many advanced features which can be combined to essentially create " "small debugging scripts, triggered by different breakpoints in code. " "Sometimes this is a useful approach (for example, for reference " "count debugging), but sometimes simply using " "g_debug() to output a debug message is simpler." msgstr "" "GDB possui muitos recursos avançados que podem ser combinados para " "essencialmente criar pequenos scripts de depuração, ativados por diferentes " "pontos de interrupção no código. Algumas vezes, essa é uma abordagem útil " "(para depuração de contagem de referência), mas " "outras vezes simplesmente usar g_debug() " "para emitir uma mensagem de depuração é mais simples." #. (itstool) path: section/title #: C/tooling.page:202 msgid "Valgrind" msgstr "Valgrind" #. (itstool) path: section/p #: C/tooling.page:204 msgid "" "Valgrind is a suite of tools for instrumenting and profiling programs. Its " "most famous tool is memcheck, but it has " "several other powerful and useful tools too. They are covered separately in " "the sections below." msgstr "" "Valgrind é uma suíte de ferramentas para instrumentar e perfilar programas. " "Sua ferramenta mais famosa é o memcheck, mas " "há, no Valgrind, também várias outras ferramentas poderosas e úteis. Elas " "são cobertas separadamente nas seções a seguir." #. (itstool) path: section/p #: C/tooling.page:211 msgid "" "A useful way of running Valgrind is to run a program’s unit test suite under " "Valgrind, setting Valgrind to return a status code indicating the number of " "errors it encountered. When run as part of make check, this will " "cause the checks to succeed if Valgrind finds no problems, and fail " "otherwise. However, running make check under Valgrind is not " "trivial to do on the command line. A macro, AX_VALGRIND_CHECK can be used which adds a new make check-valgrind " "target to automate this. To use it:" msgstr "" "Uma forma útil de executar Valgrind é executar uma suíte de teste de unidade " "do programa sob Valgrind, configurando-o para retornar um código de status " "indicando o número de erros que ele encontrou. Quando executado como parte " "de make check, isso fará com que as verificações tenham sucesso " "se Valgrind encontrar nenhum problema; do contrário, falhará. Porém, " "executar make check sob Valgrind não é algo trivial de se fazer " "na linha de comando. Uma macro, AX_VALGRIND_CHECK pode ser usada para adicionar um novo alvo make check-valgrind para automatizar isso. Para usá-lo:" #. (itstool) path: item/p #: C/tooling.page:224 msgid "" "Copy ax_valgrind_check.m4 to the m4/ directory of your project." msgstr "" "Copie ax_valgrind_check.m4 para o diretório m4/ de seu projeto." #. (itstool) path: item/p #: C/tooling.page:230 msgid "Add AX_VALGRIND_CHECK to configure.ac." msgstr "" "Adicione AX_VALGRIND_CHECK para configure.ac." #. (itstool) path: item/p #: C/tooling.page:233 msgid "" "Add @VALGRIND_CHECK_RULES@ to the Makefile.am in " "each directory which contains unit tests." msgstr "" "Adicione @VALGRIND_CHECK_RULES@ para o Makefile.am " "em cada diretório que contém testes de unidade." #. (itstool) path: section/p #: C/tooling.page:239 msgid "" "When make check-valgrind is run, it will save its results in " "test-suite-*.log, one log file per tool. Note that you will " "need to run it from the directory containing the unit tests." msgstr "" "Quando make check-valgrind é executado, ele salva seus resultados " "em test-suite-*.log, um arquivo de registro por ferramenta. " "Note que você precisará executá-lo a partir de um diretório contendo os " "testes de unidade." #. (itstool) path: section/p #: C/tooling.page:251 msgid "" "Valgrind has a way to suppress false positives, by using " "suppression files. These list patterns which may match error stack " "traces. If a stack trace from an error matches part of a suppression entry, " "it is not reported. For various reasons, GLib currently causes a number of " "false positives in memcheck and helgrind and drd which must be suppressed by " "default for Valgrind to be useful. For this reason, every project should use " "a standard GLib suppression file as well as a project specific one." msgstr "" "Valgrind possui uma forma de suprimir falsos positivos, usando arquivos de supressão. Estes listam padrões que pode corresponder " "a rastros de pilhas de erros. Se um rastro de pilha de um erro corresponde a " "parte de uma entrada de supressão, ele não é relatado. Por vários motivos, " "GLib atualmente causa vários falsos positivos no memcheck e helgrind e drd, " "o que deve ser suprimido por padrão para Valgrind ser útil. Por este motivo, " "todo projeto deve usar um arquivo de supressão padrão de GLib, bem como um " "específico do projeto." #. (itstool) path: section/p #: C/tooling.page:264 msgid "" "Suppression files are supported by the AX_VALGRIND_CHECK macro:" msgstr "" "Há suporte a arquivos de supressão na macro AX_VALGRIND_CHECK:" #. (itstool) path: section/code #: C/tooling.page:268 #, no-wrap msgid "" "@VALGRIND_CHECK_RULES@\n" "VALGRIND_SUPPRESSIONS_FILES = my-project.supp glib.supp\n" "EXTRA_DIST = $(VALGRIND_SUPPRESSIONS_FILES)" msgstr "" "@VALGRIND_CHECK_RULES@\n" "VALGRIND_SUPPRESSIONS_FILES = meu-projeto.supp glib.supp\n" "EXTRA_DIST = $(VALGRIND_SUPPRESSIONS_FILES)" #. (itstool) path: section/title #: C/tooling.page:273 msgid "memcheck" msgstr "memcheck" #. (itstool) path: section/p #: C/tooling.page:275 msgid "" "memcheck is a memory usage and allocation analyzer. It detects problems with " "memory accesses and modifications of the heap (allocations and frees). It is " "a highly robust and mature tool, and its output can be entirely trusted. If " "it says there is ‘definitely’ a memory leak, there is definitely a memory " "leak which should be fixed. If it says there is ‘potentially’ a memory leak, " "there may be a leak to be fixed, or it may be memory allocated at " "initialization time and used throughout the life of the program without " "needing to be freed." msgstr "" "O memcheck é um analisador de uso e alocação de memória. Ele detecta " "problemas com acessos e modificações de memória da heap (alocações e " "liberações). É uma ferramenta altamente robusta e madura, e sua saída pode " "ser totalmente confiada. Se ele diz que “definitely” é um vazamento de " "memória, definitivamente há um vazamento de memória que deve ser corrigido. " "Se ele diz que “potentially” é um vazamento de memória, pode haver um " "vazamento a ser corrigido, ou pode ser uma memória alocada em tempo de " "inicialização e usada ao longo da vida do programa sem precisar ser liberada." #. (itstool) path: section/p #: C/tooling.page:286 msgid "To run memcheck manually on an installed program, use:" msgstr "Para executar memcheck manualmente em um programa instalado, use:" #. (itstool) path: section/p #: C/tooling.page:289 msgid "" "valgrind --tool=memcheck --leak-check=full my-program-name" msgstr "" "valgrind --tool=memcheck --leak-check=full nome-do-meu-programa" #. (itstool) path: section/p #: C/tooling.page:293 msgid "" "Or, if running your program from the source directory, use the following to " "avoid running leak checking on the libtool helper scripts:" msgstr "" "Ou, se está executando seu programa a partir do diretório fonte, use o " "seguinte para evitar a execução de verificação de vazamento em scripts " "auxiliares do libtool:" #. (itstool) path: section/p #: C/tooling.page:297 msgid "" "libtool exec valgrind --tool=memcheck --leak-check=full ./my-" "program-name" msgstr "" "libtool exec valgrind --tool=memcheck --leak-check=full ./nome-do-" "meu-programa" #. (itstool) path: section/p #: C/tooling.page:301 msgid "" "Valgrind lists each memory problem it detects, along with a short backtrace " "(if you’ve compiled your program with debug symbols), allowing the cause of " "the memory error to be pinpointed and fixed." msgstr "" "Valgrind lista cada problema de memória que ele detecta, junto com um rastro " "curto (se você compilou seu programa com símbolos de depuração), permitindo " "que a causa do erro de memória seja apontada e corrigida." #. (itstool) path: section/p #: C/tooling.page:307 msgid "" "A full tutorial on using memcheck is here." msgstr "" "Um tutorial completo sobre uso do memcheck está aqui." #. (itstool) path: section/title #: C/tooling.page:314 msgid "cachegrind and KCacheGrind" msgstr "cachegrind e KCacheGrind" #. (itstool) path: section/p #: C/tooling.page:316 msgid "" "cachegrind is a cache performance profiler which can also measure " "instruction execution, and hence is very useful for profiling general " "performance of a program. KCacheGrind is a useful UI for it which allows " "visualization and exploration of the profiling data, and the two tools " "should rarely be used separately." msgstr "" "cachegrind é um perfilador de desempenho do cache que também pode medir a " "execução de uma instrução e, portanto, é muito útil para perfilar desempenho " "em geral de um programa. KCacheGrind é uma interface gráfica útil para isso " "que permite visualização e exploração de dados de perfil, e as ferramentas " "raramente devem ser usados separadamente." #. (itstool) path: section/p #: C/tooling.page:326 msgid "" "cachegrind works by simulating the processor’s memory hierarchy, so there " "are situations where it is not perfectly accurate. " "However, its results are always representative enough to be very useful in " "debugging performance hotspots." msgstr "" "cachegrind funciona simulando a hierarquia de memória do processador, de " "forma que há situações em que não é perfeitamente acurado. Porém, seu resultado é sempre suficientemente representativo para ser " "muito útil em depurar pontos de desempenho." #. (itstool) path: section/p #: C/tooling.page:335 msgid "" "A full tutorial on using cachegrind is here." msgstr "" "Um tutorial completo sobre uso do cachegrind está aqui." #. (itstool) path: section/title #: C/tooling.page:342 msgid "helgrind and drd" msgstr "helgrind e drd" #. (itstool) path: section/p #: C/tooling.page:344 msgid "" "helgrind and drd are threading error detectors, checking for race conditions " "in memory accesses, and abuses of the POSIX pthreads API. " "They are similar tools, but are implemented using different techniques, so " "both should be used." msgstr "" "helgrind e drd são detectores de erro em threads, verificações de condições " "de corrida em acessos de memória e abusos do API pthredas " "do POSIX. Elas são ferramentas similares, mas são implementadas " "usando técnicas diferentes, de forma que ambas deveriam ser usadas." #. (itstool) path: section/p #: C/tooling.page:352 msgid "" "The kinds of errors detected by helgrind and drd are: data accessed from " "multiple threads without consistent locking, changes in lock acquisition " "order, freeing a mutex while it is locked, locking a locked mutex, unlocking " "an unlocked mutex, and several other errors. Each error, when detected, is " "printed to the console in a little report, with a separate report giving the " "allocation or spawning details of the mutexes or threads involved so that " "their definitions can be found." msgstr "" "Os tipos de erros detectados pelo helgrind e drd são: dados acessados por " "múltiplas threads sem travamento consistente, alterações na ordem de " "aquisição de trava, liberação um mutex enquanto ele está travado, travamento " "de um mutex travado, destravamento de um mutex destravado e vários outros " "erros. Cada erro, quando detectado, é emitido para o console em um pequeno " "relatório, com um relatório separado fornecendo os detalhes de alocação ou " "criação de mutexes ou threads envolvidos, de forma que suas definições podem " "ser localizadas." #. (itstool) path: section/p #: C/tooling.page:362 msgid "" "helgrind and drd can produce more false positives than memcheck or " "cachegrind, so their output should be studied a little more carefully. " "However, threading problems are notoriously elusive even to experienced " "programmers, so helgrind and drd errors should not be dismissed lightly." msgstr "" "helgrind e drd podem produzir mais falsos positivos que memcheck ou " "cachegrind, de forma que suas saídas podem ser estudadas com um pouco de " "cuidado. Porém, problemas em threads são notoriamente elusivos mesmo para " "programadores mais experientes, de forma que erros de helgrind e drd não " "devem ser desconsiderados." #. (itstool) path: section/p #: C/tooling.page:369 msgid "" "Full tutorials on using helgrind and drd are here and here." msgstr "" "Tutorias completos sobre usar helgrind e drd estão aqui e aqui." #. (itstool) path: section/title #: C/tooling.page:378 msgid "sgcheck" msgstr "sgcheck" #. (itstool) path: section/p #: C/tooling.page:380 msgid "" "sgcheck is an array bounds checker, which detects accesses to arrays which " "have overstepped the length of the array. However, it is a very young tool, " "still marked as experimental, and hence may produce more false positives " "than other tools." msgstr "" "sgcheck é um verificador de limites de vetor que detecta acessos a vetores " "que podem ter ultrapassados o tamanho do vetor. Porém, é uma ferramenta " "muito jovem, ainda marcada como experimental e, portanto, pode produzir " "muitos mais falsos positivos que outras ferramentas." #. (itstool) path: section/p #: C/tooling.page:387 msgid "" "As it is experimental, sgcheck must be run by passing --tool=exp-" "sgcheck to Valgrind, rather than --tool=sgcheck." msgstr "" "Por ser experimental, sgcheck deve ser executado passando --tool=exp-" "sgcheck para o Valgrind, em vez de --tool=sgcheck." #. (itstool) path: section/p #: C/tooling.page:393 msgid "" "A full tutorial on using sgcheck is here." msgstr "" "Um tutorial completo sobre uso do sgcheck está aqui." #. (itstool) path: section/title #: C/tooling.page:401 msgid "gcov and lcov" msgstr "gcov e lcov" #. (itstool) path: section/p #: C/tooling.page:403 msgid "" "gcov is a " "profiling tool built into GCC, which instruments code by adding extra " "instructions at compile time. When the program is run, this code generates " ".gcda and .gcno profiling output files. These " "files can be analyzed by the lcov tool, which generates visual " "reports of code coverage at runtime, highlighting lines of code in the " "project which are run more than others." msgstr "" "gcov é " "uma ferramenta de perfilamento construída em GCC que instrumenta código " "adicionando instruções extras em tempo de compilação. Quando o programa é " "executado, esse código gera os arquivos de saída de perfilamento ." "gcda e .gcno. Esses arquivos podem ser analisados pela " "ferramenta lcov, que gera relatórios visuais de cobertura de " "código em tempo de execução, linhas destacadas de código no projeto que " "executa mais do que outros." #. (itstool) path: section/p #: C/tooling.page:413 msgid "" "A critical use for this code coverage data collection is when running the " "unit tests: if the amount of code covered (for example, which particular " "lines were run) by the unit tests is known, it can be used to guide further " "expansion of the unit tests. By regularly checking the code coverage " "attained by the unit tests, and expanding them towards 100%, you can be sure " "that the entire project is being tested. Often it is the case that a unit " "test exercises most of the code, but not a particular control flow path, " "which then harbours residual bugs." msgstr "" "Um uso crítico para essa coleção de dados de cobertura de código é quando se " "está executando testes de unidade: se a quantidade de código coberto (por " "exemplo, quais linhas em particular foram executadas) pelos testes de " "unidade é conhecida, ela pode ser usado para guiar expansões posteriores de " "testes de unidade. Ao verificar regularmente a cobertura de código atingido " "pelos testes de unidade e expandindo-os para 100%, você pode se certificar " "de que todo o projeto está sendo testado. Frequentemente é o caso de que um " "teste de unidade exercita a maioria do código, mas não um caminho de fluxo " "de controle em particular, o qual acaba por abrigar erros residuais." #. (itstool) path: section/p #: C/tooling.page:424 msgid "" "lcov supports branch coverage measurement, " "so is not suitable for demonstrating coverage of safety critical code. It is " "perfectly suitable for non-safety critical code." msgstr "" "lcov oferece suporte a medida de cobertura de ramo, " "de forma que é seja adequado para demonstrar cobertura de código crítico de " "segurança. É perfeitamente adequado para código crítico que não seja de " "segurança." #. (itstool) path: section/p #: C/tooling.page:432 msgid "" "As code coverage has to be enabled at both compile time and run time, a " "macro is provided to make things simpler. The " "AX_CODE_COVERAGE macro adds a make check-code-" "coverage target to the build system, which runs the unit tests with " "code coverage enabled, and generates a report using lcov." msgstr "" "Como a cobertura de código tem que estar habilitada em ambos tempo de " "compilação de execução, uma macro é fornecida para simplificar as coisas. A " "macro AX_CODE_COVERAGE adiciona um " "alvo de make check-code-coverage ao sistema de compilação, o qual " "executa os testes de unidade com cobertura de código habilitada e gera um " "relatório usando lcov." #. (itstool) path: section/p #: C/tooling.page:442 msgid "To add AX_CODE_COVERAGE support to a project:" msgstr "Para adicionar suporte ao AX_CODE_COVERAGE a um projeto:" #. (itstool) path: item/p #: C/tooling.page:446 msgid "" "Copy ax_code_coverage.m4 to the m4/ directory of your project." msgstr "" "Copie ax_code_coverage.m4 para o diretório m4/ de seu projeto." #. (itstool) path: item/p #: C/tooling.page:452 msgid "Add AX_CODE_COVERAGE to configure.ac." msgstr "Adicione AX_CODE_COVERAGE para configure.ac." #. (itstool) path: item/p #: C/tooling.page:455 msgid "" "Add @CODE_COVERAGE_RULES to the top-level Makefile.am." msgstr "" "Adicione @CODE_COVERAGE_RULES ao Makefile.am de " "topo de nível." #. (itstool) path: item/p #: C/tooling.page:459 msgid "" "Add $(CODE_COVERAGE_CFLAGS) to the automake *_CFLAGS variable for each target you want coverage for, for " "example for all libraries but no unit test code. Do the same for " "$(CODE_COVERAGE_LDFLAGS) and *_LDFLAGS." msgstr "" "Adicione $(CODE_COVERAGE_CFLAGS) às variáveis *_CFLAGS do automake para cada alvo ao qual você deseja cobertura, " "por exemplo para todas bibliotecas com nenhum código de teste de unidade. " "Faça o mesmo para $(CODE_COVERAGE_LDFLAGS) e *_LDFLAGS." #. (itstool) path: section/p #: C/tooling.page:468 msgid "" "Documentation on using gcov and lcov is here." msgstr "" "A documentação sobre o uso de gcov e lcov está aqui." #. (itstool) path: section/title #: C/tooling.page:475 msgid "Address, Thread and Undefined Behavior Sanitizers" msgstr "Sanitizadores de endereço, thread e comportamentos indefinidos" #. (itstool) path: section/p #: C/tooling.page:477 msgid "" "GCC and Clang both support several sanitizers: sets of extra code and checks " "which can be optionally compiled in to an application and used to flag " "various incorrect behaviors at runtime. They are powerful tools, but have to " "be enabled specially, recompiling your application to enable and disable " "them. They cannot be enabled at the same time as each other, or used at the " "same time as Valgrind. They are still young, " "so have little integration with other tooling." msgstr "" "GCC e Clang oferecem suporte a vários sanitizadores: conjuntos de código " "extra e verificações que opcionalmente podem ser compilados nele para um " "aplicativo e usado para sinalizar vários comportamentos incorretos em tempo " "de execução. Elas são ferramentas poderosas, mas em especial têm que estar " "habilitadas, recompilando seu aplicativo para habilitá-los e desabilitá-los. " "Eles não podem estar habilitados ao mesmo tempo que um ao outro, ou usado ao " "mesmo tempo que Valgrind. Eles ainda estão " "jovens, então possuem pouca integração com outras ferramentarias." #. (itstool) path: section/p #: C/tooling.page:487 msgid "" "All sanitizers are available for both GCC and Clang, accepting the same set " "of compiler options." msgstr "" "Todos os sanitizadores estão disponíveis para GCC e Clang, aceitando o mesmo " "conjunto de opções de compilador." #. (itstool) path: section/title #: C/tooling.page:500 msgid "Address Sanitizer" msgstr "Sanitizador de endereço" #. (itstool) path: section/p #: C/tooling.page:502 msgid "" "The address " "sanitizer (‘asan’) detects use-after-free and buffer overflow bugs in " "C and C++ programs. A full tutorial on using asan is available for Clang " "— the same instructions should work for GCC." msgstr "" "Também conhecido como “address sanitizer” (“asan”), ele detecta erros de uso-" "após-liberação e estouro de buffer em programas C e C++. Um tutorial " "completo sobre o uso de asan está disponível para Clang — as mesmas " "instruções devem funcionar para GCC." #. (itstool) path: section/title #: C/tooling.page:512 msgid "Thread Sanitizer" msgstr "Sanitizador de thread" #. (itstool) path: section/p #: C/tooling.page:514 msgid "" "The thread " "sanitizer (‘tsan’) detects data races on memory locations, plus a " "variety of invalid uses of POSIX threading APIs. A full tutorial on using " "tsan is available for Clang — the same instructions should work for GCC." msgstr "" "Também chamado de “thread sanitizer” (“tsan”), ele detecta corridas de dados em " "localizações de memória, além de uma variedade de usos inválidos de APIs de " "thread do POSIX. Um tutorial completo sobre o uso de tsan está disponível para " "Clang — as mesmas instruções devem funcionar para GCC." #. (itstool) path: section/title #: C/tooling.page:525 msgid "Undefined Behavior Sanitizer" msgstr "Sanitizador de comportamento indefinido" #. (itstool) path: section/p #: C/tooling.page:527 msgid "" "The undefined behavior sanitizer (‘ubsan’) is a collection of smaller " "instrumentations which detect various potentially undefined behaviors in C " "programs. A set of instructions for enabling ubsan is available " "for Clang — the same instructions should work for GCC." msgstr "" "Também chamado de “undefined behavior sanitizer” (“ubsan”), ele é uma " "coleção de instrumentações menores que detectam vários comportamentos " "indefinidos em potencial em programas C. Um conjunto de instruções para " "habilitar ubsan está disponível para Clang — as mesmas " "instruções devem funcionar para o GCC." #. (itstool) path: section/title #: C/tooling.page:538 msgid "Coverity" msgstr "Coverity" #. (itstool) path: section/p #: C/tooling.page:540 msgid "" "Coverity is one of the most " "popular and biggest commercial static analyzer tools available. However, it " "is available to use free for Open Source projects, and any project is " "encouraged to sign " "up. Analysis is performed by running some analysis " "tools locally, then uploading the source code and results as a tarball to " "Coverity’s site. The results are then visible online to members of the " "project, as annotations on the project’s source code (similarly to how lcov " "presents its results)." msgstr "" "Coverity é uma das maiores e " "mais populares ferramentas comerciais de análise estática disponível. Porém, " "está disponível para uso para projetos de código aberto e qualquer projeto é " "encorajado a se " "inscrever. A análise é realizada executando algumas " "ferramentas de análise localmente e, então, enviando o código-fonte e " "resultados como um tarball para o site do Coverity. Os resultados ficam, " "então, visíveis online para todos os membros do projeto, como anotações do " "código-fonte do projeto (similarmente a como lconv apresenta seus " "resultados)." #. (itstool) path: section/p #: C/tooling.page:553 msgid "" "As Coverity cannot be run entirely locally, it cannot be integrated properly " "into the build system. However, scripts do exist to automatically scan a " "project and upload the tarball to Coverity regularly. The recommended " "approach is to run these scripts regularly on a server (typically as a " "cronjob), using a clean checkout of the project’s git repository. Coverity " "automatically e-mails project members about new static analysis problems it " "finds, so the same approach as for compiler " "warnings can be taken: eliminate all the static analysis warnings, " "then eliminate new ones as they are detected." msgstr "" "Como o Coverity não pode ser executado inteiramente localmente, ele não pode " "ser integrado apropriadamente no sistema de compilação. Porém, scripts " "existem para varrer automaticamente um projeto e enviar o tarball " "periodicamente para Coverity. A abordagem recomendada é executar esses " "scripts periodicamente em um servidor (geralmente como um cronjob), usando " "um checkout limpo do repositório git do projeto. Coverity automaticamente " "envia e-mail para membros do projeto sobre novos problemas na análise " "estática que forem encontrados, de forma que a mesma abordagem que os avisos de compilador possam ser levados: " "elmitar todos os avisos de análise estática " #. (itstool) path: section/p #: C/tooling.page:566 msgid "" "Coverity is good, but it is not perfect, and it does produce a number of " "false positives. These should be marked as ignored in the online interface." msgstr "" "Coverity é bom, mas não é perfeito e produz um número de falsos positivos. " "Esses devem ser marcados como ignorados na interface online." #. (itstool) path: section/title #: C/tooling.page:574 msgid "Clang Static Analyzer" msgstr "Analisador estático do Clang" #. (itstool) path: section/p #: C/tooling.page:576 msgid "" "One tool which can be used to perform static analysis locally is the Clang static analyzer, which " "is a tool co-developed with the Clang " "compiler. It detects a variety of problems in C code which compilers " "cannot, and which would otherwise only be detectable at run time (using unit " "tests)." msgstr "" "Uma ferramenta que pode ser usada para realizar análise estática localmente " "é o analisador estático do " "Clang, que é uma ferramenta co-desenvolvida com o compilador Clang. Ele detecta uma variedade de problemas " "no código C que compiladores não conseguem, e que, do contrário, seria " "detectável apenas em tempo de execução (usando testes de unidade)." #. (itstool) path: section/p #: C/tooling.page:585 msgid "" "Clang produces some false positives, and there is no easy way to ignore " "them. The recommended thing to do is to file a bug report against the static " "analyzer, so that the false positive can be fixed in future." msgstr "" "Clang produz alguns falsos positivos e não há uma forma fácil de ignorá-los. " "O recomendado é preencher um relatório de erro para o analisador " "estático, de forma que o falso positivo possa ser corrigido no futuro." #. (itstool) path: section/p #: C/tooling.page:593 msgid "" "A full tutorial on using Clang is here." msgstr "" "Um tutorial completo sobre o uso Clang está aqui." #. (itstool) path: section/title #: C/tooling.page:599 msgid "Tartan" msgstr "Tartan" #. (itstool) path: section/p #: C/tooling.page:601 msgid "" "However, for all the power of the Clang static analyzer, it cannot detect " "problems with specific libraries, such as GLib. This is a problem if a " "project uses GLib exclusively, and rarely uses POSIX APIs (which Clang does " "understand). There is a plugin available for the Clang static analyzer, " "called Tartan, which extends Clang to support checks against some of the common GLib " "APIs." msgstr "" "Porém, apesar de todos os poderes do analisador estático do Clang, ele não " "pode detectar problemas com bibliotecas específicas, como o GLib. Isso é um " "problema, se um projeto usa exclusivamente o GLib, e raramente usa APIs do " "POSIX (o qual Clang entende). Há um plug-in disponível para o analisador " "estático do Clang, chamado Tartan, que estende o Clang de forma a oferecer suporte a " "verificações de algumas das APIs comuns do GLib." #. (itstool) path: section/p #: C/tooling.page:612 msgid "" "Tartan is still young software, and will produce false positives and may " "crash when run on some code. However, it can find legitimate bugs quite " "quickly, and is worth running over a code base frequently to detect new " "errors in the use of GLib in the code. Please report any problems with " "Tartan." msgstr "" "Tartan ainda é um software jovem, então ele produzirá falsos positivos e " "pode travar quando executado em algum código. Porém, ele pode localizar " "erros legítimos bem rapidamente, e compensa executar frequentemente sobre um " "código base para detectar novos erros no uso do GLib no código. Por favor, " " " "relate quaisquer problemas com Tartan." #. (itstool) path: section/p #: C/tooling.page:621 msgid "" "A full tutorial on enabling Tartan for use with the Clang static analyzer is " " " "here. If set up correctly, the output from Tartan will be mixed " "together with the normal static analyzer output." msgstr "" "Um tutorial completo sobre habilitar Tartan para uso com o analisador " "estático do Clang está aqui. Se configurado corretamente, a " "saída do Tartan será misturada com a saída normal do analisador estático." #. (itstool) path: info/desc #: C/unit-testing.page:17 msgid "Designing software to be tested and writing unit tests for it" msgstr "" "Projete software para ser testado e escreva testes de unidades para ele" #. (itstool) path: page/title #: C/unit-testing.page:20 msgid "Unit Testing" msgstr "Teste de unidade" #. (itstool) path: synopsis/p #: C/unit-testing.page:25 msgid "" "Unit testing should be the primary method of testing the bulk of code " "written, because a unit test can be written once and run many times — manual " "tests have to be planned once and then manually run each time." msgstr "" "Teste de unidade deve ser o método principal para testar o conjunto de " "código escrito porque um teste de unidade pode ser escrito uma vez e " "executado muitas outras — testes manuais têm que ser planejados uma vez e, " "então, executado manualmente cada vez." #. (itstool) path: synopsis/p #: C/unit-testing.page:31 msgid "" "Development of unit tests starts with the architecture and API design of the " "code to be tested: code should be designed to be easily testable, or will " "potentially be very difficult to test." msgstr "" "O desenvolvimento de testes de unidade se inicia com o design de API e " "arquitetura do código a ser testado: o código deve ser projetado para ser " "facilmente testável, do contrário provavelmente ele será muito difícil de " "testar." #. (itstool) path: item/p #: C/unit-testing.page:38 msgid "" "Write unit tests to be as small as possible, but no smaller. ()" msgstr "" "Escreva testes de unidade para serem tão pequenos quanto possível, mas não " "menores. ()" #. (itstool) path: item/p #: C/unit-testing.page:42 msgid "" "Use code coverage tools to write tests to get high code coverage. ()" msgstr "" "Use ferramentas de cobertura de código para escrever testes para obter alta " "cobertura de código. ()" #. (itstool) path: item/p #: C/unit-testing.page:46 msgid "" "Run all unit tests under Valgrind to check for leaks and other problems. " "()" msgstr "" "Execute todos os testes de unidade sob Valgrind para verificar ocorrências " "vazamentos e outros problemas. ()" #. (itstool) path: item/p #: C/unit-testing.page:50 msgid "" "Use appropriate tools to automatically generate unit tests where possible. " "()" msgstr "" "Use as ferramentas apropriadas para automaticamente gerar testes de unidade " "onde for possível. ()" #. (itstool) path: item/p #: C/unit-testing.page:54 msgid "" "Design code to be testable from the beginning. ()" msgstr "" "Projete o código para ser testável desde o início. ()" #. (itstool) path: section/title #: C/unit-testing.page:62 msgid "Writing Unit Tests" msgstr "Escrevendo testes de unidade" #. (itstool) path: section/p #: C/unit-testing.page:64 msgid "" "Unit tests should be written in conjunction with looking at code coverage information gained from running the " "tests. This typically means writing an initial set of unit tests, " "running them to get coverage data, then reworking and expanding them to " "increase the code coverage levels. Coverage should be increased first by " "ensuring all functions are covered (at least in part), and then by ensuring " "all lines of code are covered. By covering functions first, API problems " "which will prevent effective testing can be found quickly. These typically " "manifest as internal functions which cannot easily be called from unit " "tests. Overall, coverage levels of over 90% should be aimed for; don’t just " "test cases covered by project requirements, test everything." msgstr "" "Testes de unidade devem ser escritos em conjunto com a análise das informações de cobertura de código obtidas " "por executar os testes. Geralmente isso significa escrever um " "conjunto inicial de testes de unidade, executando-os para obter dados de " "cobertura e, então, retrabalhar e expandi-los para aumentar os níveis de " "cobertura de código. A cobertura deve primeiro ser aumentada se certificando " "de que todas as funções estejam cobertas (pelo menos em parte) e, então, se " "certificando de que todas as linhas de código estejam cobertas. Ao cobrir as " "funções primeiro, problemas de API que vão evitar testes efetivos serão " "localizados rapidamente. Essas geralmente se manifestam como funções " "internas que não podem ser facilmente chamadas a partir de testes de " "unidade. Em geral, deve-se ter como meta os níveis de cobertura em cerca de " "90%; não teste apenas os casos cobertos pelos requerimentos do projeto, " "teste tudo." #. (itstool) path: section/p #: C/unit-testing.page:79 msgid "" "Like git commits, each unit test " "should be ‘as small as possible, but no smaller’, testing a single specific " "API or behavior. Each test case must be able to be run individually, without " "depending on state from other test cases. This is important to allow " "debugging of a single failing test, without having to step through all the " "other test code as well. It also means that a single test failure can easily " "be traced back to a specific API, rather than a generic ‘unit tests failed " "somewhere’ message." msgstr "" "Assim como git commits, os testes de " "unidade devem ser “tão pequenos quanto possível, mas não menores”, testando " "especificamente uma única API ou um único comportamento. Cada caso de teste " "deve ser capaz de executar individualmente, sem depender do estado de outros " "casos de teste. Isso é importante para permitir depuração de falha em um " "teste, sem ter que também passar por todos os outros códigos de teste. Isso " "significa que a falha de um teste pode ser facilmente rastreada a uma API " "específica, em vez de uma mensagem genérica “testes de unidade falharam em " "algum lugar”." #. (itstool) path: section/p #: C/unit-testing.page:90 msgid "" "GLib has support for unit testing with its GTest framework, allowing " "tests to be arranged in groups and hierarchies. This means that groups of " "related tests can be run together for enhanced debugging too, by running the " "test binary with the -p argument: ./test-suite-name -p /path/" "to/test/group." msgstr "" "O GLib oferece suporte a testes de unidade com seu framework " "GTest, permitindo que os testes sejam organizados em grupos e " "hierarquias. Isso significa que os grupos de testes relacionados podem ser " "executados juntos para melhorar a depuração também, executando o binário de " "teste com o argumento -p: ./test-suite-nome -p " "/caminho/para/grupo/de/teste." #. (itstool) path: section/title #: C/unit-testing.page:101 msgid "Installed Tests" msgstr "Testes instalados" #. (itstool) path: section/p #: C/unit-testing.page:103 msgid "" "All unit tests should be installed system-wide, following the installed-" "tests standard." msgstr "" "Todos os testes de unidade devem ser instalados para todo o sistema, " "seguindo o padrão de testes instalados." #. (itstool) path: section/p #: C/unit-testing.page:109 msgid "" "By installing the unit tests, continuous integration (CI) is made easier, " "since tests for one project can be re-run after changes to other projects in " "the CI environment, thus testing the interfaces between modules. That is " "useful for a highly-coupled set of projects like GNOME." msgstr "" "Ao instalar os testes de unidade, integração contínua (CI) é facilitada, já " "que os testes para um projeto podem ser reexecutados após alterações em " "outros projetos no ambiente de CI, de forma a testar as interfaces entre " "módulos. Isso é útil para um conjunto altamente encaixado de projetos como o " "GNOME." #. (itstool) path: section/p #: C/unit-testing.page:116 msgid "" "To add support for installed-tests, add the following to configure.ac:" msgstr "" "Para adicionar suporte para testes instalados, adicione o seguinte ao " "configure.ac:" #. (itstool) path: section/code #: C/unit-testing.page:120 #, no-wrap msgid "" "# Installed tests\n" "AC_ARG_ENABLE([modular_tests],\n" " AS_HELP_STRING([--disable-modular-tests],\n" " [Disable build of test programs (default: no)]),,\n" " [enable_modular_tests=yes])\n" "AC_ARG_ENABLE([installed_tests],\n" " AS_HELP_STRING([--enable-installed-tests],\n" " [Install test programs (default: no)]),,\n" " [enable_installed_tests=no])\n" "AM_CONDITIONAL([BUILD_MODULAR_TESTS],\n" " [test \"$enable_modular_tests\" = \"yes\" ||\n" " test \"$enable_installed_tests\" = \"yes\"])\n" "AM_CONDITIONAL([BUILDOPT_INSTALL_TESTS],[test \"$enable_installed_tests\" = \"yes\"])" msgstr "" "# Testes instalados\n" "AC_ARG_ENABLE([modular_tests],\n" " AS_HELP_STRING([--disable-modular-tests],\n" " [Disable build of test programs (default: " "no)]),,\n" " [enable_modular_tests=yes])\n" "AC_ARG_ENABLE([installed_tests],\n" " AS_HELP_STRING([--enable-installed-tests],\n" " [Install test programs (default: no)]),,\n" " [enable_installed_tests=no])\n" "AM_CONDITIONAL([BUILD_MODULAR_TESTS],\n" " [test \"$enable_modular_tests\" = \"yes\" ||\n" " test \"$enable_installed_tests\" = \"yes\"])\n" "AM_CONDITIONAL([BUILDOPT_INSTALL_TESTS],[test \"$enable_installed_tests\" = " "\"yes\"])" #. (itstool) path: section/p #: C/unit-testing.page:134 msgid "Then in tests/Makefile.am:" msgstr "Então, em tests/Makefile.am:" #. (itstool) path: section/code #: C/unit-testing.page:137 #, no-wrap msgid "" "insttestdir = $(libexecdir)/installed-tests/[project]\n" "\n" "all_test_programs = \\\n" "\ttest-program1 \\\n" "\ttest-program2 \\\n" "\ttest-program3 \\\n" "\t$(NULL)\n" "if BUILD_MODULAR_TESTS\n" "TESTS = $(all_test_programs)\n" "noinst_PROGRAMS = $(TESTS)\n" "endif\n" "\n" "if BUILDOPT_INSTALL_TESTS\n" "insttest_PROGRAMS = $(all_test_programs)\n" "\n" "testmetadir = $(datadir)/installed-tests/[project]\n" "testmeta_DATA = $(all_test_programs:=.test)\n" "\n" "testdatadir = $(insttestdir)\n" "testdata_DATA = $(test_files)\n" "\n" "testdata_SCRIPTS = $(test_script_files)\n" "endif\n" "\n" "EXTRA_DIST = $(test_files)\n" "\n" "%.test: % Makefile\n" "\t$(AM_V_GEN) (echo '[Test]' > $@.tmp; \\\n" "\techo 'Type=session' >> $@.tmp; \\\n" "\techo 'Exec=$(insttestdir)/$<' >> $@.tmp; \\\n" "\tmv $@.tmp $@)" msgstr "" "insttestdir = $(libexecdir)/installed-tests/[project]\n" "\n" "all_test_programs = \\\n" "\ttest-program1 \\\n" "\ttest-program2 \\\n" "\ttest-program3 \\\n" "\t$(NULL)\n" "if BUILD_MODULAR_TESTS\n" "TESTS = $(all_test_programs)\n" "noinst_PROGRAMS = $(TESTS)\n" "endif\n" "\n" "if BUILDOPT_INSTALL_TESTS\n" "insttest_PROGRAMS = $(all_test_programs)\n" "\n" "testmetadir = $(datadir)/installed-tests/[project]\n" "testmeta_DATA = $(all_test_programs:=.test)\n" "\n" "testdatadir = $(insttestdir)\n" "testdata_DATA = $(test_files)\n" "\n" "testdata_SCRIPTS = $(test_script_files)\n" "endif\n" "\n" "EXTRA_DIST = $(test_files)\n" "\n" "%.test: % Makefile\n" "\t$(AM_V_GEN) (echo '[Test]' > $@.tmp; \\\n" "\techo 'Type=session' >> $@.tmp; \\\n" "\techo 'Exec=$(insttestdir)/$<' >> $@.tmp; \\\n" "\tmv $@.tmp $@)" #. (itstool) path: section/title #: C/unit-testing.page:171 msgid "Leak Checking" msgstr "Verificação de vazamento" #. (itstool) path: section/p #: C/unit-testing.page:173 msgid "" "Once unit tests with high code coverage have been written, they can be run " "under various dynamic analysis tools, such as Valgrind to check for leaks, threading errors, allocation " "problems, etc. across the entire code base. The higher the code coverage of " "the unit tests, the more confidence the Valgrind results can be treated " "with. See for more information, including build " "system integration instructions." msgstr "" "Assim que os testes de unidade com alta cobertura de código forem escritos, " "eles podem ser executados sob várias ferramentas de análise dinâmica, tal " "como Valgrind para verificar por " "vazamentos, erros de threading, problemas de alocação, etc. por toda a base " "de código. Quanto maior a cobertura de código dos testes unitários, mais " "confiança haverá nos resultados do Valgrind. Veja " "para mais informações, incluindo instruções sobre integração de sistema de " "compilação." #. (itstool) path: section/p #: C/unit-testing.page:183 msgid "" "Critically, this means that unit tests should not leak memory or other " "resources themselves, and similarly should not have any threading problems. " "Any such problems would effectively be false positives in the analysis of " "the actual project code. (False positives which need to be fixed by fixing " "the unit tests.)" msgstr "" "Mais importante de tudo é que isso significa que os testes de unidade não " "devem eles mesmos resultar em vazamento de memória ou de outros recursos e, " "de forma similar, não devem ter qualquer problemas de threading. Qualquer um " "desses problemas seria efetivamente um falso positivo na análise do código " "projeto. (Falsos positivos que precisam ser resolvidos corrigindo os testes " "de unidade.)" #. (itstool) path: section/title #: C/unit-testing.page:193 msgid "Test Generation" msgstr "Geração de testes" #. (itstool) path: section/p #: C/unit-testing.page:195 msgid "" "Certain types of code are quite repetitive, and require a lot of unit tests " "to gain good coverage; but are appropriate for test data generation, where " "a tool is used to automatically generate test vectors for the code. This can " "drastically reduce the time needed for writing unit tests, for code in these " "specific domains." msgstr "" "Certos tipos de códigos são bem repetitivos e exigem muitos testes de " "unidade para obter uma boa cobertura de código; mas são apropriados para <" "link href=\"http://en.wikipedia.org/wiki/Test_data_generation\">geração de " "dados de teste, na qual uma ferramenta é usada para automaticamente " "gerar vetores de teste para o código. Isso pode reduzir drasticamente o " "tempo necessário para escrever testes de unidade, para código nesses domínio " "em específico." #. (itstool) path: section/title #: C/unit-testing.page:205 msgid "JSON" msgstr "JSON" #. (itstool) path: section/p #: C/unit-testing.page:207 msgid "" "One example of a domain amenable to test data generation is parsing, where " "the data to be parsed is required to follow a strict schema — this is the " "case for XML and JSON documents. For JSON, a tool such as Walbottle can be " "used to generate test vectors for all types of valid and invalid input " "according to the schema." msgstr "" "Um exemplo de um domínio acessível para geração de dados de teste é análise, " "na qual exige-se que os dados a serem analisados sigam um esquema estrito — " "esse é o caso para documentos XML e JSON. Para JSON, uma ferramenta como <" "link href=\"http://people.collabora.com/~pwith/walbottle/\">Walbottle " "pode ser usado para gerar vetores de teste para todos tipos de entrada " "válida e inválida de acordo com o esquema." #. (itstool) path: section/p #: C/unit-testing.page:216 msgid "" "Every type of JSON document should have a JSON Schema defined for it, which can then be passed to " "Walbottle to generate test vectors:" msgstr "" "Todo tipo de documento JSON deve ter um JSON Schema definido para ele, que pode então ser passado para " "Walbottle para gerar vetores de teste:" #. (itstool) path: section/code #: C/unit-testing.page:221 #, no-wrap msgid "" "\n" "json-schema-generate --valid-only schema.json\n" "json-schema-generate --invalid-only schema.json" msgstr "" "\n" "json-schema-generate --valid-only schema.json\n" "json-schema-generate --invalid-only schema.json" #. (itstool) path: section/p #: C/unit-testing.page:225 msgid "" "These test vectors can then be passed to the code under test in its unit " "tests. The JSON instances generated by --valid-only should be " "accepted; those from --invalid-only should be rejected." msgstr "" "Esses vetores de teste podem, então, ser passados para o código sob teste em " "seus testes de unidade. As instâncias JSON geradas por --valid-" "only deve ser aceita; aqueles de --invalid-only deve ser " "rejeitado." #. (itstool) path: section/title #: C/unit-testing.page:234 msgid "Writing Testable Code" msgstr "Escrevendo código testável" #. (itstool) path: section/p #: C/unit-testing.page:236 msgid "" "Code should be written with testability in mind from the design stage, as it " "affects API design and architecture in fundamental ways. A few key " "principles:" msgstr "" "O código deve ser escrito com testabilidade em mente desde o estágio de " "design, já que isso afeta o design de API e arquitetura em formas " "fundamentais. Alguns princípios chaves:" #. (itstool) path: item/p #: C/unit-testing.page:242 msgid "" "Do not use global state. Singleton objects are usually a bad idea as they " "can’t be instantiated separately or controlled in the unit tests." msgstr "" "Não use um estado global. Objetos “sigleton” são geralmente uma má ideia, " "pois eles não podem ser instanciados separadamente ou controlados nos testes " "de unidade." #. (itstool) path: item/p #: C/unit-testing.page:246 msgid "" "Separate out use of external state, such as databases, networking, or the " "file system. The unit tests can then replace the accesses to external state " "with mocked objects. A common approach to this is to use dependency " "injection to pass a file system wrapper object to the code under test. For " "example, a class should not load a global database (from a fixed location in " "the file system) because the unit tests would then potentially overwrite the " "running system’s copy of the database, and could never be executed in " "parallel. They should be passed an object which provides an interface to the " "database: in a production system, this would be a thin wrapper around the " "database API; for testing, it would be a mock object which checks the " "requests given to it and returns hard-coded responses for various tests." msgstr "" "Separe o uso de estado externo, tal como banco de dados, conectividade ou " "sistema de arquivos. Os testes de unidade podem, então, substituir os " "acessos a estado externo com objetos simulados (mock). Uma abordagem comum a " "isso é usar injeção de dependência para passar um objeto interfaceador de " "sistema de arquivos para o código sob teste. Por exemplo, uma classe não " "deve carregar um banco de dados global (de uma localização fixa no sistema " "de arquivos) porque os testes de unidade poderiam acabar sobrescrevendo a " "cópia do sistema em execução do banco de dados, e nunca poderia ser " "executado em paralelo. A eles deve ser passado um objeto que fornece uma " "interface para o banco de dados: em um sistema de produção, isso seria um " "interfaceador magro em volta da API de banco de dados; para teste, seria um " "objeto simulado que verifica as requisições fornecidas a ele e retorna " "respostas codificadas para vários testes." #. (itstool) path: item/p #: C/unit-testing.page:260 msgid "Expose utility functions where they might be generally useful." msgstr "Exponha funções utilitárias onde geralmente elas podem ser úteis." #. (itstool) path: item/p #: C/unit-testing.page:263 msgid "" "Split projects up into collections of small, private libraries which are " "then linked together with a minimal amount of glue code into the overall " "executable. Each can be tested separately." msgstr "" "Divida projetos em coleções de bibliotecas pequenas e privadas, que são " "então vinculadas com uma quantidade mínima de código colante no executável " "global." #. (itstool) path: section/p #: C/unit-testing.page:274 msgid "The topic of software testability is covered in the following articles:" msgstr "" "O tópico de estabilidade de API é coberto nos seguintes artigos (em inglês):" #. (itstool) path: item/p #: C/unit-testing.page:278 msgid "" "Design " "for testability" msgstr "" "Design " "por testabilidade" #. (itstool) path: item/p #: C/unit-testing.page:282 msgid "" "Software " "testability" msgstr "" "" "testabilidade de software" #. (itstool) path: item/p #: C/unit-testing.page:286 msgid "" "Dependency " "injection" msgstr "" "Injeção de " "dependência" #. (itstool) path: item/p #: C/unit-testing.page:290 msgid "" "Software " "design for testing" msgstr "" "Design de " "software para teste" #. (itstool) path: info/desc #: C/version-control.page:17 msgid "Source code version control with git" msgstr "Controle de versão de código-fonte com git" #. (itstool) path: page/title #: C/version-control.page:20 msgid "Version Control" msgstr "Controle de versão" #. (itstool) path: synopsis/p #: C/version-control.page:25 msgid "" "git is used for version control for all GNOME projects. This page assumes " "good working knowledge of git; some introductory material is available here, and a git cheatsheet is here." msgstr "" "git é usado para controle de versão para todos os projetos do GNOME. Essa " "página presume que tenha um bom conhecimento em trabalhar com git; algum " "material introdutório está disponível aqui e um folha " "de dica está aqui." #. (itstool) path: item/p #: C/version-control.page:34 msgid "" "Make atomic, revertable commits. ()" msgstr "" "Faça commits atômicos e reversíveis. ()" #. (itstool) path: item/p #: C/version-control.page:38 msgid "" "Include full reasoning in commit messages, plus links to relevant bug " "reports or specifications. ()" msgstr "" "Inclua toda a fundamentação nas mensagens de commit, junto com links para " "especificações e relatórios de erros relevantes. ()" #. (itstool) path: item/p #: C/version-control.page:43 msgid "" "Keep large changes, such as renames, in separate commits. ()" msgstr "" "Mantenha alterações grandes, como renomeações, em commits separados. ()" #. (itstool) path: item/p #: C/version-control.page:47 msgid "" "Merge changes from feature branches by rebasing. ()" msgstr "" "Mescle alterações de ramos de recursos por meio de rebase. ()" #. (itstool) path: section/title #: C/version-control.page:55 msgid "Use of Git" msgstr "Uso do Git" #. (itstool) path: section/p #: C/version-control.page:57 msgid "Most GNOME repositories follow these rules:" msgstr "A maioria dos repositórios do GNOME seguem essas regras:" #. (itstool) path: item/p #: C/version-control.page:61 msgid "" "No forced pushes. Except for branches with the wip/ prefix " "(work-in-progress), the commits’ history must not be modified, as " "contributors rely on it." msgstr "" "Nenhum push forçado. Exceto para ramos com o prefixo wip/ (" "trabalho em progress), o histórico de commits não deve ser modificado, pois " "contribuidores dependem dele." #. (itstool) path: item/p #: C/version-control.page:66 msgid "" "Rebase commits rather than merging, to have a linear history (which is " "easier to follow)." msgstr "" "Faça rebase nos commits em vez de merge, para ter um histórico linear (que é " "mais fácil de seguir)." #. (itstool) path: item/p #: C/version-control.page:70 msgid "" "Work on feature branches on GNOME git in wip/ branches, then " "rebase on master and fast-forward merge the changes. It is a good practice " "to also add your nickname to the branch name, as wip/nickname/feature." msgstr "" "Trabalhe em ramos de recursos no git do GNOME em ramos wip/ e " "então aplique rebase no master e merge em fast-foward nas alterações. Também " "é uma boa prática adicionar seu apelido ao nome do ramo, como " "wip/apelido/recurso." #. (itstool) path: item/p #: C/version-control.page:76 msgid "" "Hide sausage making by squashing commits before merging." msgstr "" "Oculte “fazimento de salsicha” (do inglês, “sausage making”) " "compactando commits antes de mesclá-los." #. (itstool) path: section/title #: C/version-control.page:84 msgid "Guidelines for Making Commits" msgstr "Diretrizes para fazer commits" #. (itstool) path: section/p #: C/version-control.page:86 msgid "" "Commits should be as small as possible, but no smaller. Each commit should " "address a single issue, containing only changes related to that issue. The " "message for each commit should describe the issue, explain what causes it, " "and explain how it has been fixed if it is not obvious. If the commit is " "associated with a bug report, the full URI for the bug report should be put " "on a line by itself at the bottom of the commit message. Similarly, the ID " "for the git commit (from git log --oneline) should be copied into " "the bug report once the commit has been pushed, so it is easy to find one " "from the other." msgstr "" "Commits devem ser tão pequenos quanto possível, mas não menores. Cada commit " "deve resolver um único problema, contendo apenas alterações relacionadas " "àquele problema. A mensagem para cada commit deve descrever o problema, " "explicar o que o causa e explicar como ele foi corrigido, se isso não foi " "óbvio. Se o commit está associado com um relatório de erro, a URI completa " "para o relatório de erro deve ser colocado em uma linha dedicada na parte " "inferior da mensagem de commit. Similarmente, o ID para o commit do git (do " "git log --oneline) deve ser compiado para o relatório de erro uma " "vez que o commit tenha sido enviado, com push, de forma que seja fácil " "localizar um por meio do outro." #. (itstool) path: section/p #: C/version-control.page:98 msgid "" "The changes in each commit should be easy to read. For example, they should " "not unnecessarily change whitespace or indentation. Large, mechanical " "changes, such as renaming a file or function, should be put in separate " "commits from modifications to code inside that file or function, so that the " "latter changes do not get buried and lost in the former." msgstr "" "As alterações em cada commit devem ser fáceis de ler. Por exemplo, eles não " "devem desnecessariamente alterar espaços em branco e recuo. Alterações " "grandes e mecânicas, tal como renomear um arquivo ou função, devem ser " "colocadas em commits separados das modificações do código dentro daquele " "arquivo ou função, de forma que as alterações posteriores não sejam " "enterradas ou perdidas na anterior." #. (itstool) path: section/p #: C/version-control.page:106 msgid "The following principles give the reasoning for all the advice above:" msgstr "Os princípios a seguir fundamentam todos os conselhos acima:" #. (itstool) path: item/p #: C/version-control.page:110 msgid "" "Each commit should take the repository from one working state to another, " "otherwise bisection is impossible." msgstr "" "Cada commit deve levar o repositório a partir de um estado de trabalho para " "outro, do contrário bissecção é impossível." #. (itstool) path: item/p #: C/version-control.page:116 msgid "" "Each commit should be individually revertable. If it later turns out that " "the commit was a bad idea, git revert commit ID should " "take the repository from a working state to another working state." msgstr "" "Cada commit deve ser individualmente reversível. Se posteriormente o commit " "acabar sendo uma ideia ruim, git revert ID do commit " "deve levar o repositório de um estado de trabalho para outro." #. (itstool) path: item/p #: C/version-control.page:122 msgid "" "The reasoning for each commit, and its relationship to external resources " "like specifications and bug reports, should be clear, to the extent that " "commits written by one developer a year in the past should still be " "understandable by a second developer without having to trace through the " "changes and work out what they do." msgstr "" "A fundamentação de cada commit, e sua relação com recursos externos como " "especificações e relatórios de erro, deve estar clara de forma que aqueles " "commits escritos por um desenvolvedor no passado devem ainda ser entendíveis " "por um segundo desenvolvedor sem ter que seguir todo rastro de alterações e " "descobrir o que eles fazem." #. (itstool) path: item/p #: C/version-control.page:129 msgid "" "Each commit should be written once, and designed to be read many times, by " "many reviewers and future programmers." msgstr "" "Cada commit deve ser escrito uma vez e projetado para ser lido muitas vezes, " "por muitos revisores e futuros programadores." #. (itstool) path: section/title #: C/version-control.page:137 msgid "Merging Procedure" msgstr "Procedimento de mesclagem" #. (itstool) path: section/p #: C/version-control.page:139 msgid "" "To merge a feature branch named my-branch into master, use the " "following commands:" msgstr "" "Para mesclar um ramo de recursos chamado meu-ramo no master, " "use os seguintes comandos:" #. (itstool) path: section/code #: C/version-control.page:143 #, no-wrap msgid "" "\n" "git checkout master\n" "git pull\n" "\n" "git checkout wip/my-branch\n" "git rebase --interactive master\n" "# Ensure the rebase is successful; test the changes\n" "\n" "git checkout master\n" "git merge wip/my-branch\n" "git push\n" "\n" "# wip/my-branch can now be deleted\n" "git push origin :wip/my-branch\n" "git branch -D wip/my-branch" msgstr "" "\n" "git checkout master\n" "git pull\n" "\n" "git checkout wip/meu-ramo\n" "git rebase --interactive master\n" "# Certifique-se que o rebase funcione com sucesso; teste as alterações\n" "\n" "git checkout master\n" "git merge wip/meu-ramo\n" "git push\n" "\n" "# wip/meu-ramo agora pode ser excluído\n" "git push origin :wip/meu-ramo\n" "git branch -D wip/meu-ramo" #. (itstool) path: item/p #: C/version-control.page:164 msgid "" "Git best " "practices" msgstr "" "Melhores " "práticas com git" #. (itstool) path: item/p #: C/version-control.page:167 msgid "" "Git FAQ" msgstr "" "Perguntas " "frequentes do git" #. (itstool) path: item/p #: C/version-control.page:170 msgid "" "Atlassian git " "tutorial" msgstr "" "Tutorial de git do " "Atlassian" #. (itstool) path: item/p #: C/version-control.page:173 msgid "" "Official git tutorial" msgstr "" "Tutorial oficial do " "git" #. (itstool) path: item/p #: C/version-control.page:176 msgid "Interactive git tutorial" msgstr "Tutorial interativo de git" #. (itstool) path: item/p #: C/version-control.page:179 msgid "" "git-tower tutorial" msgstr "" "Tutorial git-tower" #. (itstool) path: info/desc #: C/versioning.page:17 msgid "Versioning and releasing libraries and applications" msgstr "Versionamento e lançamento de bibliotecas e aplicativos" #. (itstool) path: synopsis/p #: C/versioning.page:25 msgid "" "Module versioning differs for libraries and applications: libraries need a " "libtool version specified in addition to their package version. Applications " "just have a package version." msgstr "" "O versionamento é diferente para módulos de bibliotecas e aplicativos: as " "bibliotecas precisam de uma versão de libtool especificada junto com a " "versão de seu pacote. Por sua vez, aplicativos só possuem uma versão de " "pacote." #. (itstool) path: item/p #: C/versioning.page:32 msgid "" "Libraries and applications have a package version of the form major." "minor.micro. ()" msgstr "" "Bibliotecas e aplicativos possuem uma versão de pacote na forma de " "maior.menor.micro. ()" #. (itstool) path: item/p #: C/versioning.page:36 msgid "" "Libraries additionally have a libtool version of the form current:" "revision:age. ()" msgstr "" "Adicionalmente, bibliotecas possuem uma versão de libtool na forma de " "atual:revisão:idade. ()" #. (itstool) path: item/p #: C/versioning.page:40 msgid "" "Version numbers should be updated for each release (using release and post-" "release increments). ()" msgstr "" "Os números de versão devem ser atualizados a cada lançamento (usando " "incrementos de lançamento e pós-lançamento). ()" #. (itstool) path: item/p #: C/versioning.page:44 msgid "" "Package versions should be incremented for feature changes or additions. " "()" msgstr "" "As versões de pacotes devem ser incrementados por alterações ou adições de " "recursos. ()" #. (itstool) path: item/p #: C/versioning.page:48 msgid "" "Libtool versions should be updated for API changes or additions. ()" msgstr "" "As versões de libtool devem ser atualizadas por alterações ou adições de " "API. ()" #. (itstool) path: item/p #: C/versioning.page:52 msgid "" "Even/odd minor package versions can be used respectively for stable/" "unstable releases. ()" msgstr "" "Versões menores pares/ímpares de pacotes podem ser usadas " "respectivamente para lançamentos estáveis/instáveis. ()" #. (itstool) path: section/title #: C/versioning.page:60 msgid "Package Versioning" msgstr "Versionamento de pacote" #. (itstool) path: section/p #: C/versioning.page:62 msgid "" "Both libraries and applications have a package version of the form major." "minor.micro." msgstr "" "Bibliotecas e aplicativos possuem uma versão de pacote na forma de " "maior.menor.micro." #. (itstool) path: section/p #: C/versioning.page:67 msgid "" "The package version number is that passed to AC_INIT(), and the " "one which is typically known as the project’s version number. For example, " "the Debian package for a library will use the library’s package version " "(though may also include the major version number in the package name to " "allow for parallel installability). Package versions are updated by the following rules:" msgstr "" "O número de versão de pacote é aquele passado para AC_INIT() e " "que geralmente é conhecido como número de versão do projeto. Por exemplo, o " "pacote Debian para uma biblioteca vai usar a versão de pacote da biblioteca (" "apesar de também poder incluir o número de versão maior no nome de pacote " "para permitir instalabilidade " "paralela). Versões de pacotes são atualizadas pelas seguintes regras:" #. (itstool) path: item/p #: C/versioning.page:77 msgid "" "If breaking API compatibility in a " "library, or making a large change to an application which affects everything " "(such as a UI redesign), increment major and set minor and micro to 0." msgstr "" "Se for quebrar a compatibilidade de API " "em uma biblioteca, ou fazer uma alterações a um aplicativo que afeta tudo (" "tal como um redesenho da interface gráfica), incremente a versão maior e " "defina a menor e micro para 0." #. (itstool) path: item/p #: C/versioning.page:83 msgid "" "Otherwise, if changing or adding a feature, or adding any API, increment " "minor and set micro to 0." msgstr "" "Do contrário, se for alterar ou adicionar um recurso, ou adicionar qualquer " "API, incremente a versão menor e defina micro para 0." #. (itstool) path: item/p #: C/versioning.page:87 msgid "" "Otherwise (if making a release containing only bug fixes and translation " "updates), increment micro." msgstr "" "Do contrário (se for fazer um lançamento contendo apenas correções de erros " "e atualizações de tradução), incremente a versão micro." #. (itstool) path: section/p #: C/versioning.page:93 msgid "" "Note that the minor version number should be updated if any API is added." msgstr "" "Note que o número da versão menor deve ser atualizada se qualquer API for " "adicionada." #. (itstool) path: section/title #: C/versioning.page:99 msgid "Libtool Versioning" msgstr "Versionamento de libtool" #. (itstool) path: section/p #: C/versioning.page:101 msgid "" "Libraries have two version numbers: a libtool version which tracks ABI " "backwards compatibility (see ), and a package " "version which tracks feature changes. These are normally incremented in " "synchronization, but should be kept separate because ABI backwards " "compatibility is not necessarily related to feature changes or bug fixes. " "Furthermore, the two version numbers have different semantics, and cannot be " "automatically generated from each other." msgstr "" "Bibliotecas possuem dois números de versão: uma versão de libtool que " "rastreia a compatibilidade reversa com ABI (veja ) e uma versão de pacote que rastreia alterações de recursos. Esses são " "normalmente incrementados em sincronização, mas devem ser mantidos separados " "por causa de compatibilidade reversa com ABI não está necessariamente " "relacionada a alterações de recursos ou correções de erros. Além do mais, os " "dois números de versões possuem semânticas diferentes e não podem ser " "gerados automaticamente para cada um." #. (itstool) path: section/p #: C/versioning.page:112 msgid "" "A good overview of libtool versioning, and the differences from package " "versioning, is given in the Autotools Mythbuster; another is in the libtool manual." msgstr "" "Uma boa visão geral do versionamento de libtool, e as diferenças para " "versionamento de pacote, é fornecida no Autotools MythBuster; " "outro está no manual do libtool." #. (itstool) path: section/p #: C/versioning.page:121 msgid "" "To update the libtool version, follow the algorithm given in the comments " "below. This is a typical configure.ac snippet for setting up " "libtool versioning:" msgstr "" "Para atualizar a versão do libtool, siga o algoritmo fornecido nos comentários " "abaixo. Esse é tipicamente um bloco de código do configure.ac " "para configurar versionamento de libtool:" #. (itstool) path: section/code #: C/versioning.page:127 #, no-wrap msgid "" "\n" "# Before making a release, the LT_VERSION string should be modified. The\n" "# string is of the form c:r:a. Follow these instructions sequentially:\n" "# 1. If the library source code has changed at all since the last update, then\n" "# increment revision (‘c:r:a’ becomes ‘c:r+1:a’).\n" "# 2. If any interfaces have been added, removed, or changed since the last\n" "# update, increment current, and set revision to 0.\n" "# 3. If any interfaces have been added since the last public release, then\n" "# increment age.\n" "# 4. If any interfaces have been removed or changed since the last public\n" "# release, then set age to 0.\n" "AC_SUBST([LT_VERSION],[0:0:0])" msgstr "" "\n" "# Before making a release, the LT_VERSION string should be modified. The\n" "# string is of the form c:r:a. Follow these instructions sequentially:\n" "# 1. If the library source code has changed at all since the last update, " "then\n" "# increment revision (‘c:r:a’ becomes ‘c:r+1:a’).\n" "# 2. If any interfaces have been added, removed, or changed since the " "last\n" "# update, increment current, and set revision to 0.\n" "# 3. If any interfaces have been added since the last public release, " "then\n" "# increment age.\n" "# 4. If any interfaces have been removed or changed since the last public\n" "# release, then set age to 0.\n" "AC_SUBST([LT_VERSION],[0:0:0])" #. (itstool) path: section/p #: C/versioning.page:140 msgid "" "The following snippet can be used in a Makefile.am to pass that " "version info to libtool:" msgstr "" "O bloco de código a seguir pode ser usado em um Makefile.am " "para passar aquela informação de versão para o libtool:" #. (itstool) path: section/code #: C/versioning.page:144 #, no-wrap msgid "my_library_la_LDFLAGS = -version-info $(LT_VERSION)" msgstr "minha_biblioteca_la_LDFLAGS = -version-info $(LT_VERSION)" #. (itstool) path: section/title #: C/versioning.page:148 msgid "Stable and Unstable Package Versions" msgstr "Versões estáveis e instáveis de pacote" #. (itstool) path: section/p #: C/versioning.page:150 msgid "" "Most GNOME modules follow a convention for stable and unstable releases. The " "minor version is even for stable releases and is odd for unstable releases. " "For example, the 3.20.* versions are stable, but the 3.19.* versions are " "unstable. The 3.19.* versions can be seen as alpha and beta releases of the " "3.20 version." msgstr "" "A maioria dos módulos do GNOME seguem uma convenção para lançamentos " "estáveis e instáveis. A versão menor é par para lançamentos estáveis e é " "ímpar para lançamentos instáveis. Por exemplo, as versões 3.20.* são " "estáveis, mas as versões 3.19.* são instáveis. As versões 3.19.* podem ser " "vistas como lançamentos alfa e beta da versão 3.20." #. (itstool) path: section/p #: C/versioning.page:158 msgid "" "A new micro stable version (e.g. 3.20.0 → 3.20.1) doesn’t add new " "features, only translation updates and bug fixes. On the other hand, " "unstable micro releases (e.g. 3.19.1 → 3.19.2) can add API, or " "change or remove API which was added in a previous micro release in that " "minor series." msgstr "" "Uma nova versão micro estável (ex.: 3.20.0 → 3.20.1) não adiciona " "novos recursos, apenas atualizações de tradução e correções de erro. Por " "outro lado, lançamentos micro instáveis (ex.: 3.19.1 → 3.19.2) " "podem adicionar API, ou alterar ou remover API que foi adicionada em um " "lançamento micro anterior naquela séries menores." #. (itstool) path: section/p #: C/versioning.page:166 msgid "The libtool version should be updated only for stable package versions." msgstr "" "A versão libtool deve ser atualizada apenas para versões de pacote estável." #. (itstool) path: section/title #: C/versioning.page:172 msgid "Release Process" msgstr "Processo de lançamento" #. (itstool) path: section/p #: C/versioning.page:174 msgid "" "The standard process for making a release of a module increments the libtool " "version (if the module is a library) at the time of release, then increments " "the package version number immediately afterwards (this is called a post-" "release increment)." msgstr "" "O processo padrão para fazer um lançamento de um módulo incrementa a versão " "de libtool (se o módulo é uma biblioteca) em tempo de lançamento e, " "imediatamente após, incrementa o número de versão do pacote (isso é chamado " "de “incremento pós-lançamento” ou, em inglês, “post-release increment”)" #. (itstool) path: section/p #: C/versioning.page:181 msgid "" "Updating the libtool versions at the time of release means that they are " "only incremented once for all ABI changes in a release. The use of post-" "release increment for package versions means the package version number is " "not outdated (still equal to the previous release) during the development " "cycle." msgstr "" "Atualizar as versões de libtool em tempo de lançamento significa que eles " "são incrementados apenas uma vez para todas as alterações de ABI em um " "lançamento. O uso de incremento pós-lançamento para versões de pacotes " "significa que o número de versão de pacote não está desatualizado (ainda " "igual ao lançamento anterior) durante o ciclo de desenvolvimento." #. (itstool) path: section/p #: C/versioning.page:189 msgid "" "The release process (based on the GNOME release process):" msgstr "" "O processo de lançamento (baseado no processo de lançamento " "do GNOME):" #. (itstool) path: item/p #: C/versioning.page:195 msgid "Make sure code is up to date: git pull" msgstr "Certifique-se de que o código esteja atualizado: git pull" #. (itstool) path: item/p #: C/versioning.page:199 msgid "Make sure you have no local changes: git status" msgstr "" "Certifique-se de que você tenha nenhuma alteração local: git status" #. (itstool) path: item/p #: C/versioning.page:202 msgid "" "If the release is for a stable package version, increment the libtool " "version number in configure.ac (if it exists)" msgstr "" "Se o lançamento é para uma versão de pacote estável, incremente o número de " "versão de libtool no configure.ac (se ele existir)" #. (itstool) path: item/p #: C/versioning.page:206 msgid "Add an entry to the NEWS file" msgstr "Adicione uma entrada ao arquivo NEWS" #. (itstool) path: item/p #: C/versioning.page:210 msgid "" "Run ./autogen.sh && make && make install && " "make distcheck and ensure it succeeds" msgstr "" "Execute ./autogen.sh && make && make install && " "make distcheck e certifique-se de que foi concluído com sucesso" #. (itstool) path: item/p #: C/versioning.page:216 msgid "" "Fix any issues which come up, commit those changes, and restart at step 3" msgstr "" "Corrija quaisquer problemas que aparecerem, faça o commit das alterações " "e reinicie no passo 3" #. (itstool) path: item/p #: C/versioning.page:222 msgid "" "If make distcheck finishes with “[archive] is ready for " "distribution”, run git commit -a -m \"Release version x.y.z\" " "(where ‘x.y.z’ is the package version number)" msgstr "" "Se make distcheck finalizar com “[archive] is ready for " "distribution”, execute git commit -a -m \"Release version x.y.z\" " "(sendo “x.y.z” o número da versão do pacote)" #. (itstool) path: item/p #: C/versioning.page:228 C/versioning.page:263 msgid "Run git push" msgstr "Execute git push" #. (itstool) path: item/p #: C/versioning.page:232 msgid "" "If that fails due to other commits having been pushed in the meantime, run " "git pull to merge your commit on the branch followed by a second " "git push. This is an exception to the GNOME guideline to have a " "linear Git history (). If you " "prefer to have a linear history, you need to restart at step 1." msgstr "" "Se isso falhar em razão de outros commits terem sido enviados (push) neste " "meio tempo, execute git pull para mesclar seu commit no ramo " "seguido por um segundo git push. Isso é uma exceção às diretrizes " "do GNOME de ter um histórico de git linear (). Se você prefere ter um histórico linear, você precisa reiniciar " "o passo 1." #. (itstool) path: item/p #: C/versioning.page:242 msgid "" "Tag the release: git tag -s x.y.z (where ‘x.y.z’ is the package " "version number)" msgstr "" "Crie uma tag de lançamento: git tag -s x.y.z (sendo “x.y.z” o " "número de versão do pacote)" #. (itstool) path: item/p #: C/versioning.page:246 msgid "" "Run git push origin x.y.z (where ‘x.y.z’ is the package version " "number)" msgstr "" "Execute git push origin x.y.z (sendo “x.y.z” o número de versão " "do pacote)" #. (itstool) path: section/p #: C/versioning.page:252 msgid "" "The release is now complete, and the post-release version increment can be " "done:" msgstr "" "O lançamento agora está completo e o incremento de versão pós-lançamento " "pode ser feita:" #. (itstool) path: item/p #: C/versioning.page:257 msgid "Increment the package version number in configure.ac" msgstr "Incremente o número de versão de pacote no configure.ac" #. (itstool) path: item/p #: C/versioning.page:260 msgid "Run git commit -a -m \"Post-release version increment\"" msgstr "Execute git commit -a -m \"Post-release version increment\"" #. (itstool) path: section/p #: C/versioning.page:268 msgid "" "The package archive generated by make distcheck can now be " "uploaded to download.gnome.org or distributed in other ways." msgstr "" "O arquivo de pacote gerado por make distcheck agora pode ser " "enviado para download.gnome.org ou distribuído em outras formas." #. (itstool) path: info/desc #: C/writing-good-code.page:25 msgid "Good, readable code keeps the project maintainable" msgstr "Código bom e legível mantém o projeto manutenível" #. (itstool) path: page/title #: C/writing-good-code.page:28 msgid "The Importance of Writing Good Code" msgstr "A importância de um código bem escrito" #. (itstool) path: page/p #: C/writing-good-code.page:30 msgid "" "GNOME is a very ambitious free software project, and it is composed of many " "software packages that are more or less independent of each other. A lot of " "the work in GNOME is done by volunteers: although there are many people " "working on GNOME full-time or part-time for here, volunteers still make up a " "large percentage of our contributors. Programmers may come and go at any " "time and they will be able to dedicate different amounts of time to the " "GNOME project. People’s “real world” responsibilities may change, and this " "will be reflected in the amount of time that they can devote to GNOME." msgstr "" "GNOME é um projeto de software livre muito ambicioso e é composto por muitos " "pacotes de software que são mais ou menos independentes entre si. Muito do " "trabalho no GNOME é feito por voluntários: apesar de haver muitas pessoas " "trabalhando no GNOME em tempo integral ou parcial, voluntários ainda fazem " "uma grande porcentagem de nossas contribuições. Programadores podem ir e vir " "todo o tempo e eles serão capazes de dedicar diferentes parcelas de tempo " "para o projeto do GNOME. As responsabilidades do “mundo real” das pessoas " "podem alterar e isso refletirá na quantidade de tempo que eles devotam ao " "GNOME." #. (itstool) path: page/p #: C/writing-good-code.page:43 msgid "" "Software development takes long amounts of time and painstaking effort. This " "is why most part-time volunteers cannot start big projects by themselves; it " "is much easier and more rewarding to contribute to existing projects, as " "this yields results that are immediately visible and usable." msgstr "" "Desenvolvimento de software leva grandes quantidades de tempo e esforços " "penosos. É por isso que a maioria dos voluntários em tempo parcial não " "conseguem iniciar grandes projetos por si próprio; é muito mais fácil e " "recompensador contribuir para projetos existentes, pois isso traz resultados " "que são imediatamente visíveis e usáveis." #. (itstool) path: page/p #: C/writing-good-code.page:51 msgid "" "Thus, we conclude that it is very important for existing projects to make it " "as easy as possible for people to contribute to them. One way of doing this " "is by making sure that programs are easy to read, understand, modify, and " "maintain." msgstr "" "Portanto, nós concluímos que é muito importante para os projetos existentes " "torná-los o mais simples possível para que pessoas contribuam para eles. Uma " "forma de fazer isso é se certificar de que programas são fáceis de ler, " "entender, modificar e manter." #. (itstool) path: page/p #: C/writing-good-code.page:58 msgid "" "Messy code is hard to read, and people may lose interest if they cannot " "decipher what the code tries to do. Also, it is important that programmers " "be able to understand the code quickly so that they can start contributing " "with bug fixes and enhancements in a short amount of time. Source code is a " "form of communication, and it is more for people than for " "computers. Just as someone would not like to read a novel with spelling " "errors, bad grammar, and sloppy punctuation, programmers should strive to " "write good code that is easy to understand and modify by others." msgstr "" "Um código bagunçado é difícil de ler e as pessoas podem perder o interesse " "se elas não puderem decifrar o que o código tenta fazer. Ademais, é " "importante que os programadores sejam capazes de entender o código " "rapidamente de forma que eles possam começar a contribuir com correções de " "erro e aprimoramentos em uma pequena quantidade de tempo. Código-fonte é uma " "forma de comunicação e é mais para pessoas que para computadores. " "Assim como alguém não gostaria de ler uma novela com erros de escrita, " "gramática ruim e pontuação desleixada, programadores devem se esforçar para " "escrever um bom código que seja fácil de ser entendido e modificado por " "outros." #. (itstool) path: page/p #: C/writing-good-code.page:71 msgid "The following are some important qualities of good code:" msgstr "A seguir estão algumas qualidades importantes de um bom código:" #. (itstool) path: item/title #: C/writing-good-code.page:77 msgid "Cleanliness" msgstr "Limpeza" #. (itstool) path: item/p #: C/writing-good-code.page:78 msgid "" "Clean code is easy to read with minimum effort. This lets people start to " "understand it easily. This includes the coding style itself (brace " "placement, indentation, variable names), and the actual control flow of the " "code." msgstr "" "Um código limpo é fácil de ler com esforço mínimo. Isso permite que pessoas " "comecem a entendê-lo facilmente. Isso inclui o estilo de codificação em si " "(colocação de chaves, recuo, nomes de variáveis) e o fluxo de controle do " "código." #. (itstool) path: item/title #: C/writing-good-code.page:87 msgid "Consistency" msgstr "Consistência" #. (itstool) path: item/p #: C/writing-good-code.page:88 msgid "" "Consistent code makes it easy for people to understand how a program works. " "When reading consistent code, one subconsciously forms a number of " "assumptions and expectations about how the code works, so it is easier and " "safer to make modifications to it. Code that looks the same in two " "places should work the same, too." msgstr "" "Um código consistente facilita o entendimento de como um programa funciona. " "Ao ler um código consistente, forma-se subconscientemente um número de " "presunções e expectativas sobre como o código funciona, então é mais fácil e " "seguro fazer modificações nele. Um código que se parece o mesmo em " "dois locais deve funcionar da mesma forma, também." #. (itstool) path: item/title #: C/writing-good-code.page:99 msgid "Extensibility" msgstr "Extensibilidade" #. (itstool) path: item/p #: C/writing-good-code.page:100 msgid "" "General-purpose code is easier to reuse and modify than very specific code " "with lots of hardcoded assumptions. When someone wants to add a new feature " "to a program, it will obviously be easier to do so if the code was designed " "to be extensible from the beginning. Code that was not written this way may " "lead people into having to implement ugly hacks to add features." msgstr "" "Um código com propósito geral é mais fácil de reusar e modificar do que um " "código muito específico com diversas presunções codificadas. Quando alguém " "deseja adicionar um novo recurso a um programa, obviamente será mais fácil " "fazer isso se o código foi projetado para ser extensível desde o começo. Um " "código que não foi escrito dessa forma pode levar pessoas a ter que " "implementar hacks feios e adicionar recursos." #. (itstool) path: item/title #: C/writing-good-code.page:112 msgid "Correctness" msgstr "Corretismo" #. (itstool) path: item/p #: C/writing-good-code.page:113 msgid "" "Finally, code that is designed to be correct lets people spend less time " "worrying about bugs, and more time enhancing the features of a program. " "Users also appreciate correct code, since nobody likes software that " "crashes. Code that is written for correctness and safety (i.e. code that " "explicitly tries to ensure that the program remains in a consistent state) " "prevents many kinds of silly bugs." msgstr "" "Finalmente, um código que é projetado para ser correto permite que as " "pessoas gastem menos tempo se preocupando com erros, e mais tempo melhorando " "os recursos de um programa. Usuários também apreciam um código correto, já " "que ninguém gosta de software que trava. Código que é escrito prezando pelo " "corretismo e segurança (i.e. código que explicitamente tenta se certificar " "de que o programa permaneça em um estado de consistência) evita muitos tipos " "de erros bobos." #. (itstool) path: section/title #: C/writing-good-code.page:126 msgid "Book References" msgstr "Referências literárias" #. (itstool) path: item/p #: C/writing-good-code.page:129 msgid "" "Code Complete, by Steve McConnell." msgstr "" "Code Complete, por Steve McConnell." #. (itstool) path: item/p #: C/writing-good-code.page:132 msgid "" " Refactoring: " "Improving the Design of Existing Code , by Martin Fowler." msgstr "" " Refactoring: " "Improving the Design of Existing Code , por Martin Fowler." #. (itstool) path: item/p #: C/writing-good-code.page:137 msgid "" " Design " "Patterns: Elements of Reusable Object-Oriented Software , by Erich " "Gamma, Richard Helm, Ralph Johnson and John Vlissides." msgstr "" " Design " "Patterns: Elements of Reusable Object-Oriented Software , por Erich " "Gamma, Richard Helm, Ralph Johnson e John Vlissides." #. (itstool) path: item/p #: C/writing-good-code.page:142 msgid "" " " "Object-Oriented Design Heuristics , by Arthur Riel." msgstr "" " " "Object-Oriented Design Heuristics , por Arthur Riel."