Changeset 21095 for lang/javascript

Show
Ignore:
Timestamp:
10/11/08 02:20:13 (3 months ago)
Author:
fujidig
Message:

* noteload を実装。
* bloadを使っているサンプルを noteload を使うものに修正。

Location:
lang/javascript/hsp-on-js/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/hsp-on-js/trunk/samples.html

    r20969 r21095  
    88<title>HSP on JS</title> 
    99<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2/jquery.min.js"></script> 
    10 <script type="text/javascript" src="hsp-on-js-core-0.0.4.js" charset="utf-8"></script> 
     10<script type="text/javascript" src="hsp-on-js-core-0.0.5.js" charset="utf-8"></script> 
    1111<script type="text/javascript"> 
    1212HSPonJS.emptyFunction = function(){}; 
     
    319319<div> 
    320320<textarea cols="100" rows="10"> 
    321 sdim buf, 10000 
    322 bload "samples.html", buf // この HTML ファイル自身の内容を取得 
     321notesel buf 
     322noteload "samples.html" // この HTML ファイル自身の内容を取得 
    323323ins = instr(buf, 0, "&lt;body") 
    324324ins2 = instr(buf, ins, "&lt;h2") 
  • lang/javascript/hsp-on-js/trunk/src/builtin-funcs.js

    r21094 r21095  
    246246                this.scanArgs(arguments, 's'); 
    247247                path = path.toStrValue()._value; 
    248                 throw new FileReadException( 
    249                         path, 
    250                         function(data) { this.strsize = new IntValue(data.length); }, 
    251                         function() { this.strsize = new IntValue(-1); }); 
     248                this.fileRead(path, 
     249                              function(data) { this.strsize = new IntValue(data.length); }, 
     250                              function() { this.strsize = new IntValue(-1); }); 
    252251        }, 
    253252        0x16: function bload(path, v) { 
     253                // FIXME 第三引数のサイズ、第四引数のオフセットに対応 
    254254                this.scanArgs(arguments, 'sv'); 
    255255                path = path.toStrValue()._value; 
    256                 throw new FileReadException( 
     256                this.fileRead( 
    257257                        path, 
    258258                        function(data) { 
     
    392392                var length = val.lineLengthIncludeCR(index); 
    393393                note.splice(index, length, ''); 
     394        }, 
     395        0x25: function noteload(path) { 
     396                // FIXME 第二引数のサイズ上限に対応 
     397                this.scanArgs(arguments, 's'); 
     398                path = path.toStrValue()._value; 
     399                var note = this.getNote(); 
     400                this.fileRead( 
     401                        path, 
     402                        function(data) { 
     403                                data = CP932.encode(data) + "\0"; 
     404                                note.expandByteSize(data.length); 
     405                                note.setbytes(0, data); 
     406                        }, 
     407                        function() { 
     408                                throw new HSPError(ErrorCode.FILE_IO); 
     409                        }); 
    394410        }, 
    395411        0x27: function randomize(seed) { 
  • lang/javascript/hsp-on-js/trunk/src/evaluator.js

    r21094 r21095  
    209209                } 
    210210                return this.noteStack[this.noteStack.length - 1]; 
     211        }, 
     212        fileRead: function fileRead(path, success, error) { 
     213                throw new FileReadException(path, success, error); 
    211214        }, 
    212215        getBuiltinFuncName: function getBuiltinFuncName(insn) {