├── .gitignore ├── LICENSE ├── README.md └── gSpiderMac ├── .gitignore ├── gSpiderMac.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── gSpiderMac.xccheckout │ └── xcuserdata │ │ ├── reich.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ ├── wzhao.xcuserdatad │ │ └── UserInterfaceState.xcuserstate │ │ └── zhaohu.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── reich.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── gSpiderMac.xcscheme │ │ └── xcschememanagement.plist │ ├── wzhao.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── gSpiderMac.xcscheme │ │ └── xcschememanagement.plist │ └── zhaohu.xcuserdatad │ └── xcschemes │ ├── gSpiderMac.xcscheme │ └── xcschememanagement.plist ├── gSpiderMac ├── AjaxWrap.cpp ├── AjaxWrap.h ├── DomWrap.cpp ├── DomWrap.h ├── GSTask.cpp ├── GSTask.h ├── HTMLTree.cpp ├── HTMLTree.h ├── LocationWrap.cpp ├── LocationWrap.h ├── NavigatorWrap.cpp ├── NavigatorWrap.h ├── ScreenWrap.cpp ├── ScreenWrap.h ├── WZ_HTTPSocket.cpp ├── WZ_HTTPSocket.h ├── WindowWrap.cpp ├── WindowWrap.h ├── cssstyleWrap.cpp ├── cssstyleWrap.h ├── elementWrap.cpp ├── elementWrap.h ├── main.cpp ├── minicfg.cpp ├── minicfg.h ├── spiderActions.cpp ├── spiderActions.h ├── testWrap.cpp ├── testWrap.h ├── util.cpp └── util.h ├── nodejs └── nodejs │ ├── main.cpp │ └── src │ ├── async-wrap-inl.h │ ├── async-wrap.h │ ├── base-object-inl.h │ ├── base-object.h │ ├── cares_wrap.cc │ ├── env-inl.h │ ├── env.h │ ├── fs_event_wrap.cc │ ├── handle_wrap.cc │ ├── handle_wrap.h │ ├── node.cc │ ├── node.d │ ├── node.h │ ├── node.js │ ├── node.stp │ ├── node_buffer.cc │ ├── node_buffer.h │ ├── node_constants.cc │ ├── node_constants.h │ ├── node_contextify.cc │ ├── node_counters.cc │ ├── node_counters.h │ ├── node_crypto.cc │ ├── node_crypto.h │ ├── node_crypto_bio.cc │ ├── node_crypto_bio.h │ ├── node_crypto_clienthello-inl.h │ ├── node_crypto_clienthello.cc │ ├── node_crypto_clienthello.h │ ├── node_crypto_groups.h │ ├── node_dtrace.cc │ ├── node_dtrace.h │ ├── node_file.cc │ ├── node_file.h │ ├── node_http_parser.cc │ ├── node_http_parser.h │ ├── node_internals.h │ ├── node_javascript.cc │ ├── node_javascript.h │ ├── node_main.cc │ ├── node_object_wrap.h │ ├── node_os.cc │ ├── node_provider.d │ ├── node_root_certs.h │ ├── node_stat_watcher.cc │ ├── node_stat_watcher.h │ ├── node_v8.cc │ ├── node_version.h │ ├── node_watchdog.cc │ ├── node_watchdog.h │ ├── node_win32_etw_provider-inl.h │ ├── node_win32_etw_provider.cc │ ├── node_win32_etw_provider.h │ ├── node_win32_perfctr_provider.cc │ ├── node_win32_perfctr_provider.h │ ├── node_wrap.h │ ├── node_zlib.cc │ ├── notrace_macros.py │ ├── perfctr_macros.py │ ├── pipe_wrap.cc │ ├── pipe_wrap.h │ ├── process_wrap.cc │ ├── queue.h │ ├── req_wrap.h │ ├── res │ ├── node.exe.extra.manifest │ ├── node.ico │ ├── node.rc │ ├── node_etw_provider.man │ └── node_perfctr_provider.man │ ├── signal_wrap.cc │ ├── smalloc.cc │ ├── smalloc.h │ ├── spawn_sync.cc │ ├── spawn_sync.h │ ├── stream_wrap.cc │ ├── stream_wrap.h │ ├── string_bytes.cc │ ├── string_bytes.h │ ├── tcp_wrap.cc │ ├── tcp_wrap.h │ ├── timer_wrap.cc │ ├── tls_wrap.cc │ ├── tls_wrap.h │ ├── tree.h │ ├── tty_wrap.cc │ ├── tty_wrap.h │ ├── udp_wrap.cc │ ├── udp_wrap.h │ ├── util-inl.h │ ├── util.cc │ ├── util.h │ ├── uv.cc │ ├── v8abbr.h │ └── v8ustack.d ├── readme ├── test ├── demo_get2.php └── get.html └── testv8 ├── testv8.xcodeproj ├── project.pbxproj └── xcuserdata │ └── reich.xcuserdatad │ └── xcschemes │ ├── testv8.xcscheme │ └── xcschememanagement.plist └── testv8 └── main.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grampusSpider 2 | A web-spider that can run JS based V8 and get AJAX contents, command line mode. 3 | 4 | Idea: 5 | I need to grasp some information from web but there are ajax pages blocked there . Need JavaScript parsing and execute. 6 | So the project comes. 7 | -------------------------------------------------------------------------------- /gSpiderMac/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Debug 3 | Release 4 | 5 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcshareddata/gSpiderMac.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 08CDE7DD-3FAD-4CDA-A67B-D475207E1823 9 | IDESourceControlProjectName 10 | gSpiderMac 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | B9F0E82525F6C7457C798A5A1858635F24C869C0 14 | ssh://208.110.85.166:22222/repo/gSpiderMac 15 | 16 | IDESourceControlProjectPath 17 | gSpiderMac.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | B9F0E82525F6C7457C798A5A1858635F24C869C0 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | ssh://208.110.85.166:22222/repo/gSpiderMac 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | B9F0E82525F6C7457C798A5A1858635F24C869C0 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | B9F0E82525F6C7457C798A5A1858635F24C869C0 36 | IDESourceControlWCCName 37 | gSpiderMac 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcuserdata/reich.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reichtiger/grampusSpider/d8ba6b96a7af085c7c2420a5bcb1fa35ee8b03b7/gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcuserdata/reich.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcuserdata/wzhao.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reichtiger/grampusSpider/d8ba6b96a7af085c7c2420a5bcb1fa35ee8b03b7/gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcuserdata/wzhao.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcuserdata/zhaohu.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reichtiger/grampusSpider/d8ba6b96a7af085c7c2420a5bcb1fa35ee8b03b7/gSpiderMac/gSpiderMac.xcodeproj/project.xcworkspace/xcuserdata/zhaohu.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/reich.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 14 | 15 | 16 | 18 | 30 | 31 | 32 | 34 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/reich.xcuserdatad/xcschemes/gSpiderMac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/reich.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | gSpiderMac.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A6E70A2A19E2D1BF00105506 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/wzhao.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/wzhao.xcuserdatad/xcschemes/gSpiderMac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/wzhao.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | gSpiderMac.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A6E70A2A19E2D1BF00105506 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/zhaohu.xcuserdatad/xcschemes/gSpiderMac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac.xcodeproj/xcuserdata/zhaohu.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | gSpiderMac.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A6E70A2A19E2D1BF00105506 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/AjaxWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // AjaxWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reichtiger on 10/6/14. 6 | // Copyright (c) 2014 reichtiger. All rights reserved. 7 | // 8 | 9 | #ifndef __AJAXWRAP_HEADER__ 10 | #define __AJAXWRAP_HEADER__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include "WZ_HTTPSocket.h" 20 | #include "util.h" 21 | #include "minicfg.h" 22 | 23 | 24 | using namespace v8; 25 | 26 | namespace gSpider { 27 | /** 28 | * XMLHttpRequest declare 29 | */ 30 | 31 | class XMLHttpRequest{ 32 | public: 33 | char* _host; 34 | int _port; 35 | char* _curPath; 36 | WZ_HTTPSocket hs; 37 | int status; 38 | int readyState; 39 | char* response_txt; 40 | Persistent _onreadystatechange; 41 | //Persistent jsObject; 42 | bool callback_setted; 43 | 44 | public: 45 | XMLHttpRequest(Local _jsObject, char* host, int port); 46 | ~XMLHttpRequest(); 47 | void open(char* method, 48 | char* pagePath, 49 | bool flag); 50 | void setRequestHeader(); 51 | char* send(const v8::FunctionCallbackInfo& args); 52 | static void read_all_finished(void* sender, char* str, size_t n); 53 | char* getHost(){ 54 | if (_host) { 55 | return _host; 56 | } 57 | return NULL; 58 | } 59 | 60 | int get_status(); 61 | void set_status(int status_); 62 | int get_readyState(); 63 | void set_readyState(int state); 64 | 65 | void ready_callback(const FunctionCallbackInfo& args); 66 | }; 67 | 68 | 69 | /** 70 | * Ajax Wrap 71 | * 72 | * 73 | */ 74 | Local get_ajax_obj(const FunctionCallbackInfo& args); 75 | void init_AjaxWrap(Isolate* isolate, Handle global); 76 | void AjaxWrap_Constructor(const FunctionCallbackInfo& args); 77 | 78 | void AjaxWrap_open(const v8::FunctionCallbackInfo& args); 79 | void AjaxWrap_setRequestHeader(const v8::FunctionCallbackInfo& args); 80 | void AjaxWrap_send(const v8::FunctionCallbackInfo& args); 81 | 82 | /** 83 | * properties 84 | */ 85 | void AjaxWrap_status(Local name, const PropertyCallbackInfo& info); 86 | void AjaxWrap_readyState(Local name, const PropertyCallbackInfo& info); 87 | void AjaxWrap_onReadyStateChange(Local name, const PropertyCallbackInfo& info); 88 | void AjaxWrap_responseText(Local name, const PropertyCallbackInfo& info); 89 | void AjaxWrap_onReadyStateChangeSetter(Local name, Local value_obj, const PropertyCallbackInfo& info); 90 | 91 | } 92 | 93 | #endif -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/DomWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // DomWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/1. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__DomWrap__ 10 | #define __gSpiderMac__DomWrap__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include "WZ_HTTPSocket.h" 21 | #include "HTMLTree.h" 22 | #include "util.h" 23 | #include "elementWrap.h" 24 | #include "LocationWrap.h" 25 | 26 | using namespace::v8; 27 | 28 | namespace gSpider{ 29 | 30 | // C++ object HTMLDocument <--> DomWrap 31 | class HTMLWindow; 32 | 33 | class HTMLDocument{ 34 | public: 35 | HTMLDocument(); 36 | ~HTMLDocument(); 37 | char* _innerHTML; 38 | 39 | char* getHTML(); 40 | 41 | HTMLBranch* dom_tree; 42 | HTMLWindow* parentWin; 43 | 44 | void removeTree(); 45 | void setTree(wchar_t* inStr); 46 | }; 47 | 48 | 49 | // warpping HTMLDocument to "document" 50 | 51 | Handle init_DomWrap(Isolate* isolate, HTMLDocument* html_doc); 52 | 53 | /*************************************************************************** 54 | * properties 55 | */ 56 | void DomWrap_innerHTML(Local name, const PropertyCallbackInfo& info); 57 | void DomWrap_innerHTML_setter(Local name, Local value_obj, const PropertyCallbackInfo& info); 58 | 59 | // cookie 60 | void DomWrap_cookie(Local name, const PropertyCallbackInfo& info); 61 | void DomWrap_cookie_setter(Local name, Local value_obj, const PropertyCallbackInfo& info); 62 | 63 | void DomWrap_Location(Local name, const PropertyCallbackInfo& info); 64 | void DomWrap_body(Local name, const PropertyCallbackInfo& info); 65 | void DomWrap_defaultView(Local name, const PropertyCallbackInfo& info); 66 | void DomWrap_nodeType(Local name, const PropertyCallbackInfo& info); 67 | void DomWrap_documentElement(Local name, const PropertyCallbackInfo& info); 68 | void DomWrap_readyState(Local name, const PropertyCallbackInfo& info); 69 | /*************************************************************************** 70 | * functions 71 | */ 72 | void DomWrap_getElementById(const v8::FunctionCallbackInfo& args); 73 | void DomWrap_getElementsByTagName(const v8::FunctionCallbackInfo& args); 74 | void DomWrap_getElementsByClassName(const v8::FunctionCallbackInfo& args); 75 | void DomWrap_createElement(const v8::FunctionCallbackInfo& args); 76 | void DomWrap_createTextNode(const v8::FunctionCallbackInfo& args); 77 | void DomWrap_addEventListener(const v8::FunctionCallbackInfo& args); 78 | void DomWrap_createDocumentFragment(const v8::FunctionCallbackInfo& args); 79 | } 80 | 81 | #endif /* defined(__gSpiderMac__DomWrap__) */ 82 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/GSTask.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // GSTask.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/21. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #include "GSTask.h" 10 | 11 | GSTask::GSTask(const char* url, const char* js, int dep) 12 | { 13 | size_t url_len = strlen(url); 14 | size_t js_len = strlen(js); 15 | 16 | url_ = new char[url_len+1]; 17 | if (url_) { 18 | strncpy(url_, url, url_len); 19 | url_[url_len] = '\0'; 20 | } 21 | 22 | jsPath_ = new char[js_len+1]; 23 | if (jsPath_) { 24 | strncpy(jsPath_, js, js_len); 25 | jsPath_[js_len] = '\0'; 26 | } 27 | 28 | depth_ = dep; 29 | } 30 | 31 | GSTask::~GSTask() 32 | { 33 | if (url_ != NULL) { 34 | delete url_; 35 | } 36 | 37 | if (jsPath_ != NULL ) { 38 | delete jsPath_; 39 | } 40 | } -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/GSTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // GSTask.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/21. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__GSTask__ 10 | #define __gSpiderMac__GSTask__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | class GSTask { 23 | public: 24 | char* url_; 25 | int depth_; 26 | char* jsPath_; 27 | public: 28 | GSTask(const char* url, const char* js, int dep = 0); 29 | ~GSTask(); 30 | }; 31 | 32 | #endif /* defined(__gSpiderMac__GSTask__) */ 33 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/LocationWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // LocationWrap.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/20. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #include "LocationWrap.h" 10 | 11 | extern char gProto[16]; 12 | extern char gHost[32]; 13 | extern char* gPath; 14 | extern int gPort; 15 | 16 | namespace gSpider { 17 | 18 | Location::Location() 19 | { 20 | strcat(href_, "http://test.com/"); 21 | } 22 | 23 | Location::~Location() 24 | { 25 | 26 | } 27 | 28 | char* Location::get_href() 29 | { 30 | return href_; 31 | } 32 | 33 | void Location::set_href(char* url) 34 | { 35 | if (href_) { 36 | memset(href_, 0, strlen(href_)); 37 | strncpy(href_, url, strlen(url)); 38 | } 39 | } 40 | 41 | /** 42 | * 43 | * Location object wrap 44 | */ 45 | Handle LocationWrap(Isolate* isolate, Location* loc) { 46 | 47 | EscapableHandleScope handle_scope(isolate); 48 | 49 | Local templ = ObjectTemplate::New(); 50 | templ->SetInternalFieldCount(1); 51 | 52 | // set accessores 53 | templ->SetAccessor(String::NewFromUtf8(isolate, "hash"), LocationWrap_hash); 54 | templ->SetAccessor(String::NewFromUtf8(isolate, "host"), LocationWrap_host); 55 | templ->SetAccessor(String::NewFromUtf8(isolate, "hostname"), LocationWrap_hostname); 56 | templ->SetAccessor(String::NewFromUtf8(isolate, "href"), LocationWrap_href); 57 | templ->SetAccessor(String::NewFromUtf8(isolate, "pathname"), LocationWrap_pathname); 58 | templ->SetAccessor(String::NewFromUtf8(isolate, "port"), LocationWrap_port); 59 | templ->SetAccessor(String::NewFromUtf8(isolate, "protocol"), LocationWrap_protocol); 60 | templ->SetAccessor(String::NewFromUtf8(isolate, "search"), LocationWrap_search); 61 | 62 | // functions 63 | templ->Set(isolate, "assign", FunctionTemplate::New(isolate, LocationWrap_assign)); 64 | templ->Set(isolate, "reload", FunctionTemplate::New(isolate, LocationWrap_reload)); 65 | templ->Set(isolate, "replace", FunctionTemplate::New(isolate, LocationWrap_replace)); 66 | 67 | Local result = templ->NewInstance(); 68 | result->SetInternalField(0, External::New(isolate, loc )); 69 | 70 | return handle_scope.Escape(result); 71 | } 72 | 73 | /** 74 | * properties and functions body 75 | 76 | hash 设置或返回从井号 (#) 开始的 URL(锚)。 77 | host 设置或返回主机名和当前 URL 的端口号。 78 | hostname 设置或返回当前 URL 的主机名。 79 | href 设置或返回完整的 URL。 80 | pathname 设置或返回当前 URL 的路径部分。 81 | port 设置或返回当前 URL 的端口号。 82 | protocol 设置或返回当前 URL 的协议。 83 | search 设置或返回从问号 (?) 开始的 URL(查询部分)。 84 | 85 | */ 86 | 87 | Location* getOriLocationPtr(Local self) 88 | { 89 | Local wrap = Local::Cast(self->GetInternalField(0)); 90 | void *ptr = wrap->Value(); 91 | return static_cast(ptr); 92 | } 93 | 94 | 95 | void LocationWrap_hash(Local name, const PropertyCallbackInfo& info){ 96 | info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), "")); 97 | } 98 | void LocationWrap_host(Local name, const PropertyCallbackInfo& info){} 99 | void LocationWrap_hostname(Local name, const PropertyCallbackInfo& info){} 100 | void LocationWrap_href(Local name, const PropertyCallbackInfo& info){ 101 | 102 | Location* pLoc = getOriLocationPtr(info.Holder()); 103 | info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), pLoc->href_)); 104 | } 105 | void LocationWrap_pathname(Local name, const PropertyCallbackInfo& info){} 106 | void LocationWrap_port(Local name, const PropertyCallbackInfo& info){} 107 | void LocationWrap_protocol(Local name, const PropertyCallbackInfo& info) 108 | { 109 | if (strstr(gHost, "https://")) { 110 | info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), "https:")); 111 | }else{ 112 | info.GetReturnValue().Set(String::NewFromUtf8(info.GetIsolate(), "http:")); 113 | } 114 | } 115 | void LocationWrap_search(Local name, const PropertyCallbackInfo& info){} 116 | 117 | /*************************************************************************** 118 | * functions 119 | */ 120 | 121 | void LocationWrap_assign(const v8::FunctionCallbackInfo& args){} 122 | void LocationWrap_reload(const v8::FunctionCallbackInfo& args){} 123 | void LocationWrap_replace(const v8::FunctionCallbackInfo& args){} 124 | 125 | } -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/LocationWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // LocationWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/20. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__LocationWrap__ 10 | #define __gSpiderMac__LocationWrap__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include "WZ_HTTPSocket.h" 21 | #include "HTMLTree.h" 22 | #include "util.h" 23 | 24 | using namespace::v8; 25 | using namespace::std; 26 | 27 | namespace gSpider { 28 | 29 | class Location{ 30 | public: 31 | Location(); 32 | ~Location(); 33 | 34 | public: 35 | char href_[128]; 36 | 37 | char* get_href(); 38 | void set_href(char* url); 39 | }; 40 | 41 | Handle LocationWrap(Isolate* isolate, Location* loc); 42 | 43 | /*************************************************************************** 44 | * properties 45 | 46 | hash 设置或返回从井号 (#) 开始的 URL(锚)。 47 | host 设置或返回主机名和当前 URL 的端口号。 48 | hostname 设置或返回当前 URL 的主机名。 49 | href 设置或返回完整的 URL。 50 | pathname 设置或返回当前 URL 的路径部分。 51 | port 设置或返回当前 URL 的端口号。 52 | protocol 设置或返回当前 URL 的协议。 53 | search 设置或返回从问号 (?) 开始的 URL(查询部分)。 54 | 55 | */ 56 | void LocationWrap_hash(Local name, const PropertyCallbackInfo& info); 57 | void LocationWrap_host(Local name, const PropertyCallbackInfo& info); 58 | void LocationWrap_hostname(Local name, const PropertyCallbackInfo& info); 59 | void LocationWrap_href(Local name, const PropertyCallbackInfo& info); 60 | void LocationWrap_pathname(Local name, const PropertyCallbackInfo& info); 61 | void LocationWrap_port(Local name, const PropertyCallbackInfo& info); 62 | void LocationWrap_protocol(Local name, const PropertyCallbackInfo& info); 63 | void LocationWrap_search(Local name, const PropertyCallbackInfo& info); 64 | 65 | /*************************************************************************** 66 | * functions 67 | 68 | assign() 加载新的文档。 69 | reload() 重新加载当前文档。 70 | replace() 用新的文档替换当前文档。 71 | 72 | */ 73 | 74 | void LocationWrap_assign(const v8::FunctionCallbackInfo& args); 75 | void LocationWrap_reload(const v8::FunctionCallbackInfo& args); 76 | void LocationWrap_replace(const v8::FunctionCallbackInfo& args); 77 | 78 | } 79 | 80 | #endif /* defined(__gSpiderMac__LocationWrap__) */ 81 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/NavigatorWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NavigatorWrap.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/20. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #include "NavigatorWrap.h" 10 | 11 | namespace gSpider { 12 | /** 13 | * 14 | * Navigator object wrap 15 | */ 16 | Handle NavigatorWrap(Isolate* isolate, Navigator* navi) { 17 | 18 | EscapableHandleScope handle_scope(isolate); 19 | 20 | Local templ = ObjectTemplate::New(); 21 | templ->SetInternalFieldCount(1); 22 | 23 | // set accessores 24 | templ->SetAccessor(String::NewFromUtf8(isolate, "appCodeName"), NaviWrap_appCodeName); 25 | templ->SetAccessor(String::NewFromUtf8(isolate, "appName"), NaviWrap_appName); 26 | templ->SetAccessor(String::NewFromUtf8(isolate, "appVersion"), NaviWrap_appVersion); 27 | templ->SetAccessor(String::NewFromUtf8(isolate, "browserLanguage"), NaviWrap_browserLanguage); 28 | templ->SetAccessor(String::NewFromUtf8(isolate, "cookieEnabled"), NaviWrap_cookieEnabled); 29 | templ->SetAccessor(String::NewFromUtf8(isolate, "cpuClass"), NaviWrap_cpuClass); 30 | templ->SetAccessor(String::NewFromUtf8(isolate, "onLine"), NaviWrap_onLine); 31 | templ->SetAccessor(String::NewFromUtf8(isolate, "platform"), NaviWrap_platform); 32 | templ->SetAccessor(String::NewFromUtf8(isolate, "systemLanguage"), NaviWrap_systemLanguage); 33 | templ->SetAccessor(String::NewFromUtf8(isolate, "userAgent"), NaviWrap_userAgent); 34 | templ->SetAccessor(String::NewFromUtf8(isolate, "userLanguage"), NaviWrap_userLanguage); 35 | 36 | // functions 37 | templ->Set(isolate, "javaEnabled", FunctionTemplate::New(isolate, NaviWrap_javaEnabled)); 38 | templ->Set(isolate, "taintEnabled", FunctionTemplate::New(isolate, NaviWrap_taintEnabled)); 39 | 40 | Local result = templ->NewInstance(); 41 | result->SetInternalField(0, External::New(isolate, navi)); 42 | 43 | return handle_scope.Escape(result); 44 | } 45 | 46 | /** 47 | * properties and functions body 48 | */ 49 | 50 | void NaviWrap_appCodeName(Local name, const PropertyCallbackInfo& info){} 51 | void NaviWrap_appMinorVersion(Local name, const PropertyCallbackInfo& info){} 52 | void NaviWrap_appName(Local name, const PropertyCallbackInfo& info){} 53 | void NaviWrap_appVersion(Local name, const PropertyCallbackInfo& info){} 54 | void NaviWrap_browserLanguage(Local name, const PropertyCallbackInfo& info){} 55 | void NaviWrap_cookieEnabled(Local name, const PropertyCallbackInfo& info){} 56 | void NaviWrap_cpuClass(Local name, const PropertyCallbackInfo& info){} 57 | void NaviWrap_onLine(Local name, const PropertyCallbackInfo& info){} 58 | void NaviWrap_platform(Local name, const PropertyCallbackInfo& info){} 59 | void NaviWrap_systemLanguage(Local name, const PropertyCallbackInfo& info){} 60 | void NaviWrap_userAgent(Local name, const PropertyCallbackInfo& info){ 61 | char* agentStr = (char*)"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"; 62 | info.GetReturnValue().Set(String::NewFromUtf8( 63 | info.GetIsolate(), agentStr, String::kNormalString, 64 | static_cast(strlen(agentStr)))); 65 | } 66 | void NaviWrap_userLanguage(Local name, const PropertyCallbackInfo& info){} 67 | 68 | /*************************************************************************** 69 | * functions 70 | */ 71 | 72 | void NaviWrap_javaEnabled(const v8::FunctionCallbackInfo& args){} 73 | void NaviWrap_taintEnabled(const v8::FunctionCallbackInfo& args){} 74 | 75 | } -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/NavigatorWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // NavigatorWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/20. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__NavigatorWrap__ 10 | #define __gSpiderMac__NavigatorWrap__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include "WZ_HTTPSocket.h" 21 | #include "HTMLTree.h" 22 | #include "util.h" 23 | 24 | using namespace::v8; 25 | using namespace::std; 26 | 27 | namespace gSpider { 28 | 29 | class Navigator{ 30 | public: 31 | Navigator(){}; 32 | ~Navigator(){}; 33 | }; 34 | 35 | Handle NavigatorWrap(Isolate* isolate, Navigator* navi); 36 | 37 | /*************************************************************************** 38 | * properties 39 | 40 | appCodeName 返回浏览器的代码名。 41 | appMinorVersion 返回浏览器的次级版本。 42 | appName 返回浏览器的名称。 43 | appVersion 返回浏览器的平台和版本信息。 44 | browserLanguage 返回当前浏览器的语言。 45 | cookieEnabled 返回指明浏览器中是否启用 cookie 的布尔值。 46 | cpuClass 返回浏览器系统的 CPU 等级。 47 | onLine 返回指明系统是否处于脱机模式的布尔值。 48 | platform 返回运行浏览器的操作系统平台。 49 | systemLanguage 返回 OS 使用的默认语言。 50 | userAgent 返回由客户机发送服务器的 user-agent 头部的值。 51 | userLanguage 返回 OS 的自然语言设置。 52 | 53 | */ 54 | void NaviWrap_appCodeName(Local name, const PropertyCallbackInfo& info); 55 | void NaviWrap_appMinorVersion(Local name, const PropertyCallbackInfo& info); 56 | void NaviWrap_appName(Local name, const PropertyCallbackInfo& info); 57 | void NaviWrap_appVersion(Local name, const PropertyCallbackInfo& info); 58 | void NaviWrap_browserLanguage(Local name, const PropertyCallbackInfo& info); 59 | void NaviWrap_cookieEnabled(Local name, const PropertyCallbackInfo& info); 60 | void NaviWrap_cpuClass(Local name, const PropertyCallbackInfo& info); 61 | void NaviWrap_onLine(Local name, const PropertyCallbackInfo& info); 62 | void NaviWrap_platform(Local name, const PropertyCallbackInfo& info); 63 | void NaviWrap_systemLanguage(Local name, const PropertyCallbackInfo& info); 64 | void NaviWrap_userAgent(Local name, const PropertyCallbackInfo& info); 65 | void NaviWrap_userLanguage(Local name, const PropertyCallbackInfo& info); 66 | 67 | /*************************************************************************** 68 | * functions 69 | */ 70 | 71 | void NaviWrap_javaEnabled(const v8::FunctionCallbackInfo& args); 72 | void NaviWrap_taintEnabled(const v8::FunctionCallbackInfo& args); 73 | 74 | } 75 | #endif /* defined(__gSpiderMac__NavigatorWrap__) */ 76 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/ScreenWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ScreenWrap.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/20. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #include "ScreenWrap.h" 10 | 11 | namespace gSpider { 12 | /** 13 | * 14 | * Location object wrap 15 | */ 16 | Handle ScreenWrap(Isolate* isolate, Screen* scr) { 17 | 18 | EscapableHandleScope handle_scope(isolate); 19 | 20 | Local templ = ObjectTemplate::New(); 21 | templ->SetInternalFieldCount(1); 22 | 23 | // set accessores 24 | /*************************************************************************** 25 | * properties 26 | availHeight 返回显示屏幕的高度 (除 Windows 任务栏之外)。 27 | availWidth 返回显示屏幕的宽度 (除 Windows 任务栏之外)。 28 | bufferDepth 设置或返回调色板的比特深度。 29 | colorDepth 返回目标设备或缓冲器上的调色板的比特深度。 30 | deviceXDPI 返回显示屏幕的每英寸水平点数。 31 | deviceYDPI 返回显示屏幕的每英寸垂直点数。 32 | fontSmoothingEnabled 返回用户是否在显示控制面板中启用了字体平滑。 33 | height 返回显示屏幕的高度。 34 | logicalXDPI 返回显示屏幕每英寸的水平方向的常规点数。 35 | logicalYDPI 返回显示屏幕每英寸的垂直方向的常规点数。 36 | pixelDepth 返回显示屏幕的颜色分辨率(比特每像素)。 37 | updateInterval 设置或返回屏幕的刷新率。 38 | width 39 | */ 40 | templ->SetAccessor(String::NewFromUtf8(isolate, "availHeight"), ScreenWrap_availHeight); 41 | templ->SetAccessor(String::NewFromUtf8(isolate, "availWidth"), ScreenWrap_availWidth); 42 | templ->SetAccessor(String::NewFromUtf8(isolate, "bufferDepth"), ScreenWrap_bufferDepth); 43 | templ->SetAccessor(String::NewFromUtf8(isolate, "colorDepth"), ScreenWrap_colorDepth); 44 | templ->SetAccessor(String::NewFromUtf8(isolate, "deviceXDPI"), ScreenWrap_deviceXDPI); 45 | templ->SetAccessor(String::NewFromUtf8(isolate, "deviceYDPI"), ScreenWrap_deviceYDPI); 46 | templ->SetAccessor(String::NewFromUtf8(isolate, "fontSmoothingEnabled"), ScreenWrap_fontSmoothingEnabled); 47 | templ->SetAccessor(String::NewFromUtf8(isolate, "height"), ScreenWrap_height); 48 | templ->SetAccessor(String::NewFromUtf8(isolate, "logicalXDPI"), ScreenWrap_logicalXDPI); 49 | templ->SetAccessor(String::NewFromUtf8(isolate, "logicalYDPI"), ScreenWrap_logicalYDPI); 50 | templ->SetAccessor(String::NewFromUtf8(isolate, "pixelDepth"), ScreenWrap_pixelDepth); 51 | templ->SetAccessor(String::NewFromUtf8(isolate, "updateInterval"), ScreenWrap_updateInterval); 52 | templ->SetAccessor(String::NewFromUtf8(isolate, "width"), ScreenWrap_width); 53 | 54 | // functions 55 | templ->Set(isolate, "assign", FunctionTemplate::New(isolate, LocationWrap_assign)); 56 | templ->Set(isolate, "reload", FunctionTemplate::New(isolate, LocationWrap_reload)); 57 | templ->Set(isolate, "replace", FunctionTemplate::New(isolate, LocationWrap_replace)); 58 | 59 | Local result = templ->NewInstance(); 60 | result->SetInternalField(0, External::New(isolate, scr )); 61 | 62 | return handle_scope.Escape(result); 63 | } 64 | 65 | /** 66 | * properties and functions body 67 | */ 68 | 69 | Screen* getOriScreenPtr(Local self) 70 | { 71 | Local wrap = Local::Cast(self->GetInternalField(0)); 72 | void *ptr = wrap->Value(); 73 | return static_cast(ptr); 74 | } 75 | 76 | void ScreenWrap_availHeight(Local name, const PropertyCallbackInfo& info){} 77 | void ScreenWrap_availWidth(Local name, const PropertyCallbackInfo& info){} 78 | void ScreenWrap_bufferDepth(Local name, const PropertyCallbackInfo& info){} 79 | void ScreenWrap_colorDepth(Local name, const PropertyCallbackInfo& info){} 80 | void ScreenWrap_deviceXDPI(Local name, const PropertyCallbackInfo& info){} 81 | void ScreenWrap_deviceYDPI(Local name, const PropertyCallbackInfo& info){} 82 | void ScreenWrap_fontSmoothingEnabled(Local name, const PropertyCallbackInfo& info){} 83 | void ScreenWrap_height(Local name, const PropertyCallbackInfo& info){} 84 | void ScreenWrap_logicalXDPI(Local name, const PropertyCallbackInfo& info){} 85 | void ScreenWrap_logicalYDPI(Local name, const PropertyCallbackInfo& info){} 86 | void ScreenWrap_pixelDepth(Local name, const PropertyCallbackInfo& info){} 87 | void ScreenWrap_updateInterval(Local name, const PropertyCallbackInfo& info){} 88 | void ScreenWrap_width(Local name, const PropertyCallbackInfo& info){} 89 | 90 | } -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/ScreenWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // ScreenWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/20. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__ScreenWrap__ 10 | #define __gSpiderMac__ScreenWrap__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include "WZ_HTTPSocket.h" 21 | #include "HTMLTree.h" 22 | #include "util.h" 23 | 24 | using namespace::v8; 25 | using namespace::std; 26 | 27 | namespace gSpider { 28 | class Screen{ 29 | public: 30 | Screen(){}; 31 | ~Screen(){}; 32 | 33 | public: 34 | 35 | }; 36 | 37 | Handle ScreenWrap(Isolate* isolate, Screen* scr); 38 | 39 | /*************************************************************************** 40 | * properties 41 | availHeight 返回显示屏幕的高度 (除 Windows 任务栏之外)。 42 | availWidth 返回显示屏幕的宽度 (除 Windows 任务栏之外)。 43 | bufferDepth 设置或返回调色板的比特深度。 44 | colorDepth 返回目标设备或缓冲器上的调色板的比特深度。 45 | deviceXDPI 返回显示屏幕的每英寸水平点数。 46 | deviceYDPI 返回显示屏幕的每英寸垂直点数。 47 | fontSmoothingEnabled 返回用户是否在显示控制面板中启用了字体平滑。 48 | height 返回显示屏幕的高度。 49 | logicalXDPI 返回显示屏幕每英寸的水平方向的常规点数。 50 | logicalYDPI 返回显示屏幕每英寸的垂直方向的常规点数。 51 | pixelDepth 返回显示屏幕的颜色分辨率(比特每像素)。 52 | updateInterval 设置或返回屏幕的刷新率。 53 | width 54 | */ 55 | void ScreenWrap_availHeight(Local name, const PropertyCallbackInfo& info); 56 | void ScreenWrap_availWidth(Local name, const PropertyCallbackInfo& info); 57 | void ScreenWrap_bufferDepth(Local name, const PropertyCallbackInfo& info); 58 | void ScreenWrap_colorDepth(Local name, const PropertyCallbackInfo& info); 59 | void ScreenWrap_deviceXDPI(Local name, const PropertyCallbackInfo& info); 60 | void ScreenWrap_deviceYDPI(Local name, const PropertyCallbackInfo& info); 61 | void ScreenWrap_fontSmoothingEnabled(Local name, const PropertyCallbackInfo& info); 62 | void ScreenWrap_height(Local name, const PropertyCallbackInfo& info); 63 | void ScreenWrap_logicalXDPI(Local name, const PropertyCallbackInfo& info); 64 | void ScreenWrap_logicalYDPI(Local name, const PropertyCallbackInfo& info); 65 | void ScreenWrap_pixelDepth(Local name, const PropertyCallbackInfo& info); 66 | void ScreenWrap_updateInterval(Local name, const PropertyCallbackInfo& info); 67 | void ScreenWrap_width(Local name, const PropertyCallbackInfo& info); 68 | 69 | /*************************************************************************** 70 | * functions 71 | */ 72 | 73 | void LocationWrap_assign(const v8::FunctionCallbackInfo& args); 74 | void LocationWrap_reload(const v8::FunctionCallbackInfo& args); 75 | void LocationWrap_replace(const v8::FunctionCallbackInfo& args); 76 | 77 | } 78 | #endif /* defined(__gSpiderMac__ScreenWrap__) */ 79 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/WZ_HTTPSocket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reichtiger/grampusSpider/d8ba6b96a7af085c7c2420a5bcb1fa35ee8b03b7/gSpiderMac/gSpiderMac/WZ_HTTPSocket.cpp -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/WZ_HTTPSocket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reichtiger/grampusSpider/d8ba6b96a7af085c7c2420a5bcb1fa35ee8b03b7/gSpiderMac/gSpiderMac/WZ_HTTPSocket.h -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/cssstyleWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // cssstyleWrap.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/12/19. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #include "cssstyleWrap.h" 10 | 11 | namespace gSpider { 12 | 13 | Handle cssstyle_Wrap(Isolate* isolate, cssstyle* pStyle) 14 | { 15 | EscapableHandleScope handle_scope(isolate); 16 | 17 | Local templ = ObjectTemplate::New(); 18 | templ->SetInternalFieldCount(1); 19 | // set accessores 20 | templ->SetAccessor(String::NewFromUtf8(isolate, "color"), cssstyle_color, cssstyle_color_setter); 21 | 22 | Local result = templ->NewInstance(); 23 | result->SetInternalField(0, External::New(isolate, pStyle)); 24 | 25 | return handle_scope.Escape(result); 26 | 27 | } 28 | 29 | void cssstyle_color(Local name, const PropertyCallbackInfo& info) 30 | { 31 | 32 | } 33 | void cssstyle_color_setter(Local name, Local value_obj, const PropertyCallbackInfo& info) 34 | { 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/cssstyleWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // cssstyleWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/12/19. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__cssstyleWrap__ 10 | #define __gSpiderMac__cssstyleWrap__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include "WZ_HTTPSocket.h" 22 | #include "HTMLTree.h" 23 | #include "util.h" 24 | 25 | using namespace::v8; 26 | using namespace::std; 27 | 28 | namespace gSpider { 29 | class cssstyle{ 30 | 31 | }; 32 | 33 | void cssstyle_color(Local name, const PropertyCallbackInfo& info); 34 | void cssstyle_color_setter(Local name, Local value_obj, const PropertyCallbackInfo& info); 35 | 36 | Handle cssstyle_Wrap(Isolate* isolate, cssstyle* pStyle); 37 | 38 | } 39 | 40 | #endif /* defined(__gSpiderMac__cssstyleWrap__) */ 41 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/minicfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | NOTE!! 3 | 4 | 2014-12-3 by reichtiger 5 | 6 | Add save new values on it ! 7 | and devide different init functions for different use. 8 | ex : init_cfg, init_ip_cache, init_js_cache 9 | 10 | the minicfg class does not make ANY changes to the config files. 11 | It just read all data of the file and parse into list for later use. 12 | So there are no save function in it. 13 | 14 | */ 15 | #ifndef MINICFG_H 16 | #define MINICFG_H 17 | 18 | #include 19 | #include "util.h" 20 | 21 | 22 | #define CONTENT_BUF_SIZE 81920 23 | #define LINE_BUF_SIZE 1024 24 | #define LINE_BREAK_CHAR "\n" 25 | #define NEXT_LINE_END "\r\n" 26 | 27 | 28 | enum PARSE_RESULT { 29 | READ_ERROR = -1, 30 | FILE_TOO_LONG = 1, 31 | LINE_TOO_LONG = 2, 32 | INVALID_FORMAT = 3 33 | }; 34 | 35 | enum LINE_TYPE { 36 | UNKNOWN = -1, 37 | COMMENT = 0, 38 | VALID_STR = 1 39 | }; 40 | 41 | // lines node list 42 | struct LinesList{ 43 | LINE_TYPE type; 44 | char lineBuf[LINE_BUF_SIZE]; 45 | int len; 46 | char* key; 47 | char* value; 48 | 49 | struct LinesList* next; 50 | 51 | LinesList():type(UNKNOWN), next(NULL), len(0), key(NULL), value(NULL) 52 | { 53 | memset(lineBuf, 0, LINE_BUF_SIZE); 54 | } 55 | }; 56 | 57 | /* 58 | 59 | Class minicfg declaration 60 | 61 | */ 62 | class minicfg 63 | { 64 | private: 65 | char* filefullname; // including path and name 66 | FILE* f; 67 | char contentBuf[CONTENT_BUF_SIZE+1]; 68 | LinesList* lines_list; 69 | LinesList* lines_head; 70 | public: 71 | minicfg(const char* filepath); 72 | ~minicfg(); 73 | 74 | void init_cfg(); 75 | void init_dns_cache(); 76 | 77 | void start_parse(); 78 | 79 | int parseFile(); 80 | int parseLine(LinesList* line); 81 | char* getValue(const char* key); 82 | bool saveValue(const char* key, const char* value); 83 | 84 | void saveFile(); 85 | char* trim(char* inStr); 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/spiderActions.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // spiderActions.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/9. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | //#include "Stdafx.h" 10 | #include "spiderActions.h" 11 | 12 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/spiderActions.h: -------------------------------------------------------------------------------- 1 | // 2 | // spiderActions.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/11/9. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__spiderActions__ 10 | #define __gSpiderMac__spiderActions__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include "WZ_HTTPSocket.h" 20 | #include "util.h" 21 | 22 | using namespace v8; 23 | 24 | extern int gClick_pages; 25 | extern int gCurPage; 26 | 27 | namespace gSpider { 28 | 29 | static void add_link_Callback(const v8::FunctionCallbackInfo& args) 30 | { 31 | 32 | 33 | } 34 | 35 | static void save_Callback(const v8::FunctionCallbackInfo& args) 36 | { 37 | for (int i = 0; i < args.Length(); i++) { 38 | 39 | String::Utf8Value str(args[i]); 40 | if (args[i]->IsString()) { 41 | printf("SAVING STRING=====>%s\n", *str); 42 | }else{ 43 | printf("PRINT (OBJECT) --->%s\n", *str); 44 | } 45 | 46 | } 47 | printf("\n"); 48 | fflush(stdout); 49 | 50 | } 51 | 52 | static void log_Callback(const v8::FunctionCallbackInfo& args) 53 | { 54 | 55 | bool first = true; 56 | for (int i = 0; i < args.Length(); i++) { 57 | if (first) { 58 | first = false; 59 | } else { 60 | printf(" "); 61 | } 62 | String::Utf8Value str(args[i]); 63 | if (args[i]->IsString()) { 64 | printf("LOG (string) --->%s\n", *str); 65 | } 66 | else if (args[i]->IsInt32()){ 67 | int x = args[i]->Int32Value(); 68 | printf("LOG (int) --> %d\n", x); 69 | } 70 | else if (args[i]->IsObject()){ 71 | printf("LOG (Object) --> %s\n", *str); 72 | } 73 | 74 | 75 | } 76 | printf("\n"); 77 | fflush(stdout); 78 | } 79 | 80 | static void startLinkPage_call(const v8::FunctionCallbackInfo& args) 81 | { 82 | if (args[0]->IsInt32()) { 83 | gClick_pages = args[0]->Int32Value(); 84 | gCurPage += 1; 85 | } 86 | } 87 | 88 | static void endLinkPage_call(const v8::FunctionCallbackInfo& args) 89 | { 90 | if (gCurPage == gClick_pages) { 91 | printf("pages end.\n"); 92 | } 93 | } 94 | 95 | // do the click on element 96 | // two args need : gs_CLick(item, deepIndex); 97 | // item : document.getElementById('xxx'), the element got 98 | // deepIndex : the level of URL, default=0 99 | 100 | static void click_call(const v8::FunctionCallbackInfo& args) 101 | { 102 | // first do the click 103 | } 104 | 105 | } 106 | #endif /* defined(__gSpiderMac__spiderActions__) */ 107 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/testWrap.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // testWrap.cpp 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/10/21. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | //#include "Stdafx.h" 10 | 11 | #include "testWrap.h" 12 | 13 | namespace gSpider { 14 | void MyWindow_initialize(Isolate* isolate, Handle global) 15 | { 16 | // XMLHttpRequest wrap 17 | Handle dom_t = FunctionTemplate::New(isolate, MyWindow_Constructor); 18 | dom_t->SetClassName(String::NewFromUtf8(isolate, "MyWindow")); 19 | global->Set(String::NewFromUtf8(isolate, "MyWindow"), dom_t); 20 | 21 | Handle dom_proto = dom_t->PrototypeTemplate(); 22 | 23 | 24 | Handle inst = dom_t->InstanceTemplate(); 25 | inst->SetInternalFieldCount(1); 26 | 27 | } 28 | 29 | /** 30 | * wrap document constructor 31 | * this function will return wrapped object to JS 32 | */ 33 | void MyWindow_Constructor(const FunctionCallbackInfo& args) 34 | { 35 | Handle object = args.This(); 36 | HandleScope handle_scope(Isolate::GetCurrent()); 37 | 38 | // cause in JS no host and port to init socket. so use global to here. 39 | MyWindow *mywin = new MyWindow(); 40 | 41 | object->SetInternalField(0, External::New(Isolate::GetCurrent(), mywin)); 42 | 43 | args.GetReturnValue().Set(object); 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/testWrap.h: -------------------------------------------------------------------------------- 1 | // 2 | // testWrap.h 3 | // gSpiderMac 4 | // 5 | // Created by reich on 14/10/21. 6 | // Copyright (c) 2014年 zhaohu. All rights reserved. 7 | // 8 | 9 | #ifndef __gSpiderMac__testWrap__ 10 | #define __gSpiderMac__testWrap__ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include "HTMLTree.h" 20 | #include "util.h" 21 | #include "DomWrap.h" 22 | 23 | using namespace v8; 24 | 25 | namespace gSpider { 26 | class MyWindow{ 27 | 28 | }; 29 | void MyWindow_initialize(Isolate* isolate, Handle global); 30 | void MyWindow_Constructor(const FunctionCallbackInfo& args); 31 | } 32 | #endif /* defined(__gSpiderMac__testWrap__) */ 33 | -------------------------------------------------------------------------------- /gSpiderMac/gSpiderMac/util.cpp: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | #include "StdAfx.h" 3 | #endif 4 | 5 | #include "util.h" 6 | #include 7 | 8 | #ifdef WIN32 9 | void ConvertGBKToUtf8(std::string& amp, std::string strGBK) 10 | { 11 | int len=MultiByteToWideChar(CP_ACP, 0, (LPCSTR)strGBK.c_str(), -1, NULL,0); 12 | unsigned short * wszUtf8 = new unsigned short[len+1]; 13 | memset(wszUtf8, 0, len * 2 + 2); 14 | MultiByteToWideChar(CP_ACP, 0, (LPCSTR)strGBK.c_str(), -1, (LPWSTR)wszUtf8, len); 15 | len = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)wszUtf8, -1, NULL, 0, NULL, NULL); 16 | char *szUtf8=new char[len + 1]; 17 | memset(szUtf8, 0, len + 1); 18 | WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR)wszUtf8, -1, szUtf8, len, NULL,NULL); 19 | //strGBK = szUtf8; 20 | amp=szUtf8; 21 | delete[] szUtf8; 22 | delete[] wszUtf8; 23 | } 24 | 25 | void ConvertUtf8ToGBK(std::string&, std::string strUtf8) 26 | { 27 | int len=MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)strUtf8.c_str(), -1, NULL,0); 28 | unsigned short * wszGBK = new unsigned short[len+1]; 29 | memset(wszGBK, 0, len * 2 + 2); 30 | MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)strUtf8.c_str(), -1, (LPWSTR)wszGBK, len); 31 | len = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wszGBK, -1, NULL, 0, NULL, NULL); 32 | char *szGBK=new char[len + 1]; 33 | memset(szGBK, 0, len + 1); 34 | WideCharToMultiByte (CP_ACP, 0, (LPCWSTR)wszGBK, -1, szGBK, len, NULL,NULL); 35 | //strUtf8 = szGBK; 36 | amp=szGBK; 37 | delete[] szGBK; 38 | delete[] wszGBK; 39 | } 40 | 41 | wchar_t * UTF8ToUnicode(const char* str) 42 | { 43 | int textlen; 44 | wchar_t * result; 45 | textlen = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0); 46 | result = (wchar_t *)malloc((textlen + 1)*sizeof(wchar_t)); 47 | memset(result, 0, (textlen + 1)*sizeof(wchar_t)); 48 | MultiByteToWideChar(CP_UTF8, 0, str, -1, (LPWSTR)result, textlen); 49 | return result; 50 | } 51 | 52 | char * UnicodeToANSI(const wchar_t* str) 53 | { 54 | char* result; 55 | int textlen; 56 | textlen = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); 57 | result = (char *)malloc((textlen + 1)*sizeof(char)); 58 | memset(result, 0, sizeof(char)* (textlen + 1)); 59 | WideCharToMultiByte(CP_ACP, 0, str, -1, result, textlen, NULL, NULL); 60 | return result; 61 | } 62 | 63 | char * UTF8ToANSI(const char* str) 64 | { 65 | wchar_t* tmp = UTF8ToUnicode(str); 66 | char* result = UnicodeToANSI(tmp); 67 | free(tmp); 68 | return result; 69 | } 70 | 71 | wchar_t * ANSIToUnicode(const char* str) 72 | { 73 | int textlen; 74 | wchar_t * result; 75 | textlen = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); 76 | result = (wchar_t *)malloc((textlen + 1)*sizeof(wchar_t)); 77 | memset(result, 0, (textlen + 1)*sizeof(wchar_t)); 78 | MultiByteToWideChar(CP_ACP, 0, str, -1, (LPWSTR)result, textlen); 79 | return result; 80 | } 81 | 82 | #else 83 | 84 | // ------------- on Mac OS or Linux platform -------------------- 85 | char* convert_gbk2utf8(char* in) 86 | { 87 | if (in == NULL) { 88 | return NULL; 89 | } 90 | 91 | iconv_t converter = iconv_open("UTF-8", "GBK"); 92 | if(converter == (iconv_t)(-1)) 93 | { 94 | printf("Doesn't support convert GBK -> UTF-8! \n"); 95 | return NULL; 96 | } 97 | else 98 | { 99 | printf("Support GBK -> UTF8 !\n"); 100 | } 101 | 102 | size_t insize; 103 | const char *input = in;//汉字随便加//应是const char *而不是char * 104 | 105 | insize = strlen(input); 106 | 107 | //存储转换结果的字符串 108 | size_t outsize = insize * 3+1; 109 | char *output = new char[outsize]; 110 | char *output_old = output;//记录转换后的字符串的地址 111 | memset(output,0,outsize); 112 | 113 | //转换 114 | //size_t rc = iconv(conveter,(const char **)&input,&insize,&output_old,&outsize); 115 | size_t ret = iconv(converter, (char**)&input, &insize, &output_old, &outsize); 116 | if(ret==(size_t)-1){ 117 | std::cout<<"-------------------converting failed"< 4 | 5 | #ifdef WIN32 6 | void ConvertGBKToUtf8(std::string& amp, std::string strGBK); 7 | void ConvertUtf8ToGBK(std::string&, std::string strUtf8); 8 | wchar_t * UTF8ToUnicode(const char* str); 9 | char * UnicodeToANSI(const wchar_t* str); 10 | char * UTF8ToANSI(const char* str); 11 | char * UnicodeToANSI(const wchar_t* str); 12 | wchar_t * ANSIToUnicode(const char* str); 13 | #else 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | // ---- from GBK to UTF8 20 | char* convert_gbk2utf8(char* in); 21 | #endif 22 | 23 | #define DEBUG 1 24 | #define DEBUG_MSG_BUF_SIZE 1024 25 | 26 | void sp_debug(const char* fmt,...); 27 | 28 | char* MD5String(char* inStr); 29 | char* sha1String(char* inStr); -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // nodejs 4 | // 5 | // Created by reichtiger on 10/6/14. 6 | // Copyright (c) 2014 reichtiger. All rights reserved. 7 | // 8 | 9 | #include 10 | 11 | int main(int argc, const char * argv[]) { 12 | // insert code here... 13 | std::cout << "Hello, nodejs!\n"; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/async-wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_ASYNC_WRAP_H_ 23 | #define SRC_ASYNC_WRAP_H_ 24 | 25 | #include "base-object.h" 26 | #include "env.h" 27 | #include "v8.h" 28 | 29 | namespace node { 30 | 31 | class AsyncWrap : public BaseObject { 32 | public: 33 | enum AsyncFlags { 34 | NO_OPTIONS = 0, 35 | HAS_ASYNC_LISTENER = 1 36 | }; 37 | 38 | enum ProviderType { 39 | PROVIDER_NONE = 1 << 0, 40 | PROVIDER_CARES = 1 << 1, 41 | PROVIDER_CONNECTWRAP = 1 << 2, 42 | PROVIDER_CRYPTO = 1 << 3, 43 | PROVIDER_FSEVENTWRAP = 1 << 4, 44 | PROVIDER_GETADDRINFOREQWRAP = 1 << 5, 45 | PROVIDER_PIPEWRAP = 1 << 6, 46 | PROVIDER_PROCESSWRAP = 1 << 7, 47 | PROVIDER_REQWRAP = 1 << 8, 48 | PROVIDER_SHUTDOWNWRAP = 1 << 9, 49 | PROVIDER_SIGNALWRAP = 1 << 10, 50 | PROVIDER_STATWATCHER = 1 << 11, 51 | PROVIDER_TCPWRAP = 1 << 12, 52 | PROVIDER_TIMERWRAP = 1 << 13, 53 | PROVIDER_TLSWRAP = 1 << 14, 54 | PROVIDER_TTYWRAP = 1 << 15, 55 | PROVIDER_UDPWRAP = 1 << 16, 56 | PROVIDER_ZLIB = 1 << 17, 57 | PROVIDER_GETNAMEINFOREQWRAP = 1 << 18 58 | }; 59 | 60 | inline AsyncWrap(Environment* env, 61 | v8::Handle object, 62 | ProviderType provider); 63 | 64 | inline ~AsyncWrap(); 65 | 66 | inline bool has_async_listener(); 67 | 68 | inline uint32_t provider_type() const; 69 | 70 | // Only call these within a valid HandleScope. 71 | inline v8::Handle MakeCallback(const v8::Handle cb, 72 | int argc, 73 | v8::Handle* argv); 74 | inline v8::Handle MakeCallback(const v8::Handle symbol, 75 | int argc, 76 | v8::Handle* argv); 77 | inline v8::Handle MakeCallback(uint32_t index, 78 | int argc, 79 | v8::Handle* argv); 80 | 81 | private: 82 | inline AsyncWrap(); 83 | 84 | // TODO(trevnorris): BURN IN FIRE! Remove this as soon as a suitable 85 | // replacement is committed. 86 | inline v8::Handle MakeDomainCallback( 87 | const v8::Handle cb, 88 | int argc, 89 | v8::Handle* argv); 90 | 91 | uint32_t async_flags_; 92 | uint32_t provider_type_; 93 | }; 94 | 95 | } // namespace node 96 | 97 | 98 | #endif // SRC_ASYNC_WRAP_H_ 99 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/base-object-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_BASE_OBJECT_INL_H_ 23 | #define SRC_BASE_OBJECT_INL_H_ 24 | 25 | #include "base-object.h" 26 | #include "util.h" 27 | #include "util-inl.h" 28 | #include "v8.h" 29 | 30 | #include 31 | 32 | namespace node { 33 | 34 | inline BaseObject::BaseObject(Environment* env, v8::Local handle) 35 | : handle_(env->isolate(), handle), 36 | env_(env) { 37 | assert(!handle.IsEmpty()); 38 | } 39 | 40 | 41 | inline BaseObject::~BaseObject() { 42 | assert(handle_.IsEmpty()); 43 | } 44 | 45 | 46 | inline v8::Persistent& BaseObject::persistent() { 47 | return handle_; 48 | } 49 | 50 | 51 | inline v8::Local BaseObject::object() { 52 | return PersistentToLocal(env_->isolate(), handle_); 53 | } 54 | 55 | 56 | inline Environment* BaseObject::env() const { 57 | return env_; 58 | } 59 | 60 | 61 | template 62 | inline void BaseObject::WeakCallback( 63 | const v8::WeakCallbackData& data) { 64 | Type* self = data.GetParameter(); 65 | self->persistent().Reset(); 66 | delete self; 67 | } 68 | 69 | 70 | template 71 | inline void BaseObject::MakeWeak(Type* ptr) { 72 | v8::HandleScope scope(env_->isolate()); 73 | v8::Local handle = object(); 74 | assert(handle->InternalFieldCount() > 0); 75 | Wrap(handle, ptr); 76 | handle_.MarkIndependent(); 77 | handle_.SetWeak(ptr, WeakCallback); 78 | } 79 | 80 | 81 | inline void BaseObject::ClearWeak() { 82 | handle_.ClearWeak(); 83 | } 84 | 85 | } // namespace node 86 | 87 | #endif // SRC_BASE_OBJECT_INL_H_ 88 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/base-object.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_BASE_OBJECT_H_ 23 | #define SRC_BASE_OBJECT_H_ 24 | 25 | #include "env.h" 26 | #include "v8.h" 27 | 28 | namespace node { 29 | 30 | class BaseObject { 31 | public: 32 | BaseObject(Environment* env, v8::Local handle); 33 | ~BaseObject(); 34 | 35 | // Returns the wrapped object. Returns an empty handle when 36 | // persistent.IsEmpty() is true. 37 | inline v8::Local object(); 38 | 39 | // The parent class is responsible for calling .Reset() on destruction 40 | // when the persistent handle is strong because there is no way for 41 | // BaseObject to know when the handle goes out of scope. 42 | // Weak handles have been reset by the time the destructor runs but 43 | // calling .Reset() again is harmless. 44 | inline v8::Persistent& persistent(); 45 | 46 | inline Environment* env() const; 47 | 48 | // The handle_ must have an internal field count > 0, and the first 49 | // index is reserved for a pointer to this class. This is an 50 | // implicit requirement, but Node does not have a case where it's 51 | // required that MakeWeak() be called and the internal field not 52 | // be set. 53 | template 54 | inline void MakeWeak(Type* ptr); 55 | 56 | inline void ClearWeak(); 57 | 58 | private: 59 | BaseObject(); 60 | 61 | template 62 | static inline void WeakCallback( 63 | const v8::WeakCallbackData& data); 64 | 65 | v8::Persistent handle_; 66 | Environment* env_; 67 | }; 68 | 69 | } // namespace node 70 | 71 | #endif // SRC_BASE_OBJECT_H_ 72 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/handle_wrap.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "handle_wrap.h" 23 | #include "async-wrap.h" 24 | #include "async-wrap-inl.h" 25 | #include "env.h" 26 | #include "env-inl.h" 27 | #include "util.h" 28 | #include "util-inl.h" 29 | #include "node.h" 30 | #include "queue.h" 31 | 32 | namespace node { 33 | 34 | using v8::Context; 35 | using v8::FunctionCallbackInfo; 36 | using v8::Handle; 37 | using v8::HandleScope; 38 | using v8::Local; 39 | using v8::Object; 40 | using v8::Value; 41 | 42 | // defined in node.cc 43 | extern QUEUE handle_wrap_queue; 44 | 45 | 46 | void HandleWrap::Ref(const FunctionCallbackInfo& args) { 47 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 48 | HandleScope scope(env->isolate()); 49 | 50 | HandleWrap* wrap = Unwrap(args.Holder()); 51 | 52 | if (wrap != NULL && wrap->handle__ != NULL) { 53 | uv_ref(wrap->handle__); 54 | wrap->flags_ &= ~kUnref; 55 | } 56 | } 57 | 58 | 59 | void HandleWrap::Unref(const FunctionCallbackInfo& args) { 60 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 61 | HandleScope scope(env->isolate()); 62 | 63 | HandleWrap* wrap = Unwrap(args.Holder()); 64 | 65 | if (wrap != NULL && wrap->handle__ != NULL) { 66 | uv_unref(wrap->handle__); 67 | wrap->flags_ |= kUnref; 68 | } 69 | } 70 | 71 | 72 | void HandleWrap::Close(const FunctionCallbackInfo& args) { 73 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 74 | HandleScope scope(env->isolate()); 75 | 76 | HandleWrap* wrap = Unwrap(args.Holder()); 77 | 78 | // guard against uninitialized handle or double close 79 | if (wrap == NULL || wrap->handle__ == NULL) 80 | return; 81 | 82 | assert(!wrap->persistent().IsEmpty()); 83 | uv_close(wrap->handle__, OnClose); 84 | wrap->handle__ = NULL; 85 | 86 | if (args[0]->IsFunction()) { 87 | wrap->object()->Set(env->close_string(), args[0]); 88 | wrap->flags_ |= kCloseCallback; 89 | } 90 | } 91 | 92 | 93 | HandleWrap::HandleWrap(Environment* env, 94 | Handle object, 95 | uv_handle_t* handle, 96 | AsyncWrap::ProviderType provider) 97 | : AsyncWrap(env, object, provider), 98 | flags_(0), 99 | handle__(handle) { 100 | handle__->data = this; 101 | HandleScope scope(env->isolate()); 102 | Wrap(object, this); 103 | QUEUE_INSERT_TAIL(&handle_wrap_queue, &handle_wrap_queue_); 104 | } 105 | 106 | 107 | HandleWrap::~HandleWrap() { 108 | assert(persistent().IsEmpty()); 109 | QUEUE_REMOVE(&handle_wrap_queue_); 110 | } 111 | 112 | 113 | void HandleWrap::OnClose(uv_handle_t* handle) { 114 | HandleWrap* wrap = static_cast(handle->data); 115 | Environment* env = wrap->env(); 116 | HandleScope scope(env->isolate()); 117 | 118 | // The wrap object should still be there. 119 | assert(wrap->persistent().IsEmpty() == false); 120 | 121 | // But the handle pointer should be gone. 122 | assert(wrap->handle__ == NULL); 123 | 124 | HandleScope handle_scope(env->isolate()); 125 | Context::Scope context_scope(env->context()); 126 | Local object = wrap->object(); 127 | 128 | if (wrap->flags_ & kCloseCallback) { 129 | wrap->MakeCallback(env->close_string(), 0, NULL); 130 | } 131 | 132 | object->SetAlignedPointerInInternalField(0, NULL); 133 | wrap->persistent().Reset(); 134 | delete wrap; 135 | } 136 | 137 | 138 | } // namespace node 139 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/handle_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_HANDLE_WRAP_H_ 23 | #define SRC_HANDLE_WRAP_H_ 24 | 25 | #include "async-wrap.h" 26 | #include "env.h" 27 | #include "node.h" 28 | #include "queue.h" 29 | #include "uv.h" 30 | #include "v8.h" 31 | 32 | namespace node { 33 | 34 | // Rules: 35 | // 36 | // - Do not throw from handle methods. Set errno. 37 | // 38 | // - MakeCallback may only be made directly off the event loop. 39 | // That is there can be no JavaScript stack frames underneath it. 40 | // (Is there any way to assert that?) 41 | // 42 | // - No use of v8::WeakReferenceCallback. The close callback signifies that 43 | // we're done with a handle - external resources can be freed. 44 | // 45 | // - Reusable? 46 | // 47 | // - The uv_close_cb is used to free the c++ object. The close callback 48 | // is not made into javascript land. 49 | // 50 | // - uv_ref, uv_unref counts are managed at this layer to avoid needless 51 | // js/c++ boundary crossing. At the javascript layer that should all be 52 | // taken care of. 53 | 54 | class HandleWrap : public AsyncWrap { 55 | public: 56 | static void Close(const v8::FunctionCallbackInfo& args); 57 | static void Ref(const v8::FunctionCallbackInfo& args); 58 | static void Unref(const v8::FunctionCallbackInfo& args); 59 | 60 | inline uv_handle_t* GetHandle() { return handle__; } 61 | 62 | protected: 63 | HandleWrap(Environment* env, 64 | v8::Handle object, 65 | uv_handle_t* handle, 66 | AsyncWrap::ProviderType provider); 67 | virtual ~HandleWrap(); 68 | 69 | private: 70 | friend void GetActiveHandles(const v8::FunctionCallbackInfo&); 71 | static void OnClose(uv_handle_t* handle); 72 | QUEUE handle_wrap_queue_; 73 | unsigned int flags_; 74 | // Using double underscore due to handle_ member in tcp_wrap. Probably 75 | // tcp_wrap should rename it's member to 'handle'. 76 | uv_handle_t* handle__; 77 | 78 | static const unsigned int kUnref = 1; 79 | static const unsigned int kCloseCallback = 2; 80 | }; 81 | 82 | 83 | } // namespace node 84 | 85 | 86 | #endif // SRC_HANDLE_WRAP_H_ 87 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node.stp: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | 23 | probe node_net_server_connection = process("node").mark("net__server__connection") 24 | { 25 | remote = user_string($arg2); 26 | port = $arg3; 27 | fd = $arg4; 28 | 29 | probestr = sprintf("%s(remote=%s, port=%d, fd=%d)", 30 | $$name, 31 | remote, 32 | port, 33 | fd); 34 | } 35 | 36 | probe node_net_stream_end = process("node").mark("net__stream__end") 37 | { 38 | remote = user_string($arg2); 39 | port = $arg3; 40 | fd = $arg4; 41 | 42 | probestr = sprintf("%s(remote=%s, port=%d, fd=%d)", 43 | $$name, 44 | remote, 45 | port, 46 | fd); 47 | } 48 | 49 | probe node_net_socket_write = process("node").mark("net__socket__write") 50 | { 51 | bytes = $arg2; 52 | remote = user_string($arg3); 53 | port = $arg4; 54 | fd = $arg5; 55 | 56 | probestr = sprintf("%s(bytes=%d, remote=%s, port=%d, fd=%d)", 57 | $$name, 58 | bytes, 59 | remote, 60 | port, 61 | fd); 62 | } 63 | 64 | probe node_net_socket_read = process("node").mark("net__socket__read") 65 | { 66 | bytes = $arg2; 67 | remote = user_string($arg3); 68 | port = $arg4; 69 | fd = $arg5; 70 | 71 | probestr = sprintf("%s(bytes=%d, remote=%s, port=%d, fd=%d)", 72 | $$name, 73 | bytes, 74 | remote, 75 | port, 76 | fd); 77 | } 78 | 79 | probe node_http_server_request = process("node").mark("http__server__request") 80 | { 81 | remote = user_string($arg3); 82 | port = $arg4; 83 | method = user_string($arg5); 84 | url = user_string($arg6); 85 | fd = $arg7; 86 | 87 | probestr = sprintf("%s(remote=%s, port=%d, method=%s, url=%s, fd=%d)", 88 | $$name, 89 | remote, 90 | port, 91 | method, 92 | url, 93 | fd); 94 | } 95 | 96 | probe node_http_server_response = process("node").mark("http__server__response") 97 | { 98 | remote = user_string($arg2); 99 | port = $arg3; 100 | fd = $arg4; 101 | 102 | probestr = sprintf("%s(remote=%s, port=%d, fd=%d)", 103 | $$name, 104 | remote, 105 | port, 106 | fd); 107 | } 108 | 109 | probe node_http_client_request = process("node").mark("http__client__request") 110 | { 111 | remote = user_string($arg3); 112 | port = $arg4; 113 | method = user_string($arg5); 114 | url = user_string($arg6); 115 | fd = $arg7; 116 | 117 | probestr = sprintf("%s(remote=%s, port=%d, method=%s, url=%s, fd=%d)", 118 | $$name, 119 | remote, 120 | port, 121 | method, 122 | url, 123 | fd); 124 | } 125 | 126 | probe node_http_client_response = process("node").mark("http__client__response") 127 | { 128 | remote = user_string($arg2); 129 | port = $arg3; 130 | fd = $arg4; 131 | 132 | probestr = sprintf("%s(remote=%s, port=%d, fd=%d)", 133 | $$name, 134 | remote, 135 | port, 136 | fd); 137 | } 138 | 139 | probe node_gc_start = process("node").mark("gc__start") 140 | { 141 | scavenge = 1 << 0; 142 | compact = 1 << 1; 143 | 144 | if ($arg1 == scavenge) 145 | type = "kGCTypeScavenge"; 146 | else if ($arg1 == compact) 147 | type = "kGCTypeMarkSweepCompact"; 148 | else 149 | type = "kGCTypeAll"; 150 | 151 | flags = $arg2; 152 | 153 | probestr = sprintf("%s(type=%s,flags=%d)", 154 | $$name, 155 | type, 156 | flags); 157 | } 158 | 159 | probe node_gc_stop = process("node").mark("gc__stop") 160 | { 161 | scavenge = 1 << 0; 162 | compact = 1 << 1; 163 | 164 | if ($arg1 == scavenge) 165 | type = "kGCTypeScavenge"; 166 | else if ($arg1 == compact) 167 | type = "kGCTypeMarkSweepCompact"; 168 | else 169 | type = "kGCTypeAll"; 170 | 171 | flags = $arg2; 172 | 173 | probestr = sprintf("%s(type=%s,flags=%d)", 174 | $$name, 175 | type, 176 | flags); 177 | } 178 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_constants.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_CONSTANTS_H_ 23 | #define SRC_NODE_CONSTANTS_H_ 24 | 25 | #include "node.h" 26 | #include "v8.h" 27 | 28 | namespace node { 29 | void DefineConstants(v8::Handle target); 30 | } // namespace node 31 | 32 | #endif // SRC_NODE_CONSTANTS_H_ 33 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_counters.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "node_counters.h" 23 | #include "uv.h" 24 | #include "env.h" 25 | #include "env-inl.h" 26 | 27 | #include 28 | 29 | 30 | namespace node { 31 | 32 | using v8::FunctionCallbackInfo; 33 | using v8::FunctionTemplate; 34 | using v8::GCCallbackFlags; 35 | using v8::GCEpilogueCallback; 36 | using v8::GCPrologueCallback; 37 | using v8::GCType; 38 | using v8::Handle; 39 | using v8::HandleScope; 40 | using v8::Isolate; 41 | using v8::Local; 42 | using v8::Object; 43 | using v8::String; 44 | using v8::Value; 45 | 46 | static uint64_t counter_gc_start_time; 47 | static uint64_t counter_gc_end_time; 48 | 49 | 50 | void COUNTER_NET_SERVER_CONNECTION(const FunctionCallbackInfo&) { 51 | NODE_COUNT_SERVER_CONN_OPEN(); 52 | } 53 | 54 | 55 | void COUNTER_NET_SERVER_CONNECTION_CLOSE(const FunctionCallbackInfo&) { 56 | NODE_COUNT_SERVER_CONN_CLOSE(); 57 | } 58 | 59 | 60 | void COUNTER_HTTP_SERVER_REQUEST(const FunctionCallbackInfo&) { 61 | NODE_COUNT_HTTP_SERVER_REQUEST(); 62 | } 63 | 64 | 65 | void COUNTER_HTTP_SERVER_RESPONSE(const FunctionCallbackInfo&) { 66 | NODE_COUNT_HTTP_SERVER_RESPONSE(); 67 | } 68 | 69 | 70 | void COUNTER_HTTP_CLIENT_REQUEST(const FunctionCallbackInfo&) { 71 | NODE_COUNT_HTTP_CLIENT_REQUEST(); 72 | } 73 | 74 | 75 | void COUNTER_HTTP_CLIENT_RESPONSE(const FunctionCallbackInfo&) { 76 | NODE_COUNT_HTTP_CLIENT_RESPONSE(); 77 | } 78 | 79 | 80 | static void counter_gc_start(Isolate* isolate, 81 | GCType type, 82 | GCCallbackFlags flags) { 83 | counter_gc_start_time = NODE_COUNT_GET_GC_RAWTIME(); 84 | } 85 | 86 | 87 | static void counter_gc_done(Isolate* isolate, 88 | GCType type, 89 | GCCallbackFlags flags) { 90 | uint64_t endgc = NODE_COUNT_GET_GC_RAWTIME(); 91 | if (endgc != 0) { 92 | uint64_t totalperiod = endgc - counter_gc_end_time; 93 | uint64_t gcperiod = endgc - counter_gc_start_time; 94 | 95 | if (totalperiod > 0) { 96 | unsigned int percent = static_cast( 97 | (gcperiod * 100) / totalperiod); 98 | 99 | NODE_COUNT_GC_PERCENTTIME(percent); 100 | counter_gc_end_time = endgc; 101 | } 102 | } 103 | } 104 | 105 | 106 | void InitPerfCounters(Environment* env, Handle target) { 107 | HandleScope scope(env->isolate()); 108 | 109 | static struct { 110 | const char* name; 111 | void (*func)(const FunctionCallbackInfo&); 112 | } tab[] = { 113 | #define NODE_PROBE(name) #name, name 114 | { NODE_PROBE(COUNTER_NET_SERVER_CONNECTION) }, 115 | { NODE_PROBE(COUNTER_NET_SERVER_CONNECTION_CLOSE) }, 116 | { NODE_PROBE(COUNTER_HTTP_SERVER_REQUEST) }, 117 | { NODE_PROBE(COUNTER_HTTP_SERVER_RESPONSE) }, 118 | { NODE_PROBE(COUNTER_HTTP_CLIENT_REQUEST) }, 119 | { NODE_PROBE(COUNTER_HTTP_CLIENT_RESPONSE) } 120 | #undef NODE_PROBE 121 | }; 122 | 123 | for (int i = 0; i < ARRAY_SIZE(tab); i++) { 124 | Local key = OneByteString(env->isolate(), tab[i].name); 125 | Local val = 126 | FunctionTemplate::New(env->isolate(), tab[i].func)->GetFunction(); 127 | target->Set(key, val); 128 | } 129 | 130 | // Only Windows performance counters supported 131 | // To enable other OS, use conditional compilation here 132 | InitPerfCountersWin32(); 133 | 134 | // init times for GC percent calculation and hook callbacks 135 | counter_gc_start_time = NODE_COUNT_GET_GC_RAWTIME(); 136 | counter_gc_end_time = counter_gc_start_time; 137 | 138 | env->isolate()->AddGCPrologueCallback(counter_gc_start); 139 | env->isolate()->AddGCEpilogueCallback(counter_gc_done); 140 | } 141 | 142 | 143 | void TermPerfCounters(Handle target) { 144 | // Only Windows performance counters supported 145 | // To enable other OS, use conditional compilation here 146 | TermPerfCountersWin32(); 147 | } 148 | 149 | } // namespace node 150 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_counters.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_COUNTERS_H_ 23 | #define SRC_NODE_COUNTERS_H_ 24 | 25 | #include "node.h" 26 | 27 | #ifdef HAVE_PERFCTR 28 | #include "node_win32_perfctr_provider.h" 29 | #else 30 | #define NODE_COUNTER_ENABLED() (false) 31 | #define NODE_COUNT_HTTP_SERVER_REQUEST() 32 | #define NODE_COUNT_HTTP_SERVER_RESPONSE() 33 | #define NODE_COUNT_HTTP_CLIENT_REQUEST() 34 | #define NODE_COUNT_HTTP_CLIENT_RESPONSE() 35 | #define NODE_COUNT_SERVER_CONN_OPEN() 36 | #define NODE_COUNT_SERVER_CONN_CLOSE() 37 | #define NODE_COUNT_NET_BYTES_SENT(bytes) 38 | #define NODE_COUNT_NET_BYTES_RECV(bytes) 39 | #define NODE_COUNT_GET_GC_RAWTIME() 40 | #define NODE_COUNT_GC_PERCENTTIME() 41 | #define NODE_COUNT_PIPE_BYTES_SENT(bytes) 42 | #define NODE_COUNT_PIPE_BYTES_RECV(bytes) 43 | #endif 44 | 45 | #include "v8.h" 46 | #include "env.h" 47 | 48 | namespace node { 49 | 50 | void InitPerfCounters(Environment* env, v8::Handle target); 51 | void TermPerfCounters(v8::Handle target); 52 | 53 | } // namespace node 54 | 55 | #endif // SRC_NODE_COUNTERS_H_ 56 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_crypto_bio.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_CRYPTO_BIO_H_ 23 | #define SRC_NODE_CRYPTO_BIO_H_ 24 | 25 | #include "openssl/bio.h" 26 | #include 27 | 28 | namespace node { 29 | 30 | class NodeBIO { 31 | public: 32 | NodeBIO() : length_(0), read_head_(&head_), write_head_(&head_) { 33 | // Loop head 34 | head_.next_ = &head_; 35 | } 36 | 37 | ~NodeBIO(); 38 | 39 | static BIO* New(); 40 | 41 | // Move read head to next buffer if needed 42 | void TryMoveReadHead(); 43 | 44 | // Allocate new buffer for write if needed 45 | void TryAllocateForWrite(); 46 | 47 | // Read `len` bytes maximum into `out`, return actual number of read bytes 48 | size_t Read(char* out, size_t size); 49 | 50 | // Memory optimization: 51 | // Deallocate children of write head's child if they're empty 52 | void FreeEmpty(); 53 | 54 | // Return pointer to internal data and amount of 55 | // contiguous data available to read 56 | char* Peek(size_t* size); 57 | 58 | // Return pointers and sizes of multiple internal data chunks available for 59 | // reading 60 | size_t PeekMultiple(char** out, size_t* size, size_t* count); 61 | 62 | // Find first appearance of `delim` in buffer or `limit` if `delim` 63 | // wasn't found. 64 | size_t IndexOf(char delim, size_t limit); 65 | 66 | // Discard all available data 67 | void Reset(); 68 | 69 | // Put `len` bytes from `data` into buffer 70 | void Write(const char* data, size_t size); 71 | 72 | // Return pointer to internal data and amount of 73 | // contiguous data available for future writes 74 | char* PeekWritable(size_t* size); 75 | 76 | // Commit reserved data 77 | void Commit(size_t size); 78 | 79 | // Return size of buffer in bytes 80 | size_t inline Length() { 81 | return length_; 82 | } 83 | 84 | static inline NodeBIO* FromBIO(BIO* bio) { 85 | assert(bio->ptr != NULL); 86 | return static_cast(bio->ptr); 87 | } 88 | 89 | private: 90 | static int New(BIO* bio); 91 | static int Free(BIO* bio); 92 | static int Read(BIO* bio, char* out, int len); 93 | static int Write(BIO* bio, const char* data, int len); 94 | static int Puts(BIO* bio, const char* str); 95 | static int Gets(BIO* bio, char* out, int size); 96 | static long Ctrl(BIO* bio, int cmd, long num, void* ptr); 97 | 98 | // NOTE: Size is maximum TLS frame length, this is required if we want 99 | // to fit whole ClientHello into one Buffer of NodeBIO. 100 | static const size_t kBufferLength = 16 * 1024 + 5; 101 | static const BIO_METHOD method; 102 | 103 | class Buffer { 104 | public: 105 | Buffer() : read_pos_(0), write_pos_(0), next_(NULL) { 106 | } 107 | 108 | size_t read_pos_; 109 | size_t write_pos_; 110 | Buffer* next_; 111 | char data_[kBufferLength]; 112 | }; 113 | 114 | size_t length_; 115 | Buffer head_; 116 | Buffer* read_head_; 117 | Buffer* write_head_; 118 | }; 119 | 120 | } // namespace node 121 | 122 | #endif // SRC_NODE_CRYPTO_BIO_H_ 123 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_crypto_clienthello-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_ 23 | #define SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_ 24 | 25 | #include 26 | 27 | namespace node { 28 | 29 | inline void ClientHelloParser::Reset() { 30 | frame_len_ = 0; 31 | body_offset_ = 0; 32 | extension_offset_ = 0; 33 | session_size_ = 0; 34 | session_id_ = NULL; 35 | tls_ticket_size_ = -1; 36 | tls_ticket_ = NULL; 37 | servername_size_ = 0; 38 | servername_ = NULL; 39 | } 40 | 41 | inline void ClientHelloParser::Start(ClientHelloParser::OnHelloCb onhello_cb, 42 | ClientHelloParser::OnEndCb onend_cb, 43 | void* onend_arg) { 44 | if (!IsEnded()) 45 | return; 46 | Reset(); 47 | 48 | assert(onhello_cb != NULL); 49 | 50 | state_ = kWaiting; 51 | onhello_cb_ = onhello_cb; 52 | onend_cb_ = onend_cb; 53 | cb_arg_ = onend_arg; 54 | } 55 | 56 | inline void ClientHelloParser::End() { 57 | if (state_ == kEnded) 58 | return; 59 | state_ = kEnded; 60 | if (onend_cb_ != NULL) { 61 | onend_cb_(cb_arg_); 62 | onend_cb_ = NULL; 63 | } 64 | } 65 | 66 | inline bool ClientHelloParser::IsEnded() const { 67 | return state_ == kEnded; 68 | } 69 | 70 | inline bool ClientHelloParser::IsPaused() const { 71 | return state_ == kPaused; 72 | } 73 | 74 | } // namespace node 75 | 76 | #endif // SRC_NODE_CRYPTO_CLIENTHELLO_INL_H_ 77 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_crypto_clienthello.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_CRYPTO_CLIENTHELLO_H_ 23 | #define SRC_NODE_CRYPTO_CLIENTHELLO_H_ 24 | 25 | #include "node.h" 26 | 27 | #include // size_t 28 | #include // NULL 29 | 30 | namespace node { 31 | 32 | class ClientHelloParser { 33 | public: 34 | ClientHelloParser() : state_(kEnded), 35 | onhello_cb_(NULL), 36 | onend_cb_(NULL), 37 | cb_arg_(NULL), 38 | session_size_(0), 39 | session_id_(NULL), 40 | servername_size_(0), 41 | servername_(NULL), 42 | ocsp_request_(0), 43 | tls_ticket_size_(0), 44 | tls_ticket_(NULL) { 45 | Reset(); 46 | } 47 | 48 | class ClientHello { 49 | public: 50 | ClientHello() { 51 | } 52 | 53 | inline uint8_t session_size() const { return session_size_; } 54 | inline const uint8_t* session_id() const { return session_id_; } 55 | inline bool has_ticket() const { return has_ticket_; } 56 | inline uint8_t servername_size() const { return servername_size_; } 57 | inline const uint8_t* servername() const { return servername_; } 58 | inline int ocsp_request() const { return ocsp_request_; } 59 | 60 | private: 61 | uint8_t session_size_; 62 | const uint8_t* session_id_; 63 | bool has_ticket_; 64 | uint8_t servername_size_; 65 | const uint8_t* servername_; 66 | int ocsp_request_; 67 | 68 | friend class ClientHelloParser; 69 | }; 70 | 71 | typedef void (*OnHelloCb)(void* arg, const ClientHello& hello); 72 | typedef void (*OnEndCb)(void* arg); 73 | 74 | void Parse(const uint8_t* data, size_t avail); 75 | 76 | inline void Reset(); 77 | inline void Start(OnHelloCb onhello_cb, OnEndCb onend_cb, void* onend_arg); 78 | inline void End(); 79 | inline bool IsPaused() const; 80 | inline bool IsEnded() const; 81 | 82 | private: 83 | static const uint8_t kSSL2TwoByteHeaderBit = 0x80; 84 | static const uint8_t kSSL2HeaderMask = 0x3f; 85 | static const size_t kMaxTLSFrameLen = 16 * 1024 + 5; 86 | static const size_t kMaxSSLExFrameLen = 32 * 1024; 87 | static const uint8_t kServernameHostname = 0; 88 | static const uint8_t kStatusRequestOCSP = 1; 89 | static const size_t kMinStatusRequestSize = 5; 90 | 91 | enum ParseState { 92 | kWaiting, 93 | kTLSHeader, 94 | kSSL2Header, 95 | kPaused, 96 | kEnded 97 | }; 98 | 99 | enum FrameType { 100 | kChangeCipherSpec = 20, 101 | kAlert = 21, 102 | kHandshake = 22, 103 | kApplicationData = 23, 104 | kOther = 255 105 | }; 106 | 107 | enum HandshakeType { 108 | kClientHello = 1 109 | }; 110 | 111 | enum ExtensionType { 112 | kServerName = 0, 113 | kStatusRequest = 5, 114 | kTLSSessionTicket = 35 115 | }; 116 | 117 | bool ParseRecordHeader(const uint8_t* data, size_t avail); 118 | void ParseHeader(const uint8_t* data, size_t avail); 119 | void ParseExtension(ExtensionType type, 120 | const uint8_t* data, 121 | size_t len); 122 | bool ParseTLSClientHello(const uint8_t* data, size_t avail); 123 | #ifdef OPENSSL_NO_SSL2 124 | bool ParseSSL2ClientHello(const uint8_t* data, size_t avail); 125 | #endif // OPENSSL_NO_SSL2 126 | 127 | ParseState state_; 128 | OnHelloCb onhello_cb_; 129 | OnEndCb onend_cb_; 130 | void* cb_arg_; 131 | size_t frame_len_; 132 | size_t body_offset_; 133 | size_t extension_offset_; 134 | uint8_t session_size_; 135 | const uint8_t* session_id_; 136 | uint16_t servername_size_; 137 | const uint8_t* servername_; 138 | uint8_t ocsp_request_; 139 | uint16_t tls_ticket_size_; 140 | const uint8_t* tls_ticket_; 141 | }; 142 | 143 | } // namespace node 144 | 145 | #endif // SRC_NODE_CRYPTO_CLIENTHELLO_H_ 146 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_dtrace.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_DTRACE_H_ 23 | #define SRC_NODE_DTRACE_H_ 24 | 25 | #include "node.h" 26 | #include "v8.h" 27 | #include "env.h" 28 | 29 | extern "C" { 30 | /* 31 | * The following structures are passed directly to DTrace when probes are fired. 32 | * Translators in node.d translate these structures into the corresponding D 33 | * structures, taking care of dealing with the user process data model (32-bit 34 | * or 64-bit) and structure versions (see node_dtrace_http_server_request_t 35 | * below). 36 | */ 37 | 38 | typedef struct { 39 | int32_t fd; 40 | int32_t port; 41 | char* remote; 42 | int32_t buffered; 43 | } node_dtrace_connection_t; 44 | 45 | typedef struct { 46 | char* url; 47 | char* method; 48 | } node_dtrace_http_client_request_t; 49 | 50 | /* 51 | * The original version of this structure contained only a url and method, just 52 | * like the client request above. To add the new forwardedFor field, the 53 | * structure layout was changed to begin with an integer version. The 54 | * translator knows whether it's looking at an old- or new-version structure 55 | * based on whether the version field's value is a reasonable pointer (i.e. 56 | * address greater than 4K). No doubt this is filthy, but there's not much else 57 | * we can do, and it works reliably. 58 | * 59 | * This version of the structure also contains padding that should be zeroed out 60 | * by the consumer so that future versions of the translator can simply check if 61 | * a field is present by checking it against NULL. 62 | */ 63 | typedef struct { 64 | union { 65 | uint32_t version; 66 | uintptr_t unused; /* for compat. with old 64-bit struct */ 67 | } _un; 68 | char* url; 69 | char* method; 70 | char* forwardedFor; 71 | char* _pad[8]; 72 | } node_dtrace_http_server_request_t; 73 | 74 | } // extern "C" 75 | 76 | namespace node { 77 | 78 | void InitDTrace(Environment* env, v8::Handle target); 79 | 80 | } // namespace node 81 | 82 | #endif // SRC_NODE_DTRACE_H_ 83 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_file.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_FILE_H_ 23 | #define SRC_NODE_FILE_H_ 24 | 25 | #include "node.h" 26 | #include "v8.h" 27 | 28 | namespace node { 29 | 30 | void InitFs(v8::Handle target); 31 | 32 | } // namespace node 33 | 34 | #endif // SRC_NODE_FILE_H_ 35 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_http_parser.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_HTTP_PARSER_H_ 23 | #define SRC_NODE_HTTP_PARSER_H_ 24 | 25 | #include "v8.h" 26 | 27 | #include "http_parser.h" 28 | 29 | namespace node { 30 | 31 | void InitHttpParser(v8::Handle target); 32 | 33 | } // namespace node 34 | 35 | #endif // SRC_NODE_HTTP_PARSER_H_ 36 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_javascript.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "node.h" 23 | #include "node_natives.h" 24 | #include "v8.h" 25 | #include "env.h" 26 | #include "env-inl.h" 27 | 28 | #include 29 | #if !defined(_MSC_VER) 30 | #include 31 | #endif 32 | 33 | namespace node { 34 | 35 | using v8::Handle; 36 | using v8::HandleScope; 37 | using v8::Local; 38 | using v8::Object; 39 | using v8::String; 40 | 41 | Handle MainSource(Environment* env) { 42 | return OneByteString(env->isolate(), node_native, sizeof(node_native) - 1); 43 | } 44 | 45 | void DefineJavaScript(Environment* env, Handle target) { 46 | HandleScope scope(env->isolate()); 47 | 48 | for (int i = 0; natives[i].name; i++) { 49 | if (natives[i].source != node_native) { 50 | Local name = String::NewFromUtf8(env->isolate(), natives[i].name); 51 | Handle source = String::NewFromUtf8(env->isolate(), 52 | natives[i].source, 53 | String::kNormalString, 54 | natives[i].source_len); 55 | target->Set(name, source); 56 | } 57 | } 58 | } 59 | 60 | } // namespace node 61 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_javascript.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_JAVASCRIPT_H_ 23 | #define SRC_NODE_JAVASCRIPT_H_ 24 | 25 | #include "v8.h" 26 | #include "env.h" 27 | 28 | namespace node { 29 | 30 | void DefineJavaScript(Environment* env, v8::Handle target); 31 | v8::Handle MainSource(Environment* env); 32 | 33 | } // namespace node 34 | 35 | #endif // SRC_NODE_JAVASCRIPT_H_ 36 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "node.h" 23 | 24 | #ifdef _WIN32 25 | int wmain(int argc, wchar_t *wargv[]) { 26 | // Convert argv to to UTF8 27 | char** argv = new char*[argc]; 28 | for (int i = 0; i < argc; i++) { 29 | // Compute the size of the required buffer 30 | DWORD size = WideCharToMultiByte(CP_UTF8, 31 | 0, 32 | wargv[i], 33 | -1, 34 | NULL, 35 | 0, 36 | NULL, 37 | NULL); 38 | if (size == 0) { 39 | // This should never happen. 40 | fprintf(stderr, "Could not convert arguments to utf8."); 41 | exit(1); 42 | } 43 | // Do the actual conversion 44 | argv[i] = new char[size]; 45 | DWORD result = WideCharToMultiByte(CP_UTF8, 46 | 0, 47 | wargv[i], 48 | -1, 49 | argv[i], 50 | size, 51 | NULL, 52 | NULL); 53 | if (result == 0) { 54 | // This should never happen. 55 | fprintf(stderr, "Could not convert arguments to utf8."); 56 | exit(1); 57 | } 58 | } 59 | // Now that conversion is done, we can finally start. 60 | return node::Start(argc, argv); 61 | } 62 | #else 63 | // UNIX 64 | int main(int argc, char *argv[]) { 65 | return node::Start(argc, argv); 66 | } 67 | #endif 68 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_object_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_OBJECT_WRAP_H_ 23 | #define SRC_NODE_OBJECT_WRAP_H_ 24 | 25 | #include "v8.h" 26 | #include 27 | 28 | 29 | namespace node { 30 | 31 | class ObjectWrap { 32 | public: 33 | ObjectWrap() { 34 | refs_ = 0; 35 | } 36 | 37 | 38 | virtual ~ObjectWrap() { 39 | if (persistent().IsEmpty()) 40 | return; 41 | assert(persistent().IsNearDeath()); 42 | persistent().ClearWeak(); 43 | persistent().Reset(); 44 | } 45 | 46 | 47 | template 48 | static inline T* Unwrap(v8::Handle handle) { 49 | assert(!handle.IsEmpty()); 50 | assert(handle->InternalFieldCount() > 0); 51 | // Cast to ObjectWrap before casting to T. A direct cast from void 52 | // to T won't work right when T has more than one base class. 53 | void* ptr = handle->GetAlignedPointerFromInternalField(0); 54 | ObjectWrap* wrap = static_cast(ptr); 55 | return static_cast(wrap); 56 | } 57 | 58 | 59 | inline v8::Local handle() { 60 | return handle(v8::Isolate::GetCurrent()); 61 | } 62 | 63 | 64 | inline v8::Local handle(v8::Isolate* isolate) { 65 | return v8::Local::New(isolate, persistent()); 66 | } 67 | 68 | 69 | inline v8::Persistent& persistent() { 70 | return handle_; 71 | } 72 | 73 | 74 | protected: 75 | inline void Wrap(v8::Handle handle) { 76 | assert(persistent().IsEmpty()); 77 | assert(handle->InternalFieldCount() > 0); 78 | handle->SetAlignedPointerInInternalField(0, this); 79 | persistent().Reset(v8::Isolate::GetCurrent(), handle); 80 | MakeWeak(); 81 | } 82 | 83 | 84 | inline void MakeWeak(void) { 85 | persistent().SetWeak(this, WeakCallback); 86 | persistent().MarkIndependent(); 87 | } 88 | 89 | /* Ref() marks the object as being attached to an event loop. 90 | * Refed objects will not be garbage collected, even if 91 | * all references are lost. 92 | */ 93 | virtual void Ref() { 94 | assert(!persistent().IsEmpty()); 95 | persistent().ClearWeak(); 96 | refs_++; 97 | } 98 | 99 | /* Unref() marks an object as detached from the event loop. This is its 100 | * default state. When an object with a "weak" reference changes from 101 | * attached to detached state it will be freed. Be careful not to access 102 | * the object after making this call as it might be gone! 103 | * (A "weak reference" means an object that only has a 104 | * persistant handle.) 105 | * 106 | * DO NOT CALL THIS FROM DESTRUCTOR 107 | */ 108 | virtual void Unref() { 109 | assert(!persistent().IsEmpty()); 110 | assert(!persistent().IsWeak()); 111 | assert(refs_ > 0); 112 | if (--refs_ == 0) 113 | MakeWeak(); 114 | } 115 | 116 | int refs_; // ro 117 | 118 | private: 119 | static void WeakCallback( 120 | const v8::WeakCallbackData& data) { 121 | v8::Isolate* isolate = data.GetIsolate(); 122 | v8::HandleScope scope(isolate); 123 | ObjectWrap* wrap = data.GetParameter(); 124 | assert(wrap->refs_ == 0); 125 | assert(wrap->handle_.IsNearDeath()); 126 | assert( 127 | data.GetValue() == v8::Local::New(isolate, wrap->handle_)); 128 | wrap->handle_.Reset(); 129 | delete wrap; 130 | } 131 | 132 | v8::Persistent handle_; 133 | }; 134 | 135 | } // namespace node 136 | 137 | #endif // SRC_NODE_OBJECT_WRAP_H_ 138 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_provider.d: -------------------------------------------------------------------------------- 1 | /* Copyright Joyent, Inc. and other Node contributors. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a 4 | * copy of this software and associated documentation files (the 5 | * "Software"), to deal in the Software without restriction, including 6 | * without limitation the rights to use, copy, modify, merge, publish, 7 | * distribute, sublicense, and/or sell copies of the Software, and to permit 8 | * persons to whom the Software is furnished to do so, subject to the 9 | * following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /* 24 | * DTrace provider for node.js. 25 | */ 26 | 27 | /* 28 | * In order to have the information we need here to create the provider, 29 | * we must declare bogus definitions for our depended-upon structures. And 30 | * yes, the fact that we need to do this represents a shortcoming in DTrace, 31 | * one that would be resolved by that elusive El Dorado: dynamic translators. 32 | */ 33 | 34 | typedef struct { 35 | int dummy; 36 | } node_dtrace_connection_t; 37 | 38 | typedef struct { 39 | int dummy; 40 | } node_connection_t; 41 | 42 | typedef struct { 43 | int dummy; 44 | } node_dtrace_http_server_request_t; 45 | 46 | typedef struct { 47 | int dummy; 48 | } node_dtrace_http_client_request_t; 49 | 50 | typedef struct { 51 | int dummy; 52 | } node_http_request_t; 53 | 54 | provider node { 55 | probe net__server__connection(node_dtrace_connection_t *c, 56 | const char *a, int p, int fd) : (node_connection_t *c, string a, int p, 57 | int fd); 58 | probe net__stream__end(node_dtrace_connection_t *c, const char *a, 59 | int p, int fd) : (node_connection_t *c, string a, int p, int fd); 60 | probe net__socket__read(node_dtrace_connection_t *c, int b, 61 | const char *a, int p, int fd) : (node_connection_t *c, int b, string a, 62 | int p, int fd); 63 | probe net__socket__write(node_dtrace_connection_t *c, int b, 64 | const char *a, int p, int fd) : (node_connection_t *c, int b, string a, 65 | int p, int fd); 66 | probe http__server__request(node_dtrace_http_server_request_t *h, 67 | node_dtrace_connection_t *c, const char *a, int p, const char *m, 68 | const char *u, int fd) : (node_http_request_t *h, node_connection_t *c, 69 | string a, int p, string m, string u, int fd); 70 | probe http__server__response(node_dtrace_connection_t *c, const char *a, 71 | int p, int fd) : (node_connection_t *c, string a, int p, int fd); 72 | probe http__client__request(node_dtrace_http_client_request_t *h, 73 | node_dtrace_connection_t *c, const char *a, int p, const char *m, 74 | const char *u, int fd) : (node_http_request_t *h, node_connection_t *c, 75 | string a, int p, string m, string u, int fd); 76 | probe http__client__response(node_dtrace_connection_t *c, const char *a, 77 | int p, int fd) : (node_connection_t *c, string a, int p, int fd); 78 | probe gc__start(int t, int f, void *isolate); 79 | probe gc__done(int t, int f, void *isolate); 80 | }; 81 | 82 | #pragma D attributes Evolving/Evolving/ISA provider node provider 83 | #pragma D attributes Private/Private/Unknown provider node module 84 | #pragma D attributes Private/Private/Unknown provider node function 85 | #pragma D attributes Private/Private/ISA provider node name 86 | #pragma D attributes Evolving/Evolving/ISA provider node args 87 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_stat_watcher.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "node_stat_watcher.h" 23 | #include "async-wrap.h" 24 | #include "async-wrap-inl.h" 25 | #include "env.h" 26 | #include "env-inl.h" 27 | #include "util.h" 28 | #include "util-inl.h" 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace node { 35 | 36 | using v8::Context; 37 | using v8::FunctionCallbackInfo; 38 | using v8::FunctionTemplate; 39 | using v8::Handle; 40 | using v8::HandleScope; 41 | using v8::Integer; 42 | using v8::Local; 43 | using v8::Object; 44 | using v8::String; 45 | using v8::Value; 46 | 47 | 48 | void StatWatcher::Initialize(Environment* env, Handle target) { 49 | HandleScope scope(env->isolate()); 50 | 51 | Local t = FunctionTemplate::New(env->isolate(), 52 | StatWatcher::New); 53 | t->InstanceTemplate()->SetInternalFieldCount(1); 54 | t->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher")); 55 | 56 | NODE_SET_PROTOTYPE_METHOD(t, "start", StatWatcher::Start); 57 | NODE_SET_PROTOTYPE_METHOD(t, "stop", StatWatcher::Stop); 58 | 59 | target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "StatWatcher"), 60 | t->GetFunction()); 61 | } 62 | 63 | 64 | static void Delete(uv_handle_t* handle) { 65 | delete reinterpret_cast(handle); 66 | } 67 | 68 | 69 | StatWatcher::StatWatcher(Environment* env, Local wrap) 70 | : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_STATWATCHER), 71 | watcher_(new uv_fs_poll_t) { 72 | MakeWeak(this); 73 | uv_fs_poll_init(env->event_loop(), watcher_); 74 | watcher_->data = static_cast(this); 75 | } 76 | 77 | 78 | StatWatcher::~StatWatcher() { 79 | Stop(); 80 | uv_close(reinterpret_cast(watcher_), Delete); 81 | } 82 | 83 | 84 | void StatWatcher::Callback(uv_fs_poll_t* handle, 85 | int status, 86 | const uv_stat_t* prev, 87 | const uv_stat_t* curr) { 88 | StatWatcher* wrap = static_cast(handle->data); 89 | assert(wrap->watcher_ == handle); 90 | Environment* env = wrap->env(); 91 | HandleScope handle_scope(env->isolate()); 92 | Context::Scope context_scope(env->context()); 93 | Local argv[] = { 94 | BuildStatsObject(env, curr), 95 | BuildStatsObject(env, prev), 96 | Integer::New(env->isolate(), status) 97 | }; 98 | wrap->MakeCallback(env->onchange_string(), ARRAY_SIZE(argv), argv); 99 | } 100 | 101 | 102 | void StatWatcher::New(const FunctionCallbackInfo& args) { 103 | assert(args.IsConstructCall()); 104 | HandleScope handle_scope(args.GetIsolate()); 105 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 106 | new StatWatcher(env, args.This()); 107 | } 108 | 109 | 110 | void StatWatcher::Start(const FunctionCallbackInfo& args) { 111 | assert(args.Length() == 3); 112 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 113 | HandleScope scope(env->isolate()); 114 | 115 | StatWatcher* wrap = Unwrap(args.Holder()); 116 | node::Utf8Value path(args[0]); 117 | const bool persistent = args[1]->BooleanValue(); 118 | const uint32_t interval = args[2]->Uint32Value(); 119 | 120 | if (!persistent) 121 | uv_unref(reinterpret_cast(wrap->watcher_)); 122 | uv_fs_poll_start(wrap->watcher_, Callback, *path, interval); 123 | wrap->ClearWeak(); 124 | } 125 | 126 | 127 | void StatWatcher::Stop(const FunctionCallbackInfo& args) { 128 | StatWatcher* wrap = Unwrap(args.Holder()); 129 | Environment* env = wrap->env(); 130 | HandleScope handle_scope(env->isolate()); 131 | Context::Scope context_scope(env->context()); 132 | wrap->MakeCallback(env->onstop_string(), 0, NULL); 133 | wrap->Stop(); 134 | } 135 | 136 | 137 | void StatWatcher::Stop() { 138 | if (!uv_is_active(reinterpret_cast(watcher_))) 139 | return; 140 | uv_fs_poll_stop(watcher_); 141 | MakeWeak(this); 142 | } 143 | 144 | 145 | } // namespace node 146 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_stat_watcher.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_STAT_WATCHER_H_ 23 | #define SRC_NODE_STAT_WATCHER_H_ 24 | 25 | #include "node.h" 26 | #include "async-wrap.h" 27 | #include "env.h" 28 | #include "uv.h" 29 | #include "v8.h" 30 | 31 | namespace node { 32 | 33 | class StatWatcher : public AsyncWrap { 34 | public: 35 | virtual ~StatWatcher(); 36 | 37 | static void Initialize(Environment* env, v8::Handle target); 38 | 39 | protected: 40 | StatWatcher(Environment* env, v8::Local wrap); 41 | 42 | static void New(const v8::FunctionCallbackInfo& args); 43 | static void Start(const v8::FunctionCallbackInfo& args); 44 | static void Stop(const v8::FunctionCallbackInfo& args); 45 | 46 | private: 47 | static void Callback(uv_fs_poll_t* handle, 48 | int status, 49 | const uv_stat_t* prev, 50 | const uv_stat_t* curr); 51 | void Stop(); 52 | 53 | uv_fs_poll_t* watcher_; 54 | }; 55 | 56 | } // namespace node 57 | #endif // SRC_NODE_STAT_WATCHER_H_ 58 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_version.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_VERSION_H_ 23 | #define SRC_NODE_VERSION_H_ 24 | 25 | #define NODE_MAJOR_VERSION 0 26 | #define NODE_MINOR_VERSION 11 27 | #define NODE_PATCH_VERSION 14 28 | 29 | #define NODE_VERSION_IS_RELEASE 1 30 | 31 | #ifndef NODE_TAG 32 | # define NODE_TAG "" 33 | #endif 34 | 35 | #ifndef NODE_STRINGIFY 36 | #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n) 37 | #define NODE_STRINGIFY_HELPER(n) #n 38 | #endif 39 | 40 | #if NODE_VERSION_IS_RELEASE 41 | # define NODE_VERSION_STRING NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \ 42 | NODE_STRINGIFY(NODE_MINOR_VERSION) "." \ 43 | NODE_STRINGIFY(NODE_PATCH_VERSION) \ 44 | NODE_TAG 45 | #else 46 | # define NODE_VERSION_STRING NODE_STRINGIFY(NODE_MAJOR_VERSION) "." \ 47 | NODE_STRINGIFY(NODE_MINOR_VERSION) "." \ 48 | NODE_STRINGIFY(NODE_PATCH_VERSION) \ 49 | NODE_TAG "-pre" 50 | #endif 51 | 52 | #define NODE_VERSION "v" NODE_VERSION_STRING 53 | 54 | 55 | #define NODE_VERSION_AT_LEAST(major, minor, patch) \ 56 | (( (major) < NODE_MAJOR_VERSION) \ 57 | || ((major) == NODE_MAJOR_VERSION && (minor) < NODE_MINOR_VERSION) \ 58 | || ((major) == NODE_MAJOR_VERSION && \ 59 | (minor) == NODE_MINOR_VERSION && (patch) <= NODE_PATCH_VERSION)) 60 | 61 | /** 62 | * When this version number is changed, node.js will refuse 63 | * to load older modules. This should be done whenever 64 | * an API is broken in the C++ side, including in v8 or 65 | * other dependencies. 66 | */ 67 | #define NODE_MODULE_VERSION 14 /* v0.12 */ 68 | 69 | #endif /* SRC_NODE_VERSION_H_ */ 70 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_watchdog.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "node_watchdog.h" 23 | #include "env.h" 24 | #include "env-inl.h" 25 | #include "util.h" 26 | #include 27 | 28 | namespace node { 29 | 30 | using v8::V8; 31 | 32 | 33 | Watchdog::Watchdog(Environment* env, uint64_t ms) : env_(env), 34 | destroyed_(false) { 35 | int rc; 36 | loop_ = new uv_loop_t; 37 | CHECK(loop_); 38 | rc = uv_loop_init(loop_); 39 | CHECK_EQ(0, rc); 40 | 41 | rc = uv_async_init(loop_, &async_, &Watchdog::Async); 42 | CHECK_EQ(0, rc); 43 | 44 | rc = uv_timer_init(loop_, &timer_); 45 | CHECK_EQ(0, rc); 46 | 47 | rc = uv_timer_start(&timer_, &Watchdog::Timer, ms, 0); 48 | CHECK_EQ(0, rc); 49 | 50 | rc = uv_thread_create(&thread_, &Watchdog::Run, this); 51 | CHECK_EQ(0, rc); 52 | } 53 | 54 | 55 | Watchdog::~Watchdog() { 56 | Destroy(); 57 | } 58 | 59 | 60 | void Watchdog::Dispose() { 61 | Destroy(); 62 | } 63 | 64 | 65 | void Watchdog::Destroy() { 66 | if (destroyed_) { 67 | return; 68 | } 69 | 70 | uv_async_send(&async_); 71 | uv_thread_join(&thread_); 72 | 73 | uv_close(reinterpret_cast(&async_), NULL); 74 | 75 | // UV_RUN_DEFAULT so that libuv has a chance to clean up. 76 | uv_run(loop_, UV_RUN_DEFAULT); 77 | 78 | int rc = uv_loop_close(loop_); 79 | CHECK_EQ(0, rc); 80 | delete loop_; 81 | loop_ = NULL; 82 | 83 | destroyed_ = true; 84 | } 85 | 86 | 87 | void Watchdog::Run(void* arg) { 88 | Watchdog* wd = static_cast(arg); 89 | 90 | // UV_RUN_ONCE so async_ or timer_ wakeup exits uv_run() call. 91 | uv_run(wd->loop_, UV_RUN_ONCE); 92 | 93 | // Loop ref count reaches zero when both handles are closed. 94 | // Close the timer handle on this side and let Destroy() close async_ 95 | uv_close(reinterpret_cast(&wd->timer_), NULL); 96 | } 97 | 98 | 99 | void Watchdog::Async(uv_async_t* async) { 100 | } 101 | 102 | 103 | void Watchdog::Timer(uv_timer_t* timer) { 104 | Watchdog* w = ContainerOf(&Watchdog::timer_, timer); 105 | V8::TerminateExecution(w->env()->isolate()); 106 | } 107 | 108 | 109 | } // namespace node 110 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_watchdog.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_WATCHDOG_H_ 23 | #define SRC_NODE_WATCHDOG_H_ 24 | 25 | #include "v8.h" 26 | #include "uv.h" 27 | 28 | #include "env.h" 29 | 30 | namespace node { 31 | 32 | class Watchdog { 33 | public: 34 | explicit Watchdog(Environment* env, uint64_t ms); 35 | ~Watchdog(); 36 | 37 | void Dispose(); 38 | 39 | inline Environment* env() const { return env_; } 40 | 41 | private: 42 | void Destroy(); 43 | 44 | static void Run(void* arg); 45 | static void Async(uv_async_t* async); 46 | static void Timer(uv_timer_t* timer); 47 | 48 | Environment* env_; 49 | uv_thread_t thread_; 50 | uv_loop_t* loop_; 51 | uv_async_t async_; 52 | uv_timer_t timer_; 53 | bool destroyed_; 54 | }; 55 | 56 | } // namespace node 57 | 58 | #endif // SRC_NODE_WATCHDOG_H_ 59 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_win32_etw_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_WIN32_ETW_PROVIDER_H_ 23 | #define SRC_NODE_WIN32_ETW_PROVIDER_H_ 24 | 25 | #include "node_dtrace.h" 26 | #include 27 | 28 | namespace node { 29 | 30 | #if defined(_MSC_VER) 31 | # define INLINE __forceinline 32 | #else 33 | # define INLINE inline 34 | #endif 35 | 36 | typedef ULONG (NTAPI *EventRegisterFunc)( 37 | LPCGUID ProviderId, 38 | PENABLECALLBACK EnableCallback, 39 | PVOID CallbackContext, 40 | PREGHANDLE RegHandle 41 | ); 42 | 43 | typedef ULONG (NTAPI *EventUnregisterFunc)( 44 | REGHANDLE RegHandle 45 | ); 46 | 47 | typedef ULONG (NTAPI *EventWriteFunc)( 48 | REGHANDLE RegHandle, 49 | PCEVENT_DESCRIPTOR EventDescriptor, 50 | ULONG UserDataCount, 51 | PEVENT_DATA_DESCRIPTOR UserData 52 | ); 53 | 54 | void init_etw(); 55 | void shutdown_etw(); 56 | 57 | INLINE void NODE_HTTP_SERVER_REQUEST(node_dtrace_http_server_request_t* req, 58 | node_dtrace_connection_t* conn, const char *remote, int port, 59 | const char *method, const char *url, int fd); 60 | INLINE void NODE_HTTP_SERVER_RESPONSE(node_dtrace_connection_t* conn, 61 | const char *remote, int port, int fd); 62 | INLINE void NODE_HTTP_CLIENT_REQUEST(node_dtrace_http_client_request_t* req, 63 | node_dtrace_connection_t* conn, const char *remote, int port, 64 | const char *method, const char *url, int fd); 65 | INLINE void NODE_HTTP_CLIENT_RESPONSE(node_dtrace_connection_t* conn, 66 | const char *remote, int port, int fd); 67 | INLINE void NODE_NET_SERVER_CONNECTION(node_dtrace_connection_t* conn, 68 | const char *remote, int port, int fd); 69 | INLINE void NODE_NET_STREAM_END(node_dtrace_connection_t* conn, 70 | const char *remote, int port, int fd); 71 | INLINE void NODE_GC_START(v8::GCType type, 72 | v8::GCCallbackFlags flags, 73 | v8::Isolate* isolate); 74 | INLINE void NODE_GC_DONE(v8::GCType type, 75 | v8::GCCallbackFlags flags, 76 | v8::Isolate* isolate); 77 | INLINE void NODE_V8SYMBOL_REMOVE(const void* addr1, const void* addr2); 78 | INLINE void NODE_V8SYMBOL_MOVE(const void* addr1, const void* addr2); 79 | INLINE void NODE_V8SYMBOL_RESET(); 80 | INLINE void NODE_V8SYMBOL_ADD(LPCSTR symbol, 81 | int symbol_len, 82 | const void* addr1, 83 | int len); 84 | 85 | INLINE bool NODE_HTTP_SERVER_REQUEST_ENABLED(); 86 | INLINE bool NODE_HTTP_SERVER_RESPONSE_ENABLED(); 87 | INLINE bool NODE_HTTP_CLIENT_REQUEST_ENABLED(); 88 | INLINE bool NODE_HTTP_CLIENT_RESPONSE_ENABLED(); 89 | INLINE bool NODE_NET_SERVER_CONNECTION_ENABLED(); 90 | INLINE bool NODE_NET_STREAM_END_ENABLED(); 91 | INLINE bool NODE_NET_SOCKET_READ_ENABLED(); 92 | INLINE bool NODE_NET_SOCKET_WRITE_ENABLED(); 93 | INLINE bool NODE_V8SYMBOL_ENABLED(); 94 | 95 | #define NODE_NET_SOCKET_READ(arg0, arg1) 96 | #define NODE_NET_SOCKET_WRITE(arg0, arg1) 97 | } // namespace node 98 | 99 | #endif // SRC_NODE_WIN32_ETW_PROVIDER_H_ 100 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_win32_perfctr_provider.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_WIN32_PERFCTR_PROVIDER_H_ 23 | #define SRC_NODE_WIN32_PERFCTR_PROVIDER_H_ 24 | 25 | #if defined(_MSC_VER) 26 | # define INLINE __forceinline 27 | #else 28 | # define INLINE inline 29 | #endif 30 | 31 | namespace node { 32 | 33 | extern HANDLE NodeCounterProvider; 34 | 35 | INLINE bool NODE_COUNTER_ENABLED() { return NodeCounterProvider != NULL; } 36 | void NODE_COUNT_HTTP_SERVER_REQUEST(); 37 | void NODE_COUNT_HTTP_SERVER_RESPONSE(); 38 | void NODE_COUNT_HTTP_CLIENT_REQUEST(); 39 | void NODE_COUNT_HTTP_CLIENT_RESPONSE(); 40 | void NODE_COUNT_SERVER_CONN_OPEN(); 41 | void NODE_COUNT_SERVER_CONN_CLOSE(); 42 | void NODE_COUNT_NET_BYTES_SENT(int bytes); 43 | void NODE_COUNT_NET_BYTES_RECV(int bytes); 44 | uint64_t NODE_COUNT_GET_GC_RAWTIME(); 45 | void NODE_COUNT_GC_PERCENTTIME(unsigned int percent); 46 | void NODE_COUNT_PIPE_BYTES_SENT(int bytes); 47 | void NODE_COUNT_PIPE_BYTES_RECV(int bytes); 48 | 49 | void InitPerfCountersWin32(); 50 | void TermPerfCountersWin32(); 51 | 52 | } // namespace node 53 | 54 | #endif // SRC_NODE_WIN32_PERFCTR_PROVIDER_H_ 55 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/node_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_NODE_WRAP_H_ 23 | #define SRC_NODE_WRAP_H_ 24 | 25 | #include "env.h" 26 | #include "env-inl.h" 27 | #include "pipe_wrap.h" 28 | #include "tcp_wrap.h" 29 | #include "tty_wrap.h" 30 | #include "udp_wrap.h" 31 | #include "util.h" 32 | #include "util-inl.h" 33 | #include "uv.h" 34 | #include "v8.h" 35 | 36 | namespace node { 37 | 38 | #define WITH_GENERIC_STREAM(env, obj, BODY) \ 39 | do { \ 40 | if (env->tcp_constructor_template().IsEmpty() == false && \ 41 | env->tcp_constructor_template()->HasInstance(obj)) { \ 42 | TCPWrap* const wrap = Unwrap(obj); \ 43 | BODY \ 44 | } else if (env->tty_constructor_template().IsEmpty() == false && \ 45 | env->tty_constructor_template()->HasInstance(obj)) { \ 46 | TTYWrap* const wrap = Unwrap(obj); \ 47 | BODY \ 48 | } else if (env->pipe_constructor_template().IsEmpty() == false && \ 49 | env->pipe_constructor_template()->HasInstance(obj)) { \ 50 | PipeWrap* const wrap = Unwrap(obj); \ 51 | BODY \ 52 | } \ 53 | } while (0) 54 | 55 | inline uv_stream_t* HandleToStream(Environment* env, 56 | v8::Local obj) { 57 | v8::HandleScope scope(env->isolate()); 58 | 59 | WITH_GENERIC_STREAM(env, obj, { 60 | return reinterpret_cast(wrap->UVHandle()); 61 | }); 62 | 63 | return NULL; 64 | } 65 | 66 | } // namespace node 67 | 68 | #endif // SRC_NODE_WRAP_H_ 69 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/notrace_macros.py: -------------------------------------------------------------------------------- 1 | # This file is used by tools/js2c.py to preprocess out the DTRACE symbols in 2 | # builds that don't support DTrace. This is not used in builds that support 3 | # DTrace. 4 | macro DTRACE_HTTP_CLIENT_REQUEST(x) = ; 5 | macro DTRACE_HTTP_CLIENT_RESPONSE(x) = ; 6 | macro DTRACE_HTTP_SERVER_REQUEST(x) = ; 7 | macro DTRACE_HTTP_SERVER_RESPONSE(x) = ; 8 | macro DTRACE_NET_SERVER_CONNECTION(x) = ; 9 | macro DTRACE_NET_STREAM_END(x) = ; 10 | macro DTRACE_NET_SOCKET_READ(x) = ; 11 | macro DTRACE_NET_SOCKET_WRITE(x) = ; 12 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/perfctr_macros.py: -------------------------------------------------------------------------------- 1 | # This file is used by tools/js2c.py to preprocess out the performance counters 2 | # symbols in builds that don't support counters. This is not used in builds 3 | # that support performance counters. 4 | macro COUNTER_NET_SERVER_CONNECTION(x) = ; 5 | macro COUNTER_NET_SERVER_CONNECTION_CLOSE(x) = ; 6 | macro COUNTER_HTTP_SERVER_REQUEST(x) = ; 7 | macro COUNTER_HTTP_SERVER_RESPONSE(x) = ; 8 | macro COUNTER_HTTP_CLIENT_REQUEST(x) = ; 9 | macro COUNTER_HTTP_CLIENT_RESPONSE(x) = ; 10 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/pipe_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_PIPE_WRAP_H_ 23 | #define SRC_PIPE_WRAP_H_ 24 | 25 | #include "env.h" 26 | #include "stream_wrap.h" 27 | 28 | namespace node { 29 | 30 | class PipeWrap : public StreamWrap { 31 | public: 32 | uv_pipe_t* UVHandle(); 33 | 34 | static v8::Local Instantiate(Environment* env); 35 | static void Initialize(v8::Handle target, 36 | v8::Handle unused, 37 | v8::Handle context); 38 | 39 | private: 40 | PipeWrap(Environment* env, v8::Handle object, bool ipc); 41 | 42 | static void New(const v8::FunctionCallbackInfo& args); 43 | static void Bind(const v8::FunctionCallbackInfo& args); 44 | static void Listen(const v8::FunctionCallbackInfo& args); 45 | static void Connect(const v8::FunctionCallbackInfo& args); 46 | static void Open(const v8::FunctionCallbackInfo& args); 47 | 48 | #ifdef _WIN32 49 | static void SetPendingInstances( 50 | const v8::FunctionCallbackInfo& args); 51 | #endif 52 | 53 | static void OnConnection(uv_stream_t* handle, int status); 54 | static void AfterConnect(uv_connect_t* req, int status); 55 | 56 | uv_pipe_t handle_; 57 | }; 58 | 59 | 60 | } // namespace node 61 | 62 | 63 | #endif // SRC_PIPE_WRAP_H_ 64 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/queue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, Ben Noordhuis 2 | * 3 | * Permission to use, copy, modify, and/or distribute this software for any 4 | * purpose with or without fee is hereby granted, provided that the above 5 | * copyright notice and this permission notice appear in all copies. 6 | * 7 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | */ 15 | 16 | #ifndef SRC_QUEUE_H_ 17 | #define SRC_QUEUE_H_ 18 | 19 | typedef void *QUEUE[2]; 20 | 21 | /* Private macros. */ 22 | #define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) 23 | #define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1])) 24 | #define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) 25 | #define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) 26 | 27 | /* Public macros. */ 28 | #define QUEUE_DATA(ptr, type, field) \ 29 | ((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field))) 30 | 31 | #define QUEUE_FOREACH(q, h) \ 32 | for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) 33 | 34 | #define QUEUE_EMPTY(q) \ 35 | ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) 36 | 37 | #define QUEUE_HEAD(q) \ 38 | (QUEUE_NEXT(q)) 39 | 40 | #define QUEUE_INIT(q) \ 41 | do { \ 42 | QUEUE_NEXT(q) = (q); \ 43 | QUEUE_PREV(q) = (q); \ 44 | } \ 45 | while (0) 46 | 47 | #define QUEUE_ADD(h, n) \ 48 | do { \ 49 | QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ 50 | QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ 51 | QUEUE_PREV(h) = QUEUE_PREV(n); \ 52 | QUEUE_PREV_NEXT(h) = (h); \ 53 | } \ 54 | while (0) 55 | 56 | #define QUEUE_SPLIT(h, q, n) \ 57 | do { \ 58 | QUEUE_PREV(n) = QUEUE_PREV(h); \ 59 | QUEUE_PREV_NEXT(n) = (n); \ 60 | QUEUE_NEXT(n) = (q); \ 61 | QUEUE_PREV(h) = QUEUE_PREV(q); \ 62 | QUEUE_PREV_NEXT(h) = (h); \ 63 | QUEUE_PREV(q) = (n); \ 64 | } \ 65 | while (0) 66 | 67 | #define QUEUE_INSERT_HEAD(h, q) \ 68 | do { \ 69 | QUEUE_NEXT(q) = QUEUE_NEXT(h); \ 70 | QUEUE_PREV(q) = (h); \ 71 | QUEUE_NEXT_PREV(q) = (q); \ 72 | QUEUE_NEXT(h) = (q); \ 73 | } \ 74 | while (0) 75 | 76 | #define QUEUE_INSERT_TAIL(h, q) \ 77 | do { \ 78 | QUEUE_NEXT(q) = (h); \ 79 | QUEUE_PREV(q) = QUEUE_PREV(h); \ 80 | QUEUE_PREV_NEXT(q) = (q); \ 81 | QUEUE_PREV(h) = (q); \ 82 | } \ 83 | while (0) 84 | 85 | #define QUEUE_REMOVE(q) \ 86 | do { \ 87 | QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ 88 | QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ 89 | } \ 90 | while (0) 91 | 92 | #endif /* SRC_QUEUE_H_ */ 93 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/req_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_REQ_WRAP_H_ 23 | #define SRC_REQ_WRAP_H_ 24 | 25 | #include "async-wrap.h" 26 | #include "async-wrap-inl.h" 27 | #include "env.h" 28 | #include "env-inl.h" 29 | #include "queue.h" 30 | #include "util.h" 31 | 32 | namespace node { 33 | 34 | // defined in node.cc 35 | extern QUEUE req_wrap_queue; 36 | 37 | template 38 | class ReqWrap : public AsyncWrap { 39 | public: 40 | ReqWrap(Environment* env, 41 | v8::Handle object, 42 | AsyncWrap::ProviderType provider = AsyncWrap::PROVIDER_REQWRAP) 43 | : AsyncWrap(env, object, AsyncWrap::PROVIDER_REQWRAP) { 44 | if (env->in_domain()) 45 | object->Set(env->domain_string(), env->domain_array()->Get(0)); 46 | 47 | QUEUE_INSERT_TAIL(&req_wrap_queue, &req_wrap_queue_); 48 | } 49 | 50 | 51 | ~ReqWrap() { 52 | QUEUE_REMOVE(&req_wrap_queue_); 53 | // Assert that someone has called Dispatched() 54 | assert(req_.data == this); 55 | assert(!persistent().IsEmpty()); 56 | persistent().Reset(); 57 | } 58 | 59 | // Call this after the req has been dispatched. 60 | void Dispatched() { 61 | req_.data = this; 62 | } 63 | 64 | // TODO(bnoordhuis) Make these private. 65 | QUEUE req_wrap_queue_; 66 | T req_; // *must* be last, GetActiveRequests() in node.cc depends on it 67 | }; 68 | 69 | 70 | } // namespace node 71 | 72 | 73 | #endif // SRC_REQ_WRAP_H_ 74 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/res/node.exe.extra.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/res/node.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reichtiger/grampusSpider/d8ba6b96a7af085c7c2420a5bcb1fa35ee8b03b7/gSpiderMac/nodejs/nodejs/src/res/node.ico -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/res/node.rc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "winresrc.h" 23 | #include "node_version.h" 24 | 25 | 26 | // Application icon 27 | 1 ICON node.ico 28 | 29 | 30 | // Version resource 31 | VS_VERSION_INFO VERSIONINFO 32 | FILEVERSION NODE_MAJOR_VERSION,NODE_MINOR_VERSION,NODE_PATCH_VERSION,0 33 | PRODUCTVERSION NODE_MAJOR_VERSION,NODE_MINOR_VERSION,NODE_PATCH_VERSION,0 34 | FILEFLAGSMASK 0x3fL 35 | #ifdef _DEBUG 36 | FILEFLAGS VS_FF_DEBUG 37 | #else 38 | # ifdef NODE_VERSION_IS_RELEASE 39 | FILEFLAGS 0x0L 40 | # else 41 | FILEFLAGS VS_FF_PRERELEASE 42 | # endif 43 | #endif 44 | 45 | FILEOS VOS_NT_WINDOWS32 46 | FILETYPE VFT_APP 47 | FILESUBTYPE 0x0L 48 | BEGIN 49 | BLOCK "StringFileInfo" 50 | BEGIN 51 | BLOCK "040904b0" 52 | BEGIN 53 | VALUE "CompanyName", "Joyent, Inc" 54 | VALUE "ProductName", "Node.js" 55 | VALUE "FileDescription", "Evented I/O for V8 JavaScript" 56 | VALUE "FileVersion", NODE_VERSION_STRING 57 | VALUE "ProductVersion", NODE_VERSION_STRING 58 | VALUE "OriginalFilename", "node.exe" 59 | VALUE "InternalName", "node" 60 | VALUE "LegalCopyright", "Copyright Joyent, Inc. and other Node contributors. MIT license." 61 | END 62 | END 63 | BLOCK "VarFileInfo" 64 | BEGIN 65 | VALUE "Translation", 0x409, 1200 66 | END 67 | END 68 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/res/node_perfctr_provider.man: -------------------------------------------------------------------------------- 1 | 5 | 6 | 8 | 12 | 18 | 19 | 26 | 27 | 34 | 35 | 42 | 43 | 50 | 51 | 58 | 59 | 67 | 68 | 76 | 77 | 84 | 85 | 93 | 94 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/signal_wrap.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "async-wrap.h" 23 | #include "async-wrap-inl.h" 24 | #include "env.h" 25 | #include "env-inl.h" 26 | #include "handle_wrap.h" 27 | #include "util.h" 28 | #include "util-inl.h" 29 | #include "v8.h" 30 | 31 | namespace node { 32 | 33 | using v8::Context; 34 | using v8::Function; 35 | using v8::FunctionCallbackInfo; 36 | using v8::FunctionTemplate; 37 | using v8::Handle; 38 | using v8::HandleScope; 39 | using v8::Integer; 40 | using v8::Local; 41 | using v8::Object; 42 | using v8::Value; 43 | 44 | class SignalWrap : public HandleWrap { 45 | public: 46 | static void Initialize(Handle target, 47 | Handle unused, 48 | Handle context) { 49 | Environment* env = Environment::GetCurrent(context); 50 | Local constructor = FunctionTemplate::New(env->isolate(), 51 | New); 52 | constructor->InstanceTemplate()->SetInternalFieldCount(1); 53 | constructor->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "Signal")); 54 | 55 | NODE_SET_PROTOTYPE_METHOD(constructor, "close", HandleWrap::Close); 56 | NODE_SET_PROTOTYPE_METHOD(constructor, "ref", HandleWrap::Ref); 57 | NODE_SET_PROTOTYPE_METHOD(constructor, "unref", HandleWrap::Unref); 58 | NODE_SET_PROTOTYPE_METHOD(constructor, "start", Start); 59 | NODE_SET_PROTOTYPE_METHOD(constructor, "stop", Stop); 60 | 61 | target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "Signal"), 62 | constructor->GetFunction()); 63 | } 64 | 65 | private: 66 | static void New(const FunctionCallbackInfo& args) { 67 | // This constructor should not be exposed to public javascript. 68 | // Therefore we assert that we are not trying to call this as a 69 | // normal function. 70 | assert(args.IsConstructCall()); 71 | HandleScope handle_scope(args.GetIsolate()); 72 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 73 | new SignalWrap(env, args.This()); 74 | } 75 | 76 | SignalWrap(Environment* env, Handle object) 77 | : HandleWrap(env, 78 | object, 79 | reinterpret_cast(&handle_), 80 | AsyncWrap::PROVIDER_SIGNALWRAP) { 81 | int r = uv_signal_init(env->event_loop(), &handle_); 82 | assert(r == 0); 83 | } 84 | 85 | ~SignalWrap() { 86 | } 87 | 88 | static void Start(const FunctionCallbackInfo& args) { 89 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 90 | HandleScope scope(env->isolate()); 91 | SignalWrap* wrap = Unwrap(args.Holder()); 92 | 93 | int signum = args[0]->Int32Value(); 94 | int err = uv_signal_start(&wrap->handle_, OnSignal, signum); 95 | args.GetReturnValue().Set(err); 96 | } 97 | 98 | static void Stop(const FunctionCallbackInfo& args) { 99 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 100 | HandleScope scope(env->isolate()); 101 | SignalWrap* wrap = Unwrap(args.Holder()); 102 | 103 | int err = uv_signal_stop(&wrap->handle_); 104 | args.GetReturnValue().Set(err); 105 | } 106 | 107 | static void OnSignal(uv_signal_t* handle, int signum) { 108 | SignalWrap* wrap = ContainerOf(&SignalWrap::handle_, handle); 109 | Environment* env = wrap->env(); 110 | HandleScope handle_scope(env->isolate()); 111 | Context::Scope context_scope(env->context()); 112 | 113 | Local arg = Integer::New(env->isolate(), signum); 114 | wrap->MakeCallback(env->onsignal_string(), 1, &arg); 115 | } 116 | 117 | uv_signal_t handle_; 118 | }; 119 | 120 | 121 | } // namespace node 122 | 123 | 124 | NODE_MODULE_CONTEXT_AWARE_BUILTIN(signal_wrap, node::SignalWrap::Initialize) 125 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/smalloc.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_SMALLOC_H_ 23 | #define SRC_SMALLOC_H_ 24 | 25 | #include "node.h" 26 | #include "v8.h" 27 | 28 | namespace node { 29 | 30 | // Forward declaration 31 | class Environment; 32 | 33 | /** 34 | * Simple memory allocator. 35 | * 36 | * Utilities for external memory allocation management. Is an abstraction for 37 | * v8's external array data handling to simplify and centralize how this is 38 | * managed. 39 | */ 40 | namespace smalloc { 41 | 42 | // mirrors deps/v8/src/objects.h 43 | static const unsigned int kMaxLength = 0x3fffffff; 44 | 45 | NODE_EXTERN typedef void (*FreeCallback)(char* data, void* hint); 46 | 47 | /** 48 | * Return byte size of external array type. 49 | */ 50 | NODE_EXTERN size_t ExternalArraySize(enum v8::ExternalArrayType type); 51 | 52 | /** 53 | * Allocate external array data onto obj. 54 | * 55 | * Passed data transfers ownership, and if no callback is passed then memory 56 | * will automatically be free'd using free() (not delete[]). 57 | * 58 | * length is always the byte size of the data. Not the length of the external 59 | * array. This intentionally differs from the JS API so users always know 60 | * exactly how much memory is being allocated, regardless of the external array 61 | * type. For this reason the helper function ExternalArraySize is provided to 62 | * help determine the appropriate byte size to be allocated. 63 | * 64 | * In the following example we're allocating a Float array and setting the 65 | * "length" property on the Object: 66 | * 67 | * \code 68 | * size_t array_length = 8; 69 | * size_t byte_length = node::smalloc::ExternalArraySize( 70 | * v8::kExternalFloatArray); 71 | * v8::Local obj = v8::Object::New(); 72 | * char* data = static_cast(malloc(byte_length * array_length)); 73 | * node::smalloc::Alloc(obj, data, byte_length, v8::kExternalFloatArray); 74 | * obj->Set(v8::String::NewFromUtf8("length"), 75 | * v8::Integer::NewFromUnsigned(array_length)); 76 | * \code 77 | */ 78 | NODE_EXTERN void Alloc(Environment* env, 79 | v8::Handle obj, 80 | size_t length, 81 | enum v8::ExternalArrayType type = 82 | v8::kExternalUnsignedByteArray); 83 | NODE_EXTERN void Alloc(Environment* env, 84 | v8::Handle obj, 85 | char* data, 86 | size_t length, 87 | enum v8::ExternalArrayType type = 88 | v8::kExternalUnsignedByteArray); 89 | NODE_EXTERN void Alloc(Environment* env, 90 | v8::Handle obj, 91 | size_t length, 92 | FreeCallback fn, 93 | void* hint, 94 | enum v8::ExternalArrayType type = 95 | v8::kExternalUnsignedByteArray); 96 | NODE_EXTERN void Alloc(Environment* env, 97 | v8::Handle obj, 98 | char* data, 99 | size_t length, 100 | FreeCallback fn, 101 | void* hint, 102 | enum v8::ExternalArrayType type = 103 | v8::kExternalUnsignedByteArray); 104 | 105 | /** 106 | * Free memory associated with an externally allocated object. If no external 107 | * memory is allocated to the object then nothing will happen. 108 | */ 109 | NODE_EXTERN void AllocDispose(Environment* env, v8::Handle obj); 110 | 111 | 112 | /** 113 | * Check if the Object has externally allocated memory. 114 | */ 115 | NODE_EXTERN bool HasExternalData(Environment* env, v8::Local obj); 116 | 117 | } // namespace smalloc 118 | } // namespace node 119 | 120 | #endif // SRC_SMALLOC_H_ 121 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/tcp_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_TCP_WRAP_H_ 23 | #define SRC_TCP_WRAP_H_ 24 | 25 | #include "env.h" 26 | #include "stream_wrap.h" 27 | 28 | namespace node { 29 | 30 | class TCPWrap : public StreamWrap { 31 | public: 32 | static v8::Local Instantiate(Environment* env); 33 | static void Initialize(v8::Handle target, 34 | v8::Handle unused, 35 | v8::Handle context); 36 | 37 | uv_tcp_t* UVHandle(); 38 | 39 | private: 40 | TCPWrap(Environment* env, v8::Handle object); 41 | ~TCPWrap(); 42 | 43 | static void New(const v8::FunctionCallbackInfo& args); 44 | static void GetSockName(const v8::FunctionCallbackInfo& args); 45 | static void GetPeerName(const v8::FunctionCallbackInfo& args); 46 | static void SetNoDelay(const v8::FunctionCallbackInfo& args); 47 | static void SetKeepAlive(const v8::FunctionCallbackInfo& args); 48 | static void Bind(const v8::FunctionCallbackInfo& args); 49 | static void Bind6(const v8::FunctionCallbackInfo& args); 50 | static void Listen(const v8::FunctionCallbackInfo& args); 51 | static void Connect(const v8::FunctionCallbackInfo& args); 52 | static void Connect6(const v8::FunctionCallbackInfo& args); 53 | static void Open(const v8::FunctionCallbackInfo& args); 54 | 55 | #ifdef _WIN32 56 | static void SetSimultaneousAccepts( 57 | const v8::FunctionCallbackInfo& args); 58 | #endif 59 | 60 | static void OnConnection(uv_stream_t* handle, int status); 61 | static void AfterConnect(uv_connect_t* req, int status); 62 | 63 | uv_tcp_t handle_; 64 | }; 65 | 66 | 67 | } // namespace node 68 | 69 | 70 | #endif // SRC_TCP_WRAP_H_ 71 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/tty_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_TTY_WRAP_H_ 23 | #define SRC_TTY_WRAP_H_ 24 | 25 | #include "env.h" 26 | #include "handle_wrap.h" 27 | #include "stream_wrap.h" 28 | 29 | namespace node { 30 | 31 | class TTYWrap : public StreamWrap { 32 | public: 33 | static void Initialize(v8::Handle target, 34 | v8::Handle unused, 35 | v8::Handle context); 36 | 37 | uv_tty_t* UVHandle(); 38 | 39 | private: 40 | TTYWrap(Environment* env, 41 | v8::Handle object, 42 | int fd, 43 | bool readable); 44 | 45 | static void GuessHandleType(const v8::FunctionCallbackInfo& args); 46 | static void IsTTY(const v8::FunctionCallbackInfo& args); 47 | static void GetWindowSize(const v8::FunctionCallbackInfo& args); 48 | static void SetRawMode(const v8::FunctionCallbackInfo& args); 49 | static void New(const v8::FunctionCallbackInfo& args); 50 | 51 | uv_tty_t handle_; 52 | }; 53 | 54 | } // namespace node 55 | 56 | #endif // SRC_TTY_WRAP_H_ 57 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/udp_wrap.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_UDP_WRAP_H_ 23 | #define SRC_UDP_WRAP_H_ 24 | 25 | #include "env.h" 26 | #include "handle_wrap.h" 27 | #include "req_wrap.h" 28 | #include "uv.h" 29 | #include "v8.h" 30 | 31 | namespace node { 32 | 33 | class UDPWrap: public HandleWrap { 34 | public: 35 | static void Initialize(v8::Handle target, 36 | v8::Handle unused, 37 | v8::Handle context); 38 | static void GetFD(v8::Local, 39 | const v8::PropertyCallbackInfo&); 40 | static void New(const v8::FunctionCallbackInfo& args); 41 | static void Bind(const v8::FunctionCallbackInfo& args); 42 | static void Send(const v8::FunctionCallbackInfo& args); 43 | static void Bind6(const v8::FunctionCallbackInfo& args); 44 | static void Send6(const v8::FunctionCallbackInfo& args); 45 | static void RecvStart(const v8::FunctionCallbackInfo& args); 46 | static void RecvStop(const v8::FunctionCallbackInfo& args); 47 | static void GetSockName(const v8::FunctionCallbackInfo& args); 48 | static void AddMembership(const v8::FunctionCallbackInfo& args); 49 | static void DropMembership(const v8::FunctionCallbackInfo& args); 50 | static void SetMulticastTTL(const v8::FunctionCallbackInfo& args); 51 | static void SetMulticastLoopback( 52 | const v8::FunctionCallbackInfo& args); 53 | static void SetBroadcast(const v8::FunctionCallbackInfo& args); 54 | static void SetTTL(const v8::FunctionCallbackInfo& args); 55 | 56 | static v8::Local Instantiate(Environment* env); 57 | uv_udp_t* UVHandle(); 58 | 59 | private: 60 | UDPWrap(Environment* env, v8::Handle object); 61 | virtual ~UDPWrap(); 62 | 63 | static void DoBind(const v8::FunctionCallbackInfo& args, 64 | int family); 65 | static void DoSend(const v8::FunctionCallbackInfo& args, 66 | int family); 67 | static void SetMembership(const v8::FunctionCallbackInfo& args, 68 | uv_membership membership); 69 | 70 | static void OnAlloc(uv_handle_t* handle, 71 | size_t suggested_size, 72 | uv_buf_t* buf); 73 | static void OnSend(uv_udp_send_t* req, int status); 74 | static void OnRecv(uv_udp_t* handle, 75 | ssize_t nread, 76 | const uv_buf_t* buf, 77 | const struct sockaddr* addr, 78 | unsigned int flags); 79 | 80 | uv_udp_t handle_; 81 | }; 82 | 83 | } // namespace node 84 | 85 | #endif // SRC_UDP_WRAP_H_ 86 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/util-inl.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_UTIL_INL_H_ 23 | #define SRC_UTIL_INL_H_ 24 | 25 | #include "util.h" 26 | 27 | #include 28 | 29 | namespace node { 30 | 31 | template 32 | ContainerOfHelper::ContainerOfHelper(Inner Outer::*field, 33 | Inner* pointer) 34 | : pointer_(reinterpret_cast( 35 | reinterpret_cast(pointer) - 36 | reinterpret_cast(&(static_cast(0)->*field)))) { 37 | } 38 | 39 | template 40 | template 41 | ContainerOfHelper::operator TypeName*() const { 42 | return static_cast(pointer_); 43 | } 44 | 45 | template 46 | inline ContainerOfHelper ContainerOf(Inner Outer::*field, 47 | Inner* pointer) { 48 | return ContainerOfHelper(field, pointer); 49 | } 50 | 51 | template 52 | inline v8::Local PersistentToLocal( 53 | v8::Isolate* isolate, 54 | const v8::Persistent& persistent) { 55 | if (persistent.IsWeak()) { 56 | return WeakPersistentToLocal(isolate, persistent); 57 | } else { 58 | return StrongPersistentToLocal(persistent); 59 | } 60 | } 61 | 62 | template 63 | inline v8::Local StrongPersistentToLocal( 64 | const v8::Persistent& persistent) { 65 | return *reinterpret_cast*>( 66 | const_cast*>(&persistent)); 67 | } 68 | 69 | template 70 | inline v8::Local WeakPersistentToLocal( 71 | v8::Isolate* isolate, 72 | const v8::Persistent& persistent) { 73 | return v8::Local::New(isolate, persistent); 74 | } 75 | 76 | inline v8::Local OneByteString(v8::Isolate* isolate, 77 | const char* data, 78 | int length) { 79 | return v8::String::NewFromOneByte(isolate, 80 | reinterpret_cast(data), 81 | v8::String::kNormalString, 82 | length); 83 | } 84 | 85 | inline v8::Local OneByteString(v8::Isolate* isolate, 86 | const signed char* data, 87 | int length) { 88 | return v8::String::NewFromOneByte(isolate, 89 | reinterpret_cast(data), 90 | v8::String::kNormalString, 91 | length); 92 | } 93 | 94 | inline v8::Local OneByteString(v8::Isolate* isolate, 95 | const unsigned char* data, 96 | int length) { 97 | return v8::String::NewFromOneByte(isolate, 98 | reinterpret_cast(data), 99 | v8::String::kNormalString, 100 | length); 101 | } 102 | 103 | template 104 | void Wrap(v8::Local object, TypeName* pointer) { 105 | assert(!object.IsEmpty()); 106 | assert(object->InternalFieldCount() > 0); 107 | object->SetAlignedPointerInInternalField(0, pointer); 108 | } 109 | 110 | void ClearWrap(v8::Local object) { 111 | Wrap(object, NULL); 112 | } 113 | 114 | template 115 | TypeName* Unwrap(v8::Local object) { 116 | assert(!object.IsEmpty()); 117 | assert(object->InternalFieldCount() > 0); 118 | void* pointer = object->GetAlignedPointerFromInternalField(0); 119 | return static_cast(pointer); 120 | } 121 | 122 | } // namespace node 123 | 124 | #endif // SRC_UTIL_INL_H_ 125 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/util.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "util.h" 23 | 24 | #include "string_bytes.h" 25 | 26 | namespace node { 27 | 28 | Utf8Value::Utf8Value(v8::Handle value) 29 | : length_(0), str_(NULL) { 30 | if (value.IsEmpty()) 31 | return; 32 | 33 | v8::Local val_ = value->ToString(); 34 | 35 | // Allocate enough space to include the null terminator 36 | size_t len = StringBytes::StorageSize(val_, UTF8) + 1; 37 | 38 | char* str = static_cast(calloc(1, len)); 39 | 40 | int flags = WRITE_UTF8_FLAGS; 41 | flags |= ~v8::String::NO_NULL_TERMINATION; 42 | 43 | length_ = val_->WriteUtf8(str, 44 | len, 45 | 0, 46 | flags); 47 | 48 | str_ = reinterpret_cast(str); 49 | } 50 | } // namespace node 51 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/util.h: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #ifndef SRC_UTIL_H_ 23 | #define SRC_UTIL_H_ 24 | 25 | #include "v8.h" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace node { 32 | 33 | #define FIXED_ONE_BYTE_STRING(isolate, string) \ 34 | (node::OneByteString((isolate), (string), sizeof(string) - 1)) 35 | 36 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ 37 | void operator=(const TypeName&); \ 38 | TypeName(const TypeName&) 39 | 40 | #if defined(NDEBUG) 41 | # define ASSERT(expression) 42 | # define CHECK(expression) \ 43 | do { \ 44 | if (!(expression)) abort(); \ 45 | } while (0) 46 | #else 47 | # define ASSERT(expression) assert(expression) 48 | # define CHECK(expression) assert(expression) 49 | #endif 50 | 51 | #define CHECK_EQ(a, b) CHECK((a) == (b)) 52 | #define CHECK_GE(a, b) CHECK((a) >= (b)) 53 | #define CHECK_GT(a, b) CHECK((a) > (b)) 54 | #define CHECK_LE(a, b) CHECK((a) <= (b)) 55 | #define CHECK_LT(a, b) CHECK((a) < (b)) 56 | #define CHECK_NE(a, b) CHECK((a) != (b)) 57 | 58 | #define UNREACHABLE() abort() 59 | 60 | // The helper is for doing safe downcasts from base types to derived types. 61 | template 62 | class ContainerOfHelper { 63 | public: 64 | inline ContainerOfHelper(Inner Outer::*field, Inner* pointer); 65 | template 66 | inline operator TypeName*() const; 67 | private: 68 | Outer* const pointer_; 69 | }; 70 | 71 | // Calculate the address of the outer (i.e. embedding) struct from 72 | // the interior pointer to a data member. 73 | template 74 | inline ContainerOfHelper ContainerOf(Inner Outer::*field, 75 | Inner* pointer); 76 | 77 | // If persistent.IsWeak() == false, then do not call persistent.Reset() 78 | // while the returned Local is still in scope, it will destroy the 79 | // reference to the object. 80 | template 81 | inline v8::Local PersistentToLocal( 82 | v8::Isolate* isolate, 83 | const v8::Persistent& persistent); 84 | 85 | // Unchecked conversion from a non-weak Persistent to Local, 86 | // use with care! 87 | // 88 | // Do not call persistent.Reset() while the returned Local is still in 89 | // scope, it will destroy the reference to the object. 90 | template 91 | inline v8::Local StrongPersistentToLocal( 92 | const v8::Persistent& persistent); 93 | 94 | template 95 | inline v8::Local WeakPersistentToLocal( 96 | v8::Isolate* isolate, 97 | const v8::Persistent& persistent); 98 | 99 | // Convenience wrapper around v8::String::NewFromOneByte(). 100 | inline v8::Local OneByteString(v8::Isolate* isolate, 101 | const char* data, 102 | int length = -1); 103 | 104 | // For the people that compile with -funsigned-char. 105 | inline v8::Local OneByteString(v8::Isolate* isolate, 106 | const signed char* data, 107 | int length = -1); 108 | 109 | inline v8::Local OneByteString(v8::Isolate* isolate, 110 | const unsigned char* data, 111 | int length = -1); 112 | 113 | inline void Wrap(v8::Local object, void* pointer); 114 | 115 | inline void ClearWrap(v8::Local object); 116 | 117 | template 118 | inline TypeName* Unwrap(v8::Local object); 119 | 120 | class Utf8Value { 121 | public: 122 | explicit Utf8Value(v8::Handle value); 123 | 124 | ~Utf8Value() { 125 | free(str_); 126 | } 127 | 128 | char* operator*() { 129 | return str_; 130 | }; 131 | 132 | const char* operator*() const { 133 | return str_; 134 | }; 135 | 136 | size_t length() const { 137 | return length_; 138 | }; 139 | 140 | private: 141 | size_t length_; 142 | char* str_; 143 | }; 144 | 145 | } // namespace node 146 | 147 | #endif // SRC_UTIL_H_ 148 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/uv.cc: -------------------------------------------------------------------------------- 1 | // Copyright Joyent, Inc. and other Node contributors. 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the 5 | // "Software"), to deal in the Software without restriction, including 6 | // without limitation the rights to use, copy, modify, merge, publish, 7 | // distribute, sublicense, and/or sell copies of the Software, and to permit 8 | // persons to whom the Software is furnished to do so, subject to the 9 | // following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included 12 | // in all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #include "uv.h" 23 | #include "node.h" 24 | #include "env.h" 25 | #include "env-inl.h" 26 | 27 | namespace node { 28 | namespace uv { 29 | 30 | using v8::Context; 31 | using v8::FunctionCallbackInfo; 32 | using v8::FunctionTemplate; 33 | using v8::Handle; 34 | using v8::HandleScope; 35 | using v8::Integer; 36 | using v8::Object; 37 | using v8::String; 38 | using v8::Value; 39 | 40 | 41 | void ErrName(const FunctionCallbackInfo& args) { 42 | Environment* env = Environment::GetCurrent(args.GetIsolate()); 43 | HandleScope scope(env->isolate()); 44 | int err = args[0]->Int32Value(); 45 | if (err >= 0) 46 | return env->ThrowError("err >= 0"); 47 | const char* name = uv_err_name(err); 48 | args.GetReturnValue().Set(OneByteString(env->isolate(), name)); 49 | } 50 | 51 | 52 | void Initialize(Handle target, 53 | Handle unused, 54 | Handle context) { 55 | Environment* env = Environment::GetCurrent(context); 56 | target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "errname"), 57 | FunctionTemplate::New(env->isolate(), ErrName)->GetFunction()); 58 | #define V(name, _) \ 59 | target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UV_" # name), \ 60 | Integer::New(env->isolate(), UV_ ## name)); 61 | UV_ERRNO_MAP(V) 62 | #undef V 63 | } 64 | 65 | 66 | } // namespace uv 67 | } // namespace node 68 | 69 | NODE_MODULE_CONTEXT_AWARE_BUILTIN(uv, node::uv::Initialize) 70 | -------------------------------------------------------------------------------- /gSpiderMac/nodejs/nodejs/src/v8abbr.h: -------------------------------------------------------------------------------- 1 | /** Copyright Joyent, Inc. and other Node contributors. 2 | * 3 | * Permission is hereby granted, free of charge, to any person obtaining a 4 | * copy of this software and associated documentation files (the 5 | * "Software"), to deal in the Software without restriction, including 6 | * without limitation the rights to use, copy, modify, merge, publish, 7 | * distribute, sublicense, and/or sell copies of the Software, and to permit 8 | * persons to whom the Software is furnished to do so, subject to the 9 | * following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 17 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /* 24 | * This header defines short names for V8 constants for use by the ustack 25 | * helper. 26 | */ 27 | 28 | #ifndef SRC_V8ABBR_H_ 29 | #define SRC_V8ABBR_H_ 30 | 31 | /* Frame pointer offsets */ 32 | #define V8_OFF_FP_FUNC V8DBG_OFF_FP_FUNCTION 33 | #define V8_OFF_FP_CONTEXT V8DBG_OFF_FP_CONTEXT 34 | #define V8_OFF_FP_MARKER V8DBG_OFF_FP_MARKER 35 | 36 | /* Stack frame types */ 37 | #define V8_FT_ENTRY V8DBG_FRAMETYPE_ENTRYFRAME 38 | #define V8_FT_ENTRYCONSTRUCT V8DBG_FRAMETYPE_ENTRYCONSTRUCTFRAME 39 | #define V8_FT_EXIT V8DBG_FRAMETYPE_EXITFRAME 40 | #define V8_FT_JAVASCRIPT V8DBG_FRAMETYPE_JAVASCRIPTFRAME 41 | #define V8_FT_OPTIMIZED V8DBG_FRAMETYPE_OPTIMIZEDFRAME 42 | #define V8_FT_INTERNAL V8DBG_FRAMETYPE_INTERNALFRAME 43 | #define V8_FT_CONSTRUCT V8DBG_FRAMETYPE_CONSTRUCTFRAME 44 | #define V8_FT_ADAPTOR V8DBG_FRAMETYPE_ARGUMENTSADAPTORFRAME 45 | #define V8_FT_STUB V8DBG_FRAMETYPE_STUBFRAME 46 | 47 | /* Identification masks and tags */ 48 | #define V8_SmiTagMask (V8DBG_SMITAGMASK) 49 | #define V8_SmiTag (V8DBG_SMITAG) 50 | #define V8_SmiValueShift (V8DBG_SMISHIFTSIZE + V8DBG_SMITAGMASK) 51 | 52 | #define V8_HeapObjectTagMask V8DBG_HEAPOBJECTTAGMASK 53 | #define V8_HeapObjectTag V8DBG_HEAPOBJECTTAG 54 | 55 | #define V8_IsNotStringMask V8DBG_ISNOTSTRINGMASK 56 | #define V8_StringTag V8DBG_STRINGTAG 57 | 58 | #define V8_StringEncodingMask V8DBG_STRINGENCODINGMASK 59 | #define V8_AsciiStringTag V8DBG_ASCIISTRINGTAG 60 | 61 | #define V8_StringRepresentationMask V8DBG_STRINGREPRESENTATIONMASK 62 | #define V8_SeqStringTag V8DBG_SEQSTRINGTAG 63 | #define V8_ConsStringTag V8DBG_CONSSTRINGTAG 64 | #define V8_ExternalStringTag V8DBG_EXTERNALSTRINGTAG 65 | 66 | /* Instance types */ 67 | #define V8_IT_FIXEDARRAY V8DBG_TYPE_FIXEDARRAY__FIXED_ARRAY_TYPE 68 | #define V8_IT_CODE V8DBG_TYPE_CODE__CODE_TYPE 69 | #define V8_IT_SCRIPT V8DBG_TYPE_SCRIPT__SCRIPT_TYPE 70 | 71 | /* Node-specific offsets */ 72 | #define NODE_OFF_EXTSTR_DATA sizeof(void*) 73 | 74 | /* 75 | * Not all versions of V8 have the offset for the "chars" array in the 76 | * SeqTwoByteString class, but it's the same as the one for SeqOneByteString. 77 | */ 78 | #ifndef V8DBG_CLASS_SEQTWOBYTESTRING__CHARS__CHAR 79 | #define V8DBG_CLASS_SEQTWOBYTESTRING__CHARS__CHAR V8DBG_CLASS_SEQONEBYTESTRING__CHARS__CHAR 80 | #endif 81 | 82 | /* Heap class->field offsets */ 83 | #define V8_OFF_HEAP(off) ((off) - 1) 84 | 85 | #define V8_OFF_FUNC_SHARED \ 86 | V8_OFF_HEAP(V8DBG_CLASS_JSFUNCTION__SHARED__SHAREDFUNCTIONINFO) 87 | #define V8_OFF_SHARED_NAME \ 88 | V8_OFF_HEAP(V8DBG_CLASS_SHAREDFUNCTIONINFO__NAME__OBJECT) 89 | #define V8_OFF_SHARED_INFERRED \ 90 | V8_OFF_HEAP(V8DBG_CLASS_SHAREDFUNCTIONINFO__INFERRED_NAME__STRING) 91 | #define V8_OFF_SHARED_SCRIPT \ 92 | V8_OFF_HEAP(V8DBG_CLASS_SHAREDFUNCTIONINFO__SCRIPT__OBJECT) 93 | #define V8_OFF_SHARED_FUNTOK \ 94 | V8_OFF_HEAP(V8DBG_CLASS_SHAREDFUNCTIONINFO__FUNCTION_TOKEN_POSITION__SMI) 95 | #define V8_OFF_SCRIPT_NAME \ 96 | V8_OFF_HEAP(V8DBG_CLASS_SCRIPT__NAME__OBJECT) 97 | #define V8_OFF_SCRIPT_LENDS \ 98 | V8_OFF_HEAP(V8DBG_CLASS_SCRIPT__LINE_ENDS__OBJECT) 99 | #define V8_OFF_STR_LENGTH \ 100 | V8_OFF_HEAP(V8DBG_CLASS_STRING__LENGTH__SMI) 101 | #define V8_OFF_STR_CHARS \ 102 | V8_OFF_HEAP(V8DBG_CLASS_SEQONEBYTESTRING__CHARS__CHAR) 103 | #define V8_OFF_CONSSTR_CAR \ 104 | V8_OFF_HEAP(V8DBG_CLASS_CONSSTRING__FIRST__STRING) 105 | #define V8_OFF_CONSSTR_CDR \ 106 | V8_OFF_HEAP(V8DBG_CLASS_CONSSTRING__SECOND__STRING) 107 | #define V8_OFF_EXTSTR_RSRC \ 108 | V8_OFF_HEAP(V8DBG_CLASS_EXTERNALSTRING__RESOURCE__OBJECT) 109 | #define V8_OFF_FA_SIZE \ 110 | V8_OFF_HEAP(V8DBG_CLASS_FIXEDARRAYBASE__LENGTH__SMI) 111 | #define V8_OFF_FA_DATA \ 112 | V8_OFF_HEAP(V8DBG_CLASS_FIXEDARRAY__DATA__UINTPTR_T) 113 | #define V8_OFF_HEAPOBJ_MAP \ 114 | V8_OFF_HEAP(V8DBG_CLASS_HEAPOBJECT__MAP__MAP) 115 | #define V8_OFF_MAP_ATTRS \ 116 | V8_OFF_HEAP(V8DBG_CLASS_MAP__INSTANCE_ATTRIBUTES__INT) 117 | #define V8_OFF_TWOBYTESTR_CHARS \ 118 | V8_OFF_HEAP(V8DBG_CLASS_SEQTWOBYTESTRING__CHARS__CHAR) 119 | 120 | #endif /* SRC_V8ABBR_H_ */ 121 | -------------------------------------------------------------------------------- /gSpiderMac/readme: -------------------------------------------------------------------------------- 1 | init 2 | -------------------------------------------------------------------------------- /gSpiderMac/test/demo_get2.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gSpiderMac/test/get.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38 | 39 | 40 | 41 | 42 |
43 |
44 | ttttt 45 | BBBBBBBB 46 | CCCCCCCC 47 |
48 |
49 | 50 |
51 | TTTTTTTTTT 52 |
53 | 54 | -------------------------------------------------------------------------------- /gSpiderMac/testv8/testv8.xcodeproj/xcuserdata/reich.xcuserdatad/xcschemes/testv8.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 53 | 59 | 60 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /gSpiderMac/testv8/testv8.xcodeproj/xcuserdata/reich.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | testv8.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | C0E220D51A1AE1B10050FD49 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | --------------------------------------------------------------------------------