script_debugger_remote.h
1 /*************************************************************************/
2 /* script_debugger_remote.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef SCRIPT_DEBUGGER_REMOTE_H
30 #define SCRIPT_DEBUGGER_REMOTE_H
31 
32 
33 #include "script_language.h"
34 #include "io/stream_peer_tcp.h"
35 #include "io/packet_peer.h"
36 #include "list.h"
37 
39 
40  struct Message {
41 
42  String message;
43  Array data;
44  };
45 
46 
47 
48  Ref<StreamPeerTCP> tcp_client;
49  Ref<PacketPeerStream> packet_peer_stream;
50 
51  uint64_t last_perf_time;
52  Object *performance;
53  bool requested_quit;
54  Mutex *mutex;
55 
56  struct OutputError {
57 
58  int hr;
59  int min;
60  int sec;
61  int msec;
62  String source_file;
63  String source_func;
64  int source_line;
65  String error;
66  String error_descr;
67  bool warning;
68  Array callstack;
69 
70  };
71 
72  List<String> output_strings;
73  List<Message> messages;
74  List<OutputError> errors;
75 
76  int max_cps;
77  int char_count;
78  uint64_t last_msec;
79  uint64_t msec_count;
80 
81  bool locking; //hack to avoid a deadloop
82  static void _print_handler(void *p_this,const String& p_string);
83 
84  PrintHandlerList phl;
85 
86  void _get_output();
87  void _poll_events();
88  uint32_t poll_every;
89 
90 
91  bool _parse_live_edit(const Array &p_command);
92 
93  RequestSceneTreeMessageFunc request_scene_tree;
94  void *request_scene_tree_ud;
95 
96  void _send_video_memory();
97  LiveEditFuncs *live_edit_funcs;
98 
100  static void _err_handler(void*,const char*,const char*,int p_line,const char *, const char *,ErrorHandlerType p_type);
101 
102 
103 public:
104 
105  struct ResourceUsage {
106 
107  String path;
108  String format;
109  String type;
110  RID id;
111  int vram;
112  bool operator<(const ResourceUsage& p_img) const { return vram==p_img.vram ? id<p_img.id : vram > p_img.vram; }
113  };
114 
115  typedef void (*ResourceUsageFunc)(List<ResourceUsage>*);
116 
117  static ResourceUsageFunc resource_usage_func;
118 
119  Error connect_to_host(const String& p_host,uint16_t p_port);
120  virtual void debug(ScriptLanguage *p_script,bool p_can_continue=true);
121  virtual void idle_poll();
122  virtual void line_poll();
123 
124  virtual bool is_remote() const { return true; }
125  virtual void request_quit();
126 
127  virtual void send_message(const String& p_message, const Array& p_args);
128 
129  virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata);
130  virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs);
131 
134 };
135 
136 #endif // SCRIPT_DEBUGGER_REMOTE_H
Definition: array.h:38
Definition: script_debugger_remote.h:38
Definition: error_macros.h:59
Definition: mutex.h:45
Definition: script_language.h:147
Definition: print_string.h:39
Definition: script_language.h:242
Definition: rid.h:47
Definition: script_language.h:255
Definition: ustring.h:64
Definition: object.h:317
Definition: script_debugger_remote.h:105