Creating values, objects and functions

Functions for creating values of different types. More...

Classes

struct  flusspferd::function
 Tag class for flusspferd::create. More...
struct  flusspferd::method
 Tag class for flusspferd::create. More...
class  flusspferd::create_on
 Create multiple values / objects / stuff on a container. More...

Functions

template<typename Class >
unspecified_type flusspferd::create (...)
 Create an object or value of a type implied by Class.

Detailed Description

Functions for creating values of different types.


Function Documentation

template<typename Class >
unspecified_type flusspferd::create (   ...  )  [inline]

Create an object or value of a type implied by Class.

This function takes a number of named parameters. Some named parameters can be specified in a specific order, or even in any order, depending on Class.

The return value is always convertible to flusspferd::value.

A few simple examples (rooting is ignored):

// Create an empty object.
flusspferd::object o = flusspferd::create< flusspferd::object >();

// Create an empty object with a prototype.
o = flusspferd::create< flusspferd::object >(
      flusspferd::param::_prototype = proto);

// Create an array with three elements.
flusspferd::array a = flusspferd::create< flusspferd::array >(boost::assign::list_of(1)(2)(3));

// Create a native object of type my_class.
my_class &no = flusspferd::create< my_class >(boost::fusion::make_vector(1, 2, 3));

// Create a native function from a function pointer, directly on the global object.
flusspferd::create< flusspferd::function >(
  "fork",
  &::fork,
  flusspferd::param::_container = flusspferd::global());
Common parameters:
flusspferd::param::_container
The container object for storing the created object.
flusspferd::param::_name
The name of the property to be used for storing the object.
flusspferd::param::_attributes
Attributes to be used for creating the property.
Default: flusspferd::dont_enumerate

Class = object
Header: flusspferd/create/object.hpp

flusspferd::param::_prototype
The prototype object to be used.
Default: Object.prototype
flusspferd::param::_parent
The parent object to be used.
Default: Determined by the Javascript engine.

Parameter order: flusspferd::param::_prototype, flusspferd::param::_parent.
Result type: flusspferd::object.

Class = array
Header: flusspferd/create/array.hpp

flusspferd::param::_length
The length of the array. The elements will be undefined.
Default: 0.
flusspferd::param::_contents
The contents of the array. Must be a valid Boost.Range (all STL containers fulfill this requirement). For static contents, we recommend boost::assign::list_of.

Parameter order: First parameter is deduced: Integer values are flusspferd::param::_length, otherwise it's flusspferd::param::_contents.
Result type: flusspferd::array.

Class = function / method
Header: flusspferd/create/function.hpp

flusspferd::param::_name
The function name.
Default: flusspferd::string()
flusspferd::param::_function
The function source code or function pointer or member function pointer (method only) or functor / boost::function.
void ()(call_context &) and void (T::*)(call_context &) are handled specially: The function call information is all passed in the call_context parameter, as is the return value slot.
Default: flusspferd::string()
flusspferd::param::_argument_names
For Javascript source functions only.
The names of the function arguments. Must be compatible to Boost.Range.
Default: std::vector<flusspferd::string>()
flusspferd::param::_file
For Javascript source functions only.
The name of the source file from which the function comes.
Default: flusspferd::string()
flusspferd::param::_line
For Javascript source functions only.
The line number at which the function appears in the source file.
Default: 0
flusspferd::param::_signature
For native functions only.
The function signature type. Use flusspferd::param::type<Signature>(). The function will be converted to boost::function<Signature> first.
Default: If unspecified, the signature will be determined automatically, if possible.
flusspferd::param::_arity
The function arity.
Only used when the function arity can not otherwise be determined.
Default: 0

The difference between flusspferd::function and flusspferd::method is that, for flusspferd::method, the Javascript 'this' object is passed as the first C++ function parameter. For source functions, both have the same effect.

Parameter order: flusspferd::param::_name, flusspferd::param::_function, flusspferd::param::_argument_names, flusspferd::param::_file, flusspferd::param::_line, flusspferd::param::_signature, flusspferd::param::_arity.
Result type: flusspferd::function.

Class = class derived from native_object_base
Header: flusspferd/create/native_object.hpp

flusspferd::param::_arguments
The parameters to be passed to the Class constructor (in addition to the first parameter, which is always the object itself), as a fusion sequence.
Default: boost::fusion::vector0()
flusspferd::param::_prototype
The prototype object to be used.
Default: The class prototype.
flusspferd::param::_parent
The parent object to be used.
Default: Determined by the Javascript engine.

Parameter order: flusspferd::param::_arguments, flusspferd::param::_prototype, flusspferd::param::_parent.
Result type: Class &.

Class = class derived from native_function_base
Header: flusspferd/create/native_function.hpp

flusspferd::param::_arguments
The parameters to be passed to the Class constructor, as a fusion sequence. The first argument to the constructor will always be the function itself, after which these arguments will be passed. Default: boost::fusion::vector0()
flusspferd::param::_arity
The function arity. Only used when the function arity can not otherwise be determined.
The function arity will be tried to be determined by calling Class::determine_arity(), see native_function_base::determine_arity().
Default: 0

Result type: Class &.

Contact us at team -AT- flusspferd -DOT- org or as described on our homepage.

Generated on Fri Jul 30 02:05:02 2010 for Flusspferd by doxygen 1.6.1