File: group__m17nObject.html

package info (click to toggle)
m17n-docs 1.6.2-2.1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 22,492 kB
  • sloc: sh: 1,032; javascript: 635; makefile: 406; ansic: 206; perl: 108
file content (210 lines) | stat: -rw-r--r-- 14,190 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>The m17n Library: Managed Object</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Search" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>Managed Object<br/>
<small>
[<a class="el" href="group__m17nCore.html">CORE API</a>]</small>
</h1>
<p>Objects managed by the reference count.  
<a href="#_details">More...</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="structM17NObjectHead.html">M17NObjectHead</a></td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">The first member of a managed object.  <a href="structM17NObjectHead.html#_details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__m17nObject.html#ga90d6c570a21d615b60c2551b756e2de6">m17n_object</a> (int size, void(*freer)(void *))</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Allocate a managed object.  <a href="#ga90d6c570a21d615b60c2551b756e2de6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__m17nObject.html#ga690cd4bb0e346846bb82d8ab1d18fdee">m17n_object_ref</a> (void *object)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Increment the reference count of a managed object.  <a href="#ga690cd4bb0e346846bb82d8ab1d18fdee"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__m17nObject.html#ga248ba287a615a2cf3cdb99c13275453b">m17n_object_unref</a> (void *object)</td></tr>
<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Decrement the reference count of a managed object.  <a href="#ga248ba287a615a2cf3cdb99c13275453b"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>Objects managed by the reference count. </p>
<p>Managed objects are objects managed by the reference count.</p>
<p>There are some types of m17n objects that are managed by their reference count. Those objects are called <em>managed</em> <em>objects</em>. When created, the reference count of a managed object is initialized to one. The <a class="el" href="group__m17nObject.html#ga690cd4bb0e346846bb82d8ab1d18fdee" title="Increment the reference count of a managed object.">m17n_object_ref()</a> function increments the reference count of a managed object by one, and the <a class="el" href="group__m17nObject.html#ga248ba287a615a2cf3cdb99c13275453b" title="Decrement the reference count of a managed object.">m17n_object_unref()</a> function decrements by one. A managed object is automatically freed when its reference count becomes zero.</p>
<p>A property whose key is a managing key can have only a managed object as its value. Some functions, for instance <a class="el" href="group__m17nSymbol.html#ga9b90027677f183f65d85dac0d7d5bb9c" title="Set the value of a symbol property.">msymbol_put()</a> and <a class="el" href="group__m17nPlist.html#gafbfabe7a3e97e3dc6968263f61a3bee3" title="Set the value of a property in a property list.">mplist_put()</a>, pay special attention to such a property.</p>
<p>In addition to the predefined managed object types, users can define their own managed object types. See the documentation of the <a class="el" href="group__m17nObject.html#ga90d6c570a21d615b60c2551b756e2de6" title="Allocate a managed object.">m17n_object()</a> for more details. </p>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="ga90d6c570a21d615b60c2551b756e2de6"></a><!-- doxytag: member="m17n&#45;core.c::m17n_object" ref="ga90d6c570a21d615b60c2551b756e2de6" args="(int size, void(*freer)(void *))" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* m17n_object </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void(*)(void *)&nbsp;</td>
          <td class="paramname"> <em>freer</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Allocate a managed object. </p>
<p>The <a class="el" href="group__m17nObject.html#ga90d6c570a21d615b60c2551b756e2de6" title="Allocate a managed object.">m17n_object()</a> function allocates a new managed object of <b>size</b> bytes and sets its reference count to 1. <b>freer</b> is the function that is used to free the object when the reference count becomes 0. If <b>freer</b> is NULL, the object is freed by the free() function.</p>
<p>The heading bytes of the allocated object is occupied by <a class="el" href="structM17NObjectHead.html" title="The first member of a managed object.">M17NObjectHead</a>. That area is reserved for the m17n library and application programs should never touch it.</p>
<dl class="user"><dt><b>Return value:</b></dt><dd>This function returns a newly allocated object.</dd></dl>
<dl class="user"><dt><b>Errors:</b></dt><dd>This function never fails.</dd></dl>
<dl class="user"><dt><b>Example:</b></dt><dd><div class="fragment"><pre class="fragment"><span class="keyword">typedef</span> <span class="keyword">struct</span>
{
  <a class="code" href="structM17NObjectHead.html" title="The first member of a managed object.">M17NObjectHead</a> head;
  <span class="keywordtype">int</span> mem1;
  <span class="keywordtype">char</span> *mem2;
} MYStruct;

