MethodSignature

A MethodSignature holds the interface through which a method is known.  It holds things such as the return Type and a list of Param objects.

The methodsignature may have a variable length argument list.  In managed terms this means it has a final parameter of type System.Object[] to hold the variable length arguments.   When an unmanaged function is called that has variable length argument list, the call site for the call needs to fully qualify the types of the specific arguments being used (for marshalling purposes).   A second list of Param objects is used to list them out.   Given the two param lists and the fact that it is a VARARG function, DotNetPELib will automatically transcribe the results as necessary for the given output type.

The MethodSignature may be constructed either directly, or through the Allocator object.   Flags indicates whether it is a vararg method, an instance method, a managed method

        enum { Vararg = 1, Managed = 2, InstanceFlag = 4 };

        MethodSignature(std::string Name, int Flags, DataContainer *Container);

Access the return type.

        Type *ReturnType() const { return returnType_; }
        void ReturnType(Type *type)

Add a parameter.   This function only successfully adds a parameter if the variable length argument parameter list hasn't been started; otherwise it throws PELibError.

        void AddParam(Param *param)

Add a parameter to he variable length parameter list.

        void AddVarargParam(Param *param);

This is used to associate a call site definition for an unmanaged function with Variable Lenth argument list with the main prototype.

        void SignatureParent(MethodSignature *parent) { methodParent_ = parent; }
        MethodSignature *SignatureParent() { return methodParent_; }

Access the container this signature goes with.

        void SetContainer(DataContainer *container) { container_ = container; }

        DataContainer *GetContainer() const { return container_; }

Access the signature's Method name

        const std::string &Name() const { return name_; }

        void SetName(std::string Name) { name_ = Name; }

Internal use: support signatures for multidimensional array helper functions

       void ArrayObject(Type *tp) { arrayObject_ = tp; }

Iterate through the parameter list

        typedef std::list<Param *>::iterator iterator;

        iterator begin() { return params.begin(); }
        iterator end() { return params.end(); }

Iterate through the variable length post-parameter list

        typedef std::list<Param *>::iterator viterator;

        iterator vbegin() { return varargParams_.begin(); }
        iterator vend() { return varargParams_.end(); }

Access whether it has a this pointer

       void Instance(bool instance)

        bool Instance() const { return !!(flags_ & InstanceFlag); }

Set the vararg flag for varargs

        void SetVarargFlag() { flags_ |= Vararg; }


Get the vararg, managed, and instance flags

        int Flags() const { return flags_; }

Access param counts.

        size_t ParamCount() const { return params.size(); }

        size_t VarargParamCount() const { return varargParams_.size(); }

Internal function, can be used to match the main Param list to a list of types.

        bool Matches(std::vector<Type *> args);

Get/set the 'external' flag (used by the linker)

        void External(bool external) { external_ = External; }
        bool External() const { return external_; }