Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to print GAPC call #167

Merged
merged 8 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions rtlib/generic_opts.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
#ifndef RTLIB_GENERIC_OPTS_HH_
#define RTLIB_GENERIC_OPTS_HH_


#include <unistd.h>
extern "C" {
#include <getopt.h>
#include <unistd.h>
}

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -99,7 +101,12 @@ class Opts {
#ifdef LIBRNA_RNALIB_H_
<< " (-[tT] [0-9]+)? (-P PARAM-file)?"
#endif
<< " (-[drk] [0-9]+)* (-h)? (INPUT|-f INPUT-file)\n";
<< " (-[drk] [0-9]+)* (INPUT|-f INPUT-file)\n\n"
#if defined(GAPC_CALL_STRING) && defined(GAPC_VERSION_STRING)
<< "GAPC call: \"" << GAPC_CALL_STRING << "\"\n"
<< "GAPC version: \"" << GAPC_VERSION_STRING << "\"\n"
#endif
<< "\n";
}

void parse(int argc, char **argv) {
Expand Down
9 changes: 8 additions & 1 deletion src/cpp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ void Printer::Cpp::print_init_fn(const AST &ast) {

inc_indent();
stream << indent() << "const std::vector<std::pair<const char *, unsigned> >"
<< " &inp = opts.inputs;\n";
<< " &inp = opts.inputs;" << endl << endl;

print_buddy_init(ast);
print_seq_init(ast);
Expand Down Expand Up @@ -1684,12 +1684,19 @@ void Printer::Cpp::header(const AST &ast) {
if (ast.get_float_acc() > 0) {
stream << "#define FLOAT_ACC " << ast.get_float_acc() << "\n";
}

stream << "#define GAPC_CALL_STRING \"" << gapc_call_string << "\""
<< endl;
stream << "#define GAPC_VERSION_STRING \"" << gapc_version_string << "\""
<< endl << endl;
includes();
print_subseq_typedef(ast);
print_type_defs(ast);
}

imports(ast);
print_hash_decls(ast);

stream << indent() << "class " << class_name << " {" << endl;
stream << indent() << " public:" << endl;
inc_indent();
Expand Down
10 changes: 7 additions & 3 deletions src/printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,20 @@ void Printer::Base::end_fwd_decls() {


void Printer::Base::set_argv(char **argv, int argc) {
std::ostringstream o;
std::ostringstream o, gapc_call;
o << "A dynamic programming evaluator generated by GAP-C.\n\n"
<< " GAP-C version:\n " << gapc::version_id << "\n\n"
<< " GAP-C call:\n ";
for (int i = 0; i < argc; ++i) {
o << argv[i];
gapc_call << argv[i];
if (i+1 < argc) {
o << ' ';
gapc_call << ' ';
}
}

gapc_version_string = gapc::version_id;
gapc_call_string = gapc_call.str();
o << gapc_call_string;
o << "\n\n";
id_string = o.str();
}
Expand Down
1 change: 1 addition & 0 deletions src/printer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Base {
bool fwd_decls;

std::string id_string;
std::string gapc_call_string, gapc_version_string;

public:
Base() : ind_count(0), out(std::cerr), line_number(0), stream(*this),
Expand Down