コード例 #1
0
ファイル: cursor_gen.go プロジェクト: go-clang/v3.6
/*
	Determine the set of methods that are overridden by the given
	method.

	In both Objective-C and C++, a method (aka virtual member function,
	in C++) can override a virtual method in a base class. For
	Objective-C, a method is said to override any method in the class's
	base class, its protocols, or its categories' protocols, that has the same
	selector and is of the same kind (class or instance).
	If no such method exists, the search continues to the class's superclass,
	its protocols, and its categories, and so on. A method from an Objective-C
	implementation is considered to override the same methods as its
	corresponding method in the interface.

	For C++, a virtual member function overrides any virtual member
	function with the same signature that occurs in its base
	classes. With multiple inheritance, a virtual member function can
	override several virtual member functions coming from different
	base classes.

	In all cases, this function determines the immediate overridden
	method, rather than all of the overridden methods. For example, if
	a method is originally declared in a class A, then overridden in B
	(which in inherits from A) and also in C (which inherited from B),
	then the only overridden method returned from this function when
	invoked on C's method will be B's method. The client may then
	invoke this function again, given the previously-found overridden
	methods, to map out the complete method-override set.

	Parameter cursor A cursor representing an Objective-C or C++
	method. This routine will compute the set of methods that this
	method overrides.

	Parameter overridden A pointer whose pointee will be replaced with a
	pointer to an array of cursors, representing the set of overridden
	methods. If there are no overridden methods, the pointee will be
	set to NULL. The pointee must be freed via a call to
	clang_disposeOverriddenCursors().

	Parameter num_overridden A pointer to the number of overridden
	functions, will be set to the number of overridden functions in the
	array pointed to by \p overridden.
*/
func (c Cursor) OverriddenCursors() []Cursor {
	var cp_overridden *C.CXCursor
	var overridden []Cursor
	var numOverridden C.uint

	C.clang_getOverriddenCursors(c.c, &cp_overridden, &numOverridden)

	gos_overridden := (*reflect.SliceHeader)(unsafe.Pointer(&overridden))
	gos_overridden.Cap = int(numOverridden)
	gos_overridden.Len = int(numOverridden)
	gos_overridden.Data = uintptr(unsafe.Pointer(cp_overridden))

	return overridden
}
コード例 #2
0
ファイル: cursor.go プロジェクト: quarnster/go-clang
/**
 * \brief Determine the set of methods that are overridden by the given
 * method.
 *
 * In both Objective-C and C++, a method (aka virtual member function,
 * in C++) can override a virtual method in a base class. For
 * Objective-C, a method is said to override any method in the class's
 * interface (if we're coming from an implementation), its protocols,
 * or its categories, that has the same selector and is of the same
 * kind (class or instance). If no such method exists, the search
 * continues to the class's superclass, its protocols, and its
 * categories, and so on.
 *
 * For C++, a virtual member function overrides any virtual member
 * function with the same signature that occurs in its base
 * classes. With multiple inheritance, a virtual member function can
 * override several virtual member functions coming from different
 * base classes.
 *
 * In all cases, this function determines the immediate overridden
 * method, rather than all of the overridden methods. For example, if
 * a method is originally declared in a class A, then overridden in B
 * (which in inherits from A) and also in C (which inherited from B),
 * then the only overridden method returned from this function when
 * invoked on C's method will be B's method. The client may then
 * invoke this function again, given the previously-found overridden
 * methods, to map out the complete method-override set.
 *
 * \param cursor A cursor representing an Objective-C or C++
 * method. This routine will compute the set of methods that this
 * method overrides.
 *
 * \param overridden A pointer whose pointee will be replaced with a
 * pointer to an array of cursors, representing the set of overridden
 * methods. If there are no overridden methods, the pointee will be
 * set to NULL. The pointee must be freed via a call to
 * \c clang_disposeOverriddenCursors().
 *
 * \param num_overridden A pointer to the number of overridden
 * functions, will be set to the number of overridden functions in the
 * array pointed to by \p overridden.
 */
func (c Cursor) OverriddenCursors() (o OverriddenCursors) {
	C.clang_getOverriddenCursors(c.c, &o.c, &o.n)

	return o
}