File: PJS_Function.h

package info (click to toggle)
libjavascript-perl 1.08-1%2Blenny1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 412 kB
  • ctags: 203
  • sloc: perl: 1,686; ansic: 1,620; makefile: 55
file content (81 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (2)
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
/*!
    @header PJS_Function.h
    @abstract Types and functions related to function bindings
*/

#ifndef __PJS_FUNCTION_H__
#define __PJS_FUNCTION_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "EXTERN.h"
#include "perl.h"

#include "JavaScript_Env.h"

#include "PJS_Types.h"
#include "PJS_Common.h"

/*! @struct     PJS_Function
    @abstract   This type maps Perl subroutines to JavaScript functions by name
    @discussion A linked list of these structures are maintained by each context.
                In the future this should change to a HV *.
*/
struct PJS_Function {
    /* The name of the JavaScript function which this perl function is bound to */
    char *name;
    
    /* The perl reference to the function */
    SV *callback;
    
    /* Next function in list */
    struct PJS_Function *_next;
};

/*! @function PJS_FreeFunction
    @abstract Frees the memory consumed by a PJS_Function struct
    @param function The function to free
*/
PJS_EXTERN void
PJS_DestroyFunction(PJS_Function *function);

PJS_EXTERN void
PJS_free_JSFunctionSpec(JSFunctionSpec *);

PJS_EXTERN JSBool
PJS_invoke_perl_function(JSContext *, JSObject *, uintN, jsval *, jsval *);

/*! @functiongroup Initialize functions */

/*! @function PJS_CreateFunction
    @abstract Allocates memory and initializes a PJS_Function structure.
    @result A pointer to a new function or NULL on failure.
*/
PJS_EXTERN PJS_Function *
PJS_CreateFunction(const char *functionName, SV *perlCallback);

/*! @functiongroup Query functions */

/*! @function PJS_GetFunctionName
    @abstract Retrieves the name of a function
    @param function The function to query
    @result The name the function is bound as
*/
PJS_EXTERN const char *
PJS_GetFunctionName(PJS_Function *function);

/*! @function PJS_GetFunctionTarget
    @abstract Retrieves the target Perl subroutine
    @param function The function to query
    @result An SV pointer to the target subroutine
*/
PJS_EXTERN const SV *
PJS_GetFunctionTarget(PJS_Function *function);

#ifdef __cplusplus
}
#endif

#endif