aboutsummaryrefslogtreecommitdiffstats
path: root/manual/PRESENTATION_ExAdv/mymul_map.v
diff options
context:
space:
mode:
Diffstat (limited to 'manual/PRESENTATION_ExAdv/mymul_map.v')
0 files changed, 0 insertions, 0 deletions
ef='#n51'>51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658
#!/usr/bin/env python

# pythfilter.py v1.5.5, written by Matthias Baas (baas@ira.uka.de)

# Doxygen filter which can be used to document Python source code.
# Classes (incl. methods) and functions can be documented.
# Every comment that begins with ## is literally turned into an
# Doxygen comment. Consecutive comment lines are turned into
# comment blocks (-> /** ... */).
# All the stuff is put inside a namespace with the same name as
# the source file.

# Conversions:
# ============
# ##-blocks                  ->  /** ... */
# "class name(base): ..."    ->  "class name : public base {...}"
# "def name(params): ..."    ->  "name(params) {...}"

# Changelog:
# 21.01.2003: Raw (r"") or unicode (u"") doc string will now be properly
#             handled. (thanks to Richard Laager for the patch)
# 22.12.2003: Fixed a bug where no function names would be output for "def"
#             blocks that were not in a class.
#             (thanks to Richard Laager for the patch)
# 12.12.2003: Implemented code to handle static and class methods with
#             this logic: Methods with "self" as the first argument are
#             non-static. Methods with "cls" are Python class methods,
#             which translate into static methods for Doxygen. Other
#             methods are assumed to be static methods. As should be
#             obvious, this logic doesn't take into account if the method
#             is actually setup as a classmethod() or a staticmethod(),
#             just if it follows the normal conventions.
#             (thanks to Richard Laager for the patch)
# 11.12.2003: Corrected #includes to use os.path.sep instead of ".". Corrected
#             namespace code to use "::" instead of ".".
#             (thanks to Richard Laager for the patch)
# 11.12.2003: Methods beginning with two underscores that end with
#             something other than two underscores are considered private
#             and are handled accordingly.
#             (thanks to Richard Laager for the patch)
# 03.12.2003: The first parameter of class methods (self) is removed from
#             the documentation.
# 03.11.2003: The module docstring will be used as namespace documentation
#             (thanks to Joe Bronkema for the patch)
# 08.07.2003: Namespaces get a default documentation so that the namespace
#             and its contents will show up in the generated documentation.
# 05.02.2003: Directories will be delted during synchronization.
# 31.01.2003: -f option & filtering entire directory trees.
# 10.08.2002: In base classes the '.' will be replaced by '::'
# 18.07.2002: * and ** will be translated into arguments
# 18.07.2002: Argument lists may contain default values using constructors.
# 18.06.2002: Support for ## public:
# 21.01.2002: from ... import will be translated to "using namespace ...;"
#             TODO: "from ... import *" vs "from ... import names"
#             TODO: Using normal imports: name.name -> name::name
# 20.01.2002: #includes will be placed in front of the namespace

######################################################################

# The program is written as a state machine with the following states:
#
# - OUTSIDE               The current position is outside any comment,
#                         class definition or function.
#
# - BUILD_COMMENT         Begins with first "##".
#                         Ends with the first token that is no "##"
#                         at the same column as before.
#
# - BUILD_CLASS_DECL      Begins with "class".
#                         Ends with ":"
# - BUILD_CLASS_BODY      Begins just after BUILD_CLASS_DECL.
#                         The first following token (which is no comment)
#                         determines indentation depth.
#                         Ends with a token that has a smaller indendation.
#
# - BUILD_DEF_DECL        Begins with "def".
#                         Ends with ":".
# - BUILD_DEF_BODY        Begins just after BUILD_DEF_DECL.
#                         The first following token (which is no comment)
#                         determines indentation depth.
#                         Ends with a token that has a smaller indendation.

import getopt
import glob
import os.path
import re
import shutil
import string
import sys
import token
import tokenize

from stat import *

OUTSIDE          = 0
BUILD_COMMENT    = 1
BUILD_CLASS_DECL = 2
BUILD_CLASS_BODY = 3
BUILD_DEF_DECL   = 4
BUILD_DEF_BODY   = 5
IMPORT           = 6
IMPORT_OP        = 7
IMPORT_APPEND    = 8

# Output file stream
outfile = sys.stdout

# Output buffer
outbuffer = []

out_row = 1
out_col = 0

# Variables used by rec_name_n_param()
name         = ""
param        = ""
doc_string   = ""
record_state = 0
bracket_counter = 0

# Tuple: (row,column)
class_spos  = (0,0)
def_spos    = (0,0)
import_spos = (0,0)

# Which import was used? ("import" or "from")
import_token = ""

# Comment block buffer
comment_block = []
comment_finished = 0

# Imported modules
modules = []

# Program state
stateStack = [OUTSIDE]

# Keep track of whether module has a docstring
module_has_docstring = False

# Keep track of member protection
protection_level = "public"
private_member = False

# Keep track of the module namespace
namespace = ""

