NPN_CreateObject

  • Revision slug: NPN_CreateObject
  • Revision title: NPN_CreateObject
  • Revision id: 190786
  • Created:
  • Creator: Sheppy
  • Is current revision? Yes
  • Comment scripting template

Revision Content

{{ Np-plugin-scripting() }}

Summary

Allocates a new NPObject.

Syntax

#include <npruntime.h>
 
NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);

Parameters

The function has the following parameters:

<tt>npp</tt>
The NPP indicating which plugin wants to instantiate the object.
<tt>aClass</tt>
The class to instantiate an object of.

Returns

The newly-allocated NPObject.

Description

If the given NPClass provides an allocate function it is used to allocate the storage for the object and the NPP argument passed to NPN_CreateObject() is passed along to that function. If no allocate function is provided, malloc() is called to allocate enough memory to hold an NPObject. The newly created NPObject's reference count is initialized to 1 before it is returned.

Revision Source

<p> {{ Np-plugin-scripting() }}
</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Allocates a new <code><a href="en/NPObject">NPObject</a></code>.
</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre>#include &lt;npruntime.h&gt;
 
NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);
</pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<p>The function has the following parameters:
</p>
<dl><dt><tt>npp</tt>
</dt><dd>The <a href="en/NPP">NPP</a> indicating which plugin wants to instantiate the object.
</dd><dt><tt>aClass</tt>
</dt><dd>The class to instantiate an object of.
</dd></dl>
<h3 id="Returns" name="Returns">Returns</h3>
<p>The newly-allocated <code>NPObject</code>.
</p>
<h3 id="Description" name="Description">Description</h3>
<p>If the given <code><a href="en/NPClass">NPClass</a></code> provides an <code>allocate</code> function it is used to allocate the storage for the object and the NPP argument passed to <code>NPN_CreateObject()</code> is passed along to that function. If no <code>allocate</code> function is provided, <code>malloc()</code> is called to allocate enough memory to hold an <code>NPObject</code>. The newly created <code>NPObject</code>'s reference count is initialized to 1 before it is returned.
</p>
Revert to this revision