summaryrefslogtreecommitdiff
path: root/doc/classes/JSON/Ext/Generator/State.src/M000121.html
blob: c3556c361e5baa8fdd9385746ae02004d1d160eb (plain)
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>initialize_copy (JSON::Ext::Generator::State)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre>/*
 * call-seq: initialize_copy(orig)
 *
 * Initializes this object from orig if it to be duplicated/cloned and returns
 * it.
*/
static VALUE cState_init_copy(VALUE obj, VALUE orig)
{
    JSON_Generator_State *objState, *origState;

    Data_Get_Struct(obj, JSON_Generator_State, objState);
    Data_Get_Struct(orig, JSON_Generator_State, origState);
    if (!objState) rb_raise(rb_eArgError, &quot;unallocated JSON::State&quot;);

    MEMCPY(objState, origState, JSON_Generator_State, 1);
    objState-&gt;indent = fstrndup(origState-&gt;indent, origState-&gt;indent_len);
    objState-&gt;space = fstrndup(origState-&gt;space, origState-&gt;space_len);
    objState-&gt;space_before = fstrndup(origState-&gt;space_before, origState-&gt;space_before_len);
    objState-&gt;object_nl = fstrndup(origState-&gt;object_nl, origState-&gt;object_nl_len);
    objState-&gt;array_nl = fstrndup(origState-&gt;array_nl, origState-&gt;array_nl_len);
    if (origState-&gt;array_delim) objState-&gt;array_delim = fbuffer_dup(origState-&gt;array_delim);
    if (origState-&gt;object_delim) objState-&gt;object_delim = fbuffer_dup(origState-&gt;object_delim);
    if (origState-&gt;object_delim2) objState-&gt;object_delim2 = fbuffer_dup(origState-&gt;object_delim2);
    return obj;
}</pre>
</body>
</html>