Check if the declaration is a copy constructor,

    Args:
        constructor (declarations.constructor_t): the constructor
            to be checked.

    Returns:
        bool: True if this is a copy constructor, False instead.
196421
def is_copy_constructor(constructor):
    
    assert isinstance(constructor, calldef_members.constructor_t)
    args = constructor.arguments
    parent = constructor.parent

    # A copy constructor has only one argument
    if len(args) != 1:
        return False

    # We have only one argument, get it
    arg = args[0]

    if not isinstance(arg.decl_type, cpptypes.compound_t):
        # An argument of type declarated_t (a typedef) could be passed to
        # the constructor; and it could be a reference.
        # But in c++ you can NOT write :
        #    "typedef class MyClass { MyClass(const MyClass & arg) {} }"
        # If the argument is a typedef, this is not a copy constructor.
        # See the hierarchy of declarated_t and coumpound_t. They both
        # inherit from type_t but are not related so we can discriminate
        # between them.
        return False

    # The argument needs to be passed by reference in a copy constructor
    if not type_traits.is_reference(arg.decl_type):
        return False

    # The argument needs to be const for a copy constructor
    if not type_traits.is_const(arg.decl_type.base):
        return False

    un_aliased = type_traits.remove_alias(arg.decl_type.base)
    # un_aliased now refers to const_t instance
    if not isinstance(un_aliased.base, cpptypes.declarated_t):
        # We are looking for a declaration
        # If "class MyClass { MyClass(const int & arg) {} }" is used,
        # this is not copy constructor, so we return False here.
        # -> un_aliased.base == cpptypes.int_t (!= cpptypes.declarated_t)
        return False

    # Final check: compare the parent (the class declaration for example)
    # with the declaration of the type passed as argument.
    return id(un_aliased.base.declaration) == id(parent)
934052
private static boolean hasCompatibleConstructor(Class<?>[] paramTypes, Class<?>[] constructorTypes)
    {
        for (int i = 0; i < paramTypes.length; i++)
        {
            if (constructorTypes[i].isAssignableFrom(paramTypes[i]))
            {
                return true;
            }
        }
        return false;
    }
214446
def is_defined_in_xxx(xxx, cls):
        
        if not cls.parent:
            return False

        if not isinstance(cls.parent, namespace.namespace_t):
            return False

        if xxx != cls.parent.name:
            return False

        xxx_ns = cls.parent
        if not xxx_ns.parent:
            return False

        if not isinstance(xxx_ns.parent, namespace.namespace_t):
            return False

        if xxx_ns.parent.name != '::':
            return False

        global_ns = xxx_ns.parent
        return None is global_ns.parent
106790
public static boolean isConstructor(JCTree tree) {
        if (tree.hasTag(METHODDEF)) {
            Name name = ((JCMethodDecl) tree).name;
            return name == name.table.names.init;
        } else {
            return false;
        }
    }
657128
def instance_of(cls):
    
    def check(value):
        return (
            isinstance(value, cls),
            u"{value!r} is instance of {actual!s}, required {required!s}".format(
                value=value,
                actual=fullyQualifiedName(type(value)),
                required=fullyQualifiedName(cls),
            ),
        )
    return check
816691
public ASTConstructor getConstructor(Constructor constructor, boolean isEnum, boolean isInnerClass) {
        ASTAccessModifier modifier = ASTAccessModifier.getModifier(constructor.getModifiers());

        Annotation[][] parameterAnnotations = constructor.getParameterAnnotations();

        if(constructor.getDeclaringClass().getEnclosingClass() != null && !Modifier.isStatic(constructor.getDeclaringClass().getModifiers())){
            // An inner class constructor contains a hidden non-annotated prameter
            Annotation[][] paddedParameterAnnotations = new Annotation[parameterAnnotations.length + 1][];

            paddedParameterAnnotations[0] = new Annotation[0];
            System.arraycopy(parameterAnnotations, 0, paddedParameterAnnotations, 1, parameterAnnotations.length);

            parameterAnnotations = paddedParameterAnnotations;
        }

        ImmutableList<ASTParameter> constructorParameters = getParameters(constructor.getParameterTypes(), constructor.getGenericParameterTypes(), parameterAnnotations);
        if(isEnum) {
            constructorParameters = constructorParameters.subList(2, constructorParameters.size());
        }
        if(isInnerClass){
            constructorParameters = constructorParameters.subList(1, constructorParameters.size());
        }
        ImmutableSet<ASTType> throwsTypes = getTypes(constructor.getExceptionTypes());

        return new ASTClassConstructor(getAnnotations(constructor), constructor, constructorParameters, modifier, throwsTypes);
    }
