Skip to content

Commit

Permalink
ISSUE2 - Class properties added to generated code.
Browse files Browse the repository at this point in the history
  • Loading branch information
bafolts committed Dec 7, 2014
1 parent c211a51 commit 99cc640
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 84 deletions.
3 changes: 3 additions & 0 deletions templates/coffeescript.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class {{getFullName}}{{#if getExtends}} extends {{#with getExtends}}{{getFullName}}{{/with}}{{/if}}
{{#each getFields}}
{{this.getName}}: undefined
{{/each}}
{{#each getMethods}}
{{this.getName}}: {{#if this.getParameters}}({{#each this.getParameters}}{{#if @first}}{{else}},{{/if}}{{#if this.getName}}{{this.getName}}{{else}}param{{@index}}{{/if}}{{/each}}){{/if}} ->
{{/each}}
3 changes: 3 additions & 0 deletions templates/csharp.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{#if isAbstract}}abstract {{/if}}class {{getFullName}}{{#if getExtends}} : {{#with getExtends}}{{getFullName}}{{/with}}{{/if}} {
{{#each getFields}}
private {{this.getReturnType}} {{this.getName}};
{{/each}}
{{#each getMethods}}
public {{this.getReturnType}} {{this.getName}}{{#if this.getParameters}}({{#each this.getParameters}}{{#if @first}}{{else}},{{/if}}{{this.getReturnType}} {{#if this.getName}}{{this.getName}}{{else}}param{{@index}}{{/if}}{{/each}}){{else}}(){{/if}} {
{{#if this.needsReturnStatement}}
Expand Down
3 changes: 3 additions & 0 deletions templates/java.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{#if isAbstract}}abstract {{/if}}class {{getFullName}}{{#if getExtends}} extends {{#with getExtends}}{{getFullName}}{{/with}}{{/if}} {
{{#each getFields}}
private {{this.getReturnType}} {{this.getName}};
{{/each}}
{{#each getMethods}}
public {{this.getReturnType}} {{this.getName}}{{#if this.getParameters}}({{#each this.getParameters}}{{#if @first}}{{else}},{{/if}}{{this.getReturnType}} {{#if this.getName}}{{this.getName}}{{else}}param{{@index}}{{/if}}{{/each}}){{else}}(){{/if}} {
{{#if this.needsReturnStatement}}
Expand Down
3 changes: 3 additions & 0 deletions templates/php.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php
{{#if isAbstract}}abstract {{/if}}class {{getFullName}}{{#if getExtends}} extends {{#with getExtends}}{{getFullName}}{{/with}}{{/if}} {
{{#each getFields}}
private {{this.getName}};
{{/each}}
{{#each getMethods}}
public function {{this.getName}}{{#if this.getParameters}}({{#each this.getParameters}}{{#if @first}}{{else}},{{/if}}{{#if this.getName}}${{this.getName}}{{else}}$param{{@index}}{{/if}}{{/each}}){{else}}(){{/if}} {
{{#if this.needsReturnStatement}}
Expand Down
3 changes: 3 additions & 0 deletions templates/ruby.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class {{getFullName}}{{#if getExtends}} < {{#with getExtends}}{{getFullName}}{{/with}}{{/if}}
{{#each getFields}}
@{{this.getName}}
{{/each}}
{{#each getMethods}}
def {{this.getName}}{{#if this.getParameters}} ({{#each this.getParameters}}{{#if @first}}{{else}},{{/if}}{{#if this.getName}}{{this.getName}}{{else}}param{{@index}}{{/if}}{{/each}}){{/if}}
return
Expand Down
3 changes: 3 additions & 0 deletions templates/typescript.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class {{getFullName}}{{#if getExtends}} extends {{#with getExtends}}{{getFullName}}{{/with}}{{/if}} {
{{#each getFields}}
private {{this.getName}} : {{this.getReturnType}};
{{/each}}
{{#each getMethods}}
{{this.getName}}{{#if this.getParameters}}({{#each this.getParameters}}{{#if @first}}{{else}},{{/if}}{{#if this.getName}}{{this.getName}}{{else}}param{{@index}}{{/if}}{{/each}}){{else}}(){{/if}} {
return;
Expand Down
17 changes: 7 additions & 10 deletions tests/car.coffee
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
class Car

model: undefined
make: undefined
year: undefined
setModel: (model) ->

setMake: (make) ->

setYear: (param0) ->

getModel: ->

getMake: ->

getYear: ->


class Toyota extends Car


class Honda extends Car


class Ford extends Car



27 changes: 27 additions & 0 deletions tests/car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
abstract class Car {
private String model;
private String make;
private Number year;
public void setModel(String model) {
}
public void setMake(String make) {
}
public void setYear(Number param0) {
}
public String getModel() {
return null;
}
public String getMake() {
return null;
}
public Number getYear() {
return null;
}
}
class Toyota : Car {
}
class Honda : Car {
}
class Ford : Car {
}

30 changes: 7 additions & 23 deletions tests/car.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
abstract class Car {

private String model;
private String make;
private Number year;
public void setModel(String model) {

}

public void setMake(String make) {

}

public void setYear(Number param0) {

}

public String getModel() {

return null;

}

public String getMake() {

return null;

}

public Number getYear() {

return null;

}

}
}
class Toyota extends Car {

}
}
class Honda extends Car {

}
}
class Ford extends Car {

}
}

3 changes: 3 additions & 0 deletions tests/car.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ abstract Car {
+ String getModel()
+ String getMake()
+ Number getYear()
- String model
- String make
- Number year
}

class Toyota
Expand Down
30 changes: 7 additions & 23 deletions tests/car.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
<?php
abstract class Car {

private model;
private make;
private year;
public function setModel($model) {

}

public function setMake($make) {

}

public function setYear($param0) {

}

public function getModel() {

return null;

}

public function getMake() {

return null;

}

public function getYear() {

return null;

}

}
?>
?>
<?php
class Toyota extends Car {

}
?>
?>
<?php
class Honda extends Car {

}
?>
?>
<?php
class Ford extends Car {

}
?>
?>

21 changes: 7 additions & 14 deletions tests/car.rb
Original file line number Diff line number Diff line change
@@ -1,41 +1,34 @@
class Car

@model
@make
@year
def setModel (model)
return
end

def setMake (make)
return
end

def setYear (param0)
return
end

def getModel
return
end

def getMake
return
end

def getYear
return
end

end


class Toyota < Car

end


class Honda < Car

end


class Ford < Car

end



21 changes: 7 additions & 14 deletions tests/car.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,30 @@
class Car {

private model : String;
private make : String;
private year : Number;
setModel(model) {
return;
}

setMake(make) {
return;
}

setYear(param0) {
return;
}

getModel() {
return;
}

getMake() {
return;
}

getYear() {
return;
}

}
}
class Toyota extends Car {

}
}
class Honda extends Car {

}
}
class Ford extends Car {

}
}

0 comments on commit 99cc640

Please sign in to comment.