OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 DebugCommandProcessor.prototype.processDebugRequest = function (request) { | 951 DebugCommandProcessor.prototype.processDebugRequest = function (request) { |
952 return this.processDebugJSONRequest(request); | 952 return this.processDebugJSONRequest(request); |
953 } | 953 } |
954 | 954 |
955 | 955 |
956 DebugCommandProcessor.prototype.responseIsRunning = function (response) { | 956 DebugCommandProcessor.prototype.responseIsRunning = function (response) { |
957 return this.isRunning(response); | 957 return this.isRunning(response); |
958 } | 958 } |
959 | 959 |
960 | 960 |
961 function RequestPacket(command) { | |
962 this.seq = 0; | |
963 this.type = 'request'; | |
964 this.command = command; | |
965 } | |
966 | |
967 | |
968 RequestPacket.prototype.toJSONProtocol = function() { | |
969 // Encode the protocol header. | |
970 var json = '{'; | |
971 json += '"seq":' + this.seq; | |
972 json += ',"type":"' + this.type + '"'; | |
973 if (this.command) { | |
974 json += ',"command":' + StringToJSON_(this.command); | |
975 } | |
976 if (this.arguments) { | |
977 json += ',"arguments":'; | |
978 // Encode the arguments part. | |
979 if (this.arguments.toJSONProtocol) { | |
980 json += this.arguments.toJSONProtocol() | |
981 } else { | |
982 json += SimpleObjectToJSON_(this.arguments); | |
983 } | |
984 } | |
985 json += '}'; | |
986 return json; | |
987 } | |
988 | |
989 | |
990 DebugCommandProcessor.prototype.createRequest = function(command) { | |
991 return new RequestPacket(command); | |
992 }; | |
993 | |
994 | |
995 function ResponsePacket(request) { | 961 function ResponsePacket(request) { |
996 // Build the initial response from the request. | 962 // Build the initial response from the request. |
997 this.seq = next_response_seq++; | 963 this.seq = next_response_seq++; |
998 this.type = 'response'; | 964 this.type = 'response'; |
999 if (request) this.request_seq = request.seq; | 965 if (request) this.request_seq = request.seq; |
1000 if (request) this.command = request.command; | 966 if (request) this.command = request.command; |
1001 this.success = true; | 967 this.success = true; |
1002 this.running = false; | 968 this.running = false; |
1003 } | 969 } |
1004 | 970 |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 json += NumberToJSON_(elem); | 1641 json += NumberToJSON_(elem); |
1676 } else if (IS_STRING(elem)) { | 1642 } else if (IS_STRING(elem)) { |
1677 json += StringToJSON_(elem); | 1643 json += StringToJSON_(elem); |
1678 } else { | 1644 } else { |
1679 json += elem; | 1645 json += elem; |
1680 } | 1646 } |
1681 } | 1647 } |
1682 json += ']'; | 1648 json += ']'; |
1683 return json; | 1649 return json; |
1684 } | 1650 } |
OLD | NEW |