Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | fixes and new code |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f9d868063d29e1b0adca8c0be02c1fcc |
User & Date: | arnulf 2012-08-26 14:28:37.182 |
Context
2012-08-26
| ||
14:48 | initial version check-in: 18a41385d9 user: arnulf tags: trunk | |
14:28 | fixes and new code check-in: f9d868063d user: arnulf tags: trunk | |
13:31 | initial version check-in: 081f7049b9 user: arnulf tags: trunk | |
Changes
Changes to Interp.tcl.
︙ | ︙ | |||
11 12 13 14 15 16 17 | # * # * Copyright 2012 Arnulf P. Wiedemann #===================================================== namespace eval :: { ::itcl::class Interp { | > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # * # * Copyright 2012 Arnulf P. Wiedemann #===================================================== namespace eval :: { ::itcl::class Interp { public common obj_type2string public common string2obj_type public common string_obj_type [uplevel #0 ::Parser::StringObjType #auto] public common source_obj_type [uplevel #0 ::Parser::SourceObjType #auto] public common script_obj_type [uplevel #0 ::Parser::ScriptObjType #auto] public common script_line_obj_type [uplevel #0 ::Parser::ScriptLineObjType #auto] public common current_dir "." public proc Init {} public proc objType2String {val} public proc string2ObjType {val} } ::itcl::body Interp::Init {} { set obj_type2string(0) "OBJ_TYPE_SCRIPT" set obj_type2string(1) "OBJ_TYPE_SCRIPT_LINE" set obj_type2string(2) "OBJ_TYPE_SOURCE" set obj_type2string(3) "OBJ_TYPE_STRING" set string2obj_type(OBJ_TYPE_SCRIPT) 0 set string2obj_type(OBJ_TYPE_SCRIPT_LINE) 1 set string2obj_type(OBJ_TYPE_SOURCE) 2 set string2obj_type(OBJ_TYPE_STRING) 3 } ::itcl::body Interp::objType2String {val} { if {[info exists obj_type2string($val)]} { return $obj_type2string($val) } else { puts stderr "objType2String no such ObjType!$val!" parray obj_type2string return "" } } ::itcl::body Interp::string2ObjType {val} { if {[info exists string2obj_type($val)]} { return $string2obj_type($val) } else { puts stderr "string2ObjType no such ObjType!$val!" parray string2obj_type return "" } } } |
Changes to LatexObj.tcl.
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | public variable ref_count public variable obj_type constructor {} {} public method mySelf {} public method toString {} public method toDebugString {} public method isShared {} public method isListObj {} public method getIntRepPtr {} public method incrRefCount {where} public method decrRefCount {where} public method getString {} public method getStringLength {} | > > > > > > > > > > > > > > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | public variable ref_count public variable obj_type constructor {} {} public method mySelf {} public method toString {} public method toDebugString {} public method scriptLineValue_GetLine {} public method scriptLineValue_SetLine {val} public method scriptLineValue_GetArgc {} public method scriptLineValue_SetArgc {val} public method scriptValue_GetScript {} public method scriptValue_SetScript {script} public method sourceValue_GetFileNameObj {} public method sourceValue_SetFileNameObj {file_name_obj} public method sourceValue_GetLineNumber {} public method sourceValue_SetLineNumber {line_number} public method strValue_GetCharLength {} public method strValue_SetCharLength {char_length} public method strValue_GetMaxLength {} public method strValue_SetMaxLength {max_length} public method isShared {} public method isListObj {} public method getIntRepPtr {} public method incrRefCount {where} public method decrRefCount {where} public method getString {} public method getStringLength {} |
︙ | ︙ | |||
68 69 70 71 72 73 74 | incr oid set id $oid set bytes "" set len 0; set allocated "" set freed "" | | > > > > | | | 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 | incr oid set id $oid set bytes "" set len 0; set allocated "" set freed "" set obj_type_base [::Parser::ObjTypeBase #auto] set incr_lst [list] set decr_lst [list] set check_allocate true set ref_count 0 set value1 "" set value2 "" set value3 "" } # ==================== mySelf ================================== ::itcl::body LatexObj::mySelf {} { set str "LatexObj!$id!" return $str } # ==================== toString ===================================== ::itcl::body LatexObj::toString {} { return "[mySelf]!" } # ==================== toDebugString ===================================== ::itcl::body LatexObj::toDebugString {} { set str "[mySelf]\n" append str " ref_count: $ref_count\n" append str " len: $len\n" append str " obj_type: [::Interp::objType2String $obj_type]\n" append str " allocated: $allocated\n" append str " freed: $freed\n" append str " incr: $incr_lst\n" append str " decr: $decr_lst\n" append str " value1: $value1\n" append str " value2: $value2\n" append str " value3: $value3\n" append str " bytes: $bytes\n" if {$obj_type > 0} { switch [::Interp::objType2String $obj_type] { OBJ_TYPE_LIST { # str.append(" list_elem: "+listValue_GetElem()+"\n"); } OBJ_TYPE_INT { append str " value: [wideValue_GetValue]\n"); } } |
︙ | ︙ | |||
449 450 451 452 453 454 455 | /* ==================== returnCodeValue_SetReturnCode ================================== */ public int returnCodeValue_SetReturnCode(int return_code) { //print("returnCodeValue_SetReturnCode!"+this.mySelf()+"!"); value1 = (Object)return_code; return return_code; } | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 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 | /* ==================== returnCodeValue_SetReturnCode ================================== */ public int returnCodeValue_SetReturnCode(int return_code) { //print("returnCodeValue_SetReturnCode!"+this.mySelf()+"!"); value1 = (Object)return_code; return return_code; } } # ==================== scriptLineValue_GetLine ================================== ::itcl::body LatexObj::scriptLineValue_GetLine {} { return $value1 } # ==================== scriptLineValue_SetLine ================================== ::itcl::body LatexObj::scriptLineValue_SetLine {val} { #puts "scriptLineValue_SetLine![mySelf]!" set value1 $val return $val } # ==================== scriptLineValue_GetArgc ================================== ::itcl::body LatexObj::scriptLineValue_GetArgc {} { return $value2 } # ==================== scriptLineValue_SetArgc ================================== ::itcl::body LatexObj::scriptLineValue_SetArgc {val} { #puts "scriptLineValue_SetArgc![mySelf]!" set value2 $val return $val } # ==================== scriptValue_GetScript ================================== ::itcl::body LatexObj::scriptValue_GetScript {} { #puts "scriptValue_GetScript!$value1!" return $value1 } # ==================== scriptValue_SetScript ================================== ::itcl::body LatexObj::scriptValue_SetScript {script} { #puts "scriptValue_SetScript![mySelf]!" set value1 $script return $script } # ==================== sourceValue_GetFileNameObj ================================== ::itcl::body LatexObj::sourceValue_GetFileNameObj {} { return $value1 } # ==================== sourceValue_SetFileNameObj ================================== ::itcl::body LatexObj::sourceValue_SetFileNameObj {file_name_obj} { #pits "sourceValue_SetFileNameObj![mySelf]!" set value1 $file_name_obj return $file_name_obj } # ==================== sourceValue_GetLineNumber ================================== ::itcl::body LatexObj::sourceValue_GetLineNumber {} { return $value2 } # ==================== sourceValue_SetLineNumber ================================== ::itcl::body LatexObj::sourceValue_SetLineNumber {line_number} { #puts "sourceValue_SetLineNumber![mySelf]!" set value2 $line_number return $line_number } # ==================== strValue_GetCharLength ================================== ::itcl::body LatexObj::strValue_GetCharLength {} { if {$value2 == ""} { puts "strValue_GetCharLength fix value2!" set value2 $len } return $value2 } # ==================== strValue_SetCharLength ================================== ::itcl::body LatexObj::strValue_SetCharLength {char_length} { #puts "strValue_SetCharLength![mySelf]!" set value2 $char_length return $char_length } # ==================== strValue_GetMaxLength ================================== ::itcl::body LatexObj::strValue_GetMaxLength {} { #puts "strValue_GetMaxLength!$value1!" if {$value1 == ""} { return 0 } return $value1 } # ==================== strValue_SetMaxLength ================================== ::itcl::body LatexObj::strValue_SetMaxLength {max_length} { #puts "strValue_SetMaxLength![mySelf]!max_length); set value1 $max_length; return $max_length; } if {0} { /* ==================== twoPtrValue_GetPtr1 ================================== */ public Object twoPtrValue_GetPtr1() { return value1; } /* ==================== twoPtrValue_SetPtr1 ================================== */ public Object twoPtrValue_SetPtr1(Object ptr1) { |
︙ | ︙ |
Changes to SourceObjType.tcl.
︙ | ︙ | |||
27 28 29 30 31 32 33 | public method freeInternalRep {obj_ptr} public method dupInternalRep {src_ptr dup_ptr} public method setSourceInfo {obj_ptr file_name_ptr line_number} } # ==================== constructor ================================== ::itcl::body SourceObjType::constructor {} { | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | public method freeInternalRep {obj_ptr} public method dupInternalRep {src_ptr dup_ptr} public method setSourceInfo {obj_ptr file_name_ptr line_number} } # ==================== constructor ================================== ::itcl::body SourceObjType::constructor {} { incr oid set id $oid } # ==================== mySelf ================================== ::itcl::body SourceObjType::mySelf {} { set str "SourceObjType!$id!" return $str |
︙ | ︙ |
Changes to StringObjType.tcl.
︙ | ︙ | |||
94 95 96 97 98 99 100 | # ==================== getStringLength ================================== ::itcl::body StringObjType::getStringLength {obj_ptr} { return [$obj_ptr getLen] } # ==================== newStringObjNoAlloc ================================== ::itcl::body StringObjType::newStringObjNoAlloc {str len where} { | | | | | | | 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 | # ==================== getStringLength ================================== ::itcl::body StringObjType::getStringLength {obj_ptr} { return [$obj_ptr getLen] } # ==================== newStringObjNoAlloc ================================== ::itcl::body StringObjType::newStringObjNoAlloc {str len where} { set obj_ptr [uplevel #0 ::Parser::LatexObj #auto] if {$len == -1} { set len [string length $str] } $obj_ptr setStringRep $obj_ptr $str $len $obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_STRING] $obj_ptr setAllocated $where $obj_ptr setFreed "" return $obj_ptr; } # ==================== newStringObj ================================== # len is in bytes -- see also newStringObjUtf8() ::itcl::body StringObjType::newStringObj {str len where} { set obj_ptr [uplevel #0 ::Parser::LatexObj #auto] # Need to find out how many bytes the string requires if {$len == -1} { set len [string length $str] } $obj_ptr strValue_SetCharLength $len $obj_ptr strValue_SetMaxLength $len if {$len == 0} { $obj_ptr setLen 0 $obj_ptr setBbytes "" } else { $obj_ptr setBytes "" $obj_ptr setBytes "[$obj_ptr getBytes][string range $str 0 $len]" $obj_ptr setLen $len } # No obj_type field for the vanilla string object. $obj_ptr setObjType [::Interp::string2ObjType OBJ_TYPE_STRING] $obj_ptr setAllocated $where $obj_ptr setFreed "" return $obj_ptr; } # ==================== newEmptyStringObj ================================== ::itcl::body StringObjType::newEmptyStringObj {where} { |
︙ | ︙ |
Changes to latex_parse.tcl.
︙ | ︙ | |||
25 26 27 28 29 30 31 32 33 34 35 36 37 38 | source ./ScriptLineObjType.tcl source ./SourceObjType.tcl source ./StringObjType.tcl source ./LatexObj.tcl source ./ObjTypeBase.tcl source ./Script.tcl source ./ScriptObjType.tcl source ./latex_parse_fcn.tcl source ./latex_cmds.tcl global gState global gCmds global gPackages global gCurr | > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | source ./ScriptLineObjType.tcl source ./SourceObjType.tcl source ./StringObjType.tcl source ./LatexObj.tcl source ./ObjTypeBase.tcl source ./Script.tcl source ./ScriptObjType.tcl source ./Interp.tcl source ./latex_parse_fcn.tcl source ./latex_cmds.tcl global gState global gCmds global gPackages global gCurr |
︙ | ︙ | |||
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | } return true } buildCmdList $latex_cmds_info ::Parser::Token::Init ::LaTeX::CommandInfo::Init set parser [::Parser::Parser #auto] set str "\\begin\[pf1\]{document}\n abc \n\\end{document}" $parser parserInit $str [string length $str] 1 while {true} { if {[$parser isEof]} { break } if {! [$parser parseScript]} { puts stderr "Error in parsing!" | > > > | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | } return true } buildCmdList $latex_cmds_info ::Parser::Token::Init ::Interp::Init ::LaTeX::CommandInfo::Init set parser [::Parser::Parser #auto] set str "\\begin\[pf1\]{document}\n abc \n\\end{document}" set script [$::Interp::string_obj_type newStringObj "::set dir $::Interp::current_dir\n$str" -1 "BASE_2"] puts "SCRIPT![$script toDebugString]!" $parser parserInit $str [string length $str] 1 while {true} { if {[$parser isEof]} { break } if {! [$parser parseScript]} { puts stderr "Error in parsing!" |
︙ | ︙ |