File: Cursor.xs

package info (click to toggle)
libclang-perl 0.09-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 276 kB
  • sloc: perl: 297; cpp: 55; makefile: 10; ansic: 8
file content (153 lines) | stat: -rw-r--r-- 2,438 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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
MODULE = Clang				PACKAGE = Clang::Cursor

CursorKind
kind(self)
	Cursor self

	CODE:
		RETVAL = clang_getCursorKind(*self);

	OUTPUT: RETVAL

Type
type(self)
	Cursor self

	CODE:
		CXType *retval = malloc(sizeof(CXType));
		CXType type = clang_getCursorType(*self);
		*retval = type;
		RETVAL = retval;

	OUTPUT: RETVAL

SV *
spelling(self)
	Cursor self

	CODE:
		CXString spelling = clang_getCursorSpelling(*self);
		RETVAL = newSVpv(clang_getCString(spelling), 0);

	OUTPUT: RETVAL

int
num_arguments(self)
	Cursor self

	CODE:
		int num_arguments  = clang_Cursor_getNumArguments(*self);
		RETVAL = num_arguments;

	OUTPUT: RETVAL

SV *
displayname(self)
	Cursor self

	CODE:
		CXString dname = clang_getCursorDisplayName(*self);
		RETVAL = newSVpv(clang_getCString(dname), 0);

	OUTPUT: RETVAL

AV *
children(self)
	Cursor self

	CODE:
		AV *children = newAV();

		clang_visitChildren(*self, visitor, children);

		RETVAL = children;

	OUTPUT: RETVAL

SV *
is_pure_virtual(self)
	Cursor self

	CODE:
		RETVAL = clang_CXXMethod_isPureVirtual(*self) ? &PL_sv_yes : &PL_sv_no;

	OUTPUT: RETVAL

SV *
is_virtual(self)
	Cursor self

	CODE:
		RETVAL = clang_CXXMethod_isVirtual(*self) ? &PL_sv_yes : &PL_sv_no;

	OUTPUT: RETVAL

void
location(self)
	Cursor self

	INIT:
		CXFile file;
		const char *filename;
		unsigned int line, line_end, col, col_end, offset;

	PPCODE:
		CXSourceLocation loc = clang_getCursorLocation(*self);

		CXSourceRange range = clang_getCursorExtent(*self);

		CXSourceLocation end = clang_getRangeEnd(range);

		clang_getSpellingLocation(loc, &file, &line, &col, NULL);
		clang_getSpellingLocation(end, NULL, &line_end, &col_end, NULL);

		filename = clang_getCString(clang_getFileName(file));

		if (filename != NULL)
			mXPUSHp(filename, strlen(filename));
		else
			mXPUSHp("", 0);

		mXPUSHi(line);
		mXPUSHi(col);
		mXPUSHi(line_end);
		mXPUSHi(col_end);

SV *
access_specifier(self)
	Cursor self

	CODE:
		enum CX_CXXAccessSpecifier access =
			clang_getCXXAccessSpecifier(*self);

		const char *accessStr = 0;

		switch (access) {
			case CX_CXXInvalidAccessSpecifier:
				accessStr = "invalid";
				break;

			case CX_CXXPublic:
				accessStr = "public";
				break;

			case CX_CXXProtected:
				accessStr = "protected";
				break;

			case CX_CXXPrivate:
				accessStr = "private";
				break;
		}

		RETVAL = newSVpv(accessStr, 0);

	OUTPUT: RETVAL

void
DESTROY(self)
	Cursor self

	CODE:
		free(self);