summaryrefslogtreecommitdiff
path: root/source3/aparser/parsetree.awk
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-22 09:09:37 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-22 09:09:37 +0000
commit943340a5a3f5d725e2cd35ab47f33083837cb904 (patch)
tree9e94688083bb5cc54cb44e4ac194fc3772345435 /source3/aparser/parsetree.awk
parent74d677ec591a715e28dba29a33ee40e1b1c2f830 (diff)
downloadsamba-943340a5a3f5d725e2cd35ab47f33083837cb904.tar.gz
samba-943340a5a3f5d725e2cd35ab47f33083837cb904.tar.bz2
samba-943340a5a3f5d725e2cd35ab47f33083837cb904.zip
more aparser stuff - we now handle everything but the idl headers in srvsvc.idl
(This used to be commit 5f1e8422d0ebc589cdfe95f1001a8e55cb60af4a)
Diffstat (limited to 'source3/aparser/parsetree.awk')
-rw-r--r--source3/aparser/parsetree.awk115
1 files changed, 114 insertions, 1 deletions
diff --git a/source3/aparser/parsetree.awk b/source3/aparser/parsetree.awk
index 6fee6e2a4a..832cd5f2e8 100644
--- a/source3/aparser/parsetree.awk
+++ b/source3/aparser/parsetree.awk
@@ -1,5 +1,14 @@
# build the parse tree for a struct file
+function find_structure(name,
+ LOCAL, i)
+{
+ for (i=0;i<num_structs;i++) {
+ if (structs[i, "name"] == name) return i;
+ }
+ return "-1";
+}
+
function start_module(name)
{
module=name;
@@ -81,15 +90,119 @@ function start_union(elem)
unions[current_union, "num_elems"] = 0;
}
+function start_union_notencap(switch)
+{
+ add_struct_elem("uint32", "switch_"switch);
+ start_union("UNKNOWN[switch_"switch"]");
+}
+
+function start_union_encap(struct, type, switch, union)
+{
+ start_struct(struct);
+ add_struct_elem(type, switch);
+ add_struct_elem(type, "switch_"switch);
+ start_union(union"[switch_"switch"]");
+ encap_union="1";
+}
+
function parse_case(case, type, elem,
LOCAL, elem_num)
{
+ split(case, a, "[:]");
+ case = a[1];
elem_num = unions[current_union, "num_elems"];
unions[current_union, elem_num] = add_element(type, elem, case);
unions[current_union, "num_elems"]++;
}
-function end_union()
+function end_union(name)
{
+ if (name!="") {
+ elements[current_union, "elem"] = name;
+ }
current_union="";
+ if (encap_union=="1") {
+ end_struct(name);
+ encap_union="0";
+ }
+}
+
+function delete_element(struct, elnum,
+ LOCAL, i)
+{
+ for (i=elnum;i<structs[struct,"num_elems"]-1;i++) {
+ structs[struct, i] = structs[struct, i+1];
+ }
+ structs[struct, "num_elems"]--;
+}
+
+function copy_struct(from, to,
+ LOCAL, i)
+{
+ for (i=0;i<structs[from,"num_elems"];i++) {
+ structs[to, i] = structs[from, i];
+ }
+ structs[to, "name"] = structs[from, "name"];
+ structs[to, "num_elems"] = structs[from, "num_elems"];
+ structs[to, "num_unions"] = structs[from, "num_unions"];
}
+
+function add_sizeis_array(count, type, elem)
+{
+ copy_struct(current_struct, current_struct+1);
+ elem=substr(elem,2);
+ start_struct("array_"current_struct"_"elem);
+ add_struct_elem("uint32", count);
+ add_struct_elem(type, elem"["count"]");
+ end_struct("");
+ current_struct=num_structs;
+ add_struct_elem("array_"current_struct-1"_"elem, "*"elem"_ptr");
+}
+
+
+function start_function(type, fname)
+{
+ start_struct(fname);
+ add_function_param("[in,out]",".trailer", "");
+}
+
+function end_function(LOCAL, i)
+{
+ copy_struct(num_structs, num_structs+1);
+ structs[num_structs, "name"] = "Q_"structs[num_structs, "name"];
+ for (i=0;i<structs[num_structs, "num_elems"];i++) {
+ if (match(elements[structs[num_structs, i], "properties"], "in") == 0) {
+ delete_element(num_structs, i);
+ i--;
+ }
+ }
+ end_struct();
+ current_struct=num_structs;
+ structs[num_structs, "name"] = "R_"structs[num_structs, "name"];
+ for (i=0;i<structs[num_structs, "num_elems"];i++) {
+ if (match(elements[structs[num_structs, i], "properties"], "out") == 0) {
+ delete_element(num_structs, i);
+ i--;
+ }
+ }
+ add_function_param("[out]", "STATUS", "status");
+ end_struct();
+}
+
+function add_function_param(properties, type, elem,
+ LOCAL, elnum, len)
+{
+ len=length(type);
+ if (substr(type, len) == "*") {
+ type=substr(type, 1, len-1);
+ elem="*"elem;
+ }
+ if (substr(elem,1,1) == "*" &&
+ (match(properties,"in") == 0 ||
+ find_structure(type) != "-1")) {
+ elem=substr(elem, 2);
+ }
+ elnum = add_struct_elem(type, elem);
+ elements[elnum, "properties"] = properties;
+}
+