-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPJS_Class.h
96 lines (66 loc) · 1.96 KB
/
PJS_Class.h
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
/*!
@header PJS_Class.h
@abstract Types and functions related to class bindings
*/
#ifndef __PJS_CLASS_H__
#define __PJS_CLASS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "perl.h"
#include "JavaScript_Env.h"
#include "PJS_Types.h"
#include "PJS_Common.h"
struct PJS_Class {
/* Clasp */
JSClass *clasp;
/* Package name in Perl */
char *pkg;
/* Reference to Perl subroutine that returns an instance of the object */
SV *cons;
/* Reference to prototype object */
JSObject *proto;
/* Linked list of methods bound to class */
PJS_Function *methods;
JSFunctionSpec *fs;
JSFunctionSpec *static_fs;
/* Linked list of properties bound to class */
int8 next_property_id;
PJS_Property *properties;
JSPropertySpec *ps;
JSPropertySpec *static_ps;
/* Getters and setters */
SV *property_getter, *property_setter;
/* Flags such as JS_CLASS_NO_INSTANCE */
I32 flags;
struct PJS_Class *_next;
};
PJS_EXTERN PJS_Function *
PJS_get_method_by_name(PJS_Class *, const char *);
PJS_EXTERN PJS_Property *
PJS_get_property_by_id(PJS_Class *, int8);
PJS_EXTERN void
PJS_free_class(PJS_Class *);
PJS_EXTERN void
PJS_bind_class(PJS_Context *, char *, char *, SV *, HV *, HV *, HV *, HV *, SV *, SV*, U32);
PJS_EXTERN void
PJS_finalize(JSContext *, JSObject *);
PJS_EXTERN JSBool
PJS_construct_perl_object(JSContext *, JSObject *, uintN , jsval *, jsval *);
PJS_EXTERN JSFunctionSpec *
PJS_add_class_functions(PJS_Class *, HV *, U8);
PJS_EXTERN JSPropertySpec *
PJS_add_class_properties(PJS_Class *, HV *, U8);
PJS_EXTERN JSBool
PJS_invoke_perl_object_method(JSContext *, JSObject *, uintN , jsval *, jsval *);
PJS_EXTERN void
PJS_store_class(PJS_Context *pcx, PJS_Class *cls);
/*! @functiongroup Query functions */
PJS_EXTERN const char *
PJS_GetClassName(PJS_Class *class);
PJS_EXTERN const char *
PJS_GetClassPackage(PJS_Class *class);
#ifdef __cplusplus
}
#endif
#endif