888717
def singleton(cls):
    
    import inspect

    # Create a structure to store instances of any singletons that get
    # created.
    instances = {}

    # Make sure that the constructor for this class doesn't take any
    # arguments.  Since singletons can only be instantiated once, it doesn't
    # make any sense for the constructor to take arguments.  If the class 
    # doesn't implement its own constructor, don't do anything.  This case is 
    # considered specially because it causes a TypeError in python 3.3 but not 
    # in python 3.4.
    if cls.__init__ is not object.__init__:
        argspec = inspect.getfullargspec(cls.__init__)
        if len(argspec.args) != 1 or argspec.varargs or argspec.varkw:
            raise TypeError("Singleton classes cannot accept arguments to the constructor.")


    def get_instance():
        """ Creates and returns the singleton object.  This function is what 
        gets returned by this decorator. """

        # Check to see if an instance of this class has already been
        # instantiated.  If it hasn't, create one.  The `instances` structure
        # is technically a global variable, so it will be preserved between
        # calls to this function.
        if cls not in instances:
            instances[cls] = cls()

        # Return a previously instantiated object of the requested type.
        return instances[cls]

    # Return the decorator function.
    return get_instance
484314
public static String getConstructorDescriptor(final Constructor<?> constructor) {
    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append('(');
    Class<?>[] parameters = constructor.getParameterTypes();
    for (int i = 0; i < parameters.length; ++i) {
      appendDescriptor(stringBuilder, parameters[i]);
    }
    return stringBuilder.append(")V").toString();
  }
925440
function( Ctor ){

          var searchedProto = Ctor.OriginalConstructor ? Ctor.OriginalConstructor.prototype : Ctor.prototype;
          var current = this;
          var compare;

          while( ( current = Object.getPrototypeOf( current ) ) ){

            // It will compare either with OriginalConstructor.prototype or plain prototype
            compare = current.constructor.OriginalConstructor ?
                      current.constructor.OriginalConstructor.prototype :
                      current.constructor.prototype;

            // Actually run the comparison
            if( compare === searchedProto ) return true;
          }
          return false;
        }
657463
def is_const(*p):
    
    return is_SYMBOL('VAR', *p) and all(x.class_ == CLASS.const for x in p)
1151320
def constructors(
            self,
            name=None,
            function=None,
            return_type=None,
            arg_types=None,
            header_dir=None,
            header_file=None,
            recursive=None,
            allow_empty=None):
        """"""
        return (
            self._find_multiple(
                self._impl_matchers[scopedef_t.constructor],
                name=name,
                function=function,
                decl_type=self._impl_decl_types[
                    scopedef_t.constructor],
                return_type=return_type,
                arg_types=arg_types,
                header_dir=header_dir,
                header_file=header_file,
                recursive=recursive,
                allow_empty=allow_empty)
        )
671738
function at_method(isConstructor) {
  if (isConstructor) {
    match(/@constructor\b/);
    add_tag("method");
    add_tag("Constructor");
    skip_white();
  }
  else {
    match(/@method/);
    add_tag("method");
    maybe_name();
    skip_white();
  }
}
1185282
private static boolean isConstructor(String methodName) {
        return Const.CONSTRUCTOR_NAME.equals(methodName) || Const.STATIC_INITIALIZER_NAME.equals(methodName) || "readObject".equals(methodName)
                || "clone".equals(methodName) || "close".equals(methodName) || "writeObject".equals(methodName)
                || "toString".equals(methodName) || "init".equals(methodName) || "initialize".equals(methodName)
                || "dispose".equals(methodName) || "finalize".equals(methodName) || "this".equals(methodName)
                || "_jspInit".equals(methodName) || "_jspDestroy".equals(methodName);

    }
