Pepper_47_C_interfaces
Public Attributes | List of all members
PPB_Var_1_2 Struct Reference

#include <ppb_var.h>

Collaboration diagram for PPB_Var_1_2:
Collaboration graph

Public Attributes

void(* AddRef )(struct PP_Var var)
 
void(* Release )(struct PP_Var var)
 
struct PP_Var(* VarFromUtf8 )(const char *data, uint32_t len)
 
const char *(* VarToUtf8 )(struct PP_Var var, uint32_t *len)
 
PP_Resource(* VarToResource )(struct PP_Var var)
 
struct PP_Var(* VarFromResource )(PP_Resource resource)
 

Detailed Description

PPB_Var API

Definition at line 36 of file ppb_var.h.

Member Data Documentation

void(* PPB_Var_1_2::AddRef)(struct PP_Var var)

AddRef() adds a reference to the given var. If this is not a refcounted object, this function will do nothing so you can always call it no matter what the type.

Parameters
[in]varA PP_Var that will have a reference added.

Definition at line 44 of file ppb_var.h.

void(* PPB_Var_1_2::Release)(struct PP_Var var)

Release() removes a reference to given var, deleting it if the internal reference count becomes 0. If the PP_Var is of type PP_VARTYPE_RESOURCE, it will implicitly release a reference count on the PP_Resource (equivalent to PPB_Core::ReleaseResource()).

If the given var is not a refcounted object, this function will do nothing so you can always call it no matter what the type.

Parameters
[in]varA PP_Var that will have a reference removed.

Definition at line 57 of file ppb_var.h.

struct PP_Var(* PPB_Var_1_2::VarFromResource)(PP_Resource resource)

Creates a new PP_Var from a given resource. Implicitly adds a reference count on the PP_Resource (equivalent to PPB_Core::AddRefResource(resource)).

Parameters
[in]resourceA PP_Resource to be wrapped in a var.
Returns
A PP_Var created for this resource, with type PP_VARTYPE_RESOURCE. The reference count of the var is set to 1 on behalf of the caller.

Definition at line 123 of file ppb_var.h.

struct PP_Var(* PPB_Var_1_2::VarFromUtf8)(const char *data, uint32_t len)

VarFromUtf8() creates a string var from a string. The string must be encoded in valid UTF-8 and is NOT NULL-terminated, the length must be specified in len. It is an error if the string is not valid UTF-8.

If the length is 0, the *data pointer will not be dereferenced and may be NULL. Note, however if length is 0, the "NULL-ness" will not be preserved, as VarToUtf8() will never return NULL on success, even for empty strings.

The resulting object will be a refcounted string object. It will be AddRef'ed for the caller. When the caller is done with it, it should be Released.

On error (basically out of memory to allocate the string, or input that is not valid UTF-8), this function will return a Null var.

Parameters
[in]dataA string
[in]lenThe length of the string.
Returns
A PP_Var structure containing a reference counted string object.

Definition at line 82 of file ppb_var.h.

PP_Resource(* PPB_Var_1_2::VarToResource)(struct PP_Var var)

Converts a resource-type var to a PP_Resource.

Parameters
[in]varA PP_Var struct containing a resource-type var.
Returns
A PP_Resource retrieved from the var, or 0 if the var is not a resource. The reference count of the resource is incremented on behalf of the caller.

Definition at line 111 of file ppb_var.h.

const char*(* PPB_Var_1_2::VarToUtf8)(struct PP_Var var, uint32_t *len)

VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This string is NOT NULL-terminated. The length will be placed in *len. If the string is valid but empty the return value will be non-NULL, but *len will still be 0.

If the var is not a string, this function will return NULL and *len will be 0.

The returned buffer will be valid as long as the underlying var is alive. If the instance frees its reference, the string will be freed and the pointer will be to arbitrary memory.

Parameters
[in]varA PP_Var struct containing a string-type var.
[in,out]lenA pointer to the length of the string-type var.
Returns
A char* encoded in UTF-8.

Definition at line 101 of file ppb_var.h.


The documentation for this struct was generated from the following file: