---
CodeGen - v0.2
April 5, 2000
---

CodeGen is a developer only tool. If you don't write code then don't bother downloading it. It won't be useful. Come to think of it it may not even be useful even if you are a developer. :-)

CodeGen is an extremely simple services based app you can use to generate accessor methods from ivar declarations. It currently generates Objective C or Java (though I've never tested that the Java output even compiles). 

If you have an object that you've added some ivars to:

	NSString *_name;
	NSString *_address;
	BOOL _isEmployed;

you can copy and paste these further down where you want your method declarations, select the ivars and choose "Services -> CodeGen -> Generate ObjC Interface Accessors". You'll have your ivar declarations replaced with:

- (NSString*) name;
- (void) setName:(NSString*)newName;

- (NSString*) address;
- (void) setAddress:(NSString*)newAddress;

- (BOOL) isEmployed;
- (void) setIsEmployed:(BOOL)newIsEmployed;

Do the same in your implementation file (CodeGen -> Generate ObjC Implementation Accessors) and you'll have instant accessors so you can concentrate on writing the code that actually does something in your app.

Installation
Open the CodeGen project in Project Builder and build and install it (defaults to your Applications folder). Log out. Log back in. Fire up your favorite text editor that has access to services. Under the Services menu you should see a submenu called CodeGen.

Template Locations
Don't like the code that my templates spit out? Copy them from the project, alter them and put them in any of the following locations:

The currently searched locations are (in the order they are searched):
	~/Library/CodeGen
	/Local/Library/CodeGen
	/System/Library/CodeGen
	app wrapper

The MiscMergeEngine is used to create the output so you might want to take a look at the Test.txt in MiscMerge.subproj to see what kind of constructs are allowed in your templates.

Adding Templates
	You can easily add new services by editing the services the application declares in it's CustomInfo.plist file. For instance, say you wanted to add a template called "CodeGen/Generate dealloc statements" and created a template called "ObjCDeallocImplementation". You just need to create a new template (following the style in the already provided templates) and create a new services entry that looks like:

	{
		NSMenuItem = {default = "CodeGen/Generate Dealloc Code"; }; 
		NSMessage = generateFromTemplate; 	
		NSPortName = CodeGen; 
		NSSendTypes = (NSStringPboardType); 
		NSReturnTypes = (NSStringPboardType); 
		NSUserData = "{template=ObjCDeallocIvars;}";
    }

For each new entry only the NSMenuItem and NSUserData items change.

MiscMergeKit Notes
	The MiscMergeKit code came directly from the AutoDoc beta 5 release.

Known Bugs
	- the parsing isn't very good at all. Two word C types such as "unsigned int" aren't parsed correctly.


This code falls under the "Don't come looking for me if this software harms your data or hardware in any way" license. Use at your own risk. 


Send any bug reports/suggestions to:
Todd Thomas <rtthomas@mediaone.net>