1303975
def is_struct(declaration):
    
    if not is_class(declaration):
        return False
    decl = class_traits.get_declaration(declaration)
    return decl.class_type == class_declaration.CLASS_TYPES.STRUCT
538700
private void check(Class clazz) {

        final Constructor<?>[] constructors = clazz.getDeclaredConstructors();

        if (constructors.length > 1) {
            throw new AssertionError(clazz + " has more than one constructor");
        }

        final Constructor<?> constructor = constructors[0];

        constructor.setAccessible(true);

        if (!Modifier.isPrivate(constructor.getModifiers())) {
            throw new AssertionError("Constructor of " + clazz + " must be private");
        }

        final Class<?>[] parameterTypes = constructor.getParameterTypes();

        if (parameterTypes.length > 0) {
            if (expectedParameters == null) {
                throw new AssertionError(clazz + " has non-default constructor with some parameters");
            } else {
                if (!Arrays.equals(parameterTypes, expectedParameters)) {
                    throw new AssertionError("Expected constructor with parameters " + getReadableClassesOutput(expectedParameters) + " but found constructor with parameters " + getReadableClassesOutput(parameterTypes));
                } else {
                    return;
                }
            }
        }

        try {
            constructor.newInstance();
        } catch (InstantiationException e) {
            throw new RuntimeException("Can not instantiate instance of " + clazz, e);
        } catch (IllegalAccessException e) {
            // Fixed by setAccessible(true)
            throw new RuntimeException(e);
        } catch (InvocationTargetException e) {
            final Throwable cause = e.getCause();

            // It's okay case if we expect some exception from this constructor
            if (expectedTypeOfException != null || expectedExceptionMessage != null) {
                if (expectedTypeOfException != null && !expectedTypeOfException.equals(cause.getClass())) {
                    throw new IllegalStateException("For " + clazz + " expected exception of type = " + expectedTypeOfException + ", but was exception of type = " + e.getCause().getClass());
                }

                if (expectedExceptionMessage != null && !expectedExceptionMessage.equals(cause.getMessage())) {
                    throw new IllegalStateException("For " + clazz + " expected exception message = '" + expectedExceptionMessage + "', but was = '" + cause.getMessage() + "'", e.getCause());
                }

                // Everything is okay
            } else {
                throw new IllegalStateException("For " + clazz + " no exception was expected", e);
            }
        } catch (IllegalArgumentException e) {
            throw new RuntimeException("Looks like constructor of " + clazz + " is not default", e);
        }
    }
283908
function checkDescriptor(descriptor, err){
	if(typeof descriptor != 'object') return false;
	
	for(var key in CONST.descriptorType){
		if(!checkType(descriptor[key], CONST.descriptorType[key])){
			err.key = key;
			err.expect = CONST.descriptorType[key];
			err.type = typeof descriptor[key];
			return false;
		}
	}

	for(var key in CONST.descriptorOptType){
		if(typeof descriptor[key] != 'undefined' && checkType(descriptor[key], CONST.descriptorOptType[key].type)) continue;
		if(typeof descriptor[key] == 'undefined'){
			if(typeof CONST.descriptorOptType[key].value != 'undefined') descriptor[key] = CONST.descriptorOptType[key].value;
			continue;
		}

		err.key = key;
		err.expect = CONST.descriptorOptType[key].type;
		err.type = typeof descriptor[key];
		return false;
	}

	return true;
}
70491
def _find_constructor(self):
        

        def isconstructor(object):
            return inspect.isfunction(object) and object.__name__ == '__init__'

        # find all the dependencies from the constructor
        constructors = inspect.getmembers(self.class_type, predicate=isconstructor)

        if constructors:
            name, func = constructors[0]
            return func

        # No explicit __init__
        return None