Creating JavaScript classes

Creating JavaScript classes — Dealing with Seed class definitions and constructors

Functions

Types and Values

Includes

#include <seed/seed.h>

Description

Defining new Seed classes allows for implementing more complex behavior than possible with the traditional JavaScript object system and default class. When writing Seed modules, it is often the best pattern to define many of your types through classes and static functions/value. Please note that inside the finalize callback of a class, it is not legal to call any method requiring a SeedContext (with the exception of protect/unprotect, though it is not guaranteed this will continue to work with future versions of JSCore).

Functions

seed_create_class ()

SeedClass
seed_create_class (seed_class_definition *def);

Parameters

def

A JSClassDefinition.

 

Returns

A SeedClass, described by def .


seed_make_constructor ()

SeedObject
seed_make_constructor (SeedContext ctx,
                       SeedClass klass,
                       SeedObjectCallAsConstructorCallback constructor);

Parameters

ctx

A SeedContext.

 

constructor

The JSObjectCallAsConstructorCallback function to call when the constructor is invoked with 'new'.

 

Returns

A SeedObject, which is a constructor function.

Types and Values

enum SeedPropertyAttributes

Members

SEED_PROPERTY_ATTRIBUTE_NONE

   

SEED_PROPERTY_ATTRIBUTE_READ_ONLY

   

SEED_PROPERTY_ATTRIBUTE_DONT_ENUM

   

SEED_PROPERTY_ATTRIBUTE_DONT_DELETE

   

enum SeedClassAttributes

Members

SEED_CLASS_ATTRIBUTE_NONE

   

SEED_CLASS_ATTRIBUTE_NO_SHARED_PROTOTYPE

   

SeedClass

typedef gpointer SeedClass;


seed_empty_class

#define             seed_empty_class