Skip to content
This repository
Browse code

add a code generator

  • Loading branch information...
commit 5aecfcae7a9fcf98737484ba99b16a78a0699b2a 1 parent 6ee4df3
iptton iptton authored

Showing 1 changed file with 66 additions and 0 deletions. Show diff stats Hide diff stats

  1. +66 0 codeGenerator.html
66 codeGenerator.html
... ... @@ -0,0 +1,66 @@
  1 +<!DOCTYPE html>
  2 +<html>
  3 +<head>
  4 + <meta name="generator" content="iptton#gmail.com"/>
  5 + <title>c++ .h define to declare</title>
  6 +</head>
  7 +<body>
  8 +<textarea id="defines" style="width:300px;height:200px">
  9 +public:
  10 + void
  11 + a();
  12 + void *b()const;
  13 + const a* b():const;
  14 + const a& c():const;
  15 +signals:
  16 + void k();
  17 +private:
  18 + void d(d& c,C c=3):const;
  19 +
  20 +signals:
  21 + void k();
  22 +</textarea>
  23 +<textArea id="output" style="width:300px;height:200px">
  24 +
  25 +</textArea><br/>
  26 +<label for="className">class name</label><input type="text" id="className" /> <br/>
  27 +<label for="useSpace">use space instead of tab</label><input type="checkBox" checked /><br/>
  28 +<label for="tabWidth">tab width</label><input type="text" value="4" id="tabWidth"/>
  29 +<button id="go">go</button>
  30 +<script>
  31 +function $(id){return document.getElementById(id);}
  32 +$('go').onclick=function(){
  33 + s = $('defines').value;
  34 + s=s.replace(/[\n]/g,"");
  35 + s=s.replace(/[\t]/g,"");
  36 + //console.info(s);
  37 + s = s.trim();
  38 + s = s.replace(/[\s]{2,}/g," ");
  39 + //console.info(s);
  40 + s=s.replace(/signals\:.*(?:((private|public|protected)))/g,"");//replace all signals
  41 + s=s.replace(/signals\:.*$/g,"");//replace all signals
  42 + s=s.replace(/((public)|(private)|(protected))\:/g,"");
  43 + fs = s.split(";");
  44 +
  45 + var className=$('className').value;
  46 + var outputStr=[];
  47 + for(var i=0;i<fs.length;++i){
  48 + var f = fs[i];
  49 + f=f.trim();
  50 + if(!f)continue;
  51 + //console.info(f);
  52 + var j = f.search(/[^\s]+\(/); // bala bala fName(argType arg1,argType2 arg2...):const;
  53 + if(j==-1){
  54 + outputStr.push("/*invalid function:",f,"*/");
  55 + continue;
  56 + }
  57 + var type=f.substr(0,j);
  58 + var fnameAndArg=f.substr(j,f.length-1-j);
  59 + outputStr.push([type,className,"::",fnameAndArg,"{\\TODO auto generator by ippan\r\n\r\n}"].join(""));
  60 + }
  61 + $('output').value=outputStr.join("\r\n");
  62 + $('output').select();
  63 +}
  64 +</script>
  65 +</body>
  66 +</html>

0 comments on commit 5aecfca

Please sign in to comment.
Something went wrong with that request. Please try again.