File: langs.e

package info (click to toggle)
entity 0.7.2-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,352 kB
  • ctags: 5,272
  • sloc: ansic: 61,707; sh: 7,921; makefile: 732; perl: 399
file content (96 lines) | stat: -rwxr-xr-x 1,314 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env entity

<object dragable="true">

<!-- This file contains equivalent code for each language. -->

<perl>
<![CDATA[
sub handler
{
  my($node) = @_;

  my $attr = "bob";
  my $value = 1;

  my $onode = $node->node("tag.name");

  $node->{$attr} =  $value;

  $path = $node->{path};
  @selection = $node->{selection};

  foreach $nnode (@selection)
  {
    print $nnode{name}."\n";
  }

  return 0;
}
]]>
</perl>


<c-code>
<![CDATA[
int handler(ENode* node)
{
  char* path;
  char* attr = "bob";
  char* value = "1";
  int value_int = 1;
  GSList* selection;

  ENode* onode;
  onode = en_node(node, "tag.name");

  en_set(node, attr, value);
  /*OR (either will work.)*/
  en_set_int(node, attr, value_int);


  path = en_get(node, "path");

  selection = en_get(node, "selection"); 
  while(selection)
  {
    ENode* nnode = (ENode*)selection->data

    printf("%s\n", en_get(nnode, "name") );

    selection = selection->next;
  }

  return 0;
}
]]>
</c-code>

<!-- Joze, could you please add the tcl code test? MW-->
<tcl>
<![CDATA[
]]>
</tcl>

<python>
<![CDATA[
def handler(node):
	value = 1
	attr = 'bob'
	
	onode = enode("tag.name");
	node[attr] = value
	
	path = node.path

	selection = node['selection']

	for nnode in selection:
		print nnode['name']
		
	return 0
]]>
</python>

</object>