New file.
1998-10-10 Martin Baulig <martin@home-of-linux.org> * typemap: New file. * perl.awk: Make it work with the new format of `features.def'. * Makefile.PL.in: Added typemap. * Libgtop.pm (new): New function.
This commit is contained in:
committed by
Martin Baulig
parent
8014f2590b
commit
3af2e87c77
@@ -17,33 +17,81 @@ BEGIN {
|
||||
print "";
|
||||
print "#include <glibtop.h>";
|
||||
print "#include <glibtop/union.h>";
|
||||
print "#include <glibtop/xmalloc.h>";
|
||||
print "";
|
||||
print "MODULE = Libgtop\t\tPACKAGE = Libgtop";
|
||||
print "";
|
||||
print "PROTOTYPES: ENABLE";
|
||||
print "";
|
||||
print "glibtop *";
|
||||
print "init (CLASS)";
|
||||
print "\tchar *CLASS;";
|
||||
print "CODE:";
|
||||
print "\tRETVAL = glibtop_calloc (1, sizeof (glibtop *));";
|
||||
print "\tglibtop_init_s (&RETVAL, 0, 0);";
|
||||
print "OUTPUT:";
|
||||
print "\tRETVAL";
|
||||
print "";
|
||||
|
||||
type_convert["long"] = "int64_t";
|
||||
type_convert["ulong"] = "u_int64_t";
|
||||
type_convert["pid_t"] = "pid_t";
|
||||
type_convert["int"] = "int";
|
||||
|
||||
convert["long"] = "newSViv";
|
||||
convert["ulong"] = "newSViv";
|
||||
convert["double"] = "newSVnv";
|
||||
}
|
||||
|
||||
/^(\w+)/ {
|
||||
feature = $1;
|
||||
function output(line) {
|
||||
split (line, line_fields, /\|/);
|
||||
retval = line_fields[1];
|
||||
feature = line_fields[2];
|
||||
element_def = line_fields[3];
|
||||
param_def = line_fields[4];
|
||||
|
||||
print "void";
|
||||
if (feature ~ /^proc_/) {
|
||||
print feature"(pid)";
|
||||
print "\tunsigned\tpid;";
|
||||
orig = feature; sub(/^@/,"",feature);
|
||||
space = feature; gsub(/./," ",space);
|
||||
|
||||
if (feature ~ /^proc_map/)
|
||||
return;
|
||||
else if (feature ~ /^mountlist/)
|
||||
return;
|
||||
else if (feature ~ /^fsusage/)
|
||||
return;
|
||||
|
||||
if (param_def == "string") {
|
||||
call_param = line_fields[5];
|
||||
param_decl = "\tconst char *"line_fields[5]";\n";
|
||||
} else {
|
||||
print feature"()";
|
||||
call_param = "";
|
||||
param_decl = "";
|
||||
nr_params = split (param_def, params, /:/);
|
||||
for (param = 1; param <= nr_params; param++) {
|
||||
list = params[param];
|
||||
type = params[param];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^.*\(/, "", list); sub(/\)$/, "", list);
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
param_decl = param_decl"\t";
|
||||
call_param = call_param", ";
|
||||
param_decl = param_decl""type_convert[type]" "fields[field]";\n";
|
||||
call_param = call_param""fields[field];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "PREINIT:";
|
||||
|
||||
print "void";
|
||||
print feature" (server"call_param")";
|
||||
print "\tglibtop *server;";
|
||||
print param_decl"PREINIT:";
|
||||
print "\tglibtop_"feature" "feature";";
|
||||
|
||||
if (feature ~ /^proclist/) {
|
||||
print "\tunsigned i, *ptr;";
|
||||
print "PPCODE:";
|
||||
print "\tptr = glibtop_get_proclist (&proclist);";
|
||||
print "\tptr = glibtop_get_proclist (&proclist, which, arg);";
|
||||
print "";
|
||||
print "\tif (ptr) {";
|
||||
print "\t\tfor (i = 0; i < proclist.number; i++)";
|
||||
@@ -53,28 +101,27 @@ BEGIN {
|
||||
print "\tglibtop_free (ptr);";
|
||||
} else {
|
||||
print "PPCODE:";
|
||||
if (feature ~ /^proc_/) {
|
||||
print "\tglibtop_get_"feature" (&"feature", pid);";
|
||||
} else {
|
||||
print "\tglibtop_get_"feature" (&"feature");";
|
||||
}
|
||||
if (call_param != "")
|
||||
print "\tglibtop_get_"feature"_l (server, &"feature""call_param");";
|
||||
else
|
||||
print "\tglibtop_get_"feature"_l (server, &"feature");";
|
||||
print "";
|
||||
|
||||
nr_elements = split ($2, elements, /:/);
|
||||
nr_elements = split (element_def, elements, /:/);
|
||||
for (element = 1; element <= nr_elements; element++) {
|
||||
list = elements[element];
|
||||
type = elements[element];
|
||||
sub(/\(.*/, "", type);
|
||||
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
|
||||
sub(/^.*\(/, "", list); sub(/\)$/, "", list);
|
||||
count = split (list, fields, /,/);
|
||||
for (field = 1; field <= count; field++) {
|
||||
if (type ~ /^str$/) {
|
||||
print "\tXPUSHs (sv_2mortal (newSVpv ("$1"."fields[field]", 0)));";
|
||||
print "\tXPUSHs (sv_2mortal (newSVpv ("feature"."fields[field]", 0)));";
|
||||
} else {
|
||||
if (type ~ /^char$/) {
|
||||
print "\tXPUSHs (sv_2mortal (newSVpv (&"$1"."fields[field]", 1)));";
|
||||
print "\tXPUSHs (sv_2mortal (newSVpv (&"feature"."fields[field]", 1)));";
|
||||
} else {
|
||||
print "\tXPUSHs (sv_2mortal ("convert[type]" ("$1"."fields[field]")));";
|
||||
print "\tXPUSHs (sv_2mortal ("convert[type]" ("feature"."fields[field]")));";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,3 +131,5 @@ BEGIN {
|
||||
print "";
|
||||
}
|
||||
|
||||
/^[^#]/ { output($0) }
|
||||
|
||||
|
Reference in New Issue
Block a user