<span class="keywordtype">void</span>
my_freer (<span class="keywordtype">void</span> *obj)
{
  free (((MYStruct *) obj)-&gt;mem2);
  free (obj);
}

<span class="keywordtype">void</span>
my_func (<a class="code" href="group__m17nMtext.html#gae8bba45315c15c8f79ec4a73ebc52aec" title="Type of M-texts.">MText</a> *mt, <a class="code" href="group__m17nSymbol.html#ga0f53a95817f0b5c26442f8e12f89c16d" title="Type of symbols.">MSymbol</a> key, <span class="keywordtype">int</span> num, <span class="keywordtype">char</span> *str)
{
  MYStruct *st = <a class="code" href="group__m17nObject.html#ga90d6c570a21d615b60c2551b756e2de6" title="Allocate a managed object.">m17n_object</a> (<span class="keyword">sizeof</span> (MYStruct), my_freer);

  st-&gt;mem1 = num;
  st-&gt;mem2 = strdup (str);
  <span class="comment">/* KEY must be a managing key.   */</span>
  <a class="code" href="group__m17nTextProperty.html#ga0ebfee8b550cc5ccaefd6f091fc5695f" title="Set a text property.">mtext_put_prop</a> (mt, 0, <a class="code" href="group__m17nMtext.html#ga28ea3879a9dae45127bd62499645c7c3" title="Number of characters in M-text.">mtext_len</a> (mt), key, st);
  <span class="comment">/* This sets the reference count of ST back to 1.  */</span>
  <a class="code" href="group__m17nObject.html#ga248ba287a615a2cf3cdb99c13275453b" title="Decrement the reference count of a managed object.">m17n_object_unref</a> (st);
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="ga690cd4bb0e346846bb82d8ab1d18fdee"></a><!-- doxytag: member="m17n&#45;core.c::m17n_object_ref" ref="ga690cd4bb0e346846bb82d8ab1d18fdee" args="(void *object)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int m17n_object_ref </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>object</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Increment the reference count of a managed object. </p>
<p>The <a class="el" href="group__m17nObject.html#ga690cd4bb0e346846bb82d8ab1d18fdee" title="Increment the reference count of a managed object.">m17n_object_ref()</a> function increments the reference count of the managed object pointed to by <b>object</b>.</p>
<dl class="user"><dt><b>Return value:</b></dt><dd>This function returns the resulting reference count if it fits in a 16-bit unsigned integer (i.e. less than 0x10000). Otherwise, it return -1.</dd></dl>
<dl class="user"><dt><b>Errors:</b></dt><dd>This function never fails. </dd></dl>

</div>
</div>
<a class="anchor" id="ga248ba287a615a2cf3cdb99c13275453b"></a><!-- doxytag: member="m17n&#45;core.c::m17n_object_unref" ref="ga248ba287a615a2cf3cdb99c13275453b" args="(void *object)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int m17n_object_unref </td>
          <td>(</td>
          <td class="paramtype">void *&nbsp;</td>
          <td class="paramname"> <em>object</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Decrement the reference count of a managed object. </p>
<p>The <a class="el" href="group__m17nObject.html#ga248ba287a615a2cf3cdb99c13275453b" title="Decrement the reference count of a managed object.">m17n_object_unref()</a> function decrements the reference count of the managed object pointed to by <b>object</b>. When the reference count becomes zero, the object is freed by its freer function.</p>
<dl class="user"><dt><b>Return value:</b></dt><dd>This function returns the resulting reference count if it fits in a 16-bit unsigned integer (i.e. less than 0x10000). Otherwise, it returns -1. Thus, the return value zero means that <b>object</b> is freed.</dd></dl>
<dl class="user"><dt><b>Errors:</b></dt><dd>This function never fails. </dd></dl>

</div>
</div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr>

<ADDRESS>
<a href="http://www.m17n.org/m17n-lib-en/index.html" target="mulewindow"><img src="parrot.png" align=bottom alt="m17n-lib Home" border=0></a>
</ADDRESS>
</body>
</HTML>

<!-- Copyright information

Copyright (C) 2001 Information-technology Promotion Agency (IPA)
Copyright (C) 2001-2011
  National Institute of Advanced Industrial Science and Technology (AIST)

This file is part of the m17n library documentation.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Section, no Front-Cover Texts,
and no Back-Cover Texts.  A copy of the license is included in the
appendix entitled "GNU Free Documentation License".
-->