// Copyright (c) 2004-2013, Benoit PERROT.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
//
//     * Neither the name of the White Hole Project nor the names of its
//       contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Build a Java class representing an enumerated type in a binary decoding
// scheme. Said class is immutable.
//

define('org/whitehole/binary/generateSchemeModel',
       [ 'org/whitehole/infra/IO',
         'org/whitehole/binary/generateEnumeration',
         'org/whitehole/binary/generateFlagSet',
         'org/whitehole/binary/generateStructure'],
         function(IO, generateEnumeration, generateFlagSet, generateStructure) {
	'use strict';

	function generate(ns, name, e) {
	}
	
	return function(schemaPath, destNS) {
		var schema = IO.readJSONFile(schemaPath);

		var destPath = 'src/' + destNS.replace(/\./g, '/');

		for (k in schema.enumerations)
			if (schema.enumerations.hasOwnProperty(k))
				IO.writeFile(destPath + '/' + k + '.java',
				             generateEnumeration(destNS, k, schema.enumerations[k]));

		for (k in schema.flagSets)
			if (schema.flagSets.hasOwnProperty(k))
				IO.writeFile(destPath + '/' + k + '.java',
				             generateFlagSet(destNS, k, schema.flagSets[k]));

		for (k in schema.structures)
			if (schema.structures.hasOwnProperty(k))
				if (k !== 'ImageFile' && k !== 'OptionalHeader' && k !== 'WindowsSpecificPEFields')
					IO.writeFile(destPath + '/' + k + '.java',
					             generateStructure(destNS, k, schema.structures[k]));
	}
});

@@ -2234,24 +2234,26 @@
 hemaPath);%0D%0A
+%09%09
 %0D%0A%09%09var dest
@@ -2370,32 +2370,100 @@
 sOwnProperty(k))
+ %7B%0D%0A%09%09%09%09print(%22Generating %22 + destPath + '/' + k + '.java' + %22...%22);
 %0D%0A%09%09%09%09IO.writeFi
@@ -2563,32 +2563,40 @@
 erations%5Bk%5D));%0D%0A
+%09%09%09%7D%0D%0A%09%09
 %0D%0A%09%09for (k in sc
@@ -2648,24 +2648,92 @@
 Property(k))
+ %7B%0D%0A%09%09%09%09print(%22Generating %22 + destPath + '/' + k + '.java' + %22...%22);
 %0D%0A%09%09%09%09IO.wri
@@ -2833,24 +2833,32 @@
 Sets%5Bk%5D));%0D%0A
+%09%09%09%7D%0D%0A%09%09
 %0D%0A%09%09for (k i
@@ -3011,16 +3011,85 @@
 Fields')
+ %7B%0D%0A%09%09%09%09%09print(%22Generating %22 + destPath + '/' + k + '.java' + %22...%22);
 %0D%0A%09%09%09%09%09I
@@ -3203,16 +3203,23 @@
 %5Bk%5D));%0D%0A
+%09%09%09%09%7D%0D%0A
 %09%7D%0D%0A%7D);%0D

Add some trace when generating