######################################################################
# Output string s. '\n' may only be at the end of the string (not
# somewhere in the middle).
#
# In: s    - String
#     spos - Startpos
######################################################################
def output(s,spos, immediate=0):
    global outbuffer, out_row, out_col, outfile

    os = string.rjust(s,spos[1]-out_col+len(s))

    if immediate:
        outfile.write(os)
    else:
        outbuffer.append(os)

    assert -1 == string.find(s[0:-2], "\n"), s

    if (s[-1:]=="\n"):
        out_row = out_row+1
        out_col = 0
    else:
        out_col = spos[1]+len(s)


######################################################################
# Records a name and parameters. The name is either a class name or
# a function name. Then the parameter is either the base class or
# the function parameters.
# The name is stored in the global variable "name", the parameters
# in "param".
# The variable "record_state" holds the current state of this internal
# state machine.
# The recording is started by calling start_recording().
#
# In: type, tok
######################################################################
def rec_name_n_param(type, tok):
    global record_state,name,param,doc_string,bracket_counter
    s = record_state
    # State 0: Do nothing.
    if   (s==0):
         return
    # State 1: Remember name.
    elif (s==1):
        name = tok
        record_state = 2
    # State 2: Wait for opening bracket or colon
    elif (s==2):
        if (tok=='('):
            bracket_counter = 1
            record_state=3
        if (tok==':'): record_state=4
    # State 3: Store parameter (or base class) and wait for an ending bracket
    elif (s==3):
        if (tok=='*' or tok=='**'):
            tok=''
        if (tok=='('):
            bracket_counter = bracket_counter+1
        if (tok==')'):
            bracket_counter = bracket_counter-1
        if bracket_counter==0:
            record_state=4
        else:
            param=param+tok
    # State 4: Look for doc string
    elif (s==4):
        if (type==token.NEWLINE or type==token.INDENT or type==token.SLASHEQUAL):
            return
        elif (tok==":"):
            return
        elif (type==token.STRING):
            while tok[:1]=='r' or tok[:1]=='u':
                tok=tok[1:]
            while tok[:1]=='"':
                tok=tok[1:]
            while tok[-1:]=='"':
                tok=tok[:-1]
            doc_string=tok
        record_state=0

######################################################################
# Starts the recording of a name & param part.
# The function rec_name_n_param() has to be fed with tokens. After
# the necessary tokens are fed the name and parameters can be found
# in the global variables "name" und "param".
######################################################################
def start_recording():
    global record_state,param,name, doc_string
    record_state=1
    name=""
    param=""
    doc_string=""

######################################################################
# Test if recording is finished
######################################################################
def is_recording_finished():
    global record_state
    return record_state==0

######################################################################
## Gather comment block
######################################################################
def gather_comment(type,tok,spos):
    global comment_block,comment_finished
    if (type!=tokenize.COMMENT):
        comment_finished = 1
    else:
        # Output old comment block if a new one is started.
        if (comment_finished):
            print_comment(spos)
            comment_finished=0
        if (tok[0:2]=="##" and tok[0:3]!="###"):
            append_comment_lines(tok[2:])

######################################################################
## Output comment block and empty buffer.
######################################################################
def print_comment(spos):
    global comment_block,comment_finished
    if (comment_block!=[]):
        output("/** ",spos)
        for c in comment_block:
            output(c,spos)
        output("*/\n",spos)
    comment_block    = []
    comment_finished = 0

######################################################################
def set_state(s):
    global stateStack
    stateStack[len(stateStack)-1]=s

######################################################################
def get_state():
    global stateStack
    return stateStack[len(stateStack)-1]

######################################################################
def push_state(s):
    global stateStack
    stateStack.append(s)

######################################################################
def pop_state():
    global stateStack
    stateStack.pop()


######################################################################
def tok_eater(type, tok, spos, epos, line):
    global stateStack,name,param,class_spos,def_spos,import_spos
    global doc_string, modules, import_token, module_has_docstring
    global protection_level, private_member
    global out_row

    while out_row + 1 < spos[0]:
        output("\n", (0, 0))

    rec_name_n_param(type,tok)
    if (string.replace(string.strip(tok)," ","")=="##private:"):
         protection_level = "private"
         output("private:\n",spos)
    elif (string.replace(string.strip(tok)," ","")=="##protected:"):
         protection_level = "protected"
         output("protected:\n",spos)
    elif (string.replace(string.strip(tok)," ","")=="##public:"):
         protection_level = "public"
         output("public:\n",spos)
    else:
         gather_comment(type,tok,spos)

    state = get_state()

#    sys.stderr.write("%d: %s\n"%(state, tok))

    # OUTSIDE
    if   (state==OUTSIDE):
        if  (tok=="class"):
            start_recording()
            class_spos = spos
            push_state(BUILD_CLASS_DECL)
        elif (tok=="def"):
            start_recording()
            def_spos = spos
            push_state(BUILD_DEF_DECL)
        elif (tok=="import") or (tok=="from"):
            import_token = tok
            import_spos = spos
            modules     = []
            push_state(IMPORT)
        elif (spos[1] == 0 and tok[:3] == '"""'):