From 493ee85cb01efb108d46bd61cca89487f10a3883 Mon Sep 17 00:00:00 2001 From: Luis Ontanon Date: Tue, 24 Oct 2006 17:34:17 +0000 Subject: Improve the documentation generators add some docs. svn path=/trunk/; revision=19671 --- epan/wslua/make-doc.pl | 47 +++++++++++---------------------------------- epan/wslua/wslua_field.c | 33 +++++++++++++++---------------- epan/wslua/wslua_listener.c | 2 +- epan/wslua/wslua_proto.c | 24 +++++++++++------------ 4 files changed, 39 insertions(+), 67 deletions(-) (limited to 'epan/wslua') diff --git a/epan/wslua/make-doc.pl b/epan/wslua/make-doc.pl index 4ab4dbee64..5097c31e85 100755 --- a/epan/wslua/make-doc.pl +++ b/epan/wslua/make-doc.pl @@ -57,14 +57,12 @@ my $docbook_template = { module_desc => "\t%s\n", module_footer => "\n", class_header => "\t
%s\n", - class_footer => "\t
\n", class_desc => "\t\t%s\n", - class_constructors_header => "\t\t
\n\t\t\t%s Constructors\n", - class_constructors_footer => "\t\t
\n", - class_methods_header => "\t\t
\n\t\t\t%s Methods\n", - class_methods_footer => "\t\t
\n", - class_attributes_header => "\t\t
\n\t\t\t%s Attributes\n", - class_attributes_footer => "\t\t
\n", + class_footer => "\t \n", +# class_constructors_header => "\t\t
\n\t\t\t%s Constructors\n", +# class_constructors_footer => "\t\t
\n", +# class_methods_header => "\t\t
\n\t\t\t%s Methods\n", +# class_methods_footer => "\t\t
\n", class_attr_header => "\t\t
\n\t\t\t%s\n", class_attr_footer => "\t\t
\n", class_attr_descr => "\t\t\t%s\n", @@ -89,28 +87,6 @@ my $docbook_template = { non_method_functions_footer => "\t\t \n", }; -my $wiki_template = { - class_header => "= %s =\n", - class_desc => "%s\n", - class_constructors_header => "== %s constructors ==\n", - class_methods_header => "== %s methods ==\n", - class_attributes_header => "== %s Attributes ==\n", - class_attr_header => "=== %s ===\n", - class_attr_descr => "%s\n", - function_header => "=== %s ===\n", - function_descr => "%s\n", - function_arg_header => "==== %s ====\n", - function_arg_descr => "%s\n", - function_argerrors_header => "'''Errors:'''\n", - function_argerror => " * %s\n", - function_returns_header => "==== returns ====\n", - function_returns => " * %s\n", - function_errors_header => "==== errors ====\n", - function_errors => " * %s\n", - non_method_functions_header => "= Non method functions =\n", -}; - - my %metamethods = %{{ __tostring => "tostring(__)", __index => "__[]", @@ -150,7 +126,7 @@ sub { $module{descr} = $2 }], - [ 'WSLUA_CLASS_DEFINE\050\s*([A-Z][a-zA-Z]+)\s*,.*?\051' . $TRAILING_COMMENT_RE, + [ 'WSLUA_CLASS_DEFINE\050\s*([A-Z][a-zA-Z]+).*?\051;' . $TRAILING_COMMENT_RE, sub { deb ">c=$1=$2=$3=$4=$5=$6=$7=\n"; $class = { @@ -239,7 +215,7 @@ sub { [ '/\052\s+WSLUA_ATTRIBUTE\s+([A-Za-z]+)_([a-z_]+)\s+([A-Z]*)\s*(.*?)\052/', sub { deb ">at=$1=$2=$3=$4=$5=$6=$7=\n"; - push @{${$class}{attributes}}, { name => $2, descr => gorolla($4), mode=>$3 }; + push @{${$class}{attributes}}, { name => "$1.$2", descr => gorolla($4), mode=>$3 }; } ], [ '/\052\s+WSLUA_MOREARGS\s+([A-Za-z_]+)\s+(.*?)\052/', @@ -328,7 +304,10 @@ while ( $file = shift) { for my $cname (sort keys %classes) { my $cl = $classes{$cname}; printf D ${$template_ref}{class_header}, $cname, $cname; - printf D ${$template_ref}{class_desc} , ${$cl}{descr} if ${$cl}{descr}; + + if ( ${$cl}{descr} ) { + printf D ${$template_ref}{class_desc} , ${$cl}{descr}; + } if ( $#{${$cl}{constructors}} >= 0) { # printf D ${$template_ref}{class_constructors_header}, $cname, $cname; @@ -355,16 +334,12 @@ while ( $file = shift) { } if ( $#{${$cl}{attributes}} >= 0) { - printf D ${$template_ref}{class_attributes_header}, $cname, $cname; - for my $a (@{${$cl}{attributes}}) { printf D ${$template_ref}{class_attr_header}, ${$a}{name}, ${$a}{name}; printf D ${$template_ref}{class_attr_descr}, ${$a}{descr}, ${$a}{descr} if ${$a}{descr}; printf D ${$template_ref}{class_attr_footer}, ${$a}{name}, ${$a}{name}; } - - printf D ${$template_ref}{class_attributes_footer}, $cname, $cname; } if (exists ${$template_ref}{class_footer}) { diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c index 74bbc84533..a46723a5a1 100644 --- a/epan/wslua/wslua_field.c +++ b/epan/wslua/wslua_field.c @@ -37,7 +37,7 @@ WSLUA_CLASS_DEFINE(FieldInfo,NOP,NOP); WSLUA_METAMETHOD FieldInfo__len(lua_State* L) { /* - The Length of the field + Obtain the Length of the field */ FieldInfo fi = checkFieldInfo(L,1); lua_pushnumber(L,fi->length); @@ -46,7 +46,7 @@ WSLUA_METAMETHOD FieldInfo__len(lua_State* L) { WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) { /* - The Offset of the field + Obtain the Offset of the field */ FieldInfo fi = checkFieldInfo(L,1); lua_pushnumber(L,fi->start); @@ -55,7 +55,7 @@ WSLUA_METAMETHOD FieldInfo__unm(lua_State* L) { WSLUA_METAMETHOD FieldInfo__call(lua_State* L) { /* - The Value of the field + Obtain the Value of the field */ FieldInfo fi = checkFieldInfo(L,1); @@ -137,6 +137,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) { } WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) { + /* the string representation of the field */ FieldInfo fi = checkFieldInfo(L,1); if (fi) { if (fi->value.ftype->val_to_string_repr) @@ -147,13 +148,8 @@ WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) { return 1; } -WSLUA_ATTR_GET FieldInfo_get_data_source(lua_State* L) { - FieldInfo fi = checkFieldInfo(L,1); - pushTvb(L,fi->ds_tvb); - return 1; -} - WSLUA_ATTR_GET FieldInfo_get_range(lua_State* L) { + /* the TvbRange covering this field */ FieldInfo fi = checkFieldInfo(L,1); TvbRange r = ep_alloc(sizeof(struct _wslua_tvbrange)); @@ -165,20 +161,15 @@ WSLUA_ATTR_GET FieldInfo_get_range(lua_State* L) { return 1; } - -WSLUA_ATTR_GET FieldInfo_get_hidden(lua_State* L) { - FieldInfo fi = checkFieldInfo(L,1); - lua_pushboolean(L,FI_GET_FLAG(fi, FI_HIDDEN)); - return 1; -} - WSLUA_ATTR_GET FieldInfo_get_generated(lua_State* L) { + /* Whether this field was marked as generated. */ FieldInfo fi = checkFieldInfo(L,1); lua_pushboolean(L,FI_GET_FLAG(fi, FI_GENERATED)); return 1; } WSLUA_ATTR_GET FieldInfo_get_name(lua_State* L) { + /* the filter name of this field. */ FieldInfo fi = checkFieldInfo(L,1); lua_pushstring(L,fi->hfinfo->abbrev); return 1; @@ -197,7 +188,7 @@ static const luaL_reg FieldInfo_get[] = { {0, 0} }; -WSLUA_METAMETHOD FieldInfo__index(lua_State* L) { +static int FieldInfo__index(lua_State* L) { /* Other attributes: */ @@ -216,6 +207,7 @@ WSLUA_METAMETHOD FieldInfo__index(lua_State* L) { } WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) { + /* checks whether lhs is within rhs */ FieldInfo l = checkFieldInfo(L,1); FieldInfo r = checkFieldInfo(L,2); @@ -231,11 +223,12 @@ WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) { } WSLUA_METAMETHOD FieldInfo__le(lua_State* L) { + /* checks whether the end byte of lhs is before the end of rhs */ FieldInfo l = checkFieldInfo(L,1); FieldInfo r = checkFieldInfo(L,2); if (l->ds_tvb != r->ds_tvb) - WSLUA_ERROR(FieldInfo__eq,"data source must be the same for both fields"); + return 0; if (r->start + r->length <= l->start + r->length) { lua_pushboolean(L,1); @@ -246,6 +239,7 @@ WSLUA_METAMETHOD FieldInfo__le(lua_State* L) { } WSLUA_METAMETHOD FieldInfo__lt(lua_State* L) { + /* checks whether the end byte of rhs is before the beginning of rhs */ FieldInfo l = checkFieldInfo(L,1); FieldInfo r = checkFieldInfo(L,2); @@ -280,6 +274,7 @@ int FieldInfo_register(lua_State* L) { WSLUA_FUNCTION wslua_all_field_infos(lua_State* L) { + /* obtain all fields from the current tree */ GPtrArray* found = lua_tree->tree ? proto_all_finfos(lua_tree->tree) : NULL; int items_found = 0; guint i; @@ -382,6 +377,7 @@ WSLUA_CONSTRUCTOR Field_new(lua_State *L) { } WSLUA_METAMETHOD Field__call (lua_State* L) { + /* obtain all values (see FieldInfo) for this field. */ Field f = checkField(L,1); header_field_info* in = *f; int items_found = 0; @@ -411,6 +407,7 @@ WSLUA_METAMETHOD Field__call (lua_State* L) { } WSLUA_METAMETHOD Field_tostring(lua_State* L) { + /* obtain a srting with the field name */ Field f = checkField(L,1); if ( !(f && *f) ) { diff --git a/epan/wslua/wslua_listener.c b/epan/wslua/wslua_listener.c index 19ae78102e..182d25180e 100644 --- a/epan/wslua/wslua_listener.c +++ b/epan/wslua/wslua_listener.c @@ -107,7 +107,7 @@ int lua_tap_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, const switch ( lua_pcall(tap->L,3,1,1) ) { case 0: - if (lua_gettop(tap->L) == 1) + if (lua_gettop(tap->L) > 0) retval = luaL_checkint(tap->L,1); else retval = 1; diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c index c0618a1f84..0ac56a95d2 100644 --- a/epan/wslua/wslua_proto.c +++ b/epan/wslua/wslua_proto.c @@ -75,9 +75,9 @@ WSLUA_CONSTRUCTOR Pref_bool(lua_State* L) { /* * Creates a boolean preference to be added to a Protocol's prefs table. */ -#define WSLUA_ATTR_Pref_bool_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */ -#define WSLUA_ATTR_Pref_bool_DEFAULT 2 /* The default value for this preference */ -#define WSLUA_ATTR_Pref_bool_DESCR 3 /* A description of what this preference is */ +#define WSLUA_ARG_Pref_bool_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */ +#define WSLUA_ARG_Pref_bool_DEFAULT 2 /* The default value for this preference */ +#define WSLUA_ARG_Pref_bool_DESCR 3 /* A description of what this preference is */ return new_pref(L,PREF_BOOL); } @@ -85,9 +85,9 @@ WSLUA_CONSTRUCTOR Pref_uint(lua_State* L) { /* * Creates an (unsigned) integer preference to be added to a Protocol's prefs table. */ -#define WSLUA_ATTR_Pref_uint_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */ -#define WSLUA_ATTR_Pref_uint_DEFAULT 2 /* The default value for this preference */ -#define WSLUA_ATTR_Pref_uint_DESCR 3 /* A description of what this preference is */ +#define WSLUA_ARG_Pref_uint_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */ +#define WSLUA_ARG_Pref_uint_DEFAULT 2 /* The default value for this preference */ +#define WSLUA_ARG_Pref_uint_DESCR 3 /* A description of what this preference is */ return new_pref(L,PREF_UINT); } @@ -95,9 +95,9 @@ WSLUA_CONSTRUCTOR Pref_string(lua_State* L) { /* * Creates a string preference to be added to a Protocol's prefs table. */ -#define WSLUA_ATTR_Pref_string_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */ -#define WSLUA_ATTR_Pref_string_DEFAULT 2 /* The default value for this preference */ -#define WSLUA_ATTR_Pref_string_DESCR 3 /* A description of what this preference is */ +#define WSLUA_ARG_Pref_string_LABEL 1 /* The Label (text in the right side of the preference input) for this preference */ +#define WSLUA_ARG_Pref_string_DEFAULT 2 /* The default value for this preference */ +#define WSLUA_ARG_Pref_string_DESCR 3 /* A description of what this preference is */ return new_pref(L,PREF_STRING); } @@ -858,10 +858,10 @@ typedef struct { } proto_actions_t; static const proto_actions_t proto_actions[] = { - /* WSLUA_ATTRIBUTE Pinfo_dissector RW the protocol's dissector, a function you define */ + /* WSLUA_ATTRIBUTE Proto_dissector RW the protocol's dissector, a function you define */ {"dissector",Proto_get_dissector, Proto_set_dissector}, - /* WSLUA_ATTRIBUTE Pinfo_fields RO the Fields Table of this dissector */ + /* WSLUA_ATTRIBUTE Proto_fields RO the Fields Table of this dissector */ {"fields" ,Proto_get_fields, Proto_set_fields}, /* WSLUA_ATTRIBUTE Proto_get_prefs RO the preferences of this dissector */ @@ -870,7 +870,7 @@ static const proto_actions_t proto_actions[] = { /* WSLUA_ATTRIBUTE Proto_init WO the init routine of this dissector, a function you define */ {"init",NULL,Proto_set_init}, - /* WSLUA_ATTRIBUTE Proto_init RO the name given to this dissector */ + /* WSLUA_ATTRIBUTE Proto_name RO the name given to this dissector */ {"name",Proto_get_name,NULL}, {NULL,NULL,NULL} }; -- cgit v1.2.1