Permalink
Browse files

removing old autogen stuff

  • Loading branch information...
1 parent d8c6c65 commit 7c7bc898cc224a84190e6e52e7872ed9811bda72 @tmpvar committed Aug 25, 2011
Showing with 0 additions and 968 deletions.
  1. +0 −197 util/generate.js
  2. BIN util/gmon.out
  3. +0 −11 util/templates/file.cc
  4. +0 −21 util/templates/file.h
  5. +0 −739 util/webgl.idl
View
@@ -1,197 +0,0 @@
-var fs = require('fs');
-var idl = fs.readFileSync(__dirname + '/webgl.idl').toString();
-
-var t_h = fs.readFileSync(__dirname + '/templates/file.h').toString();
-var t_cc = fs.readFileSync(__dirname + '/templates/file.cc').toString();
-
-var currentProperties = [];
-var current = '';
-var h = '';
-var cc = '';
-var queue = '';
-var files = {};
-var includes = [];
-
-
-var skip = [
- 'void', 'void*', 'bool', 'int', 'float', 'long',
- 'double', 'long', 'GLfloat', 'GLenum', 'GLboolean', 'GLint',
- 'GLsizeiptr', 'GLclampf', 'GLsizei', 'GLuint', 'GLbitfield',
- 'GLintptr', 'GLclampf', 'GLboolean'
-];
-
-idl = idl.replace(/readonly attribute/g, 'readonly');
-idl = idl.replace(/attribute boolean/g, 'bool');
-idl = idl.replace(/ boolean/g, ' bool');
-idl = idl.replace(/\[[ ]*\]/g, '\*\*');
-
-idl = idl.replace(/sequence<(.*)>/g, '$1\*\*');
-
-function addInclude(file, addLine) {
- file = file.replace(/\*/g, '');
- var include = '#include "' + file + '.h"';
-
- if (file && includes.indexOf(include) < 0 && skip.indexOf(file) === -1) {
- includes.push(include);
- if (addLine !== false && !files[file]) {
- lines.push('interface ' + file + ' {');
- lines.push(' ');
- lines.push('};');
- files[file] = true;
- }
- }
-}
-
-function addPointer(type, value) {
- value = value || '';
- // Add a pointer if needed
- if (type.indexOf('*') < 0 && skip.indexOf(type) < 0) {
- return '*' + value;
- }
- return value;
-}
-
-var lines = idl.split('\n');
-var line;
-var i = 0;
-while(1) {
- i++;
- if (i >= lines.length) {
- break;
- }
-
- var line = lines[i];
- line = line.replace(/any/, 'void* ');
- line = line.replace(/object/, 'void* ');
-
- // Handle interfaces
- if (line.indexOf('interface') > -1) {
- var match = line.match(/interface +(.*) +\{/);
- var nameParts = match[1].split(' : ');
- var name, parent = '', parentClass = '', parentInclude = '';
-
- if (nameParts.length === 2) {
- parent = nameParts.pop();
- parentClass = ' : ' + parent;
- addInclude(parent);
- }
-
- name = current = nameParts.pop().replace(/^\W*|\W*$/g,'');
- files[name] = true;
-
- h = t_h.replace(/%FILE%/g, name);
- h = h.replace(/%PARENT_CLASS%/, parentClass);
-
- cc = t_cc.replace(/%FILE%/g, name);
- cc += name + '::' + name + '() {\n \n}\n\n';
- cc += name + '::~' + name + '() {\n \n}\n\n';
-
- currentProperties = [
- ];
-
- // Handle the end of an interface
- } else if (line.indexOf('};') > -1) {
- if (current === '') {
- continue;
- }
-
- if (currentProperties.length > 0) {
-
- var h_props = [];
- currentProperties.forEach(function(prop) {
- // only function calls
- if (prop.indexOf('(') > -1) {
-
-
- var propParts = prop.replace(/^ +/, '').split(' ');
- if (propParts.length > 2) {
- //propParts[2] = current + '::' + propParts[2];
- prop = propParts.join(' ').replace(';', ' {');
- // calculate extra includes
- var matches = prop.match(/^(.+) (.*)\((.*)\)/i);
- if (matches && matches.length === 4) {
- addInclude(matches[1]);
-
- var args = [];
-
- matches[3].split(', ').forEach(function(arg) {
-
- arg = arg.replace(/sequence<(.*)>/, '$1\*');
- arg = arg.replace(/^boolean$/, 'bool');
- var argParts = arg.split(' ');
- var type = argParts[0];
-
- argParts[1] = addPointer(type, argParts[1]);
-
- var arg = argParts.join(' ');
-
- args.push(arg);
-
-
-
- addInclude(type);
- });
- h_props.push(' ' + matches[1] + addPointer(matches[1], ' ') + matches[2] + '(' + args.join(', ') + ');');
- cc += matches[1] + addPointer(matches[1], ' ') + current + '::' + matches[2] + '(' + args.join(', ') + ') {\n \n}\n\n';
- } else {
- console.log('miss', prop, matches);
- }
- }
-
- if (propParts.length === 2) {
- addInclude(propParts[0]);
- cc += propParts[0] + addPointer(propParts[0], ' ') + current + '::' + propParts[1].replace(';', ' {\n \n}\n\n') + '\n';
- h_props.push(' ' + propParts[0] + addPointer(propParts[0], ' ') + propParts[1]);
- }
-
- } else {
-
- // split off = and add instance to .cc
- var matches = prop.match(/(.*) (.*) = (.*)$/i);
- if (matches) {
- matches[1] = matches[1].replace('const', 'static const');
- h_props.push(matches[1] + ' ' + matches[2] + ' = ' + matches[3] + ';');
- } else {
-
-
- attributeMatch = prop.match(/readonly (.*) (.*);/);
-
- if (attributeMatch) {
- addInclude(attributeMatch[1]);
- var titleCase = attributeMatch[2].substring(0,1).toUpperCase() + attributeMatch[2].substring(1);
- prop = attributeMatch[1] + ' get' + titleCase + '();'
- cc += attributeMatch[1] + ' ' + current + '::get' + titleCase + '() {\n \n}\n\n';
- }
-
- h_props.push(' ' + prop.replace(/^\W*/, ''));
- }
- }
- });
-
- h = h.replace(/%PUBLIC%/, '\n public:\n' + h_props.join('\n') + '\n');
- }
-
- h = h.replace(/%PARENT_INCLUDE%/, includes.join('\n') + '\n');
- h = h.replace(/%PUBLIC%/, '\n public:\n');
- includes = [];
-
- fs.writeFileSync(__dirname + '/../src/' + current + '.h', h);
- fs.writeFileSync(__dirname + '/../src/' + current + '.cc', cc);
-
- current = '';
- currentProperties = [];
- h = '';
- cc = '';
- } else if (line.indexOf(';') > -1) {
-
- queue += line;
- queue = queue.split('\n').join('');
-
- currentProperties.push(' ' + queue.replace(/ +/g,' '));
- queue = '';
- } else if (line.match(/(, )|,$/)) {
- queue += line;
- } else if (queue !== '') {
- queue += line.replace(/ +/g,' ');
- }
-};
View
Binary file not shown.
View
@@ -1,11 +0,0 @@
-/**
- WebGL Standalone
-
- %FILE%.h
-
- Released under the MIT license (see: ../LICENSE)
- Copyright Elijah Insua <tmpvar@gmail.com> 2011
-**/
-
-#include "%FILE%.h"
-
View
@@ -1,21 +0,0 @@
-/**
- WebGL Standalone
-
- %FILE%.h
-
- Released under the MIT license (see: ../LICENSE)
- Copyright Elijah Insua <tmpvar@gmail.com> 2011
-**/
-#ifndef _INCLUDED_%FILE%_
-#define _INCLUDED_%FILE%_
-
-#include "arch/wrapper.h"
-
-%PARENT_INCLUDE%
-
-class %FILE%%PARENT_CLASS% {%PUBLIC%
- %FILE%();
- ~%FILE%();
-};
-
-#endif
Oops, something went wrong.

0 comments on commit 7c7bc89

Please sign in to comment.