"Fossies" - the Fresh Open Source Software Archive

Member "highlight-3.57-x64/extras/swig/testmod.pl" (12 May 2020, 1051 Bytes) of package /windows/www/highlight-3.57-x64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 # Perl SWIG module test script
    2 #
    3 # Import highlight.pm, which is the interface for the highlight.so module.
    4 # See highlight.pm for all available attributes and class members.
    5 
    6 use highlight;
    7 
    8 #get a generator instance (for HTML output)
    9 my $gen = highlight::CodeGenerator::getInstance($highlight::CodeGenerator::HTML);
   10  
   11 my $dir = new highlight::DataDir();
   12 
   13 #$dir->searchDataDir("");
   14 $dir->initSearchDirectories("");
   15 
   16 
   17 my $themepath=$dir->getThemePath("seashell.theme");
   18 my $langpath=$dir->getLangPath("c.lang");
   19 
   20 #initialize the generator with a colour theme and the language definition
   21 $gen->initTheme($themepath);
   22 $gen->loadLanguage($langpath);
   23 
   24 #set some parameters
   25 $gen->setIncludeStyle(1);
   26 $gen->setEncoding("ISO-8859-1");
   27 
   28 #get output string
   29 my $output=$gen->generateString("int main(int argc, char **argv) {\n".
   30                            " HighlightApp app;\n".
   31                            " return app.run(argc, argv);\n".
   32                            "}\n");
   33 print $output;
   34 
   35 # clear the instance
   36 highlight::CodeGenerator::deleteInstance($gen);