Magic Prototyper

The Magic Prototyper is a plugin that makes writing class definitions and corresponding declarations a snap - it takes care of all the copy-paste actions you normally have to perform when filling out the implementation of class methods. It is even more useful when writing class template methods, saving three or more copy-paste operations per method.

The prototyper starts out empty, the prototyper button indicates the empty state.

When the user selects function definitions, declarations, classes with member functions, templates, etc. and clicks the prototyper, the prototyper clipboard gets loaded with prototypes and the prototyper button changes.

Pressing on the prototyper button displays the clipboard with prototypes, ready to be pasted into a source file. The user can examine generated prototypes in the clipboard before pasting them.

Clicking on the full prototyper button pastes the prototypes into the current selection.

Click or Press an empty prototyper button

Loads the prototyper with prototypes of selected C/C++/Obj-C code

Press a full prototyper button

Displays the prototypes in a popup window

Click on a full prototyper button

Pastes the prototypes into the current selection

Control-click on a full prototyper

Empties the prototyper

Hold down Option key while loading the prototyper

Forces generating prototypes for everything (including static functions, pure virtual functions, etc.)

Hold down Shift while loading the prototyper

Appends new prototypes to prototyper clipboard after the existing prototypes

C functions

Using the prototyper on a non-static C function definition will result in generating corresponding function declarations with extern prefixes. Holding down the Option key includes prototypes for static functions. Using the prototyper on C function declarations generates an inverse prototype - an empty version of the function with empty curly braces ready to fill out with code.

C++ functions, Obj-C methods

Selecting C++ functions or Obj-C methods and clicking the prototyper will generate member function definitions, formatted such that they can be immediately pasted into a corresponding class declaration

C++ class, Obj-C Interface - inverse prototyping

Selecting a C++ class definition or Obj-C Interface and clicking the prototyper button will generate corresponding empty functions or empty methods. C++ Functions containing inline code, pure virtuals and static functions are not included by default. C++ Default parameter values are removed by the prototyper (note the default value of nullptr for the parameter param is removed in the generated constructor definition in the prototyper clipboard).

C++ extras

By holding down the Option key you may choose to also include prototypes for pure virtual functions, static functions and functions that are inlined in the class definition. In the example above, the prototyper clipboard contains prototypes for Pure and for Count, even though Count is inlined inside the class definition.

While loading the prototyper clipboard, if the only function contained by the selection is a pure virtual, static or inlined in the class, the prototyper will still load the clipboard for an empty definition for that function even without holding down the Option key.

When pasting empty function definitions into a header file, the prototyper assumes that they are intended to be inlines and adds inline appropriately. If you paste the same definitions in a .cpp file, inline keywords will not be added.

Template class members and specially template member functions are particularly easy to pull out of their enclosing class. Normally a major and error-prone copy-paste operation, the prototyper makes this supper easy, letting you go from this:

... to this:

in two clicks.

Finally the prototyper can be used to create instantiations of class static member variables.

Obj-C classes

Even though going from method declarations to definitions is much less tedious than with C++ classes and templates, the Prototyper in Eddie can still greatly simplify the typical workflow of creating a new Obj-C class. Just like with C++, you may select a bunch of methods in the Obj-C class @interface, click to generate the prototypes, then switch to the source file and click again to paste them:

Notice the resulting method definitions are conveniently wrapped in an appropriate @implementation block. The Eddie Prototyper inspects the code you are pasting into and if there isn't an @implementation block present, it includes it with the pasted methods. Conversely, if you paste one or two new methods that you just added to an existing, established class, the pasted definitions will be pasted without the @implementation wrapper. Say we add a new initWithImage: title: initializer method to our class, selecting it, clicking the prototyper button, then switching to the source file and pasting alongside the other existing methods will paste just that new method:

Keyboard shortcuts

By default the Prototyper defines the following keyboard shortcuts. Several others are available by binding the respective primitive function with a SetKey keyboard shortcut. For a full list of Prototyper keyboard shortcuts, execute Primitives | grep Prototyper in the Worksheet.

Control-Option-P

If empty, loads prototypes, if full pastes prototypes into selection

Control-P

If empty, loads all prototypes, including pure virtual and already inlined, if full, pastes prototypes into selection


Prototype formatting can be configured in the Eddie Preferences, allowing you to choose the exact white space sequences for the particular parts of the generated prototypes to suite your style. Eddie can also be set up to prepend function banners before generated functions and methods.

You may choose from one of the preconfigured themes or customize the desired white space to your liking.