/usr/include/gnash/asobj/as_function.h is in gnash-dev 0.8.11~git20160109-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | //
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef GNASH_AS_FUNCTION_H
#define GNASH_AS_FUNCTION_H
#include <string>
#include "as_object.h"
// Forward declarations
namespace gnash {
class NativeFunction;
class Global_as;
template <typename T> class FunctionArgs;
}
namespace gnash {
/// ActionScript Function, either builtin or SWF-defined
//
/// In ActionScript, every Function is also a class.
/// The *exported interface* of the class is defined
/// as a 'prototype' member of the function object.
///
/// Any instance of the class defined by this function will
/// inherit any member of the class 'prototype'.
/// To have an object inherit from a class you can set its
/// __proto__ member so to point to the class prototype, ie:
///
/// function MyClass() {}
/// MyClass.prototype.doit = function() { trace("doing it"; }
///
/// var myobj = new Object;
/// myobj.__proto__ = MyClass.prototype;
///
/// The 'prototype' of a class must provide a 'constructor'
/// member, which would point back to the Function object
/// itself, which is used as the constructor, so given the
/// code above you can assert that:
///
/// myobj.__proto__.constructor == MyClass
///
/// This class will automatically setup the 'prototype' member
/// if not explicitly provided (ie: will set 'constructor' so
/// that it points to the instance).
class as_function : public as_object
{
public:
/// Destructor
virtual ~as_function() {}
/// Return this as_object as an as_function.
virtual as_function* to_function() { return this; }
/// Function dispatch.
//
/// Override from as_object, although as_objects cannot generally
/// be called.
virtual as_value call(const fn_call& fn) = 0;
/// Return the string value of this as_object subclass
//
/// It's "function".
virtual std::string stringValue() const;
/// Run this function as a constructor on an object
//
/// This function assigns various constructor properties and runs the
/// constructor.
//
/// NB: This function does not make the object an 'instance of' the
/// constructor, i.e. it does not assign a __proto__ property. For
/// ActionScript compatibility, callers should ensure this is already
/// done.
//
/// @param newobj The object to construct. This will be used as the
/// 'this' object in the constructor.
/// @param env The environment to use for stack, local variables,
/// registers and scope chain.
/// @param args Arguments for the constructor invocation
/// @return The constructed object. TODO: return void; currently
/// there is a hack to cope with some remaining bogus
/// constructors, which
/// necessitates returning a different object from the
/// passed 'this' pointer.
as_object* construct(as_object& newobj, const as_environment& env,
FunctionArgs<as_value>& args);
/// Return true if this is a built-in class.
virtual bool isBuiltin() { return false; }
protected:
/// Construct a function.
as_function(Global_as& gl);
};
/// Construct a new object from the given constructor
//
/// This function takes care of creating the new object and assigning the
/// __proto__ property. The construct() function is then called with the
/// new object as its 'this' object.
//
/// @param ctor The constructor to run.
/// @param env The environment to use for the function call.
/// @param arg The arguments to pass to the constructor function.
/// @return A newly-created object constructed by the specified
/// function.
as_object* constructInstance(as_function& ctor, const as_environment& env,
FunctionArgs<as_value>& args);
} // gnash namespace
#endif
|