ExtractInterface.refscript

This page describes the ExtractInterface RefactorScript shipped with VisualGDB.

Overview

This script generates an interface based on the selected methods of a class.
In order to run this script, first select one or more methods via Code Explorer -> Outline.

Script


[Main, Description("Extract Interface")]
generator ExtractInterface(Array methods)
{
>class I$methods.First.ContainingType.ShortName
>{
>public:
    foreach(mtd in methods)
    {
>>    virtual $mtd.ReturnType.Literal $mtd.ShortName(
        foreach(arg in mtd.Arguments)
        {
            >>$arg.Type.Literal $arg.ShortName$arg.Type.LiteralSuffix
            if (!arg.IsLast)
                >>, 
        }
>) = 0;
    }
>};
}

Sample Input

class SimpleClass
{
public:
    void UnimplementedMethod(int x, void *p);
    double UnimplementedMethod2(double x);
};

Sample Output

class ISimpleClass
{
public:
    virtual void UnimplementedMethod(int x, void * p) = 0;
    virtual double UnimplementedMethod2(double x) = 0;
};
A detailed reference on RefactorScript syntax and data model is available here.
See this page for a full list of RefactorScripts shipped with VisualGDB.