Debian Codegraph @

libs/pplib/pplib-src/doc/_build/html/ppnew.html

raw symbols SCIP
1
2
3 <!doctype html>
4
5 <html xmlns="http://www.w3.org/1999/xhtml">
6 <head>
7 <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9 <title>1.x vs 2.x &#8212; pplib 0.1 documentation</title>
10 <link rel="stylesheet" href="_static/bizstyle.css" type="text/css" />
11 <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
12
13 <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
14 <script type="text/javascript" src="_static/jquery.js"></script>
15 <script type="text/javascript" src="_static/underscore.js"></script>
16 <script type="text/javascript" src="_static/doctools.js"></script>
17 <script type="text/javascript" src="_static/language_data.js"></script>
18 <script type="text/javascript" src="_static/bizstyle.js"></script>
19 <link rel="index" title="Index" href="genindex.html" />
20 <link rel="search" title="Search" href="search.html" />
21 <link rel="next" title="pplib 2.x" href="ppapi-2.x.html" />
22 <link rel="prev" title="pplib" href="pplib.html" />
23 <meta name="viewport" content="width=device-width,initial-scale=1.0">
24 <!--[if lt IE 9]>
25 <script type="text/javascript" src="_static/css3-mediaqueries.js"></script>
26 <![endif]-->
27 </head><body>
28 <div class="related" role="navigation" aria-label="related navigation">
29 <h3>Navigation</h3>
30 <ul>
31 <li class="right" style="margin-right: 10px">
32 <a href="genindex.html" title="General Index"
33 accesskey="I">index</a></li>
34 <li class="right" >
35 <a href="ppapi-2.x.html" title="pplib 2.x"
36 accesskey="N">next</a> |</li>
37 <li class="right" >
38 <a href="pplib.html" title="pplib"
39 accesskey="P">previous</a> |</li>
40 <li class="nav-item nav-item-0"><a href="pplib.html">pplib 0.1 documentation</a> &#187;</li>
41 </ul>
42 </div>
43 <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
44 <div class="sphinxsidebarwrapper">
45 <h3><a href="pplib.html">Table of Contents</a></h3>
46 <ul>
47 <li><a class="reference internal" href="#">1.x vs 2.x</a><ul>
48 <li><a class="reference internal" href="#allocation">Allocation</a></li>
49 <li><a class="reference internal" href="#strings-and-names">Strings And Names</a></li>
50 <li><a class="reference internal" href="#cleanups">Cleanups</a></li>
51 </ul>
52 </li>
53 </ul>
54
55 <h4>Previous topic</h4>
56 <p class="topless"><a href="pplib.html"
57 title="previous chapter">pplib</a></p>
58 <h4>Next topic</h4>
59 <p class="topless"><a href="ppapi-2.x.html"
60 title="next chapter"><code class="docutils literal notranslate"><span class="pre">pplib</span></code> 2.x</a></p>
61 <div role="note" aria-label="source link">
62 <h3>This Page</h3>
63 <ul class="this-page-menu">
64 <li><a href="_sources/ppnew.rst.txt"
65 rel="nofollow">Show Source</a></li>
66 </ul>
67 </div>
68 <div id="searchbox" style="display: none" role="search">
69 <h3>Quick search</h3>
70 <div class="searchformwrapper">
71 <form class="search" action="search.html" method="get">
72 <input type="text" name="q" />
73 <input type="submit" value="Go" />
74 <input type="hidden" name="check_keywords" value="yes" />
75 <input type="hidden" name="area" value="default" />
76 </form>
77 </div>
78 </div>
79 <script type="text/javascript">$('#searchbox').show(0);</script>
80 </div>
81 </div>
82
83 <div class="document">
84 <div class="documentwrapper">
85 <div class="bodywrapper">
86 <div class="body" role="main">
87
88 <div class="section" id="x-vs-2-x">
89 <h1>1.x vs 2.x<a class="headerlink" href="#x-vs-2-x" title="Permalink to this headline">¶</a></h1>
90 <div class="section" id="allocation">
91 <h2>Allocation<a class="headerlink" href="#allocation" title="Permalink to this headline">¶</a></h2>
92 <p>Allocation mechanisms has been revised. All objects are still allocated from a private storage (called heap),
93 but now the heap serves properly aligned memory chunks. Implementation of the heap is (hopefully) platform
94 independent, so all <code class="docutils literal notranslate"><span class="pre">ARM_COMPLIANT</span></code> checks has been removed. Some details work differently on 32/64-bit
95 machines, this distinction seems inevitable. Allocation related code has been moved to <code class="docutils literal notranslate"><span class="pre">util/utilmem*.c</span></code> files.</p>
96 <p>[There are actually 3 different allocators - <strong>heap</strong>, <strong>stock</strong>, and <strong>pool</strong> - each of which has 4 variants
97 for 1, 2, 4 and 8 bytes alignment. So far <code class="docutils literal notranslate"><span class="pre">pplib</span></code> uses only the <strong>heap</strong>, but I want to have this part
98 in a single place for a while. More notes about allocators in <code class="docutils literal notranslate"><span class="pre">utilmemallc.h</span></code>.]</p>
99 <p><code class="docutils literal notranslate"><span class="pre">pplib</span></code> uses two heaps:</p>
100 <ul class="simple">
101 <li>bytes heap - providing 2-bytes aligned memory chunks for byte data</li>
102 <li>structures heap - providing 8-bytes aligned chunks for all structures</li>
103 </ul>
104 <p>2-bytes alignment of byte data is caused by implementation details / limits, <code class="docutils literal notranslate"><span class="pre">pplib</span></code> doesn’t make a use of it
105 (could be unaligned as well). All the structures are stored in 8-bytes aligned chunks on both 32 and 64-bit machines
106 (in some structures we use <code class="docutils literal notranslate"><span class="pre">double</span></code> and <code class="docutils literal notranslate"><span class="pre">int64_t</span></code>, which generally needs 8-bytes).</p>
107 </div>
108 <div class="section" id="strings-and-names">
109 <h2>Strings And Names<a class="headerlink" href="#strings-and-names" title="Permalink to this headline">¶</a></h2>
110 <p>So far, both <code class="docutils literal notranslate"><span class="pre">ppname</span></code> and <code class="docutils literal notranslate"><span class="pre">ppstring</span></code> were aliases to <code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code> with an extra structure hidden just below
111 the data address. The idea was to make a string or name usable whenever chars array can, at the cost of some
112 pointers trickery. Both names and strings keep an information about pdf-encoded data, as well as plain bytes data.
113 I implemented this feature once <code class="docutils literal notranslate"><span class="pre">pplib</span> <span class="pre">1.0</span></code> was almost done, and to avoid a revolution, I made that with yet
114 another trick. This all was dirty and caused lots of alignment issues.</p>
115 <p>Now <code class="docutils literal notranslate"><span class="pre">ppstring</span></code> and <code class="docutils literal notranslate"><span class="pre">ppname</span></code> are <strong>structures</strong>, keeping data and size members, pretty much like <code class="docutils literal notranslate"><span class="pre">pparray</span></code>:</p>
116 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ppname</span> <span class="p">{</span>
117 <span class="n">ppbyte</span> <span class="o">*</span><span class="n">data</span><span class="p">;</span>
118 <span class="n">size_t</span> <span class="n">size</span><span class="p">;</span>
119 <span class="n">ppname</span> <span class="o">*</span><span class="n">alterego</span><span class="p">;</span>
120 <span class="nb">int</span> <span class="n">flags</span><span class="p">;</span>
121 <span class="p">};</span>
122
123 <span class="n">struct</span> <span class="n">ppstring</span> <span class="p">{</span>
124 <span class="n">ppbyte</span> <span class="o">*</span><span class="n">data</span><span class="p">;</span>
125 <span class="n">size_t</span> <span class="n">size</span><span class="p">;</span>
126 <span class="n">ppstring</span> <span class="o">*</span><span class="n">alterego</span><span class="p">;</span>
127 <span class="nb">int</span> <span class="n">flags</span><span class="p">;</span>
128 <span class="p">};</span>
129 </pre></div>
130 </div>
131 <p>Data member is a pointer to (2-bytes aligned) bytes array – <code class="docutils literal notranslate"><span class="pre">ppbyte</span> <span class="pre">*</span></code>. <code class="docutils literal notranslate"><span class="pre">ppbyte</span></code> is an alias to <code class="docutils literal notranslate"><span class="pre">char</span></code>.
132 <code class="docutils literal notranslate"><span class="pre">pplib</span></code> makes no assumptions about <code class="docutils literal notranslate"><span class="pre">ppbyte</span></code> signedness. [I’d prefer to have <code class="docutils literal notranslate"><span class="pre">uint8_t</span></code>, but better
133 keep that in sync with <code class="docutils literal notranslate"><span class="pre">ppdict_get_*</span></code> suite, which accepts <code class="docutils literal notranslate"><span class="pre">char</span> <span class="pre">*</span></code>. Using <code class="docutils literal notranslate"><span class="pre">&quot;string</span> <span class="pre">literals&quot;</span></code>
134 with <code class="docutils literal notranslate"><span class="pre">ppdict_get</span></code> function is the most common case, I guess.]</p>
135 <p><code class="docutils literal notranslate"><span class="pre">ppname_size()</span></code> and <code class="docutils literal notranslate"><span class="pre">ppstring_size()</span> <span class="pre">``</span> <span class="pre">now</span> <span class="pre">have</span>
136 <span class="pre">trivial</span> <span class="pre">``ppname_data()</span></code> and <code class="docutils literal notranslate"><span class="pre">ppstring_data()</span></code> counterparts:</p>
137 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1">#define ppname_size(name) ((name)-&gt;size)</span>
138 <span class="c1">#define ppname_data(name) ((name)-&gt;data)</span>
139
140 <span class="c1">#define ppstring_size(string) ((string)-&gt;size)</span>
141 <span class="c1">#define ppstring_data(string) ((string)-&gt;data)</span>
142 </pre></div>
143 </div>
144 <p>Switching between encoded / decoded variants is made via explicit <code class="docutils literal notranslate"><span class="pre">alterego</span></code> member. If encoded and decoded forms
145 are identical, then <code class="docutils literal notranslate"><span class="pre">self-&gt;alfterego</span> <span class="pre">==</span> <span class="pre">self</span></code> (never NULL). Helper functions for that:</p>
146 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">PPAPI</span> <span class="n">ppname</span> <span class="o">*</span> <span class="n">ppname_decoded</span> <span class="p">(</span><span class="n">ppname</span> <span class="o">*</span><span class="n">name</span><span class="p">);</span>
147 <span class="n">PPAPI</span> <span class="n">ppname</span> <span class="o">*</span> <span class="n">ppname_encoded</span> <span class="p">(</span><span class="n">ppname</span> <span class="o">*</span><span class="n">name</span><span class="p">);</span>
148
149 <span class="n">PPAPI</span> <span class="n">ppbyte</span> <span class="o">*</span> <span class="n">ppname_decoded_data</span> <span class="p">(</span><span class="n">ppname</span> <span class="o">*</span><span class="n">name</span><span class="p">);</span>
150 <span class="n">PPAPI</span> <span class="n">ppbyte</span> <span class="o">*</span> <span class="n">ppname_encoded_data</span> <span class="p">(</span><span class="n">ppname</span> <span class="o">*</span><span class="n">name</span><span class="p">);</span>
151
152 <span class="n">PPAPI</span> <span class="n">ppstring</span> <span class="o">*</span> <span class="n">ppstring_decoded</span> <span class="p">(</span><span class="n">ppstring</span> <span class="o">*</span><span class="n">string</span><span class="p">);</span>
153 <span class="n">PPAPI</span> <span class="n">ppstring</span> <span class="o">*</span> <span class="n">ppstring_encoded</span> <span class="p">(</span><span class="n">ppstring</span> <span class="o">*</span><span class="n">string</span><span class="p">);</span>
154
155 <span class="n">PPAPI</span> <span class="n">ppbyte</span> <span class="o">*</span> <span class="n">ppstring_decoded_data</span> <span class="p">(</span><span class="n">ppstring</span> <span class="o">*</span><span class="n">string</span><span class="p">);</span>
156 <span class="n">PPAPI</span> <span class="n">ppbyte</span> <span class="o">*</span> <span class="n">ppstring_encoded_data</span> <span class="p">(</span><span class="n">ppstring</span> <span class="o">*</span><span class="n">string</span><span class="p">);</span>
157 </pre></div>
158 </div>
159 <p>Since <code class="docutils literal notranslate"><span class="pre">ppname</span></code> and <code class="docutils literal notranslate"><span class="pre">ppstring</span></code> are now structures, all API functions returning name/string or taking name/string
160 as an argument, now take <strong>a pointer to name/string</strong>. Watch out for <code class="docutils literal notranslate"><span class="pre">ppdict_get_*</span></code> functions suite. They still accept
161 <code class="docutils literal notranslate"><span class="pre">const</span> <span class="pre">char</span> <span class="pre">*</span></code> key as an argument, but <code class="docutils literal notranslate"><span class="pre">ppname</span></code> type can no longer be used there:</p>
162 <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ppname</span> <span class="n">key</span><span class="p">;</span>
163 <span class="n">ppdict_get_something</span><span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">key</span><span class="p">);</span> <span class="o">//</span> <span class="n">wrong</span>
164 <span class="n">ppdict_get_something</span><span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">key</span><span class="o">.</span><span class="n">data</span><span class="p">);</span> <span class="o">//</span> <span class="n">ok</span>
165
166 <span class="n">ppname</span> <span class="o">*</span><span class="n">pkey</span><span class="p">;</span>
167 <span class="n">ppdict_get_something</span><span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="p">(</span><span class="n">const</span> <span class="n">char</span> <span class="o">*</span><span class="p">)</span><span class="n">pkey</span><span class="p">);</span> <span class="o">//</span> <span class="n">wrong</span>
168 <span class="n">ppdict_get_something</span><span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">pkey</span><span class="o">-&gt;</span><span class="n">data</span><span class="p">);</span> <span class="o">//</span> <span class="n">ok</span>
169 </pre></div>
170 </div>
171 <p>Consequently, functions / macros that used pointer to <code class="docutils literal notranslate"><span class="pre">ppname</span></code> (<code class="docutils literal notranslate"><span class="pre">ppdict_first()</span></code> / <code class="docutils literal notranslate"><span class="pre">ppdict_next()</span></code>),
172 now needs <code class="docutils literal notranslate"><span class="pre">ppname</span> <span class="pre">**pname</span></code>.</p>
173 </div>
174 <div class="section" id="cleanups">
175 <h2>Cleanups<a class="headerlink" href="#cleanups" title="Permalink to this headline">¶</a></h2>
176 <p>Some of unused utils were removed. There is still some code in utils part that is not used by the library,
177 but I need this tollbox in many other places and don’t want to maintain two versions.</p>
178 <p>Some unification in integer types; <code class="docutils literal notranslate"><span class="pre">size_t</span></code> seems to be the best choice for and integer representing machine
179 word (<code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span></code> is not long enough on windows), less utils dependencies, less compiler warnings.</p>
180 </div>
181 </div>
182
183
184 </div>
185 </div>
186 </div>
187 <div class="clearer"></div>
188 </div>
189 <div class="related" role="navigation" aria-label="related navigation">
190 <h3>Navigation</h3>
191 <ul>
192 <li class="right" style="margin-right: 10px">
193 <a href="genindex.html" title="General Index"
194 >index</a></li>
195 <li class="right" >
196 <a href="ppapi-2.x.html" title="pplib 2.x"
197 >next</a> |</li>
198 <li class="right" >
199 <a href="pplib.html" title="pplib"
200 >previous</a> |</li>
201 <li class="nav-item nav-item-0"><a href="pplib.html">pplib 0.1 documentation</a> &#187;</li>
202 </ul>
203 </div>
204 <div class="footer" role="contentinfo">
205 &#169; Copyright 2019, [email protected].
206 Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.
207 </div>
208 </body>
209 </html>