NAME

PerlObject - Encapsulates generic perl objects in JavaScript space

DESCRIPTION

When a perl object enters javascript land JSPL's engine will select the kind of wrapper needed for it. If the object belongs to a javascript class created by "bind_class" in JSPL::Context it becomes an instance of that class. Otherwise it becomes an instance of the generic wrapper class PerlObject.

Wrapper classes, installed with bind_class, define all the semantic for objects wrapped in them. So, you should check their documentation on how to use them. This page describes the semantics of the generic wrapper.

JAVASCRIPT INTERFACE

Instances of PerlObject behave much like any other javascript object. You can get and set its properties and you can call its methods.

You can even extend them adding new properties and methods. You can override its methods with new ones written as javascript functions.

They inherit from Object (via its prototype chain). You can use any of the functions from Object.prototype.

In fact, the PerlObject wrapper is written as transparent as possible to avoid name clashes with the methods and properties of the associated perl object nor affect the expected javascript semantics.

Be aware that any changes you made to the instance will not normally be visible in perl land. And that's a good thing and expected behavior: If you override some method to implement an specific workaround for something too 'perlish', you are changing your instance for javascript only, perl land will continue using the 'perlish' original method.

Instance properties

All properties defined in the associated perl object are available as properties in javascript.

When you reference a property of a PerlObject instance it will be obtain from the perl side, wrapped or converted according to is type, see "From perl to javascript" in JSPL. Unless you have override on javascript that property, of course.

The only instance property of special interest is:

__proto__

Every object in SpiderMonkey's javascript has a readonly property named __proto__. The head of the prototype chain of the object. In it the JSPL module implements PerlObject's magic. Here you will see an instance of Stash proxy, that associates the PerlObject with the original perl package (a "stash" in perl parlance) in which the object was blessed. See JSPL::Stash for the details.

Instance methods

Any instance methods defined in the associated perl object and its inheritance @ISA tree.

When you call a method of a PerlObject instance you are referencing a property in it, accordingly to the previous section you will obtain a PerlSub instance. So that PerlSub instance will be called. See PerlSub for the details.