diff --git a/native/build/cocos2d_libs.xcodeproj/project.pbxproj b/native/build/cocos2d_libs.xcodeproj/project.pbxproj index 80b08ceaaf..b83c15f621 100644 --- a/native/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/native/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -107,33 +107,140 @@ 1A29D785205666B200168D9A /* LocalStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D781205666B100168D9A /* LocalStorage.cpp */; }; 1A29D788205666B200168D9A /* LocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D783205666B100168D9A /* LocalStorage.h */; }; 1A29D789205666B200168D9A /* LocalStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D783205666B100168D9A /* LocalStorage.h */; }; - 1A29D792205666F500168D9A /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78A205666F100168D9A /* jsb_opengl_manual.cpp */; }; - 1A29D793205666F500168D9A /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78A205666F100168D9A /* jsb_opengl_manual.cpp */; }; - 1A29D794205666F500168D9A /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78B205666F200168D9A /* jsb_opengl_registration.cpp */; }; - 1A29D795205666F500168D9A /* jsb_opengl_registration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78B205666F200168D9A /* jsb_opengl_registration.cpp */; }; + 1A29D794205666F500168D9A /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78B205666F200168D9A /* jsb_opengl_manual.cpp */; }; + 1A29D795205666F500168D9A /* jsb_opengl_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78B205666F200168D9A /* jsb_opengl_manual.cpp */; }; 1A29D796205666F500168D9A /* jsb_opengl_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78C205666F200168D9A /* jsb_opengl_utils.cpp */; }; 1A29D797205666F500168D9A /* jsb_opengl_utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D78C205666F200168D9A /* jsb_opengl_utils.cpp */; }; - 1A29D798205666F500168D9A /* jsb_opengl_functions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D78D205666F200168D9A /* jsb_opengl_functions.hpp */; }; - 1A29D799205666F500168D9A /* jsb_opengl_functions.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D78D205666F200168D9A /* jsb_opengl_functions.hpp */; }; 1A29D79A205666F500168D9A /* jsb_opengl_utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D78E205666F200168D9A /* jsb_opengl_utils.hpp */; }; 1A29D79B205666F500168D9A /* jsb_opengl_utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D78E205666F200168D9A /* jsb_opengl_utils.hpp */; }; - 1A29D79C205666F500168D9A /* jsb_opengl_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D78F205666F200168D9A /* jsb_opengl_manual.hpp */; }; - 1A29D79D205666F500168D9A /* jsb_opengl_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D78F205666F200168D9A /* jsb_opengl_manual.hpp */; }; - 1A29D79E205666F500168D9A /* jsb_opengl_registration.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D790205666F500168D9A /* jsb_opengl_registration.hpp */; }; - 1A29D79F205666F500168D9A /* jsb_opengl_registration.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D790205666F500168D9A /* jsb_opengl_registration.hpp */; }; - 1A29D7A0205666F500168D9A /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D791205666F500168D9A /* jsb_opengl_functions.cpp */; }; - 1A29D7A1205666F500168D9A /* jsb_opengl_functions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A29D791205666F500168D9A /* jsb_opengl_functions.cpp */; }; + 1A29D79E205666F500168D9A /* jsb_opengl_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D790205666F500168D9A /* jsb_opengl_manual.hpp */; }; + 1A29D79F205666F500168D9A /* jsb_opengl_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D790205666F500168D9A /* jsb_opengl_manual.hpp */; }; 1A29D7A320566CAC00168D9A /* CCCanvasRenderingContext2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D7A220566CAB00168D9A /* CCCanvasRenderingContext2D.h */; }; 1A29D7A420566CAC00168D9A /* CCCanvasRenderingContext2D.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A29D7A220566CAB00168D9A /* CCCanvasRenderingContext2D.h */; }; 1A37E9C5200DD0680078AF72 /* CCReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A37E9C3200DD0680078AF72 /* CCReachability.h */; }; 1A37E9C6200DD0680078AF72 /* CCReachability.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A37E9C4200DD0680078AF72 /* CCReachability.cpp */; }; 1A37E9C7200DDFC70078AF72 /* CCReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A37E9C3200DD0680078AF72 /* CCReachability.h */; }; 1A37E9C8200DDFC90078AF72 /* CCReachability.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A37E9C4200DD0680078AF72 /* CCReachability.cpp */; }; + 1A52DAF6205BB81400350EE3 /* CCThreadPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DAF4205BB81400350EE3 /* CCThreadPool.h */; }; + 1A52DAF7205BB81400350EE3 /* CCThreadPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DAF4205BB81400350EE3 /* CCThreadPool.h */; }; + 1A52DAF8205BB81400350EE3 /* CCThreadPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DAF5205BB81400350EE3 /* CCThreadPool.cpp */; }; + 1A52DAF9205BB81400350EE3 /* CCThreadPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DAF5205BB81400350EE3 /* CCThreadPool.cpp */; }; + 1A52DB21205BCD9200350EE3 /* inspector_socket_server.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DAFB205BCD9200350EE3 /* inspector_socket_server.h */; }; + 1A52DB22205BCD9200350EE3 /* env.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DAFC205BCD9200350EE3 /* env.h */; }; + 1A52DB23205BCD9200350EE3 /* Class.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DAFD205BCD9200350EE3 /* Class.hpp */; }; + 1A52DB24205BCD9200350EE3 /* ObjectWrap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DAFE205BCD9200350EE3 /* ObjectWrap.cpp */; }; + 1A52DB25205BCD9200350EE3 /* HelperMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DAFF205BCD9200350EE3 /* HelperMacros.h */; }; + 1A52DB26205BCD9200350EE3 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB00205BCD9200350EE3 /* Utils.cpp */; }; + 1A52DB27205BCD9200350EE3 /* node.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB01205BCD9200350EE3 /* node.cc */; }; + 1A52DB28205BCD9200350EE3 /* inspector_agent.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB02205BCD9200350EE3 /* inspector_agent.h */; }; + 1A52DB29205BCD9200350EE3 /* base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB03205BCD9200350EE3 /* base64.h */; }; + 1A52DB2A205BCD9200350EE3 /* inspector_io.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB04205BCD9200350EE3 /* inspector_io.h */; }; + 1A52DB2B205BCD9200350EE3 /* inspector_socket_server.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB05205BCD9200350EE3 /* inspector_socket_server.cc */; }; + 1A52DB2C205BCD9200350EE3 /* node_mutex.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB06205BCD9200350EE3 /* node_mutex.h */; }; + 1A52DB2D205BCD9200350EE3 /* ObjectWrap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB07205BCD9200350EE3 /* ObjectWrap.h */; }; + 1A52DB2E205BCD9200350EE3 /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB08205BCD9200350EE3 /* Object.cpp */; }; + 1A52DB2F205BCD9200350EE3 /* http_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB09205BCD9200350EE3 /* http_parser.h */; }; + 1A52DB30205BCD9200350EE3 /* ScriptEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB0A205BCD9200350EE3 /* ScriptEngine.cpp */; }; + 1A52DB31205BCD9200350EE3 /* inspector_agent.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB0B205BCD9200350EE3 /* inspector_agent.cc */; }; + 1A52DB32205BCD9200350EE3 /* SHA1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB0C205BCD9200350EE3 /* SHA1.cpp */; }; + 1A52DB33205BCD9200350EE3 /* node.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB0D205BCD9200350EE3 /* node.h */; }; + 1A52DB34205BCD9200350EE3 /* Object.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB0F205BCD9200350EE3 /* Object.hpp */; }; + 1A52DB35205BCD9200350EE3 /* util.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB10205BCD9200350EE3 /* util.cc */; }; + 1A52DB36205BCD9200350EE3 /* util-inl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB11205BCD9200350EE3 /* util-inl.h */; }; + 1A52DB37205BCD9200350EE3 /* inspector_socket.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB12205BCD9200350EE3 /* inspector_socket.cc */; }; + 1A52DB38205BCD9200350EE3 /* ScriptEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB13205BCD9200350EE3 /* ScriptEngine.hpp */; }; + 1A52DB39205BCD9200350EE3 /* inspector_io.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB14205BCD9200350EE3 /* inspector_io.cc */; }; + 1A52DB3A205BCD9200350EE3 /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB15205BCD9200350EE3 /* util.h */; }; + 1A52DB3B205BCD9200350EE3 /* v8_inspector_protocol_json.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB16205BCD9200350EE3 /* v8_inspector_protocol_json.h */; }; + 1A52DB3C205BCD9200350EE3 /* SHA1.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB17205BCD9200350EE3 /* SHA1.h */; }; + 1A52DB3D205BCD9200350EE3 /* SeApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB18205BCD9200350EE3 /* SeApi.h */; }; + 1A52DB3E205BCD9200350EE3 /* Class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB19205BCD9200350EE3 /* Class.cpp */; }; + 1A52DB3F205BCD9200350EE3 /* http_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB1A205BCD9200350EE3 /* http_parser.c */; }; + 1A52DB40205BCD9200350EE3 /* inspector_socket.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB1B205BCD9200350EE3 /* inspector_socket.h */; }; + 1A52DB41205BCD9200350EE3 /* node_debug_options.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB1C205BCD9200350EE3 /* node_debug_options.cc */; }; + 1A52DB42205BCD9200350EE3 /* Utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB1D205BCD9200350EE3 /* Utils.hpp */; }; + 1A52DB43205BCD9200350EE3 /* node_debug_options.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB1E205BCD9200350EE3 /* node_debug_options.h */; }; + 1A52DB44205BCD9200350EE3 /* env.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB1F205BCD9200350EE3 /* env.cc */; }; + 1A52DB45205BCD9200350EE3 /* Base.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB20205BCD9200350EE3 /* Base.h */; }; + 1A52DB5E205BCDC700350EE3 /* Class.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB47205BCDC700350EE3 /* Class.hpp */; }; + 1A52DB5F205BCDC700350EE3 /* HelperMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB48205BCDC700350EE3 /* HelperMacros.h */; }; + 1A52DB60205BCDC700350EE3 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB49205BCDC700350EE3 /* Utils.cpp */; }; + 1A52DB61205BCDC700350EE3 /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB4A205BCDC700350EE3 /* Object.cpp */; }; + 1A52DB62205BCDC700350EE3 /* ScriptEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB4B205BCDC700350EE3 /* ScriptEngine.cpp */; }; + 1A52DB63205BCDC700350EE3 /* Object.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB4C205BCDC700350EE3 /* Object.hpp */; }; + 1A52DB64205BCDC700350EE3 /* ScriptEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB4D205BCDC700350EE3 /* ScriptEngine.hpp */; }; + 1A52DB65205BCDC700350EE3 /* SeApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB4E205BCDC700350EE3 /* SeApi.h */; }; + 1A52DB66205BCDC700350EE3 /* Class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB4F205BCDC700350EE3 /* Class.cpp */; }; + 1A52DB67205BCDC700350EE3 /* Utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB50205BCDC700350EE3 /* Utils.hpp */; }; + 1A52DB68205BCDC700350EE3 /* Base.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB51205BCDC700350EE3 /* Base.h */; }; + 1A52DB69205BCDC700350EE3 /* Class.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB53205BCDC700350EE3 /* Class.hpp */; }; + 1A52DB6A205BCDC700350EE3 /* HelperMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB54205BCDC700350EE3 /* HelperMacros.h */; }; + 1A52DB6B205BCDC700350EE3 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB55205BCDC700350EE3 /* Utils.cpp */; }; + 1A52DB6C205BCDC700350EE3 /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB56205BCDC700350EE3 /* Object.cpp */; }; + 1A52DB6D205BCDC700350EE3 /* ScriptEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB57205BCDC700350EE3 /* ScriptEngine.cpp */; }; + 1A52DB6E205BCDC700350EE3 /* Object.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB58205BCDC700350EE3 /* Object.hpp */; }; + 1A52DB6F205BCDC700350EE3 /* ScriptEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB59205BCDC700350EE3 /* ScriptEngine.hpp */; }; + 1A52DB70205BCDC700350EE3 /* SeApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB5A205BCDC700350EE3 /* SeApi.h */; }; + 1A52DB71205BCDC700350EE3 /* Class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB5B205BCDC700350EE3 /* Class.cpp */; }; + 1A52DB72205BCDC700350EE3 /* Utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB5C205BCDC700350EE3 /* Utils.hpp */; }; + 1A52DB73205BCDC700350EE3 /* Base.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB5D205BCDC700350EE3 /* Base.h */; }; + 1A52DB74205BCDD000350EE3 /* Base.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB5D205BCDC700350EE3 /* Base.h */; }; + 1A52DB75205BCDD000350EE3 /* Class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB5B205BCDC700350EE3 /* Class.cpp */; }; + 1A52DB76205BCDD000350EE3 /* Class.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB53205BCDC700350EE3 /* Class.hpp */; }; + 1A52DB77205BCDD000350EE3 /* HelperMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB54205BCDC700350EE3 /* HelperMacros.h */; }; + 1A52DB78205BCDD000350EE3 /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB56205BCDC700350EE3 /* Object.cpp */; }; + 1A52DB79205BCDD000350EE3 /* Object.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB58205BCDC700350EE3 /* Object.hpp */; }; + 1A52DB7A205BCDD000350EE3 /* ScriptEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB57205BCDC700350EE3 /* ScriptEngine.cpp */; }; + 1A52DB7B205BCDD000350EE3 /* ScriptEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB59205BCDC700350EE3 /* ScriptEngine.hpp */; }; + 1A52DB7C205BCDD000350EE3 /* SeApi.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB5A205BCDC700350EE3 /* SeApi.h */; }; + 1A52DB7D205BCDD000350EE3 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB55205BCDC700350EE3 /* Utils.cpp */; }; + 1A52DB7E205BCDD000350EE3 /* Utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB5C205BCDC700350EE3 /* Utils.hpp */; }; + 1A52DB882060B11800350EE3 /* jsb_platfrom_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB862060B11800350EE3 /* jsb_platfrom_apple.mm */; }; + 1A52DB892060B11800350EE3 /* jsb_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB872060B11800350EE3 /* jsb_platform.h */; }; + 1A52DB8C2060B12600350EE3 /* jsb_platform_ios.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A52DB8A2060B12500350EE3 /* jsb_platform_ios.h */; }; + 1A52DB8D2060B12600350EE3 /* jsb_platfrom_ios.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB8B2060B12600350EE3 /* jsb_platfrom_ios.mm */; }; + 1A52DB8E2060DEF500350EE3 /* jsb_platfrom_apple.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A52DB862060B11800350EE3 /* jsb_platfrom_apple.mm */; }; + 1A586C432064C90500B47573 /* EJConvertTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A586C412064C90500B47573 /* EJConvertTypedArray.h */; }; + 1A586C442064C90500B47573 /* EJConvertTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A586C412064C90500B47573 /* EJConvertTypedArray.h */; }; + 1A586C452064C90500B47573 /* EJConvertTypedArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A586C422064C90500B47573 /* EJConvertTypedArray.m */; }; + 1A586C462064C90500B47573 /* EJConvertTypedArray.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A586C422064C90500B47573 /* EJConvertTypedArray.m */; }; + 1A586C492064C97800B47573 /* EJConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A586C472064C97800B47573 /* EJConvert.h */; }; + 1A586C4A2064C97800B47573 /* EJConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A586C472064C97800B47573 /* EJConvert.h */; }; + 1A586C4B2064C97800B47573 /* EJConvert.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A586C482064C97800B47573 /* EJConvert.m */; }; + 1A586C4C2064C97800B47573 /* EJConvert.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A586C482064C97800B47573 /* EJConvert.m */; }; 1A9A4C6E1F98B1C000C14552 /* libcocosanalytics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A9A4C6D1F98B1C000C14552 /* libcocosanalytics.a */; }; 1A9F0F971F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9F0F951F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp */; }; 1A9F0F981F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A9F0F951F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp */; }; 1A9F0F991F301DE200A499E1 /* b2ObjectDestroyNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9F0F961F301DE200A499E1 /* b2ObjectDestroyNotifier.h */; }; 1A9F0F9A1F301DE200A499E1 /* b2ObjectDestroyNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A9F0F961F301DE200A499E1 /* b2ObjectDestroyNotifier.h */; }; + 1AAAC873205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC871205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp */; }; + 1AAAC874205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC871205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp */; }; + 1AAAC875205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC872205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp */; }; + 1AAAC876205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC872205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp */; }; + 1AAAC8DF205CB6E9005321B9 /* AudioDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC879205CB6E9005321B9 /* AudioDecoder.h */; }; + 1AAAC8E0205CB6E9005321B9 /* AudioDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC879205CB6E9005321B9 /* AudioDecoder.h */; }; + 1AAAC8E1205CB6E9005321B9 /* AudioPlayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87A205CB6E9005321B9 /* AudioPlayer.mm */; }; + 1AAAC8E2205CB6E9005321B9 /* AudioPlayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87A205CB6E9005321B9 /* AudioPlayer.mm */; }; + 1AAAC8E3205CB6E9005321B9 /* AudioDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87B205CB6E9005321B9 /* AudioDecoder.mm */; }; + 1AAAC8E4205CB6E9005321B9 /* AudioDecoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87B205CB6E9005321B9 /* AudioDecoder.mm */; }; + 1AAAC8E5205CB6E9005321B9 /* AudioPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC87C205CB6E9005321B9 /* AudioPlayer.h */; }; + 1AAAC8E6205CB6E9005321B9 /* AudioPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC87C205CB6E9005321B9 /* AudioPlayer.h */; }; + 1AAAC8E7205CB6E9005321B9 /* AudioEngine-inl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87D205CB6E9005321B9 /* AudioEngine-inl.mm */; }; + 1AAAC8E8205CB6E9005321B9 /* AudioEngine-inl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87D205CB6E9005321B9 /* AudioEngine-inl.mm */; }; + 1AAAC8E9205CB6E9005321B9 /* AudioMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC87E205CB6E9005321B9 /* AudioMacros.h */; }; + 1AAAC8EA205CB6E9005321B9 /* AudioMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC87E205CB6E9005321B9 /* AudioMacros.h */; }; + 1AAAC8EB205CB6E9005321B9 /* AudioCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87F205CB6E9005321B9 /* AudioCache.mm */; }; + 1AAAC8EC205CB6E9005321B9 /* AudioCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC87F205CB6E9005321B9 /* AudioCache.mm */; }; + 1AAAC8ED205CB6E9005321B9 /* AudioCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC880205CB6E9005321B9 /* AudioCache.h */; }; + 1AAAC8EE205CB6E9005321B9 /* AudioCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC880205CB6E9005321B9 /* AudioCache.h */; }; + 1AAAC8EF205CB6E9005321B9 /* AudioEngine-inl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC881205CB6E9005321B9 /* AudioEngine-inl.h */; }; + 1AAAC8F0205CB6E9005321B9 /* AudioEngine-inl.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC881205CB6E9005321B9 /* AudioEngine-inl.h */; }; + 1AAAC8F1205CB6E9005321B9 /* AudioEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC882205CB6E9005321B9 /* AudioEngine.cpp */; }; + 1AAAC8F2205CB6E9005321B9 /* AudioEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AAAC882205CB6E9005321B9 /* AudioEngine.cpp */; }; + 1AAAC8F3205CB6E9005321B9 /* AudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC884205CB6E9005321B9 /* AudioEngine.h */; }; + 1AAAC8F4205CB6E9005321B9 /* AudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC884205CB6E9005321B9 /* AudioEngine.h */; }; + 1AAAC8F5205CB6E9005321B9 /* Export.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC885205CB6E9005321B9 /* Export.h */; }; + 1AAAC8F6205CB6E9005321B9 /* Export.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AAAC885205CB6E9005321B9 /* Export.h */; }; 1ACF6A3C1E4AFDC80033C137 /* libcrypto.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ACF6A3A1E4AFDC80033C137 /* libcrypto.a */; }; 1ACF6A3D1E4AFDC80033C137 /* libssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ACF6A3B1E4AFDC80033C137 /* libssl.a */; }; 294D7D9A1D0E93A2002CE7B7 /* CCDevice-apple.h in Headers */ = {isa = PBXBuildFile; fileRef = 294D7D981D0E93A2002CE7B7 /* CCDevice-apple.h */; }; @@ -243,10 +350,10 @@ 4693039B2046AE05004A3D6C /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302462046AE05004A3D6C /* Utils.cpp */; }; 4693039C2046AE05004A3D6C /* PlatformUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 469302472046AE05004A3D6C /* PlatformUtils.h */; }; 4693039D2046AE05004A3D6C /* PlatformUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 469302472046AE05004A3D6C /* PlatformUtils.h */; }; - 4693039E2046AE05004A3D6C /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302482046AE05004A3D6C /* Object.cpp */; }; - 4693039F2046AE05004A3D6C /* Object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302482046AE05004A3D6C /* Object.cpp */; }; - 469303A02046AE05004A3D6C /* ScriptEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302492046AE05004A3D6C /* ScriptEngine.cpp */; }; - 469303A12046AE05004A3D6C /* ScriptEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302492046AE05004A3D6C /* ScriptEngine.cpp */; }; + 4693039E2046AE05004A3D6C /* Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 469302482046AE05004A3D6C /* Object.mm */; }; + 4693039F2046AE05004A3D6C /* Object.mm in Sources */ = {isa = PBXBuildFile; fileRef = 469302482046AE05004A3D6C /* Object.mm */; }; + 469303A02046AE05004A3D6C /* ScriptEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 469302492046AE05004A3D6C /* ScriptEngine.mm */; }; + 469303A12046AE05004A3D6C /* ScriptEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 469302492046AE05004A3D6C /* ScriptEngine.mm */; }; 469303A22046AE05004A3D6C /* Object.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4693024A2046AE05004A3D6C /* Object.hpp */; }; 469303A32046AE05004A3D6C /* Object.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4693024A2046AE05004A3D6C /* Object.hpp */; }; 469303A42046AE05004A3D6C /* ScriptEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4693024B2046AE05004A3D6C /* ScriptEngine.hpp */; }; @@ -279,8 +386,6 @@ 469304132046AE06004A3D6C /* jsb_classtype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302D02046AE05004A3D6C /* jsb_classtype.cpp */; }; 469304142046AE06004A3D6C /* jsb_renderer_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 469302D12046AE05004A3D6C /* jsb_renderer_manual.hpp */; }; 469304152046AE06004A3D6C /* jsb_renderer_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 469302D12046AE05004A3D6C /* jsb_renderer_manual.hpp */; }; - 469304162046AE06004A3D6C /* jsb_platfrom_ios.m in Sources */ = {isa = PBXBuildFile; fileRef = 469302D22046AE05004A3D6C /* jsb_platfrom_ios.m */; }; - 469304172046AE06004A3D6C /* jsb_platfrom_ios.m in Sources */ = {isa = PBXBuildFile; fileRef = 469302D22046AE05004A3D6C /* jsb_platfrom_ios.m */; }; 469304202046AE06004A3D6C /* jsb_gfx_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 469302D72046AE05004A3D6C /* jsb_gfx_manual.hpp */; }; 469304212046AE06004A3D6C /* jsb_gfx_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 469302D72046AE05004A3D6C /* jsb_gfx_manual.hpp */; }; 469304262046AE06004A3D6C /* jsb_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 469302DA2046AE05004A3D6C /* jsb_conversions.cpp */; }; @@ -463,12 +568,8 @@ 46FDDB94202ADDCE00931238 /* TGAlib.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB0E202ADDCE00931238 /* TGAlib.cpp */; }; 46FDDB99202ADDCE00931238 /* ccUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB11202ADDCE00931238 /* ccUTF8.cpp */; }; 46FDDB9A202ADDCE00931238 /* ccUTF8.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB11202ADDCE00931238 /* ccUTF8.cpp */; }; - 46FDDB9D202ADDCE00931238 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB13202ADDCE00931238 /* ObjectFactory.h */; }; - 46FDDB9E202ADDCE00931238 /* ObjectFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB13202ADDCE00931238 /* ObjectFactory.h */; }; 46FDDB9F202ADDCE00931238 /* CCVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB14202ADDCE00931238 /* CCVector.h */; }; 46FDDBA0202ADDCE00931238 /* CCVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB14202ADDCE00931238 /* CCVector.h */; }; - 46FDDBA1202ADDCE00931238 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB15202ADDCE00931238 /* ObjectFactory.cpp */; }; - 46FDDBA2202ADDCE00931238 /* ObjectFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB15202ADDCE00931238 /* ObjectFactory.cpp */; }; 46FDDBA3202ADDCE00931238 /* pvr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB16202ADDCE00931238 /* pvr.cpp */; }; 46FDDBA4202ADDCE00931238 /* pvr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46FDDB16202ADDCE00931238 /* pvr.cpp */; }; 46FDDBB5202ADDCE00931238 /* uthash.h in Headers */ = {isa = PBXBuildFile; fileRef = 46FDDB1F202ADDCE00931238 /* uthash.h */; }; @@ -966,22 +1067,101 @@ 1A29D77A2056667800168D9A /* csscolorparser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = csscolorparser.hpp; sourceTree = ""; }; 1A29D781205666B100168D9A /* LocalStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalStorage.cpp; sourceTree = ""; }; 1A29D783205666B100168D9A /* LocalStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalStorage.h; sourceTree = ""; }; - 1A29D78A205666F100168D9A /* jsb_opengl_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_manual.cpp; sourceTree = ""; }; - 1A29D78B205666F200168D9A /* jsb_opengl_registration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_registration.cpp; sourceTree = ""; }; + 1A29D78B205666F200168D9A /* jsb_opengl_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_manual.cpp; sourceTree = ""; }; 1A29D78C205666F200168D9A /* jsb_opengl_utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_utils.cpp; sourceTree = ""; }; - 1A29D78D205666F200168D9A /* jsb_opengl_functions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_opengl_functions.hpp; sourceTree = ""; }; 1A29D78E205666F200168D9A /* jsb_opengl_utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_opengl_utils.hpp; sourceTree = ""; }; - 1A29D78F205666F200168D9A /* jsb_opengl_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_opengl_manual.hpp; sourceTree = ""; }; - 1A29D790205666F500168D9A /* jsb_opengl_registration.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_opengl_registration.hpp; sourceTree = ""; }; - 1A29D791205666F500168D9A /* jsb_opengl_functions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_opengl_functions.cpp; sourceTree = ""; }; + 1A29D790205666F500168D9A /* jsb_opengl_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_opengl_manual.hpp; sourceTree = ""; }; 1A29D7A220566CAB00168D9A /* CCCanvasRenderingContext2D.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCCanvasRenderingContext2D.h; sourceTree = ""; }; 1A37E9C3200DD0680078AF72 /* CCReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCReachability.h; sourceTree = ""; }; 1A37E9C4200DD0680078AF72 /* CCReachability.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCReachability.cpp; sourceTree = ""; }; + 1A52DAF4205BB81400350EE3 /* CCThreadPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCThreadPool.h; sourceTree = ""; }; + 1A52DAF5205BB81400350EE3 /* CCThreadPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCThreadPool.cpp; sourceTree = ""; }; + 1A52DAFB205BCD9200350EE3 /* inspector_socket_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inspector_socket_server.h; sourceTree = ""; }; + 1A52DAFC205BCD9200350EE3 /* env.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = env.h; sourceTree = ""; }; + 1A52DAFD205BCD9200350EE3 /* Class.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Class.hpp; sourceTree = ""; }; + 1A52DAFE205BCD9200350EE3 /* ObjectWrap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectWrap.cpp; sourceTree = ""; }; + 1A52DAFF205BCD9200350EE3 /* HelperMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelperMacros.h; sourceTree = ""; }; + 1A52DB00205BCD9200350EE3 /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = ""; }; + 1A52DB01205BCD9200350EE3 /* node.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = node.cc; sourceTree = ""; }; + 1A52DB02205BCD9200350EE3 /* inspector_agent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inspector_agent.h; sourceTree = ""; }; + 1A52DB03205BCD9200350EE3 /* base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = base64.h; sourceTree = ""; }; + 1A52DB04205BCD9200350EE3 /* inspector_io.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inspector_io.h; sourceTree = ""; }; + 1A52DB05205BCD9200350EE3 /* inspector_socket_server.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inspector_socket_server.cc; sourceTree = ""; }; + 1A52DB06205BCD9200350EE3 /* node_mutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = node_mutex.h; sourceTree = ""; }; + 1A52DB07205BCD9200350EE3 /* ObjectWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectWrap.h; sourceTree = ""; }; + 1A52DB08205BCD9200350EE3 /* Object.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Object.cpp; sourceTree = ""; }; + 1A52DB09205BCD9200350EE3 /* http_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = http_parser.h; sourceTree = ""; }; + 1A52DB0A205BCD9200350EE3 /* ScriptEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptEngine.cpp; sourceTree = ""; }; + 1A52DB0B205BCD9200350EE3 /* inspector_agent.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inspector_agent.cc; sourceTree = ""; }; + 1A52DB0C205BCD9200350EE3 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = ""; }; + 1A52DB0D205BCD9200350EE3 /* node.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = node.h; sourceTree = ""; }; + 1A52DB0F205BCD9200350EE3 /* Object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Object.hpp; sourceTree = ""; }; + 1A52DB10205BCD9200350EE3 /* util.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = util.cc; sourceTree = ""; }; + 1A52DB11205BCD9200350EE3 /* util-inl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "util-inl.h"; sourceTree = ""; }; + 1A52DB12205BCD9200350EE3 /* inspector_socket.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inspector_socket.cc; sourceTree = ""; }; + 1A52DB13205BCD9200350EE3 /* ScriptEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ScriptEngine.hpp; sourceTree = ""; }; + 1A52DB14205BCD9200350EE3 /* inspector_io.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inspector_io.cc; sourceTree = ""; }; + 1A52DB15205BCD9200350EE3 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = ""; }; + 1A52DB16205BCD9200350EE3 /* v8_inspector_protocol_json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = v8_inspector_protocol_json.h; sourceTree = ""; }; + 1A52DB17205BCD9200350EE3 /* SHA1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SHA1.h; sourceTree = ""; }; + 1A52DB18205BCD9200350EE3 /* SeApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeApi.h; sourceTree = ""; }; + 1A52DB19205BCD9200350EE3 /* Class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Class.cpp; sourceTree = ""; }; + 1A52DB1A205BCD9200350EE3 /* http_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = http_parser.c; sourceTree = ""; }; + 1A52DB1B205BCD9200350EE3 /* inspector_socket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inspector_socket.h; sourceTree = ""; }; + 1A52DB1C205BCD9200350EE3 /* node_debug_options.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = node_debug_options.cc; sourceTree = ""; }; + 1A52DB1D205BCD9200350EE3 /* Utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Utils.hpp; sourceTree = ""; }; + 1A52DB1E205BCD9200350EE3 /* node_debug_options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = node_debug_options.h; sourceTree = ""; }; + 1A52DB1F205BCD9200350EE3 /* env.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = env.cc; sourceTree = ""; }; + 1A52DB20205BCD9200350EE3 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = ""; }; + 1A52DB47205BCDC700350EE3 /* Class.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Class.hpp; sourceTree = ""; }; + 1A52DB48205BCDC700350EE3 /* HelperMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelperMacros.h; sourceTree = ""; }; + 1A52DB49205BCDC700350EE3 /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = ""; }; + 1A52DB4A205BCDC700350EE3 /* Object.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Object.cpp; sourceTree = ""; }; + 1A52DB4B205BCDC700350EE3 /* ScriptEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptEngine.cpp; sourceTree = ""; }; + 1A52DB4C205BCDC700350EE3 /* Object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Object.hpp; sourceTree = ""; }; + 1A52DB4D205BCDC700350EE3 /* ScriptEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ScriptEngine.hpp; sourceTree = ""; }; + 1A52DB4E205BCDC700350EE3 /* SeApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeApi.h; sourceTree = ""; }; + 1A52DB4F205BCDC700350EE3 /* Class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Class.cpp; sourceTree = ""; }; + 1A52DB50205BCDC700350EE3 /* Utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Utils.hpp; sourceTree = ""; }; + 1A52DB51205BCDC700350EE3 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = ""; }; + 1A52DB53205BCDC700350EE3 /* Class.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Class.hpp; sourceTree = ""; }; + 1A52DB54205BCDC700350EE3 /* HelperMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelperMacros.h; sourceTree = ""; }; + 1A52DB55205BCDC700350EE3 /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = ""; }; + 1A52DB56205BCDC700350EE3 /* Object.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Object.cpp; sourceTree = ""; }; + 1A52DB57205BCDC700350EE3 /* ScriptEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptEngine.cpp; sourceTree = ""; }; + 1A52DB58205BCDC700350EE3 /* Object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Object.hpp; sourceTree = ""; }; + 1A52DB59205BCDC700350EE3 /* ScriptEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ScriptEngine.hpp; sourceTree = ""; }; + 1A52DB5A205BCDC700350EE3 /* SeApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SeApi.h; sourceTree = ""; }; + 1A52DB5B205BCDC700350EE3 /* Class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Class.cpp; sourceTree = ""; }; + 1A52DB5C205BCDC700350EE3 /* Utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Utils.hpp; sourceTree = ""; }; + 1A52DB5D205BCDC700350EE3 /* Base.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base.h; sourceTree = ""; }; + 1A52DB862060B11800350EE3 /* jsb_platfrom_apple.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jsb_platfrom_apple.mm; sourceTree = ""; }; + 1A52DB872060B11800350EE3 /* jsb_platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_platform.h; sourceTree = ""; }; + 1A52DB8A2060B12500350EE3 /* jsb_platform_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_platform_ios.h; sourceTree = ""; }; + 1A52DB8B2060B12600350EE3 /* jsb_platfrom_ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jsb_platfrom_ios.mm; sourceTree = ""; }; + 1A586C412064C90500B47573 /* EJConvertTypedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EJConvertTypedArray.h; sourceTree = ""; }; + 1A586C422064C90500B47573 /* EJConvertTypedArray.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EJConvertTypedArray.m; sourceTree = ""; }; + 1A586C472064C97800B47573 /* EJConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EJConvert.h; sourceTree = ""; }; + 1A586C482064C97800B47573 /* EJConvert.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EJConvert.m; sourceTree = ""; }; 1A97ABFC1A1D962A0076D9CC /* MathUtilNeon64.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MathUtilNeon64.inl; sourceTree = ""; }; 1A97ABFD1A1D962A0076D9CC /* MathUtilSSE.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MathUtilSSE.inl; sourceTree = ""; }; 1A9A4C6D1F98B1C000C14552 /* libcocosanalytics.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcocosanalytics.a; path = ../external/ios/libs/libcocosanalytics.a; sourceTree = ""; }; 1A9F0F951F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = b2ObjectDestroyNotifier.cpp; sourceTree = ""; }; 1A9F0F961F301DE200A499E1 /* b2ObjectDestroyNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2ObjectDestroyNotifier.h; sourceTree = ""; }; + 1AAAC871205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_cocos2dx_audioengine_auto.cpp; sourceTree = ""; }; + 1AAAC872205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_cocos2dx_audioengine_auto.hpp; sourceTree = ""; }; + 1AAAC879205CB6E9005321B9 /* AudioDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioDecoder.h; sourceTree = ""; }; + 1AAAC87A205CB6E9005321B9 /* AudioPlayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioPlayer.mm; sourceTree = ""; }; + 1AAAC87B205CB6E9005321B9 /* AudioDecoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioDecoder.mm; sourceTree = ""; }; + 1AAAC87C205CB6E9005321B9 /* AudioPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioPlayer.h; sourceTree = ""; }; + 1AAAC87D205CB6E9005321B9 /* AudioEngine-inl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "AudioEngine-inl.mm"; sourceTree = ""; }; + 1AAAC87E205CB6E9005321B9 /* AudioMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioMacros.h; sourceTree = ""; }; + 1AAAC87F205CB6E9005321B9 /* AudioCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AudioCache.mm; sourceTree = ""; }; + 1AAAC880205CB6E9005321B9 /* AudioCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioCache.h; sourceTree = ""; }; + 1AAAC881205CB6E9005321B9 /* AudioEngine-inl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AudioEngine-inl.h"; sourceTree = ""; }; + 1AAAC882205CB6E9005321B9 /* AudioEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioEngine.cpp; sourceTree = ""; }; + 1AAAC884205CB6E9005321B9 /* AudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioEngine.h; sourceTree = ""; }; + 1AAAC885205CB6E9005321B9 /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; 1ACF6A3A1E4AFDC80033C137 /* libcrypto.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcrypto.a; path = ../external/ios/libs/libcrypto.a; sourceTree = ""; }; 1ACF6A3B1E4AFDC80033C137 /* libssl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssl.a; path = ../external/ios/libs/libssl.a; sourceTree = ""; }; 294D7D981D0E93A2002CE7B7 /* CCDevice-apple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CCDevice-apple.h"; sourceTree = ""; }; @@ -1039,8 +1219,8 @@ 469302452046AE05004A3D6C /* HelperMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelperMacros.h; sourceTree = ""; }; 469302462046AE05004A3D6C /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = ""; }; 469302472046AE05004A3D6C /* PlatformUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformUtils.h; sourceTree = ""; }; - 469302482046AE05004A3D6C /* Object.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Object.cpp; sourceTree = ""; }; - 469302492046AE05004A3D6C /* ScriptEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptEngine.cpp; sourceTree = ""; }; + 469302482046AE05004A3D6C /* Object.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Object.mm; sourceTree = ""; }; + 469302492046AE05004A3D6C /* ScriptEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScriptEngine.mm; sourceTree = ""; }; 4693024A2046AE05004A3D6C /* Object.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Object.hpp; sourceTree = ""; }; 4693024B2046AE05004A3D6C /* ScriptEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ScriptEngine.hpp; sourceTree = ""; }; 4693024C2046AE05004A3D6C /* PlatformUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformUtils.mm; sourceTree = ""; }; @@ -1052,50 +1232,11 @@ 4693025D2046AE05004A3D6C /* jsb_gfx_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_gfx_auto.cpp; sourceTree = ""; }; 469302632046AE05004A3D6C /* jsb_gfx_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_gfx_auto.hpp; sourceTree = ""; }; 469302822046AE05004A3D6C /* jsb_renderer_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_renderer_auto.hpp; sourceTree = ""; }; - 469302922046AE05004A3D6C /* jsb_cocos2d.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d.js; sourceTree = ""; }; - 469302932046AE05004A3D6C /* jsb_audioengine.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_audioengine.js; sourceTree = ""; }; - 469302942046AE05004A3D6C /* jsb_cocosanalytics.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocosanalytics.js; sourceTree = ""; }; - 469302962046AE05004A3D6C /* jsb_cocos2d_extension.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_cocos2d_extension.js; sourceTree = ""; }; - 469302972046AE05004A3D6C /* jsb_property_impls.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_property_impls.js; sourceTree = ""; }; - 469302982046AE05004A3D6C /* jsb_opengl_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_opengl_constants.js; sourceTree = ""; }; - 469302992046AE05004A3D6C /* jsb_opengl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_opengl.js; sourceTree = ""; }; - 4693029A2046AE05004A3D6C /* jsb_boot.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_boot.js; sourceTree = ""; }; - 4693029B2046AE05004A3D6C /* jsb_common.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_common.js; sourceTree = ""; }; - 4693029C2046AE05004A3D6C /* jsb_prepare.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_prepare.js; sourceTree = ""; }; - 4693029D2046AE05004A3D6C /* jsb_create_apis.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_create_apis.js; sourceTree = ""; }; - 4693029E2046AE05004A3D6C /* jsb_property_apis.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_property_apis.js; sourceTree = ""; }; - 4693029F2046AE05004A3D6C /* jsb_spine.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_spine.js; sourceTree = ""; }; - 469302A02046AE05004A3D6C /* jsb_dragonbones.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_dragonbones.js; sourceTree = ""; }; - 469302A22046AE05004A3D6C /* protocol.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = protocol.js; sourceTree = ""; }; - 469302A32046AE05004A3D6C /* transport.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = transport.js; sourceTree = ""; }; - 469302A42046AE05004A3D6C /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - 469302A52046AE05004A3D6C /* event-emitter.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "event-emitter.js"; sourceTree = ""; }; - 469302A62046AE05004A3D6C /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = main.js; sourceTree = ""; }; - 469302A82046AE05004A3D6C /* utils.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = utils.js; sourceTree = ""; }; - 469302AA2046AE05004A3D6C /* object.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = object.js; sourceTree = ""; }; - 469302AB2046AE05004A3D6C /* event-core.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "event-core.js"; sourceTree = ""; }; - 469302AC2046AE05004A3D6C /* target.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = target.js; sourceTree = ""; }; - 469302AD2046AE05004A3D6C /* heritage.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = heritage.js; sourceTree = ""; }; - 469302AF2046AE05004A3D6C /* object.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = object.js; sourceTree = ""; }; - 469302B12046AE05004A3D6C /* ScriptStore.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ScriptStore.js; sourceTree = ""; }; - 469302B22046AE05004A3D6C /* TabSources.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = TabSources.js; sourceTree = ""; }; - 469302B32046AE05004A3D6C /* script.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = script.js; sourceTree = ""; }; - 469302B42046AE05004A3D6C /* root.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = root.js; sourceTree = ""; }; - 469302B52046AE05004A3D6C /* source.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = source.js; sourceTree = ""; }; - 469302B62046AE05004A3D6C /* common.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = common.js; sourceTree = ""; }; - 469302B72046AE05004A3D6C /* webconsole.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = webconsole.js; sourceTree = ""; }; - 469302B82046AE05004A3D6C /* breakpoint.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = breakpoint.js; sourceTree = ""; }; - 469302B92046AE05004A3D6C /* environment.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = environment.js; sourceTree = ""; }; - 469302BA2046AE05004A3D6C /* frame.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = frame.js; sourceTree = ""; }; - 469302BB2046AE05004A3D6C /* DevToolsUtils.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = DevToolsUtils.js; sourceTree = ""; }; - 469302BC2046AE05004A3D6C /* jsb_debugger.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb_debugger.js; sourceTree = ""; }; - 469302BD2046AE05004A3D6C /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jsb.js; sourceTree = ""; }; 469302C72046AE05004A3D6C /* jsb_global.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsb_global.h; sourceTree = ""; }; 469302CB2046AE05004A3D6C /* jsb_global.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_global.cpp; sourceTree = ""; }; 469302CF2046AE05004A3D6C /* jsb_helper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_helper.hpp; sourceTree = ""; }; 469302D02046AE05004A3D6C /* jsb_classtype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_classtype.cpp; sourceTree = ""; }; 469302D12046AE05004A3D6C /* jsb_renderer_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_renderer_manual.hpp; sourceTree = ""; }; - 469302D22046AE05004A3D6C /* jsb_platfrom_ios.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = jsb_platfrom_ios.m; sourceTree = ""; }; 469302D72046AE05004A3D6C /* jsb_gfx_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsb_gfx_manual.hpp; sourceTree = ""; }; 469302DA2046AE05004A3D6C /* jsb_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_conversions.cpp; sourceTree = ""; }; 469302DD2046AE05004A3D6C /* jsb_renderer_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jsb_renderer_manual.cpp; sourceTree = ""; }; @@ -1187,9 +1328,7 @@ 46FDDB0C202ADDCE00931238 /* ccUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccUtils.cpp; sourceTree = ""; }; 46FDDB0E202ADDCE00931238 /* TGAlib.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TGAlib.cpp; sourceTree = ""; }; 46FDDB11202ADDCE00931238 /* ccUTF8.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccUTF8.cpp; sourceTree = ""; }; - 46FDDB13202ADDCE00931238 /* ObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectFactory.h; sourceTree = ""; }; 46FDDB14202ADDCE00931238 /* CCVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCVector.h; sourceTree = ""; }; - 46FDDB15202ADDCE00931238 /* ObjectFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFactory.cpp; sourceTree = ""; }; 46FDDB16202ADDCE00931238 /* pvr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pvr.cpp; sourceTree = ""; }; 46FDDB1F202ADDCE00931238 /* uthash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uthash.h; sourceTree = ""; }; 46FDDB20202ADDCE00931238 /* ccUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccUtils.h; sourceTree = ""; }; @@ -1496,6 +1635,7 @@ 1551A334158F2AB200E66CFE = { isa = PBXGroup; children = ( + 1AAAC877205CB6E9005321B9 /* audio */, 1A29D77F205666B100168D9A /* storage */, 461785FD20522468008256E1 /* network */, 469301F42046AE05004A3D6C /* js-bindings */, @@ -1663,6 +1803,86 @@ path = "local-storage"; sourceTree = ""; }; + 1A52DAFA205BCD9200350EE3 /* v8 */ = { + isa = PBXGroup; + children = ( + 1A52DB20205BCD9200350EE3 /* Base.h */, + 1A52DB03205BCD9200350EE3 /* base64.h */, + 1A52DB19205BCD9200350EE3 /* Class.cpp */, + 1A52DAFD205BCD9200350EE3 /* Class.hpp */, + 1A52DB1F205BCD9200350EE3 /* env.cc */, + 1A52DAFC205BCD9200350EE3 /* env.h */, + 1A52DAFF205BCD9200350EE3 /* HelperMacros.h */, + 1A52DB1A205BCD9200350EE3 /* http_parser.c */, + 1A52DB09205BCD9200350EE3 /* http_parser.h */, + 1A52DB0B205BCD9200350EE3 /* inspector_agent.cc */, + 1A52DB02205BCD9200350EE3 /* inspector_agent.h */, + 1A52DB14205BCD9200350EE3 /* inspector_io.cc */, + 1A52DB04205BCD9200350EE3 /* inspector_io.h */, + 1A52DB05205BCD9200350EE3 /* inspector_socket_server.cc */, + 1A52DAFB205BCD9200350EE3 /* inspector_socket_server.h */, + 1A52DB12205BCD9200350EE3 /* inspector_socket.cc */, + 1A52DB1B205BCD9200350EE3 /* inspector_socket.h */, + 1A52DB1C205BCD9200350EE3 /* node_debug_options.cc */, + 1A52DB1E205BCD9200350EE3 /* node_debug_options.h */, + 1A52DB06205BCD9200350EE3 /* node_mutex.h */, + 1A52DB01205BCD9200350EE3 /* node.cc */, + 1A52DB0D205BCD9200350EE3 /* node.h */, + 1A52DB08205BCD9200350EE3 /* Object.cpp */, + 1A52DB0F205BCD9200350EE3 /* Object.hpp */, + 1A52DAFE205BCD9200350EE3 /* ObjectWrap.cpp */, + 1A52DB07205BCD9200350EE3 /* ObjectWrap.h */, + 1A52DB0A205BCD9200350EE3 /* ScriptEngine.cpp */, + 1A52DB13205BCD9200350EE3 /* ScriptEngine.hpp */, + 1A52DB18205BCD9200350EE3 /* SeApi.h */, + 1A52DB0C205BCD9200350EE3 /* SHA1.cpp */, + 1A52DB17205BCD9200350EE3 /* SHA1.h */, + 1A52DB11205BCD9200350EE3 /* util-inl.h */, + 1A52DB10205BCD9200350EE3 /* util.cc */, + 1A52DB15205BCD9200350EE3 /* util.h */, + 1A52DB00205BCD9200350EE3 /* Utils.cpp */, + 1A52DB1D205BCD9200350EE3 /* Utils.hpp */, + 1A52DB16205BCD9200350EE3 /* v8_inspector_protocol_json.h */, + ); + path = v8; + sourceTree = ""; + }; + 1A52DB46205BCDC700350EE3 /* chakracore */ = { + isa = PBXGroup; + children = ( + 1A52DB47205BCDC700350EE3 /* Class.hpp */, + 1A52DB48205BCDC700350EE3 /* HelperMacros.h */, + 1A52DB49205BCDC700350EE3 /* Utils.cpp */, + 1A52DB4A205BCDC700350EE3 /* Object.cpp */, + 1A52DB4B205BCDC700350EE3 /* ScriptEngine.cpp */, + 1A52DB4C205BCDC700350EE3 /* Object.hpp */, + 1A52DB4D205BCDC700350EE3 /* ScriptEngine.hpp */, + 1A52DB4E205BCDC700350EE3 /* SeApi.h */, + 1A52DB4F205BCDC700350EE3 /* Class.cpp */, + 1A52DB50205BCDC700350EE3 /* Utils.hpp */, + 1A52DB51205BCDC700350EE3 /* Base.h */, + ); + path = chakracore; + sourceTree = ""; + }; + 1A52DB52205BCDC700350EE3 /* sm */ = { + isa = PBXGroup; + children = ( + 1A52DB5D205BCDC700350EE3 /* Base.h */, + 1A52DB5B205BCDC700350EE3 /* Class.cpp */, + 1A52DB53205BCDC700350EE3 /* Class.hpp */, + 1A52DB54205BCDC700350EE3 /* HelperMacros.h */, + 1A52DB56205BCDC700350EE3 /* Object.cpp */, + 1A52DB58205BCDC700350EE3 /* Object.hpp */, + 1A52DB57205BCDC700350EE3 /* ScriptEngine.cpp */, + 1A52DB59205BCDC700350EE3 /* ScriptEngine.hpp */, + 1A52DB5A205BCDC700350EE3 /* SeApi.h */, + 1A52DB55205BCDC700350EE3 /* Utils.cpp */, + 1A52DB5C205BCDC700350EE3 /* Utils.hpp */, + ); + path = sm; + sourceTree = ""; + }; 1A57033E180BD0490088DEC7 /* external */ = { isa = PBXGroup; children = ( @@ -1682,6 +1902,42 @@ name = external; sourceTree = ""; }; + 1AAAC877205CB6E9005321B9 /* audio */ = { + isa = PBXGroup; + children = ( + 1AAAC878205CB6E9005321B9 /* apple */, + 1AAAC882205CB6E9005321B9 /* AudioEngine.cpp */, + 1AAAC883205CB6E9005321B9 /* include */, + ); + name = audio; + path = ../cocos/audio; + sourceTree = ""; + }; + 1AAAC878205CB6E9005321B9 /* apple */ = { + isa = PBXGroup; + children = ( + 1AAAC879205CB6E9005321B9 /* AudioDecoder.h */, + 1AAAC87A205CB6E9005321B9 /* AudioPlayer.mm */, + 1AAAC87B205CB6E9005321B9 /* AudioDecoder.mm */, + 1AAAC87C205CB6E9005321B9 /* AudioPlayer.h */, + 1AAAC87D205CB6E9005321B9 /* AudioEngine-inl.mm */, + 1AAAC87E205CB6E9005321B9 /* AudioMacros.h */, + 1AAAC87F205CB6E9005321B9 /* AudioCache.mm */, + 1AAAC880205CB6E9005321B9 /* AudioCache.h */, + 1AAAC881205CB6E9005321B9 /* AudioEngine-inl.h */, + ); + path = apple; + sourceTree = ""; + }; + 1AAAC883205CB6E9005321B9 /* include */ = { + isa = PBXGroup; + children = ( + 1AAAC884205CB6E9005321B9 /* AudioEngine.h */, + 1AAAC885205CB6E9005321B9 /* Export.h */, + ); + path = include; + sourceTree = ""; + }; 461785FD20522468008256E1 /* network */ = { isa = PBXGroup; children = ( @@ -1714,7 +1970,6 @@ children = ( 469301F52046AE05004A3D6C /* jswrapper */, 469302512046AE05004A3D6C /* auto */, - 469302912046AE05004A3D6C /* script */, 469302BE2046AE05004A3D6C /* manual */, 469302F82046AE05004A3D6C /* event */, ); @@ -1725,21 +1980,24 @@ 469301F52046AE05004A3D6C /* jswrapper */ = { isa = PBXGroup; children = ( - 469302292046AE05004A3D6C /* RefCounter.hpp */, - 4693022A2046AE05004A3D6C /* HandleObject.cpp */, - 4693022B2046AE05004A3D6C /* State.cpp */, - 469302382046AE05004A3D6C /* config.hpp */, - 469302392046AE05004A3D6C /* Value.hpp */, - 4693023A2046AE05004A3D6C /* MappingUtils.cpp */, - 4693023B2046AE05004A3D6C /* Object.hpp */, - 4693023C2046AE05004A3D6C /* HandleObject.hpp */, - 4693023D2046AE05004A3D6C /* State.hpp */, - 4693023E2046AE05004A3D6C /* config.cpp */, - 4693023F2046AE05004A3D6C /* Value.cpp */, - 469302402046AE05004A3D6C /* MappingUtils.hpp */, - 469302412046AE05004A3D6C /* SeApi.h */, - 469302422046AE05004A3D6C /* RefCounter.cpp */, + 1A52DB46205BCDC700350EE3 /* chakracore */, 469302432046AE05004A3D6C /* jsc */, + 1A52DB52205BCDC700350EE3 /* sm */, + 4693023E2046AE05004A3D6C /* config.cpp */, + 469302382046AE05004A3D6C /* config.hpp */, + 4693022A2046AE05004A3D6C /* HandleObject.cpp */, + 4693023C2046AE05004A3D6C /* HandleObject.hpp */, + 4693023A2046AE05004A3D6C /* MappingUtils.cpp */, + 469302402046AE05004A3D6C /* MappingUtils.hpp */, + 4693023B2046AE05004A3D6C /* Object.hpp */, + 469302422046AE05004A3D6C /* RefCounter.cpp */, + 469302292046AE05004A3D6C /* RefCounter.hpp */, + 469302412046AE05004A3D6C /* SeApi.h */, + 4693022B2046AE05004A3D6C /* State.cpp */, + 4693023D2046AE05004A3D6C /* State.hpp */, + 1A52DAFA205BCD9200350EE3 /* v8 */, + 4693023F2046AE05004A3D6C /* Value.cpp */, + 469302392046AE05004A3D6C /* Value.hpp */, ); path = jswrapper; sourceTree = ""; @@ -1747,19 +2005,23 @@ 469302432046AE05004A3D6C /* jsc */ = { isa = PBXGroup; children = ( + 1A586C472064C97800B47573 /* EJConvert.h */, + 1A586C482064C97800B47573 /* EJConvert.m */, + 1A586C412064C90500B47573 /* EJConvertTypedArray.h */, + 1A586C422064C90500B47573 /* EJConvertTypedArray.m */, + 469302502046AE05004A3D6C /* Base.h */, + 4693024E2046AE05004A3D6C /* Class.cpp */, 469302442046AE05004A3D6C /* Class.hpp */, 469302452046AE05004A3D6C /* HelperMacros.h */, - 469302462046AE05004A3D6C /* Utils.cpp */, - 469302472046AE05004A3D6C /* PlatformUtils.h */, - 469302482046AE05004A3D6C /* Object.cpp */, - 469302492046AE05004A3D6C /* ScriptEngine.cpp */, + 469302482046AE05004A3D6C /* Object.mm */, 4693024A2046AE05004A3D6C /* Object.hpp */, - 4693024B2046AE05004A3D6C /* ScriptEngine.hpp */, + 469302472046AE05004A3D6C /* PlatformUtils.h */, 4693024C2046AE05004A3D6C /* PlatformUtils.mm */, + 469302492046AE05004A3D6C /* ScriptEngine.mm */, + 4693024B2046AE05004A3D6C /* ScriptEngine.hpp */, 4693024D2046AE05004A3D6C /* SeApi.h */, - 4693024E2046AE05004A3D6C /* Class.cpp */, + 469302462046AE05004A3D6C /* Utils.cpp */, 4693024F2046AE05004A3D6C /* Utils.hpp */, - 469302502046AE05004A3D6C /* Base.h */, ); path = jsc; sourceTree = ""; @@ -1767,6 +2029,8 @@ 469302512046AE05004A3D6C /* auto */ = { isa = PBXGroup; children = ( + 1AAAC871205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp */, + 1AAAC872205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp */, 1A29D767205665BE00168D9A /* jsb_cocos2dx_auto.cpp */, 1A29D768205665BE00168D9A /* jsb_cocos2dx_auto.hpp */, 461786692052609B008256E1 /* jsb_cocos2dx_network_auto.cpp */, @@ -1779,102 +2043,13 @@ path = auto; sourceTree = ""; }; - 469302912046AE05004A3D6C /* script */ = { - isa = PBXGroup; - children = ( - 469302922046AE05004A3D6C /* jsb_cocos2d.js */, - 469302932046AE05004A3D6C /* jsb_audioengine.js */, - 469302942046AE05004A3D6C /* jsb_cocosanalytics.js */, - 469302952046AE05004A3D6C /* extension */, - 469302972046AE05004A3D6C /* jsb_property_impls.js */, - 469302982046AE05004A3D6C /* jsb_opengl_constants.js */, - 469302992046AE05004A3D6C /* jsb_opengl.js */, - 4693029A2046AE05004A3D6C /* jsb_boot.js */, - 4693029B2046AE05004A3D6C /* jsb_common.js */, - 4693029C2046AE05004A3D6C /* jsb_prepare.js */, - 4693029D2046AE05004A3D6C /* jsb_create_apis.js */, - 4693029E2046AE05004A3D6C /* jsb_property_apis.js */, - 4693029F2046AE05004A3D6C /* jsb_spine.js */, - 469302A02046AE05004A3D6C /* jsb_dragonbones.js */, - 469302A12046AE05004A3D6C /* debugger */, - 469302BC2046AE05004A3D6C /* jsb_debugger.js */, - 469302BD2046AE05004A3D6C /* jsb.js */, - ); - path = script; - sourceTree = ""; - }; - 469302952046AE05004A3D6C /* extension */ = { - isa = PBXGroup; - children = ( - 469302962046AE05004A3D6C /* jsb_cocos2d_extension.js */, - ); - path = extension; - sourceTree = ""; - }; - 469302A12046AE05004A3D6C /* debugger */ = { - isa = PBXGroup; - children = ( - 469302A22046AE05004A3D6C /* protocol.js */, - 469302A32046AE05004A3D6C /* transport.js */, - 469302A42046AE05004A3D6C /* README.md */, - 469302A52046AE05004A3D6C /* event-emitter.js */, - 469302A62046AE05004A3D6C /* main.js */, - 469302A72046AE05004A3D6C /* webconsole */, - 469302A92046AE05004A3D6C /* sdk */, - 469302AE2046AE05004A3D6C /* actors */, - 469302BB2046AE05004A3D6C /* DevToolsUtils.js */, - ); - path = debugger; - sourceTree = ""; - }; - 469302A72046AE05004A3D6C /* webconsole */ = { - isa = PBXGroup; - children = ( - 469302A82046AE05004A3D6C /* utils.js */, - ); - path = webconsole; - sourceTree = ""; - }; - 469302A92046AE05004A3D6C /* sdk */ = { - isa = PBXGroup; - children = ( - 469302AA2046AE05004A3D6C /* object.js */, - 469302AB2046AE05004A3D6C /* event-core.js */, - 469302AC2046AE05004A3D6C /* target.js */, - 469302AD2046AE05004A3D6C /* heritage.js */, - ); - path = sdk; - sourceTree = ""; - }; - 469302AE2046AE05004A3D6C /* actors */ = { - isa = PBXGroup; - children = ( - 469302AF2046AE05004A3D6C /* object.js */, - 469302B02046AE05004A3D6C /* utils */, - 469302B32046AE05004A3D6C /* script.js */, - 469302B42046AE05004A3D6C /* root.js */, - 469302B52046AE05004A3D6C /* source.js */, - 469302B62046AE05004A3D6C /* common.js */, - 469302B72046AE05004A3D6C /* webconsole.js */, - 469302B82046AE05004A3D6C /* breakpoint.js */, - 469302B92046AE05004A3D6C /* environment.js */, - 469302BA2046AE05004A3D6C /* frame.js */, - ); - path = actors; - sourceTree = ""; - }; - 469302B02046AE05004A3D6C /* utils */ = { - isa = PBXGroup; - children = ( - 469302B12046AE05004A3D6C /* ScriptStore.js */, - 469302B22046AE05004A3D6C /* TabSources.js */, - ); - path = utils; - sourceTree = ""; - }; 469302BE2046AE05004A3D6C /* manual */ = { isa = PBXGroup; children = ( + 1A52DB8A2060B12500350EE3 /* jsb_platform_ios.h */, + 1A52DB8B2060B12600350EE3 /* jsb_platfrom_ios.mm */, + 1A52DB872060B11800350EE3 /* jsb_platform.h */, + 1A52DB862060B11800350EE3 /* jsb_platfrom_apple.mm */, 469302D02046AE05004A3D6C /* jsb_classtype.cpp */, 469302DF2046AE05004A3D6C /* jsb_classtype.hpp */, 1A29D76D205665D100168D9A /* jsb_cocos2dx_manual.cpp */, @@ -1887,15 +2062,10 @@ 469302C72046AE05004A3D6C /* jsb_global.h */, 469302DE2046AE05004A3D6C /* jsb_helper.cpp */, 469302CF2046AE05004A3D6C /* jsb_helper.hpp */, - 1A29D791205666F500168D9A /* jsb_opengl_functions.cpp */, - 1A29D78D205666F200168D9A /* jsb_opengl_functions.hpp */, - 1A29D78A205666F100168D9A /* jsb_opengl_manual.cpp */, - 1A29D78F205666F200168D9A /* jsb_opengl_manual.hpp */, - 1A29D78B205666F200168D9A /* jsb_opengl_registration.cpp */, - 1A29D790205666F500168D9A /* jsb_opengl_registration.hpp */, + 1A29D78B205666F200168D9A /* jsb_opengl_manual.cpp */, + 1A29D790205666F500168D9A /* jsb_opengl_manual.hpp */, 1A29D78C205666F200168D9A /* jsb_opengl_utils.cpp */, 1A29D78E205666F200168D9A /* jsb_opengl_utils.hpp */, - 469302D22046AE05004A3D6C /* jsb_platfrom_ios.m */, 469302DD2046AE05004A3D6C /* jsb_renderer_manual.cpp */, 469302D12046AE05004A3D6C /* jsb_renderer_manual.hpp */, 461786592052607E008256E1 /* jsb_socketio.cpp */, @@ -2044,6 +2214,8 @@ 46FDDAE9202ADDCE00931238 /* base */ = { isa = PBXGroup; children = ( + 1A52DAF5205BB81400350EE3 /* CCThreadPool.cpp */, + 1A52DAF4205BB81400350EE3 /* CCThreadPool.h */, 1A29D7792056667700168D9A /* csscolorparser.cpp */, 1A29D77A2056667800168D9A /* csscolorparser.hpp */, 461786522052301A008256E1 /* CCScheduler.cpp */, @@ -2072,9 +2244,7 @@ 46FDDB0C202ADDCE00931238 /* ccUtils.cpp */, 46FDDB0E202ADDCE00931238 /* TGAlib.cpp */, 46FDDB11202ADDCE00931238 /* ccUTF8.cpp */, - 46FDDB13202ADDCE00931238 /* ObjectFactory.h */, 46FDDB14202ADDCE00931238 /* CCVector.h */, - 46FDDB15202ADDCE00931238 /* ObjectFactory.cpp */, 46FDDB16202ADDCE00931238 /* pvr.cpp */, 46FDDB1F202ADDCE00931238 /* uthash.h */, 46FDDB20202ADDCE00931238 /* ccUtils.h */, @@ -2526,28 +2696,32 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 1A52DB21205BCD9200350EE3 /* inspector_socket_server.h in Headers */, 1A28FF891F20AFAB007A1D9D /* SRURLUtilities.h in Headers */, 46FDDAA7202ACC6A00931238 /* ForwardRenderer.h in Headers */, 4DED48101DFFA4AF0070C5C4 /* b2Settings.h in Headers */, 4DED486A1DFFA4AF0070C5C4 /* b2MotorJoint.h in Headers */, - 46FDDB9D202ADDCE00931238 /* ObjectFactory.h in Headers */, 46FDDC41202AEAC500931238 /* Atomics.h in Headers */, 46FDDBC3202ADDCE00931238 /* ccConfig.h in Headers */, 46FDDA77202ACC6A00931238 /* Light.h in Headers */, 1A28FF5D1F20AFAB007A1D9D /* SRProxyConnect.h in Headers */, 46FDDBFF202ADDCE00931238 /* firePngData.h in Headers */, + 1A52DB5F205BCDC700350EE3 /* HelperMacros.h in Headers */, 46FDDACF202ACC6A00931238 /* RenderBuffer.h in Headers */, 46FDDAAF202ACC6A00931238 /* Texture2D.h in Headers */, 5091A7A319BFABA800AC8789 /* CCPlatformDefine.h in Headers */, 46FDDBCF202ADDCE00931238 /* CCMap.h in Headers */, + 1A52DB34205BCD9200350EE3 /* Object.hpp in Headers */, 469303962046AE05004A3D6C /* Class.hpp in Headers */, + 1A52DB6F205BCDC700350EE3 /* ScriptEngine.hpp in Headers */, 469304002046AE06004A3D6C /* jsb_global.h in Headers */, + 1A586C492064C97800B47573 /* EJConvert.h in Headers */, + 1A52DB2F205BCD9200350EE3 /* http_parser.h in Headers */, 4DED48621DFFA4AF0070C5C4 /* b2GearJoint.h in Headers */, 469303EE2046AE05004A3D6C /* jsb_renderer_auto.hpp in Headers */, 4617863720522469008256E1 /* HttpClient.h in Headers */, 50ABBD461925AB0000A911A9 /* CCVertex.h in Headers */, 46FDDA9B202ACC6A00931238 /* Effect.h in Headers */, - 1A29D79C205666F500168D9A /* jsb_opengl_manual.hpp in Headers */, 50ABBD3E1925AB0000A911A9 /* CCGeometry.h in Headers */, 46FDDAD9202ACC6A00931238 /* Program.h in Headers */, ED30579B1BEC77B70083C3ED /* ConvertUTF.h in Headers */, @@ -2573,6 +2747,7 @@ 4617862920522469008256E1 /* Uri.h in Headers */, 4DED483E1DFFA4AF0070C5C4 /* b2CircleContact.h in Headers */, 469303902046AE05004A3D6C /* MappingUtils.hpp in Headers */, + 1AAAC8F5205CB6E9005321B9 /* Export.h in Headers */, 4DED48181DFFA4AF0070C5C4 /* b2Timer.h in Headers */, 1A28FF5B1F20AFAB007A1D9D /* NSURLRequest+SRWebSocketPrivate.h in Headers */, 46FDDBE7202ADDCE00931238 /* CCNS.h in Headers */, @@ -2583,26 +2758,32 @@ 46FDDA97202ACC6A00931238 /* Model.h in Headers */, 50ABBD4A1925AB0000A911A9 /* Mat4.h in Headers */, 46FDDC3B202AEAC500931238 /* MacroArgs.h in Headers */, + 1A52DB38205BCD9200350EE3 /* ScriptEngine.hpp in Headers */, + 1A52DB892060B11800350EE3 /* jsb_platform.h in Headers */, + 1A52DB64205BCDC700350EE3 /* ScriptEngine.hpp in Headers */, 46FDDA83202ACC6A00931238 /* Technique.h in Headers */, 46FDDC43202AEAC500931238 /* Pair.h in Headers */, + 1A52DB63205BCDC700350EE3 /* Object.hpp in Headers */, 4DED480C1DFFA4AF0070C5C4 /* b2Math.h in Headers */, 469303802046AE05004A3D6C /* config.hpp in Headers */, 46FDDA6D202ACC6A00931238 /* INode.h in Headers */, + 1A52DB28205BCD9200350EE3 /* inspector_agent.h in Headers */, 1A28FF811F20AFAB007A1D9D /* SRRandom.h in Headers */, 50ABC0671926664800A911A9 /* CCPlatformDefine-mac.h in Headers */, 4DED48461DFFA4AF0070C5C4 /* b2ContactSolver.h in Headers */, 469303922046AE05004A3D6C /* SeApi.h in Headers */, 461786532052301A008256E1 /* CCScheduler.h in Headers */, - 1A29D798205666F500168D9A /* jsb_opengl_functions.hpp in Headers */, 46FDDB4D202ADDCE00931238 /* pvr.h in Headers */, 4DED48061DFFA4AF0070C5C4 /* b2Draw.h in Headers */, 46FDDC45202AEAC500931238 /* Move.h in Headers */, 4DED48721DFFA4AF0070C5C4 /* b2PrismaticJoint.h in Headers */, 4617863920522469008256E1 /* CCDownloaderImpl-apple.h in Headers */, 46FDDC2F202AEAC500931238 /* Assertions.h in Headers */, + 1A52DB73205BCDC700350EE3 /* Base.h in Headers */, 1A28FF551F20AFAB007A1D9D /* SRIOConsumerPool.h in Headers */, 461786632052607E008256E1 /* jsb_socketio.hpp in Headers */, 46FDDC2D202AEAC500931238 /* Compiler.h in Headers */, + 1A52DB2A205BCD9200350EE3 /* inspector_io.h in Headers */, 46FDDBDD202ADDCE00931238 /* TGAlib.h in Headers */, BAEA45551E279D5C00FA219F /* tinydir.h in Headers */, 46FDDAB7202ACC6A00931238 /* IndexBuffer.h in Headers */, @@ -2610,12 +2791,14 @@ 4617865D2052607E008256E1 /* jsb_xmlhttprequest.hpp in Headers */, 46FDDA7B202ACC6A00931238 /* Camera.h in Headers */, 46FDDAA5202ACC6A00931238 /* Scene.h in Headers */, + 1A52DB3B205BCD9200350EE3 /* v8_inspector_protocol_json.h in Headers */, 46FDDB53202ADDCE00931238 /* utlist.h in Headers */, 4DED47F41DFFA4AF0070C5C4 /* b2CircleShape.h in Headers */, 46FDDB5D202ADDCE00931238 /* ccMacros.h in Headers */, 46FDDC27202AEAC500931238 /* WebGLTypes.h in Headers */, 1A29D76B205665BE00168D9A /* jsb_cocos2dx_auto.hpp in Headers */, 4DED48321DFFA4AF0070C5C4 /* b2WorldCallbacks.h in Headers */, + 1A52DB3D205BCD9200350EE3 /* SeApi.h in Headers */, 46FDDC47202AEAC500931238 /* StaticAnalysisFunctions.h in Headers */, 46FDDABD202ACC6A00931238 /* DeviceGraphics.h in Headers */, 469303982046AE05004A3D6C /* HelperMacros.h in Headers */, @@ -2629,9 +2812,12 @@ 1A28FF591F20AFAB007A1D9D /* NSRunLoop+SRWebSocketPrivate.h in Headers */, 1A29D79A205666F500168D9A /* jsb_opengl_utils.hpp in Headers */, 46FDDB5B202ADDCE00931238 /* CCData.h in Headers */, - 1A29D79E205666F500168D9A /* jsb_opengl_registration.hpp in Headers */, + 1A29D79E205666F500168D9A /* jsb_opengl_manual.hpp in Headers */, 4DED488A1DFFA4AF0070C5C4 /* b2Rope.h in Headers */, 469303A22046AE05004A3D6C /* Object.hpp in Headers */, + 1A52DAF6205BB81400350EE3 /* CCThreadPool.h in Headers */, + 1AAAC8E9205CB6E9005321B9 /* AudioMacros.h in Headers */, + 1AAAC8EF205CB6E9005321B9 /* AudioEngine-inl.h in Headers */, 46FDDC29202AEAC500931238 /* Casting.h in Headers */, 4DED48361DFFA4AF0070C5C4 /* b2ChainAndCircleContact.h in Headers */, 46FDDB83202ADDCE00931238 /* ccRandom.h in Headers */, @@ -2650,29 +2836,42 @@ 46FDDA91202ACC6A00931238 /* Pass.h in Headers */, 46FDDC35202AEAC500931238 /* IntegerTypeTraits.h in Headers */, 46FDDAC7202ACC6A00931238 /* GFX.h in Headers */, + 1A52DB3A205BCD9200350EE3 /* util.h in Headers */, 46FDDC63202D502F00931238 /* CCApplication.h in Headers */, 469303A42046AE05004A3D6C /* ScriptEngine.hpp in Headers */, 4DED48081DFFA4AF0070C5C4 /* b2GrowableStack.h in Headers */, + 1A52DB68205BCDC700350EE3 /* Base.h in Headers */, BA68D79A1D62F4B700B7A3F9 /* clipper.hpp in Headers */, 4626B202202D9BE700BE30B9 /* CCGLView-desktop.h in Headers */, 50ABBD521925AB0000A911A9 /* Quaternion.h in Headers */, + 1A52DB2D205BCD9200350EE3 /* ObjectWrap.h in Headers */, BA68D7931D62F4A500B7A3F9 /* sweep_context.h in Headers */, + 1A52DB6A205BCDC700350EE3 /* HelperMacros.h in Headers */, 4DED482A1DFFA4AF0070C5C4 /* b2TimeStep.h in Headers */, + 1A52DB23205BCD9200350EE3 /* Class.hpp in Headers */, + 1A52DB43205BCD9200350EE3 /* node_debug_options.h in Headers */, 1A28FF9B1F20AFAB007A1D9D /* SRWebSocket.h in Headers */, 50643BE219BFCF1800EF68ED /* CCPlatformConfig.h in Headers */, 1A28FF611F20AFAB007A1D9D /* SRRunLoopThread.h in Headers */, 50ABBD561925AB0000A911A9 /* TransformUtils.h in Headers */, 469303D22046AE05004A3D6C /* jsb_gfx_auto.hpp in Headers */, + 1A52DB5E205BCDC700350EE3 /* Class.hpp in Headers */, 4693039C2046AE05004A3D6C /* PlatformUtils.h in Headers */, + 1AAAC8E5205CB6E9005321B9 /* AudioPlayer.h in Headers */, + 1AAAC8ED205CB6E9005321B9 /* AudioCache.h in Headers */, 46FDDBBB202ADDCE00931238 /* CCRefPtr.h in Headers */, 46FDDADB202ACC6A00931238 /* State.h in Headers */, 46FDDC33202AEAC500931238 /* Types.h in Headers */, + 1A52DB22205BCD9200350EE3 /* env.h in Headers */, 1A29D771205665D200168D9A /* jsb_cocos2dx_manual.hpp in Headers */, + 1A52DB2C205BCD9200350EE3 /* node_mutex.h in Headers */, 46FDDACB202ACC6A00931238 /* VertexFormat.h in Headers */, 46FDDA81202ACC6A00931238 /* RendererUtils.h in Headers */, 469304142046AE06004A3D6C /* jsb_renderer_manual.hpp in Headers */, 46FDDAD1202ACC6A00931238 /* Texture.h in Headers */, 4DED48421DFFA4AF0070C5C4 /* b2Contact.h in Headers */, + 1A52DB72205BCDC700350EE3 /* Utils.hpp in Headers */, + 1A52DB70205BCDC700350EE3 /* SeApi.h in Headers */, 1A28FF971F20AFAB007A1D9D /* SRSecurityPolicy.h in Headers */, 5027253A190BF1B900AAF4ED /* cocos2d.h in Headers */, 50ABBD421925AB0000A911A9 /* CCMathBase.h in Headers */, @@ -2683,6 +2882,8 @@ 4DED47D61DFFA4AF0070C5C4 /* b2BroadPhase.h in Headers */, 4DED47F81DFFA4AF0070C5C4 /* b2EdgeShape.h in Headers */, 50ABBD4E1925AB0000A911A9 /* MathUtil.h in Headers */, + 1A52DB67205BCDC700350EE3 /* Utils.hpp in Headers */, + 1A52DB25205BCD9200350EE3 /* HelperMacros.h in Headers */, 4DED48241DFFA4AF0070C5C4 /* b2Fixture.h in Headers */, 469303AC2046AE05004A3D6C /* Utils.hpp in Headers */, 1A28FF911F20AFAB007A1D9D /* NSURLRequest+SRWebSocket.h in Headers */, @@ -2711,7 +2912,10 @@ 46FDDBB7202ADDCE00931238 /* ccUtils.h in Headers */, 46FDDB6B202ADDCE00931238 /* base64.h in Headers */, 46FDDC3F202AEAC500931238 /* Likely.h in Headers */, + 1A52DB33205BCD9200350EE3 /* node.h in Headers */, + 1A52DB45205BCD9200350EE3 /* Base.h in Headers */, 4DED484A1DFFA4AF0070C5C4 /* b2EdgeAndCircleContact.h in Headers */, + 1A52DB65205BCDC700350EE3 /* SeApi.h in Headers */, 1A28FF6D1F20AFAB007A1D9D /* SRError.h in Headers */, 4DED48821DFFA4AF0070C5C4 /* b2WeldJoint.h in Headers */, 4DED48661DFFA4AF0070C5C4 /* b2Joint.h in Headers */, @@ -2720,6 +2924,7 @@ 46FDDBC9202ADDCE00931238 /* ccFPSImages.h in Headers */, 46FDDA85202ACC6A00931238 /* View.h in Headers */, 4DED484E1DFFA4AF0070C5C4 /* b2EdgeAndPolygonContact.h in Headers */, + 1AAAC875205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp in Headers */, BA68D7811D62F4A500B7A3F9 /* utils.h in Headers */, 1A28FF951F20AFAB007A1D9D /* SocketRocket.h in Headers */, BA68D78B1D62F4A500B7A3F9 /* cdt.h in Headers */, @@ -2729,11 +2934,14 @@ 50ABBD5A1925AB0000A911A9 /* Vec2.h in Headers */, 1A37E9C7200DDFC70078AF72 /* CCReachability.h in Headers */, 46FDDB81202ADDCE00931238 /* ccTypes.h in Headers */, + 1A52DB36205BCD9200350EE3 /* util-inl.h in Headers */, 469304302046AE06004A3D6C /* jsb_classtype.hpp in Headers */, 46FDDADD202ACC6A00931238 /* VertexBuffer.h in Headers */, 4DED486E1DFFA4AF0070C5C4 /* b2MouseJoint.h in Headers */, 1A28FF8D1F20AFAB007A1D9D /* NSRunLoop+SRWebSocket.h in Headers */, + 1A52DB40205BCD9200350EE3 /* inspector_socket.h in Headers */, 4DED48521DFFA4AF0070C5C4 /* b2PolygonAndCircleContact.h in Headers */, + 1A52DB3C205BCD9200350EE3 /* SHA1.h in Headers */, 4DED48861DFFA4AF0070C5C4 /* b2WheelJoint.h in Headers */, 469304202046AE06004A3D6C /* jsb_gfx_manual.hpp in Headers */, 4DED485A1DFFA4AF0070C5C4 /* b2DistanceJoint.h in Headers */, @@ -2744,6 +2952,7 @@ 46FDDBCB202ADDCE00931238 /* ZipUtils.h in Headers */, 50ABBFFD1926664800A911A9 /* CCFileUtils-apple.h in Headers */, 46FDDA8F202ACC6A00931238 /* BaseRenderer.h in Headers */, + 1A52DB69205BCDC700350EE3 /* Class.hpp in Headers */, 46FDDAD7202ACC6A00931238 /* GFXUtils.h in Headers */, 4617866D2052609B008256E1 /* jsb_cocos2dx_network_auto.hpp in Headers */, 50ABC00F1926664800A911A9 /* CCFileUtils.h in Headers */, @@ -2755,14 +2964,19 @@ 46FDDC49202AEAC500931238 /* WebGLFormats.h in Headers */, 46FDDBD1202ADDCE00931238 /* ccUTF8.h in Headers */, 4693045A2046AE06004A3D6C /* EventDispatcher.h in Headers */, + 1AAAC8F3205CB6E9005321B9 /* AudioEngine.h in Headers */, + 1A52DB6E205BCDC700350EE3 /* Object.hpp in Headers */, ED3057A21BEC77D50083C3ED /* xxhash.h in Headers */, + 1A52DB42205BCD9200350EE3 /* Utils.hpp in Headers */, 50ABC00B1926664800A911A9 /* CCDevice.h in Headers */, 46FDDB89202ADDCE00931238 /* CCRef.h in Headers */, 46FDDC3D202AEAC500931238 /* CheckedInt.h in Headers */, 4DED47E41DFFA4AF0070C5C4 /* b2Distance.h in Headers */, + 1A52DB29205BCD9200350EE3 /* base64.h in Headers */, 46FDDBE9202ADDCE00931238 /* CCAutoreleasePool.h in Headers */, 46FDDB4F202ADDCE00931238 /* CCValue.h in Headers */, 46FDDBB5202ADDCE00931238 /* uthash.h in Headers */, + 1AAAC8DF205CB6E9005321B9 /* AudioDecoder.h in Headers */, 4617862520522469008256E1 /* CCDownloader.h in Headers */, 1A28FF7D1F20AFAB007A1D9D /* SRMutex.h in Headers */, 1A28FF711F20AFAB007A1D9D /* SRHash.h in Headers */, @@ -2771,6 +2985,7 @@ ED30577F1BEC76C90083C3ED /* ioapi_mem.h in Headers */, 4617864B20522469008256E1 /* HttpCookie.h in Headers */, 4DED48281DFFA4AF0070C5C4 /* b2Island.h in Headers */, + 1A586C432064C90500B47573 /* EJConvertTypedArray.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2801,7 +3016,6 @@ BA68D7801D62F4A500B7A3F9 /* shapes.h in Headers */, 1A29D76C205665BE00168D9A /* jsb_cocos2dx_auto.hpp in Headers */, 46FDDC3E202AEAC500931238 /* CheckedInt.h in Headers */, - 1A29D79D205666F500168D9A /* jsb_opengl_manual.hpp in Headers */, 46FDDBB8202ADDCE00931238 /* ccUtils.h in Headers */, 50643BE319BFCF1800EF68ED /* CCPlatformConfig.h in Headers */, 46FDDA92202ACC6A00931238 /* Pass.h in Headers */, @@ -2818,7 +3032,11 @@ 46FDDAA6202ACC6A00931238 /* Scene.h in Headers */, 46FDDC4A202AEAC500931238 /* WebGLFormats.h in Headers */, 4DED486F1DFFA4AF0070C5C4 /* b2MouseJoint.h in Headers */, + 1A586C4A2064C97800B47573 /* EJConvert.h in Headers */, + 1AAAC8E0205CB6E9005321B9 /* AudioDecoder.h in Headers */, 1A28FF821F20AFAB007A1D9D /* SRRandom.h in Headers */, + 1A52DB79205BCDD000350EE3 /* Object.hpp in Headers */, + 1A52DB8C2060B12600350EE3 /* jsb_platform_ios.h in Headers */, 50643BD619BFAEDA00EF68ED /* CCPlatformDefine.h in Headers */, 4DED48871DFFA4AF0070C5C4 /* b2WheelJoint.h in Headers */, 4DED47F91DFFA4AF0070C5C4 /* b2EdgeShape.h in Headers */, @@ -2828,6 +3046,7 @@ 4DED48831DFFA4AF0070C5C4 /* b2WeldJoint.h in Headers */, 4DED48191DFFA4AF0070C5C4 /* b2Timer.h in Headers */, 4DED487B1DFFA4AF0070C5C4 /* b2RevoluteJoint.h in Headers */, + 1A586C442064C90500B47573 /* EJConvertTypedArray.h in Headers */, 46FDDC44202AEAC500931238 /* Pair.h in Headers */, BA68D7941D62F4A500B7A3F9 /* sweep_context.h in Headers */, 46FDDA82202ACC6A00931238 /* RendererUtils.h in Headers */, @@ -2843,6 +3062,7 @@ 4DED482F1DFFA4AF0070C5C4 /* b2World.h in Headers */, 469304112046AE06004A3D6C /* jsb_helper.hpp in Headers */, 50ABBD571925AB0000A911A9 /* TransformUtils.h in Headers */, + 1A52DAF7205BB81400350EE3 /* CCThreadPool.h in Headers */, 50ABBD5B1925AB0000A911A9 /* Vec2.h in Headers */, 50ABBD411925AB0000A911A9 /* CCMath.h in Headers */, 4DED47ED1DFFA4AF0070C5C4 /* b2TimeOfImpact.h in Headers */, @@ -2862,6 +3082,7 @@ 469303EF2046AE05004A3D6C /* jsb_renderer_auto.hpp in Headers */, 1A28FF521F20AFAB007A1D9D /* SRIOConsumer.h in Headers */, 1A28FF981F20AFAB007A1D9D /* SRSecurityPolicy.h in Headers */, + 1A52DB76205BCDD000350EE3 /* Class.hpp in Headers */, 50643BDC19BFAF4400EF68ED /* CCStdC.h in Headers */, 469303AF2046AE05004A3D6C /* Base.h in Headers */, 46930467204FE20F004A3D6C /* CCLog.h in Headers */, @@ -2870,6 +3091,7 @@ 46FDDBBC202ADDCE00931238 /* CCRefPtr.h in Headers */, 4DED48211DFFA4AF0070C5C4 /* b2ContactManager.h in Headers */, 4617864C20522469008256E1 /* HttpCookie.h in Headers */, + 1A52DB74205BCDD000350EE3 /* Base.h in Headers */, 469304012046AE06004A3D6C /* jsb_global.h in Headers */, 4DED47E91DFFA4AF0070C5C4 /* b2DynamicTree.h in Headers */, 46FDDBCA202ADDCE00931238 /* ccFPSImages.h in Headers */, @@ -2907,6 +3129,7 @@ 46FDDAC4202ACC6A00931238 /* FrameBuffer.h in Headers */, 46FDDAD2202ACC6A00931238 /* Texture.h in Headers */, 469303992046AE05004A3D6C /* HelperMacros.h in Headers */, + 1AAAC8EE205CB6E9005321B9 /* AudioCache.h in Headers */, 1A28FF721F20AFAB007A1D9D /* SRHash.h in Headers */, 4DED48631DFFA4AF0070C5C4 /* b2GearJoint.h in Headers */, 46FDDC2E202AEAC500931238 /* Compiler.h in Headers */, @@ -2922,7 +3145,6 @@ 4DED47FD1DFFA4AF0070C5C4 /* b2PolygonShape.h in Headers */, 4693038B2046AE05004A3D6C /* State.hpp in Headers */, 46FDDADC202ACC6A00931238 /* State.h in Headers */, - 46FDDB9E202ADDCE00931238 /* ObjectFactory.h in Headers */, 46FDDC42202AEAC500931238 /* Atomics.h in Headers */, 46FDDB8A202ADDCE00931238 /* CCRef.h in Headers */, 4DED47D71DFFA4AF0070C5C4 /* b2BroadPhase.h in Headers */, @@ -2932,8 +3154,10 @@ 4DED48571DFFA4AF0070C5C4 /* b2PolygonContact.h in Headers */, 469303D32046AE05004A3D6C /* jsb_gfx_auto.hpp in Headers */, 4DED47F51DFFA4AF0070C5C4 /* b2CircleShape.h in Headers */, + 1AAAC8F4205CB6E9005321B9 /* AudioEngine.h in Headers */, 46FDDA78202ACC6A00931238 /* Light.h in Headers */, 1A29D7A420566CAC00168D9A /* CCCanvasRenderingContext2D.h in Headers */, + 1A52DB7C205BCDD000350EE3 /* SeApi.h in Headers */, 4DED48671DFFA4AF0070C5C4 /* b2Joint.h in Headers */, 469303A92046AE05004A3D6C /* SeApi.h in Headers */, 46FDDAAE202ACC6A00931238 /* Macro.h in Headers */, @@ -2943,6 +3167,7 @@ 1A28FF4E1F20AFAB007A1D9D /* SRDelegateController.h in Headers */, 469301D0203FC696004A3D6C /* CCConfiguration.h in Headers */, 46FDDB6E202ADDCE00931238 /* etc1.h in Headers */, + 1AAAC8E6205CB6E9005321B9 /* AudioPlayer.h in Headers */, 4DED481D1DFFA4AF0070C5C4 /* b2Body.h in Headers */, 469303A52046AE05004A3D6C /* ScriptEngine.hpp in Headers */, 4DED48731DFFA4AF0070C5C4 /* b2PrismaticJoint.h in Headers */, @@ -2958,7 +3183,6 @@ 461786542052301A008256E1 /* CCScheduler.h in Headers */, 50ABC0181926664800A911A9 /* CCImage.h in Headers */, 503DD8EB1926736A00CD74DD /* CCGL-ios.h in Headers */, - 1A29D799205666F500168D9A /* jsb_opengl_functions.hpp in Headers */, 46FDDA7C202ACC6A00931238 /* Camera.h in Headers */, 4DED48151DFFA4AF0070C5C4 /* b2StackAllocator.h in Headers */, 4617862420522469008256E1 /* CCIDownloaderImpl.h in Headers */, @@ -2967,6 +3191,8 @@ BA68D79B1D62F4B700B7A3F9 /* clipper.hpp in Headers */, 4DED48111DFFA4AF0070C5C4 /* b2Settings.h in Headers */, 46FDDAAC202ACC6A00931238 /* Types.h in Headers */, + 1AAAC876205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.hpp in Headers */, + 1A52DB7B205BCDD000350EE3 /* ScriptEngine.hpp in Headers */, 1A29D772205665D200168D9A /* jsb_cocos2dx_manual.hpp in Headers */, 1A29D789205666B200168D9A /* LocalStorage.h in Headers */, 46FDDC67202D504E00931238 /* CCApplication.h in Headers */, @@ -2979,13 +3205,14 @@ 50643BD519BFAECF00EF68ED /* CCGL.h in Headers */, 46FDDB84202ADDCE00931238 /* ccRandom.h in Headers */, 46FDDC4E202AEAC500931238 /* WebGLTexelConversions.h in Headers */, + 1AAAC8EA205CB6E9005321B9 /* AudioMacros.h in Headers */, 46FDDC30202AEAC500931238 /* Assertions.h in Headers */, 4617862620522469008256E1 /* CCDownloader.h in Headers */, 46FDDBD2202ADDCE00931238 /* ccUTF8.h in Headers */, 46FDDC2A202AEAC500931238 /* Casting.h in Headers */, 50ABBD5F1925AB0000A911A9 /* Vec3.h in Headers */, 46FDDC02202ADDCE00931238 /* ccCArray.h in Headers */, - 1A29D79F205666F500168D9A /* jsb_opengl_registration.hpp in Headers */, + 1A29D79F205666F500168D9A /* jsb_opengl_manual.hpp in Headers */, 46FDDAE0202ACC6A00931238 /* RenderTarget.h in Headers */, 50ABBD471925AB0000A911A9 /* CCVertex.h in Headers */, 46FDDA90202ACC6A00931238 /* BaseRenderer.h in Headers */, @@ -2995,7 +3222,9 @@ 4617863220522469008256E1 /* SocketIO.h in Headers */, 46FDDAB8202ACC6A00931238 /* IndexBuffer.h in Headers */, 1A28FF5C1F20AFAB007A1D9D /* NSURLRequest+SRWebSocketPrivate.h in Headers */, + 1AAAC8F0205CB6E9005321B9 /* AudioEngine-inl.h in Headers */, 1A28FF6E1F20AFAB007A1D9D /* SRError.h in Headers */, + 1AAAC8F6205CB6E9005321B9 /* Export.h in Headers */, 4DED47F11DFFA4AF0070C5C4 /* b2ChainShape.h in Headers */, 4DED48771DFFA4AF0070C5C4 /* b2PulleyJoint.h in Headers */, 4DED483F1DFFA4AF0070C5C4 /* b2CircleContact.h in Headers */, @@ -3008,8 +3237,10 @@ 46178671205262BC008256E1 /* jsb_conversions.hpp in Headers */, 469304212046AE06004A3D6C /* jsb_gfx_manual.hpp in Headers */, 50ABC01C1926664800A911A9 /* CCSAXParser.h in Headers */, + 1A52DB77205BCDD000350EE3 /* HelperMacros.h in Headers */, 469304312046AE06004A3D6C /* jsb_classtype.hpp in Headers */, 46FDDBD0202ADDCE00931238 /* CCMap.h in Headers */, + 1A52DB7E205BCDD000350EE3 /* Utils.hpp in Headers */, 503DD8F11926736A00CD74DD /* OpenGL_Internal-ios.h in Headers */, 1A28FF5A1F20AFAB007A1D9D /* NSRunLoop+SRWebSocketPrivate.h in Headers */, 1A28FF861F20AFAB007A1D9D /* SRSIMDHelpers.h in Headers */, @@ -3089,16 +3320,19 @@ buildActionMask = 2147483647; files = ( 46FDDBB9202ADDCE00931238 /* CCNS.cpp in Sources */, - 1A29D794205666F500168D9A /* jsb_opengl_registration.cpp in Sources */, + 1A29D794205666F500168D9A /* jsb_opengl_manual.cpp in Sources */, 4693038C2046AE05004A3D6C /* config.cpp in Sources */, 46FDDA7D202ACC6A00931238 /* Light.cpp in Sources */, 4693042C2046AE06004A3D6C /* jsb_renderer_manual.cpp in Sources */, + 1AAAC8E3205CB6E9005321B9 /* AudioDecoder.mm in Sources */, + 1A52DB66205BCDC700350EE3 /* Class.cpp in Sources */, 46FDDC37202AEAC500931238 /* Assertions.cpp in Sources */, 1A28FF7F1F20AFAB007A1D9D /* SRMutex.m in Sources */, 4DED48381DFFA4AF0070C5C4 /* b2ChainAndPolygonContact.cpp in Sources */, 469303942046AE05004A3D6C /* RefCounter.cpp in Sources */, 469304262046AE06004A3D6C /* jsb_conversions.cpp in Sources */, 469304582046AE06004A3D6C /* EventDispatcher.cpp in Sources */, + 1A52DAF8205BB81400350EE3 /* CCThreadPool.cpp in Sources */, 4DED48221DFFA4AF0070C5C4 /* b2Fixture.cpp in Sources */, 46FDDB65202ADDCE00931238 /* ccRandom.cpp in Sources */, 46FDDAB9202ACC6A00931238 /* FrameBuffer.cpp in Sources */, @@ -3112,7 +3346,9 @@ 46FDDAA3202ACC6A00931238 /* InputAssembler.cpp in Sources */, 4DED48581DFFA4AF0070C5C4 /* b2DistanceJoint.cpp in Sources */, 46FDDC25202AEAC500931238 /* WebGLTexelConversions.cpp in Sources */, - 469304162046AE06004A3D6C /* jsb_platfrom_ios.m in Sources */, + 1AAAC8EB205CB6E9005321B9 /* AudioCache.mm in Sources */, + 1A52DB61205BCDC700350EE3 /* Object.cpp in Sources */, + 1A52DB44205BCD9200350EE3 /* env.cc in Sources */, 50ABBD501925AB0000A911A9 /* Quaternion.cpp in Sources */, ED30579A1BEC77B70083C3ED /* ConvertUTF.c in Sources */, 46FDDA79202ACC6A00931238 /* Camera.cpp in Sources */, @@ -3120,24 +3356,34 @@ 46FDDAC1202ACC6A00931238 /* Texture.cpp in Sources */, 1A28FF6B1F20AFAB007A1D9D /* SRConstants.m in Sources */, 294D7D9C1D0E93A2002CE7B7 /* CCDevice-apple.mm in Sources */, + 1A586C452064C90500B47573 /* EJConvertTypedArray.m in Sources */, 1A29D77B2056667800168D9A /* csscolorparser.cpp in Sources */, 46FDDA71202ACC6A00931238 /* Scene.cpp in Sources */, 469303C62046AE05004A3D6C /* jsb_gfx_auto.cpp in Sources */, + 1A52DB3F205BCD9200350EE3 /* http_parser.c in Sources */, 4DED48301DFFA4AF0070C5C4 /* b2WorldCallbacks.cpp in Sources */, 4DED48741DFFA4AF0070C5C4 /* b2PulleyJoint.cpp in Sources */, + 1A52DB37205BCD9200350EE3 /* inspector_socket.cc in Sources */, + 1A52DB41205BCD9200350EE3 /* node_debug_options.cc in Sources */, 4DED481A1DFFA4AF0070C5C4 /* b2Body.cpp in Sources */, 469304122046AE06004A3D6C /* jsb_classtype.cpp in Sources */, 50ABBFFF1926664800A911A9 /* CCFileUtils-apple.mm in Sources */, 4DED48701DFFA4AF0070C5C4 /* b2PrismaticJoint.cpp in Sources */, 4DED48681DFFA4AF0070C5C4 /* b2MotorJoint.cpp in Sources */, 4617866B2052609B008256E1 /* jsb_cocos2dx_network_auto.cpp in Sources */, + 1A52DB30205BCD9200350EE3 /* ScriptEngine.cpp in Sources */, + 1A52DB62205BCDC700350EE3 /* ScriptEngine.cpp in Sources */, BA68D7911D62F4A500B7A3F9 /* sweep_context.cc in Sources */, 4DED480A1DFFA4AF0070C5C4 /* b2Math.cpp in Sources */, 4DED47EE1DFFA4AF0070C5C4 /* b2ChainShape.cpp in Sources */, 4DC57D211F7A58B5005B6546 /* xxtea.cpp in Sources */, 4DED482C1DFFA4AF0070C5C4 /* b2World.cpp in Sources */, + 1A586C4B2064C97800B47573 /* EJConvert.m in Sources */, 4DED47D81DFFA4AF0070C5C4 /* b2CollideCircle.cpp in Sources */, + 1AAAC8E7205CB6E9005321B9 /* AudioEngine-inl.mm in Sources */, 46FDDB71202ADDCE00931238 /* base64.cpp in Sources */, + 1A52DB2B205BCD9200350EE3 /* inspector_socket_server.cc in Sources */, + 1AAAC873205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp in Sources */, 46FDDA8D202ACC6A00931238 /* Config.cpp in Sources */, BA68D7851D62F4A500B7A3F9 /* advancing_front.cc in Sources */, 46930468204FE20F004A3D6C /* CCLog.cpp in Sources */, @@ -3145,14 +3391,17 @@ 4DED48881DFFA4AF0070C5C4 /* b2Rope.cpp in Sources */, 46FDDAE1202ACC6A00931238 /* GFXUtils.cpp in Sources */, 4DED48541DFFA4AF0070C5C4 /* b2PolygonContact.cpp in Sources */, + 1A52DB6B205BCDC700350EE3 /* Utils.cpp in Sources */, BA68D78D1D62F4A500B7A3F9 /* sweep.cc in Sources */, 4693042E2046AE06004A3D6C /* jsb_helper.cpp in Sources */, - 469303A02046AE05004A3D6C /* ScriptEngine.cpp in Sources */, + 1A52DB31205BCD9200350EE3 /* inspector_agent.cc in Sources */, + 469303A02046AE05004A3D6C /* ScriptEngine.mm in Sources */, 46FDDAB5202ACC6A00931238 /* Program.cpp in Sources */, 46FDDBF9202ADDCE00931238 /* etc1.cpp in Sources */, 50ABBD4C1925AB0000A911A9 /* MathUtil.cpp in Sources */, 46FDDA99202ACC6A00931238 /* Model.cpp in Sources */, 4693038E2046AE05004A3D6C /* Value.cpp in Sources */, + 1A52DB39205BCD9200350EE3 /* inspector_io.cc in Sources */, 46FDDC4F202AEAC500931238 /* WebGLFormats.cpp in Sources */, 46FDDA89202ACC6A00931238 /* Effect.cpp in Sources */, 4DED48161DFFA4AF0070C5C4 /* b2Timer.cpp in Sources */, @@ -3166,12 +3415,14 @@ 46FDDB8B202ADDCE00931238 /* CCAutoreleasePool.cpp in Sources */, 461786652052607E008256E1 /* jsb_websocket.cpp in Sources */, 46FDDA87202ACC6A00931238 /* View.cpp in Sources */, + 1A52DB71205BCDC700350EE3 /* Class.cpp in Sources */, 4617862120522469008256E1 /* HttpCookie.cpp in Sources */, 1A29D769205665BE00168D9A /* jsb_cocos2dx_auto.cpp in Sources */, ED3057821BEC76C90083C3ED /* unzip.cpp in Sources */, 1A28FF8F1F20AFAB007A1D9D /* NSRunLoop+SRWebSocket.m in Sources */, 469303A62046AE05004A3D6C /* PlatformUtils.mm in Sources */, ED3057801BEC76C90083C3ED /* ioapi.cpp in Sources */, + 1A52DB26205BCD9200350EE3 /* Utils.cpp in Sources */, 46FDDA9F202ACC6A00931238 /* ProgramLib.cpp in Sources */, 46FDDABB202ACC6A00931238 /* VertexFormat.cpp in Sources */, 4DED48801DFFA4AF0070C5C4 /* b2WeldJoint.cpp in Sources */, @@ -3185,6 +3436,7 @@ 4DED47DE1DFFA4AF0070C5C4 /* b2Collision.cpp in Sources */, 46FDDAA9202ACC6A00931238 /* Types.cpp in Sources */, 4DED48001DFFA4AF0070C5C4 /* b2BlockAllocator.cpp in Sources */, + 1A52DB32205BCD9200350EE3 /* SHA1.cpp in Sources */, BA68D7981D62F4B600B7A3F9 /* clipper.cpp in Sources */, 1A28FF4F1F20AFAB007A1D9D /* SRDelegateController.m in Sources */, 4DED485C1DFFA4AF0070C5C4 /* b2FrictionJoint.cpp in Sources */, @@ -3192,14 +3444,19 @@ 4DED48041DFFA4AF0070C5C4 /* b2Draw.cpp in Sources */, 4DED487C1DFFA4AF0070C5C4 /* b2RopeJoint.cpp in Sources */, 46FDDBFB202ADDCE00931238 /* ccCArray.cpp in Sources */, + 1AAAC8E1205CB6E9005321B9 /* AudioPlayer.mm in Sources */, 1A28FF631F20AFAB007A1D9D /* SRRunLoopThread.m in Sources */, + 1A52DB27205BCD9200350EE3 /* node.cc in Sources */, 50ABBD5C1925AB0000A911A9 /* Vec3.cpp in Sources */, 469303662046AE05004A3D6C /* HandleObject.cpp in Sources */, 469301D1203FC696004A3D6C /* CCConfiguration.cpp in Sources */, + 1A52DB35205BCD9200350EE3 /* util.cc in Sources */, ED3057911BEC77770083C3ED /* edtaa3func.cpp in Sources */, 46FDDB93202ADDCE00931238 /* TGAlib.cpp in Sources */, + 1A52DB60205BCDC700350EE3 /* Utils.cpp in Sources */, 1A28FF831F20AFAB007A1D9D /* SRRandom.m in Sources */, 46FDDAC5202ACC6A00931238 /* RenderTarget.cpp in Sources */, + 1A52DB6D205BCDC700350EE3 /* ScriptEngine.cpp in Sources */, 50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */, 1A28FF771F20AFAB007A1D9D /* SRHTTPConnectMessage.m in Sources */, 46FDDB99202ADDCE00931238 /* ccUTF8.cpp in Sources */, @@ -3213,20 +3470,18 @@ 1A28FF7B1F20AFAB007A1D9D /* SRLog.m in Sources */, 1A29D7772056660300168D9A /* CCCanvasRenderingContext2D-mac.mm in Sources */, 4DED48401DFFA4AF0070C5C4 /* b2Contact.cpp in Sources */, - 1A29D792205666F500168D9A /* jsb_opengl_manual.cpp in Sources */, 46FDDAC9202ACC6A00931238 /* RenderBuffer.cpp in Sources */, 4DED48441DFFA4AF0070C5C4 /* b2ContactSolver.cpp in Sources */, BA68D7891D62F4A500B7A3F9 /* cdt.cc in Sources */, 1A28FF6F1F20AFAB007A1D9D /* SRError.m in Sources */, 1A28FF531F20AFAB007A1D9D /* SRIOConsumer.m in Sources */, 1A29D784205666B200168D9A /* LocalStorage.cpp in Sources */, - 1A29D7A0205666F500168D9A /* jsb_opengl_functions.cpp in Sources */, 46FDDB4B202ADDCE00931238 /* ccFPSImages.c in Sources */, 4DED48501DFFA4AF0070C5C4 /* b2PolygonAndCircleContact.cpp in Sources */, 4617864920522469008256E1 /* CCDownloader.cpp in Sources */, 1A9F0F971F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp in Sources */, 1A37E9C8200DDFC90078AF72 /* CCReachability.cpp in Sources */, - 4693039E2046AE05004A3D6C /* Object.cpp in Sources */, + 4693039E2046AE05004A3D6C /* Object.mm in Sources */, 46FDDA8B202ACC6A00931238 /* ForwardRenderer.cpp in Sources */, 50ABBD481925AB0000A911A9 /* Mat4.cpp in Sources */, 50ABBD441925AB0000A911A9 /* CCVertex.cpp in Sources */, @@ -3245,14 +3500,20 @@ 469303682046AE05004A3D6C /* State.cpp in Sources */, 4693039A2046AE05004A3D6C /* Utils.cpp in Sources */, 4DED47FA1DFFA4AF0070C5C4 /* b2PolygonShape.cpp in Sources */, + 1A52DB882060B11800350EE3 /* jsb_platfrom_apple.mm in Sources */, 4617864720522469008256E1 /* CCDownloaderImpl-apple.mm in Sources */, 4DED48841DFFA4AF0070C5C4 /* b2WheelJoint.cpp in Sources */, + 1A52DB24205BCD9200350EE3 /* ObjectWrap.cpp in Sources */, + 1AAAC8F1205CB6E9005321B9 /* AudioEngine.cpp in Sources */, 46FDDAE5202ACC6B00931238 /* IndexBuffer.cpp in Sources */, 1A29D76F205665D200168D9A /* jsb_cocos2dx_manual.cpp in Sources */, 50ABC00D1926664800A911A9 /* CCFileUtils.cpp in Sources */, 4DED486C1DFFA4AF0070C5C4 /* b2MouseJoint.cpp in Sources */, 46FDDBA3202ADDCE00931238 /* pvr.cpp in Sources */, 46FDDBE3202ADDCE00931238 /* CCData.cpp in Sources */, + 1A52DB3E205BCD9200350EE3 /* Class.cpp in Sources */, + 1A52DB2E205BCD9200350EE3 /* Object.cpp in Sources */, + 1A52DB6C205BCDC700350EE3 /* Object.cpp in Sources */, 1A28FF731F20AFAB007A1D9D /* SRHash.m in Sources */, 46FDDAB3202ACC6A00931238 /* VertexBuffer.cpp in Sources */, 4DED48601DFFA4AF0070C5C4 /* b2GearJoint.cpp in Sources */, @@ -3280,7 +3541,6 @@ 4DED47DA1DFFA4AF0070C5C4 /* b2CollideEdge.cpp in Sources */, 46FDDA95202ACC6A00931238 /* RendererUtils.cpp in Sources */, 1A28FF9D1F20AFAB007A1D9D /* SRWebSocket.m in Sources */, - 46FDDBA1202ADDCE00931238 /* ObjectFactory.cpp in Sources */, 46FDDB8F202ADDCE00931238 /* ccUtils.cpp in Sources */, 1A29D796205666F500168D9A /* jsb_opengl_utils.cpp in Sources */, 1A28FF931F20AFAB007A1D9D /* NSURLRequest+SRWebSocket.m in Sources */, @@ -3293,6 +3553,7 @@ files = ( ED30578D1BEC77550083C3ED /* unzip.cpp in Sources */, 46FDDA9E202ACC6A00931238 /* BaseRenderer.cpp in Sources */, + 1A586C462064C90500B47573 /* EJConvertTypedArray.m in Sources */, 46FDDAC6202ACC6A00931238 /* RenderTarget.cpp in Sources */, 4617864820522469008256E1 /* CCDownloaderImpl-apple.mm in Sources */, 1A28FF601F20AFAB007A1D9D /* SRProxyConnect.m in Sources */, @@ -3323,6 +3584,7 @@ ED30578C1BEC77510083C3ED /* ioapi.cpp in Sources */, 4617866C2052609B008256E1 /* jsb_cocos2dx_network_auto.cpp in Sources */, 4DED48411DFFA4AF0070C5C4 /* b2Contact.cpp in Sources */, + 1AAAC8F2205CB6E9005321B9 /* AudioEngine.cpp in Sources */, 4DED48791DFFA4AF0070C5C4 /* b2RevoluteJoint.cpp in Sources */, 4DED47D91DFFA4AF0070C5C4 /* b2CollideCircle.cpp in Sources */, 46FDDAE4202ACC6B00931238 /* GFX.cpp in Sources */, @@ -3345,15 +3607,13 @@ 1A28FF681F20AFAB007A1D9D /* SRPinningSecurityPolicy.m in Sources */, 1A28FF9E1F20AFAB007A1D9D /* SRWebSocket.m in Sources */, 46FDDA9A202ACC6A00931238 /* Model.cpp in Sources */, - 1A29D793205666F500168D9A /* jsb_opengl_manual.cpp in Sources */, 4693038F2046AE05004A3D6C /* Value.cpp in Sources */, 1A37E9C6200DD0680078AF72 /* CCReachability.cpp in Sources */, - 46FDDBA2202ADDCE00931238 /* ObjectFactory.cpp in Sources */, BA68D7991D62F4B600B7A3F9 /* clipper.cpp in Sources */, - 469303A12046AE05004A3D6C /* ScriptEngine.cpp in Sources */, + 469303A12046AE05004A3D6C /* ScriptEngine.mm in Sources */, 46FDDB8C202ADDCE00931238 /* CCAutoreleasePool.cpp in Sources */, 461786622052607E008256E1 /* jsb_socketio.cpp in Sources */, - 4693039F2046AE05004A3D6C /* Object.cpp in Sources */, + 4693039F2046AE05004A3D6C /* Object.mm in Sources */, 46FDDABA202ACC6A00931238 /* FrameBuffer.cpp in Sources */, 4DED48511DFFA4AF0070C5C4 /* b2PolygonAndCircleContact.cpp in Sources */, 461786562052301A008256E1 /* CCScheduler.cpp in Sources */, @@ -3362,6 +3622,8 @@ 46FDDB8E202ADDCE00931238 /* ccTypes.cpp in Sources */, 50ABBD4D1925AB0000A911A9 /* MathUtil.cpp in Sources */, BA68D78A1D62F4A500B7A3F9 /* cdt.cc in Sources */, + 1A52DB75205BCDD000350EE3 /* Class.cpp in Sources */, + 1AAAC8E4205CB6E9005321B9 /* AudioDecoder.mm in Sources */, 46FDDB90202ADDCE00931238 /* ccUtils.cpp in Sources */, 4DED48711DFFA4AF0070C5C4 /* b2PrismaticJoint.cpp in Sources */, 4DED48851DFFA4AF0070C5C4 /* b2WheelJoint.cpp in Sources */, @@ -3370,8 +3632,10 @@ 46FDDA94202ACC6A00931238 /* Technique.cpp in Sources */, 46FDDA72202ACC6A00931238 /* Scene.cpp in Sources */, 4DED47F31DFFA4AF0070C5C4 /* b2CircleShape.cpp in Sources */, + 1A52DB7D205BCDD000350EE3 /* Utils.cpp in Sources */, 1A29D770205665D200168D9A /* jsb_cocos2dx_manual.cpp in Sources */, 4DED48611DFFA4AF0070C5C4 /* b2GearJoint.cpp in Sources */, + 1A52DAF9205BB81400350EE3 /* CCThreadPool.cpp in Sources */, 4617864A20522469008256E1 /* CCDownloader.cpp in Sources */, 4DED48271DFFA4AF0070C5C4 /* b2Island.cpp in Sources */, 4DED48131DFFA4AF0070C5C4 /* b2StackAllocator.cpp in Sources */, @@ -3381,17 +3645,19 @@ 46FDDB9A202ADDCE00931238 /* ccUTF8.cpp in Sources */, 469304092046AE06004A3D6C /* jsb_global.cpp in Sources */, 46FDDA70202ACC6A00931238 /* Pass.cpp in Sources */, - 1A29D7A1205666F500168D9A /* jsb_opengl_functions.cpp in Sources */, + 1A52DB7A205BCDD000350EE3 /* ScriptEngine.cpp in Sources */, 46FDDBBA202ADDCE00931238 /* CCNS.cpp in Sources */, 1A28FF741F20AFAB007A1D9D /* SRHash.m in Sources */, 46FDDB70202ADDCE00931238 /* ZipUtils.cpp in Sources */, 50ABBD511925AB0000A911A9 /* Quaternion.cpp in Sources */, 46930469204FE20F004A3D6C /* CCLog.cpp in Sources */, 4DED485D1DFFA4AF0070C5C4 /* b2FrictionJoint.cpp in Sources */, + 1AAAC874205CB647005321B9 /* jsb_cocos2dx_audioengine_auto.cpp in Sources */, 50ABBD491925AB0000A911A9 /* Mat4.cpp in Sources */, 469303672046AE05004A3D6C /* HandleObject.cpp in Sources */, 46FDDACA202ACC6A00931238 /* RenderBuffer.cpp in Sources */, 4DED484D1DFFA4AF0070C5C4 /* b2EdgeAndPolygonContact.cpp in Sources */, + 1A52DB78205BCDD000350EE3 /* Object.cpp in Sources */, 46FDDC26202AEAC500931238 /* WebGLTexelConversions.cpp in Sources */, 46FDDB4C202ADDCE00931238 /* ccFPSImages.c in Sources */, 469303A72046AE05004A3D6C /* PlatformUtils.mm in Sources */, @@ -3400,8 +3666,8 @@ 46FDDA8C202ACC6A00931238 /* ForwardRenderer.cpp in Sources */, ED30579D1BEC77B90083C3ED /* ConvertUTF.c in Sources */, 4DED483D1DFFA4AF0070C5C4 /* b2CircleContact.cpp in Sources */, - 469304172046AE06004A3D6C /* jsb_platfrom_ios.m in Sources */, 4617864D205224CC008256E1 /* WebSocket-apple.mm in Sources */, + 1AAAC8E2205CB6E9005321B9 /* AudioPlayer.mm in Sources */, 469304132046AE06004A3D6C /* jsb_classtype.cpp in Sources */, 46FDDAA4202ACC6A00931238 /* InputAssembler.cpp in Sources */, 1A28FF941F20AFAB007A1D9D /* NSURLRequest+SRWebSocket.m in Sources */, @@ -3414,10 +3680,12 @@ 1A28FF641F20AFAB007A1D9D /* SRRunLoopThread.m in Sources */, 1A28FF6C1F20AFAB007A1D9D /* SRConstants.m in Sources */, 4693042D2046AE06004A3D6C /* jsb_renderer_manual.cpp in Sources */, + 1AAAC8E8205CB6E9005321B9 /* AudioEngine-inl.mm in Sources */, 4617862220522469008256E1 /* HttpCookie.cpp in Sources */, 46FDDAE2202ACC6A00931238 /* GFXUtils.cpp in Sources */, 1A9F0F981F301DE200A499E1 /* b2ObjectDestroyNotifier.cpp in Sources */, 4DED48551DFFA4AF0070C5C4 /* b2PolygonContact.cpp in Sources */, + 1A586C4C2064C97800B47573 /* EJConvert.m in Sources */, 469304272046AE06004A3D6C /* jsb_conversions.cpp in Sources */, 46FDDA7A202ACC6A00931238 /* Camera.cpp in Sources */, 4DED48591DFFA4AF0070C5C4 /* b2DistanceJoint.cpp in Sources */, @@ -3444,6 +3712,7 @@ 50ABBD391925AB0000A911A9 /* CCAffineTransform.cpp in Sources */, 4DED480F1DFFA4AF0070C5C4 /* b2Settings.cpp in Sources */, 46FDDC38202AEAC500931238 /* Assertions.cpp in Sources */, + 1A52DB8E2060DEF500350EE3 /* jsb_platfrom_apple.mm in Sources */, 503DD8E71926736A00CD74DD /* CCEAGLView-ios.mm in Sources */, 1A29D785205666B200168D9A /* LocalStorage.cpp in Sources */, 4DED48811DFFA4AF0070C5C4 /* b2WeldJoint.cpp in Sources */, @@ -3454,6 +3723,7 @@ 46FDDA7E202ACC6A00931238 /* Light.cpp in Sources */, BA68D7861D62F4A500B7A3F9 /* advancing_front.cc in Sources */, 469303AB2046AE05004A3D6C /* Class.cpp in Sources */, + 1AAAC8EC205CB6E9005321B9 /* AudioCache.mm in Sources */, 46FDDBE4202ADDCE00931238 /* CCData.cpp in Sources */, 1A29D775205665F100168D9A /* CCCanvasRenderingContext2D-ios.mm in Sources */, 469304592046AE06004A3D6C /* EventDispatcher.cpp in Sources */, @@ -3481,12 +3751,13 @@ 4DED48231DFFA4AF0070C5C4 /* b2Fixture.cpp in Sources */, 1A29D77C2056667800168D9A /* csscolorparser.cpp in Sources */, 46FDDA8E202ACC6A00931238 /* Config.cpp in Sources */, - 1A29D795205666F500168D9A /* jsb_opengl_registration.cpp in Sources */, + 1A29D795205666F500168D9A /* jsb_opengl_manual.cpp in Sources */, 503DD8E31926736A00CD74DD /* CCDevice-ios.mm in Sources */, 1A28FF701F20AFAB007A1D9D /* SRError.m in Sources */, 1A28FF501F20AFAB007A1D9D /* SRDelegateController.m in Sources */, 46FDDAC0202ACC6A00931238 /* State.cpp in Sources */, 4DED48051DFFA4AF0070C5C4 /* b2Draw.cpp in Sources */, + 1A52DB8D2060B12600350EE3 /* jsb_platfrom_ios.mm in Sources */, 4DED47EF1DFFA4AF0070C5C4 /* b2ChainShape.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3613,7 +3884,7 @@ ); MACH_O_TYPE = staticlib; OTHER_LDFLAGS = "-llibsql3"; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/mac/include $(SRCROOT)/../external/sources $(SRCROOT)/../external/mac/include/freetype"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/mac/include $(SRCROOT)/../external/sources $(SRCROOT)/../external/mac/include/freetype $(SRCROOT)/../external/mac/include/spidermonkey $(SRCROOT)/../external/mac/include/chakracore $(SRCROOT)/../external/mac/include/v8"; }; name = Debug; }; @@ -3641,7 +3912,7 @@ ); MACH_O_TYPE = staticlib; OTHER_LDFLAGS = "-llibsql3"; - USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/mac/include $(SRCROOT)/../external/sources $(SRCROOT)/../external/mac/include/freetype"; + USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../external/mac/include $(SRCROOT)/../external/sources $(SRCROOT)/../external/mac/include/freetype $(SRCROOT)/../external/mac/include/spidermonkey $(SRCROOT)/../external/mac/include/chakracore $(SRCROOT)/../external/mac/include/v8"; }; name = Release; }; diff --git a/native/cocos/Android.mk b/native/cocos/Android.mk index 6cca479dc4..cff9bb4c6c 100644 --- a/native/cocos/Android.mk +++ b/native/cocos/Android.mk @@ -36,7 +36,7 @@ base/CCRef.cpp \ base/CCUserDefault-android.cpp \ base/CCUserDefault.cpp \ base/CCValue.cpp \ -base/ObjectFactory.cpp \ +base/CCThreadPool.cpp \ base/TGAlib.cpp \ base/ZipUtils.cpp \ base/base64.cpp \ @@ -84,10 +84,9 @@ scripting/js-bindings/auto/jsb_gfx_auto.cpp \ scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp \ scripting/js-bindings/auto/jsb_renderer_auto.cpp \ scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp \ +scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp \ scripting/js-bindings/manual/JavaScriptJavaBridge.cpp \ -scripting/js-bindings/manual/jsb_opengl_functions.cpp \ scripting/js-bindings/manual/jsb_opengl_manual.cpp \ -scripting/js-bindings/manual/jsb_opengl_registration.cpp \ scripting/js-bindings/manual/jsb_opengl_utils.cpp \ scripting/js-bindings/manual/jsb_classtype.cpp \ scripting/js-bindings/manual/jsb_conversions.cpp \ @@ -98,6 +97,7 @@ scripting/js-bindings/manual/jsb_renderer_manual.cpp \ scripting/js-bindings/manual/jsb_socketio.cpp \ scripting/js-bindings/manual/jsb_websocket.cpp \ scripting/js-bindings/manual/jsb_xmlhttprequest.cpp \ +scripting/js-bindings/manual/jsb_platform_android.cpp \ scripting/js-bindings/jswrapper/config.cpp \ scripting/js-bindings/jswrapper/HandleObject.cpp \ scripting/js-bindings/jswrapper/MappingUtils.cpp \ @@ -165,7 +165,7 @@ LOCAL_STATIC_LIBRARIES += cocos_webp_static LOCAL_STATIC_LIBRARIES += cocos_zlib_static LOCAL_STATIC_LIBRARIES += uv_static LOCAL_STATIC_LIBRARIES += v8_static -# LOCAL_STATIC_LIBRARIES += audioengine_static +LOCAL_STATIC_LIBRARIES += audioengine_static LOCAL_STATIC_LIBRARIES += cocos_network_static LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dxandroid_static @@ -190,7 +190,7 @@ include $(BUILD_STATIC_LIBRARY) #$(call import-module,.) $(call import-module,android) $(call import-module,platform/android) -# $(call import-module,audio/android) +$(call import-module,audio/android) $(call import-module,network) $(call import-module,extensions) $(call import-module,android/cpufeatures) diff --git a/native/cocos/audio/AudioEngine.cpp b/native/cocos/audio/AudioEngine.cpp index 776b05f185..1f435f3814 100644 --- a/native/cocos/audio/AudioEngine.cpp +++ b/native/cocos/audio/AudioEngine.cpp @@ -26,11 +26,14 @@ #include "platform/CCPlatformConfig.h" #include "audio/include/AudioEngine.h" -#include -#include #include "platform/CCFileUtils.h" #include "base/ccUtils.h" +#include +#include +#include +#include + #if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID #include "audio/android/AudioEngine-inl.h" #elif CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC diff --git a/native/cocos/audio/android/AudioDecoderSLES.cpp b/native/cocos/audio/android/AudioDecoderSLES.cpp index bbcc9382b2..1f367fd73a 100644 --- a/native/cocos/audio/android/AudioDecoderSLES.cpp +++ b/native/cocos/audio/android/AudioDecoderSLES.cpp @@ -28,6 +28,9 @@ THE SOFTWARE. #include "audio/android/AudioDecoderSLES.h" #include "platform/CCFileUtils.h" +#include +#include + namespace cocos2d { namespace experimental { /* Explicitly requesting SL_IID_ANDROIDSIMPLEBUFFERQUEUE and SL_IID_PREFETCHSTATUS @@ -194,12 +197,12 @@ bool AudioDecoderSLES::decodeToPcm() { off_t start = 0, length = 0; std::string relativePath; - size_t position = _url.find("assets/"); + size_t position = _url.find("@assets/"); if (0 == position) { - // "assets/" is at the beginning of the path and we don't want it - relativePath = _url.substr(strlen("assets/")); + // "@assets/" is at the beginning of the path and we don't want it + relativePath = _url.substr(strlen("@assets/")); } else { relativePath = _url; diff --git a/native/cocos/audio/android/AudioDecoderWav.cpp b/native/cocos/audio/android/AudioDecoderWav.cpp index a89526ced1..285890cb8a 100644 --- a/native/cocos/audio/android/AudioDecoderWav.cpp +++ b/native/cocos/audio/android/AudioDecoderWav.cpp @@ -29,6 +29,8 @@ THE SOFTWARE. #include "audio/android/tinysndfile.h" #include "platform/CCFileUtils.h" +#include + namespace cocos2d { namespace experimental { AudioDecoderWav::AudioDecoderWav() diff --git a/native/cocos/audio/android/AudioEngine-inl.cpp b/native/cocos/audio/android/AudioEngine-inl.cpp index 81bd20f335..d135d94b70 100644 --- a/native/cocos/audio/android/AudioEngine-inl.cpp +++ b/native/cocos/audio/android/AudioEngine-inl.cpp @@ -33,20 +33,18 @@ #include #include #include - #include -#include "platform/android/jni/JniHelper.h" #include -#include +#include +#include + #include "audio/include/AudioEngine.h" -#include "base/CCDirector.h" +#include "platform/CCApplication.h" #include "base/CCScheduler.h" -#include "base/CCEventDispatcher.h" -#include "base/CCEventType.h" -#include "base/CCEventListenerCustom.h" #include "base/ccUTF8.h" #include "platform/android/CCFileUtils-android.h" -#include "platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.h" +#include "platform/android/jni/JniImp.h" +#include "platform/android/jni/JniHelper.h" #include "audio/android/IAudioPlayer.h" #include "audio/android/ICallerThreadUtils.h" @@ -71,7 +69,7 @@ class CallerThreadUtils : public ICallerThreadUtils public: virtual void performFunctionInCallerThread(const std::function& func) { - Director::getInstance()->getScheduler()->performFunctionInCocosThread(func); + Application::getInstance()->getScheduler()->performFunctionInCocosThread(func); }; virtual std::thread::id getCallerThreadId() @@ -147,12 +145,12 @@ AudioEngineImpl::~AudioEngineImpl() if (_onPauseListener != nullptr) { - Director::getInstance()->getEventDispatcher()->removeEventListener(_onPauseListener); +//TODO:cjh Application::getInstance()->getEventDispatcher()->removeEventListener(_onPauseListener); } if (_onResumeListener != nullptr) { - Director::getInstance()->getEventDispatcher()->removeEventListener(_onResumeListener); +//TODO:cjh Director::getInstance()->getEventDispatcher()->removeEventListener(_onResumeListener); } __impl = nullptr; @@ -185,11 +183,11 @@ bool AudioEngineImpl::init() result = (*_outputMixObject)->Realize(_outputMixObject, SL_BOOLEAN_FALSE); if(SL_RESULT_SUCCESS != result){ ERRORLOG("realize the output mix fail"); break; } - _audioPlayerProvider = new AudioPlayerProvider(_engineEngine, _outputMixObject, getDeviceSampleRate(), getDeviceAudioBufferSizeInFrames(), fdGetter, &__callerThreadUtils); + _audioPlayerProvider = new AudioPlayerProvider(_engineEngine, _outputMixObject, getDeviceSampleRateJNI(), getDeviceAudioBufferSizeInFramesJNI(), fdGetter, &__callerThreadUtils); - _onPauseListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(AudioEngineImpl::onEnterBackground, this)); + _onPauseListener = nullptr;//Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_BACKGROUND, CC_CALLBACK_1(AudioEngineImpl::onEnterBackground, this)); - _onResumeListener = Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(AudioEngineImpl::onEnterForeground, this)); + _onResumeListener = nullptr;//Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_COME_TO_FOREGROUND, CC_CALLBACK_1(AudioEngineImpl::onEnterForeground, this)); ret = true; }while (false); diff --git a/native/cocos/audio/android/AudioEngine-inl.h b/native/cocos/audio/android/AudioEngine-inl.h index 9b68d43d25..d042e6f5ad 100644 --- a/native/cocos/audio/android/AudioEngine-inl.h +++ b/native/cocos/audio/android/AudioEngine-inl.h @@ -31,6 +31,8 @@ #include #include #include +#include + #include "base/CCRef.h" #include "base/ccUtils.h" diff --git a/native/cocos/audio/android/AudioPlayerProvider.cpp b/native/cocos/audio/android/AudioPlayerProvider.cpp index b414c470e0..0b2a24f7f4 100644 --- a/native/cocos/audio/android/AudioPlayerProvider.cpp +++ b/native/cocos/audio/android/AudioPlayerProvider.cpp @@ -358,12 +358,12 @@ AudioPlayerProvider::AudioFileInfo AudioPlayerProvider::getFileInfo( if (audioFilePath[0] != '/') { std::string relativePath; - size_t position = audioFilePath.find("assets/"); + size_t position = audioFilePath.find("@assets/"); if (0 == position) { - // "assets/" is at the beginning of the path and we don't want it - relativePath = audioFilePath.substr(strlen("assets/")); + // "@assets/" is at the beginning of the path and we don't want it + relativePath = audioFilePath.substr(strlen("@assets/")); } else { diff --git a/native/cocos/audio/android/ccdandroidUtils.cpp b/native/cocos/audio/android/ccdandroidUtils.cpp deleted file mode 100644 index 1146c61c6b..0000000000 --- a/native/cocos/audio/android/ccdandroidUtils.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#include "audio/android/ccdandroidUtils.h" - -#include -#include -#include "platform/android/jni/JniHelper.h" -#include "platform/CCFileUtils.h" - - -USING_NS_CC; - -namespace CocosDenshion { - namespace android { - std::string getFullPathWithoutAssetsPrefix(const char* pszFilename) { - // Changing file path to full path - std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(pszFilename); - // Removing `assets` since it isn't needed for the API of playing sound. - size_t pos = fullPath.find("assets/"); - if (pos == 0) - { - fullPath = fullPath.substr(strlen("assets/")); - } - return fullPath; - } - } -} diff --git a/native/cocos/audio/android/ccdandroidUtils.h b/native/cocos/audio/android/ccdandroidUtils.h deleted file mode 100644 index 1edab8d4a7..0000000000 --- a/native/cocos/audio/android/ccdandroidUtils.h +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2012 cocos2d-x.org -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -#ifndef __CCDANDROIDUTILS_H__ -#define __CCDANDROIDUTILS_H__ - -#include - -namespace CocosDenshion { - namespace android { - std::string getFullPathWithoutAssetsPrefix(const char* pszFilename); - } -} - -#endif //__CCDANDROIDUTILS_H__ diff --git a/native/cocos/audio/apple/AudioCache.mm b/native/cocos/audio/apple/AudioCache.mm index 67df4a2481..ab4102b6f6 100644 --- a/native/cocos/audio/apple/AudioCache.mm +++ b/native/cocos/audio/apple/AudioCache.mm @@ -33,7 +33,7 @@ #import #import #include -#include "base/CCDirector.h" +#include "platform/CCApplication.h" #include "base/CCScheduler.h" #include "audio/apple/AudioDecoder.h" @@ -420,7 +420,7 @@ void AudioCache::invokingLoadCallbacks() } auto isDestroyed = _isDestroyed; - auto scheduler = Director::getInstance()->getScheduler(); + auto scheduler = Application::getInstance()->getScheduler(); scheduler->performFunctionInCocosThread([&, isDestroyed](){ if (*isDestroyed) { diff --git a/native/cocos/audio/apple/AudioEngine-inl.mm b/native/cocos/audio/apple/AudioEngine-inl.mm index 0cc06b032d..d61e75e5bb 100644 --- a/native/cocos/audio/apple/AudioEngine-inl.mm +++ b/native/cocos/audio/apple/AudioEngine-inl.mm @@ -35,7 +35,7 @@ #include "audio/include/AudioEngine.h" #include "platform/CCFileUtils.h" -#include "base/CCDirector.h" +#include "platform/CCApplication.h" #include "base/CCScheduler.h" #include "base/ccUtils.h" @@ -155,10 +155,10 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio NSError *error = nil; [[AVAudioSession sharedInstance] setActive:YES error:&error]; alcMakeContextCurrent(s_ALContext); - if (Director::getInstance()->isPaused()) + //FIXME:cjh if (Director::getInstance()->isPaused()) { ALOGD("AVAudioSessionInterruptionTypeEnded, director was paused, try to resume it."); - Director::getInstance()->resume(); +//FIXME:cjh Director::getInstance()->resume(); } } else @@ -197,7 +197,7 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio else if (isAudioSessionInterrupted) { ALOGD("Audio session is still interrupted, pause director!"); - Director::getInstance()->pause(); + //FIXME:cjh Director::getInstance()->pause(); } } } @@ -246,7 +246,7 @@ AudioEngineImpl::~AudioEngineImpl() { if (_scheduler != nullptr) { - _scheduler->unschedule(CC_SCHEDULE_SELECTOR(AudioEngineImpl::update), this); + _scheduler->unschedule("AudioEngine", this); } if (s_ALContext) { @@ -355,7 +355,7 @@ bool AudioEngineImpl::init() // ================ Workaround end ================ // - _scheduler = Director::getInstance()->getScheduler(); + _scheduler = Application::getInstance()->getScheduler(); ret = true; ALOGI("OpenAL was initialized successfully!"); } @@ -431,7 +431,7 @@ int AudioEngineImpl::play2d(const std::string &filePath ,bool loop ,float volume if (_lazyInitLoop) { _lazyInitLoop = false; - _scheduler->schedule(CC_SCHEDULE_SELECTOR(AudioEngineImpl::update), this, 0.05f, false); + _scheduler->schedule(CC_CALLBACK_1(AudioEngineImpl::update, this), this, 0.05f, false, "AudioEngine"); } return _currentAudioID++; @@ -685,7 +685,7 @@ void AudioEngineImpl::update(float dt) if(_audioPlayers.empty()){ _lazyInitLoop = true; - _scheduler->unschedule(CC_SCHEDULE_SELECTOR(AudioEngineImpl::update), this); + _scheduler->unschedule("AudioEngine", this); } } diff --git a/native/cocos/audio/win32/AudioCache.cpp b/native/cocos/audio/win32/AudioCache.cpp index 34ba49c880..3c32b06b88 100644 --- a/native/cocos/audio/win32/AudioCache.cpp +++ b/native/cocos/audio/win32/AudioCache.cpp @@ -31,7 +31,7 @@ #include "audio/win32/AudioCache.h" #include -#include "base/CCDirector.h" +#include "platform/CCApplication.h" #include "base/CCScheduler.h" #include "audio/win32/AudioDecoderManager.h" @@ -360,7 +360,7 @@ void AudioCache::invokingLoadCallbacks() } auto isDestroyed = _isDestroyed; - auto scheduler = Director::getInstance()->getScheduler(); + auto scheduler = Application::getInstance()->getScheduler(); scheduler->performFunctionInCocosThread([&, isDestroyed](){ if (*isDestroyed) { diff --git a/native/cocos/base/CCScheduler.cpp b/native/cocos/base/CCScheduler.cpp index 78ac3eb6c8..a8d58f1750 100644 --- a/native/cocos/base/CCScheduler.cpp +++ b/native/cocos/base/CCScheduler.cpp @@ -444,9 +444,7 @@ void Scheduler::resumeTargets(const std::set& targetsToResume) void Scheduler::performFunctionInCocosThread(const std::function &function) { _performMutex.lock(); - _functionsToPerform.push_back(function); - _performMutex.unlock(); } diff --git a/native/cocos/base/CCThreadPool.cpp b/native/cocos/base/CCThreadPool.cpp new file mode 100644 index 0000000000..d51ed50c82 --- /dev/null +++ b/native/cocos/base/CCThreadPool.cpp @@ -0,0 +1,441 @@ +/**************************************************************************** + Copyright (c) 2016-2017 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + Inspired by https://github.com/vit-vit/CTPL + + ****************************************************************************/ + +#include "base/CCThreadPool.h" + + +#ifdef __ANDROID__ +#include +#define LOG_TAG "ThreadPool" +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG,__VA_ARGS__) +#else +#define LOGD(...) printf(__VA_ARGS__) +#endif + +namespace cocos2d { namespace experimental { + +#define DEFAULT_THREAD_POOL_MIN_NUM (4) +#define DEFAULT_THREAD_POOL_MAX_NUM (20) + +#define DEFAULT_SHRINK_INTERVAL (5.0f) +#define DEFAULT_SHRINK_STEP (2) +#define DEFAULT_STRETCH_STEP (2) + +static ThreadPool *__defaultThreadPool = nullptr; + +ThreadPool *ThreadPool::getDefaultThreadPool() +{ + if (__defaultThreadPool == nullptr) + { + __defaultThreadPool = newCachedThreadPool(DEFAULT_THREAD_POOL_MIN_NUM, + DEFAULT_THREAD_POOL_MAX_NUM, + DEFAULT_SHRINK_INTERVAL, DEFAULT_SHRINK_STEP, + DEFAULT_STRETCH_STEP); + } + + return __defaultThreadPool; +} + +void ThreadPool::destroyDefaultThreadPool() +{ + delete __defaultThreadPool; + __defaultThreadPool = nullptr; +} + +ThreadPool *ThreadPool::newCachedThreadPool(int minThreadNum, int maxThreadNum, int shrinkInterval, + int shrinkStep, int stretchStep) +{ + ThreadPool *pool = new(std::nothrow) ThreadPool(minThreadNum, maxThreadNum); + if (pool != nullptr) + { + pool->setFixedSize(false); + pool->setShrinkInterval(shrinkInterval); + pool->setShrinkStep(shrinkStep); + pool->setStretchStep(stretchStep); + } + return pool; +} + +ThreadPool *ThreadPool::newFixedThreadPool(int threadNum) +{ + ThreadPool *pool = new(std::nothrow) ThreadPool(threadNum, threadNum); + if (pool != nullptr) + { + pool->setFixedSize(true); + } + return pool; +} + +ThreadPool *ThreadPool::newSingleThreadPool() +{ + ThreadPool *pool = new(std::nothrow) ThreadPool(1, 1); + if (pool != nullptr) + { + pool->setFixedSize(true); + } + return pool; +} + +ThreadPool::ThreadPool(int minNum, int maxNum) + : _isDone(false), _isStop(false), _idleThreadNum(0), _minThreadNum(minNum), + _maxThreadNum(maxNum), _initedThreadNum(0), _shrinkInterval(DEFAULT_SHRINK_INTERVAL), + _shrinkStep(DEFAULT_SHRINK_STEP), _stretchStep(DEFAULT_STRETCH_STEP), + _isFixedSize(false) +{ + init(); +} + +// the destructor waits for all the functions in the queue to be finished +ThreadPool::~ThreadPool() +{ + stop(); +} + +// number of idle threads +int ThreadPool::getIdleThreadNum() const +{ + ThreadPool* thiz = const_cast(this); + std::lock_guard lk(thiz->_idleThreadNumMutex); + return _idleThreadNum; +} + +void ThreadPool::init() +{ + gettimeofday(&_lastShrinkTime, nullptr); + + _maxThreadNum = std::max(_minThreadNum, _maxThreadNum); + + _threads.resize(_maxThreadNum); + _abortFlags.resize(_maxThreadNum); + _idleFlags.resize(_maxThreadNum); + _initedFlags.resize(_maxThreadNum); + + for (int i = 0; i < _maxThreadNum; ++i) + { + _idleFlags[i] = std::make_shared>(false); + if (i < _minThreadNum) + { + _abortFlags[i] = std::make_shared>(false); + setThread(i); + _initedFlags[i] = std::make_shared>(true); + ++_initedThreadNum; + } + else + { + _abortFlags[i] = std::make_shared>(true); + _initedFlags[i] = std::make_shared>(false); + } + } +} + +bool ThreadPool::tryShrinkPool() +{ + LOGD("shrink pool, _idleThreadNum = %d \n", getIdleThreadNum()); + + struct timeval before; + gettimeofday(&before, nullptr); + + std::vector threadIDsToJoin; + int maxThreadNumToJoin = std::min(_initedThreadNum - _minThreadNum, _shrinkStep); + + for (int i = 0; i < _maxThreadNum; ++i) + { + if ((int)threadIDsToJoin.size() >= maxThreadNumToJoin) + { + break; + } + + if (*_idleFlags[i]) + { + *_abortFlags[i] = true; + threadIDsToJoin.push_back(i); + } + } + + { + // stop the detached threads that were waiting + std::unique_lock lock(_mutex); + _cv.notify_all(); + } + + for (const auto& threadID : threadIDsToJoin) + { // wait for the computing threads to finish + if (_threads[threadID]->joinable()) + { + _threads[threadID]->join(); + } + + _threads[threadID].reset(); + *_initedFlags[threadID] = false; + --_initedThreadNum; + } + + struct timeval after; + gettimeofday(&after, nullptr); + + float seconds = (after.tv_sec - before.tv_sec) + (after.tv_usec - before.tv_usec) / 1000000.0f; + + LOGD("shrink %d threads, waste: %f seconds\n", (int) threadIDsToJoin.size(), seconds); + + if (_initedThreadNum <= _minThreadNum) + return true; + + return false; +} + +void ThreadPool::stretchPool(int count) +{ + struct timeval before; + gettimeofday(&before, nullptr); + + int oldThreadCount = _initedThreadNum; + int newThreadCount = 0; + + for (int i = 0; i < _maxThreadNum; ++i) + { + if (!*_initedFlags[i]) + { + *_abortFlags[i] = false; + setThread(i); + *_initedFlags[i] = true; + ++_initedThreadNum; + + if (++newThreadCount >= count) + { + break; + } + } + } + + if (newThreadCount > 0) + { + struct timeval after; + gettimeofday(&after, nullptr); + + float seconds = + (after.tv_sec - before.tv_sec) + (after.tv_usec - before.tv_usec) / 1000000.0f; + + LOGD("stretch pool from %d to %d, waste %f seconds\n", oldThreadCount, _initedThreadNum, + seconds); + } +} + +void ThreadPool::pushTask(const std::function& runnable, + TaskType type/* = DEFAULT*/) +{ + if (!_isFixedSize) + { + _idleThreadNumMutex.lock(); + int idleNum = _idleThreadNum; + _idleThreadNumMutex.unlock(); + + if (idleNum > _minThreadNum) + { + if (_taskQueue.empty()) + { + struct timeval now; + gettimeofday(&now, nullptr); + + float seconds = (now.tv_sec - _lastShrinkTime.tv_sec) + + (now.tv_usec - _lastShrinkTime.tv_usec) / 1000000.0f; + if (seconds > _shrinkInterval) + { + tryShrinkPool(); + _lastShrinkTime = now; + } + } + } + else if (idleNum == 0) + { + stretchPool(_stretchStep); + } + } + + auto callback = new(std::nothrow) std::function([runnable](int tid) { + runnable(tid); + }); + + Task task; + task.type = type; + task.callback = callback; + _taskQueue.push(std::move(task)); + + { + std::unique_lock lock(_mutex); + _cv.notify_one(); + } +} + +void ThreadPool::stopAllTasks() +{ + Task task; + while (_taskQueue.pop(task)) + { + delete task.callback; // empty the queue + } +} + +void ThreadPool::stopTasksByType(TaskType type) +{ + Task task; + + std::vector notStopTasks; + notStopTasks.reserve(_taskQueue.size()); + + while (_taskQueue.pop(task)) + { + if (task.type == type) + {// Delete the task from queue + delete task.callback; + } + else + {// If task type isn't match, push it into a vector, then insert to task queue again + notStopTasks.push_back(task); + } + } + + if (!notStopTasks.empty()) + { + for (const auto& t : notStopTasks) + { + _taskQueue.push(t); + } + } +} + +void ThreadPool::joinThread(int tid) +{ + if (tid < 0 || tid >= (int)_threads.size()) + { + LOGD("Invalid thread id %d\n", tid); + return; + } + + // wait for the computing threads to finish + if (*_initedFlags[tid] && _threads[tid]->joinable()) + { + _threads[tid]->join(); + *_initedFlags[tid] = false; + --_initedThreadNum; + } +} + +int ThreadPool::getTaskNum() const +{ + return (int) _taskQueue.size(); +} + +void ThreadPool::setFixedSize(bool isFixedSize) +{ + _isFixedSize = isFixedSize; +} + +void ThreadPool::setShrinkInterval(int seconds) +{ + if (seconds >= 0) + _shrinkInterval = seconds; +} + +void ThreadPool::setShrinkStep(int step) +{ + if (step > 0) + _shrinkStep = step; +} + +void ThreadPool::setStretchStep(int step) +{ + if (step > 0) + _stretchStep = step; +} + +void ThreadPool::stop() +{ + if (_isDone || _isStop) + return; + _isDone = true; // give the waiting threads a command to finish + + { + std::unique_lock lock(_mutex); + _cv.notify_all(); // stop all waiting threads + } + + for (int i = 0, n = static_cast(_threads.size()); i < n; ++i) + { + joinThread(i); + } + // if there were no threads in the pool but some functors in the queue, the functors are not deleted by the threads + // therefore delete them here + stopAllTasks(); + _threads.clear(); + _abortFlags.clear(); +} + +void ThreadPool::setThread(int tid) +{ + std::shared_ptr> abort_ptr( + _abortFlags[tid]); // a copy of the shared ptr to the flag + auto f = [this, tid, abort_ptr/* a copy of the shared ptr to the abort */]() { + std::atomic& abort = *abort_ptr; + Task task; + bool isPop = _taskQueue.pop(task); + while (true) + { + while (isPop) + { // if there is anything in the queue + std::unique_ptr> func( + task.callback); // at return, delete the function even if an exception occurred + (*task.callback)(tid); + if (abort) + return; // the thread is wanted to stop, return even if the queue is not empty yet + else + isPop = _taskQueue.pop(task); + } + // the queue is empty here, wait for the next command + std::unique_lock lock(_mutex); + _idleThreadNumMutex.lock(); + ++_idleThreadNum; + _idleThreadNumMutex.unlock(); + + *_idleFlags[tid] = true; + _cv.wait(lock, [this, &task, &isPop, &abort]() { + isPop = _taskQueue.pop(task); + return isPop || _isDone || abort; + }); + *_idleFlags[tid] = false; + _idleThreadNumMutex.lock(); + --_idleThreadNum; + _idleThreadNumMutex.unlock(); + + if (!isPop) + return; // if the queue is empty and isDone == true or *flag then return + } + }; + _threads[tid].reset( + new(std::nothrow) std::thread(f)); // compiler may not support std::make_unique() +} + +}} // namespace cocos2d { namespace experimental { diff --git a/native/cocos/base/CCThreadPool.h b/native/cocos/base/CCThreadPool.h new file mode 100644 index 0000000000..6d7c40e4f4 --- /dev/null +++ b/native/cocos/base/CCThreadPool.h @@ -0,0 +1,237 @@ +/**************************************************************************** + Copyright (c) 2016-2017 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + Inspired by https://github.com/vit-vit/CTPL + + ****************************************************************************/ +#pragma once + +#include "platform/CCStdC.h" +#include "platform/CCPlatformDefine.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace cocos2d { namespace experimental { + +/** + * @addtogroup base + * @{ + */ + +class CC_DLL ThreadPool +{ +public: + + enum class TaskType + { + DEFAULT = 0, + NETWORK, + IO, + AUDIO, + USER = 1000 + }; + + /* + * Gets the default thread pool which is a cached thread pool with default parameters. + */ + static ThreadPool *getDefaultThreadPool(); + + /* + * Destroys the default thread pool + */ + static void destroyDefaultThreadPool(); + + /* + * Creates a cached thread pool + * @note The return value has to be delete while it doesn't needed + */ + static ThreadPool *newCachedThreadPool(int minThreadNum, int maxThreadNum, int shrinkInterval, + int shrinkStep, int stretchStep); + + /* + * Creates a thread pool with fixed thread count + * @note The return value has to be delete while it doesn't needed + */ + static ThreadPool *newFixedThreadPool(int threadNum); + + /* + * Creates a thread pool with only one thread in the pool, it could be used to execute multiply tasks serially in just one thread. + * @note The return value has to be delete while it doesn't needed + */ + static ThreadPool *newSingleThreadPool(); + + // the destructor waits for all the functions in the queue to be finished + ~ThreadPool(); + + /* Pushs a task to thread pool + * @param runnable The callback of the task executed in sub thread + * @param type The task type, it's TASK_TYPE_DEFAULT if this argument isn't assigned + * @note This function has to be invoked in cocos thread + */ + void pushTask(const std::function& runnable, TaskType type = TaskType::DEFAULT); + + // Stops all tasks, it will remove all tasks in queue + void stopAllTasks(); + + // Stops some tasks by type + void stopTasksByType(TaskType type); + + // Gets the minimum thread numbers + inline int getMinThreadNum() const + { return _minThreadNum; }; + + // Gets the maximum thread numbers + inline int getMaxThreadNum() const + { return _maxThreadNum; }; + + // Gets the number of idle threads + int getIdleThreadNum() const; + + // Gets the number of initialized threads + inline int getInitedThreadNum() const + { return _initedThreadNum; }; + + // Gets the task number + int getTaskNum() const; + + /* + * Trys to shrink pool + * @note This method is only available for cached thread pool + */ + bool tryShrinkPool(); + +private: + ThreadPool(int minNum, int maxNum); + + ThreadPool(const ThreadPool&); + + ThreadPool(ThreadPool&&); + + ThreadPool& operator=(const ThreadPool&); + + ThreadPool& operator=(ThreadPool&&); + + void init(); + + void stop(); + + void setThread(int tid); + + void joinThread(int tid); + + void setFixedSize(bool isFixedSize); + + void setShrinkInterval(int seconds); + + void setShrinkStep(int step); + + void setStretchStep(int step); + + void stretchPool(int count); + + std::vector> _threads; + std::vector>> _abortFlags; + std::vector>> _idleFlags; + std::vector>> _initedFlags; + + template + class ThreadSafeQueue + { + public: + bool push(T const& value) + { + std::unique_lock lock(this->mutex); + this->q.push(value); + return true; + } + + // deletes the retrieved element, do not use for non integral types + bool pop(T& v) + { + std::unique_lock lock(this->mutex); + if (this->q.empty()) + return false; + v = this->q.front(); + this->q.pop(); + return true; + } + + bool empty() const + { + auto thiz = const_cast(this); + std::unique_lock lock(thiz->mutex); + return this->q.empty(); + } + + size_t size() const + { + auto thiz = const_cast(this); + std::unique_lock lock(thiz->mutex); + return this->q.size(); + } + + private: + std::queue q; + std::mutex mutex; + }; + + struct Task + { + TaskType type; + std::function *callback; + }; + + ThreadSafeQueue _taskQueue; + std::atomic _isDone; + std::atomic _isStop; + + //FIXME: std::atomic isn't supported by ndk-r10e while compiling with `armeabi` arch. + // So using a mutex here instead. + int _idleThreadNum; // how many threads are waiting + std::mutex _idleThreadNumMutex; + + std::mutex _mutex; + std::condition_variable _cv; + + int _minThreadNum; + int _maxThreadNum; + int _initedThreadNum; + + struct timeval _lastShrinkTime; + float _shrinkInterval; + int _shrinkStep; + int _stretchStep; + bool _isFixedSize; +}; + +// end of base group +/// @} + +}} // namespace cocos2d { namespace experimental { diff --git a/native/cocos/base/ObjectFactory.cpp b/native/cocos/base/ObjectFactory.cpp deleted file mode 100644 index 0a0efa21fc..0000000000 --- a/native/cocos/base/ObjectFactory.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#include -#include "base/ObjectFactory.h" - - -NS_CC_BEGIN - -ObjectFactory::TInfo::TInfo(void) -:_class("") -,_fun(nullptr) -,_func(nullptr) -{ -} - -ObjectFactory::TInfo::TInfo(const std::string& type, Instance ins) -:_class(type) -,_fun(ins) -,_func(nullptr) -{ - ObjectFactory::getInstance()->registerType(*this); -} - -ObjectFactory::TInfo::TInfo(const std::string& type, InstanceFunc ins) - :_class(type) - ,_fun(nullptr) - ,_func(ins) -{ - ObjectFactory::getInstance()->registerType(*this); -} - -ObjectFactory::TInfo::TInfo(const TInfo &t) -{ - _class = t._class; - _fun = t._fun; - _func = t._func; -} - -ObjectFactory::TInfo::~TInfo(void) -{ - _class = ""; - _fun = nullptr; - _func = nullptr; -} - -ObjectFactory::TInfo& ObjectFactory::TInfo::operator= (const TInfo &t) -{ - _class = t._class; - _fun = t._fun; - _func = t._func; - return *this; -} - - -ObjectFactory* ObjectFactory::_sharedFactory = nullptr; - -ObjectFactory::ObjectFactory(void) -{ - -} - -ObjectFactory::~ObjectFactory(void) -{ - _typeMap.clear(); -} - -ObjectFactory* ObjectFactory::getInstance() -{ - if ( nullptr == _sharedFactory) - { - _sharedFactory = new (std::nothrow) ObjectFactory(); - } - return _sharedFactory; -} - -void ObjectFactory::destroyInstance() -{ - CC_SAFE_DELETE(_sharedFactory); -} - -Ref* ObjectFactory::createObject(const std::string &name) -{ - Ref *o = nullptr; - do - { - const TInfo t = _typeMap[name]; - if (t._fun != nullptr) - { - o = t._fun(); - }else if (t._func != nullptr) - { - o = t._func(); - } - } while (0); - - return o; -} - -void ObjectFactory::registerType(const TInfo &t) -{ - _typeMap.insert(std::make_pair(t._class, t)); -} - -NS_CC_END diff --git a/native/cocos/base/ObjectFactory.h b/native/cocos/base/ObjectFactory.h deleted file mode 100644 index 7100c1285b..0000000000 --- a/native/cocos/base/ObjectFactory.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -Copyright (c) 2013-2016 Chukong Technologies Inc. -Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __TRIGGERFACTORY_H__ -#define __TRIGGERFACTORY_H__ - -#include -#include -#include -#include "base/CCRef.h" -#include "base/ccMacros.h" - -NS_CC_BEGIN - -class CC_DLL ObjectFactory -{ -public: - typedef cocos2d::Ref* (*Instance)(void); - typedef std::function InstanceFunc; - struct CC_DLL TInfo - { - TInfo(void); - TInfo(const std::string& type, Instance ins = nullptr); - TInfo(const std::string& type, InstanceFunc ins = nullptr); - TInfo(const TInfo &t); - ~TInfo(void); - TInfo& operator= (const TInfo &t); - std::string _class; - Instance _fun; - InstanceFunc _func; - }; - typedef std::unordered_map FactoryMap; - - static ObjectFactory* getInstance(); - static void destroyInstance(); - cocos2d::Ref* createObject(const std::string &name); - - void registerType(const TInfo &t); - void removeAll(); - -protected: - ObjectFactory(void); - virtual ~ObjectFactory(void); -private: - static ObjectFactory *_sharedFactory; - FactoryMap _typeMap; -}; - -NS_CC_END - -#endif diff --git a/native/cocos/base/ZipUtils.h b/native/cocos/base/ZipUtils.h index 1bce3f5bef..e36c609519 100644 --- a/native/cocos/base/ZipUtils.h +++ b/native/cocos/base/ZipUtils.h @@ -228,7 +228,7 @@ typedef struct unz_file_info_s unz_file_info; * * @param zipFile Zip file name * @param filter The first part of file names, which should be accessible. - * For example, "assets/". Other files will be missed. + * For example, "@assets/". Other files will be missed. * * @since v2.0.5 */ diff --git a/native/cocos/platform/CCCanvasRenderingContext2D.h b/native/cocos/platform/CCCanvasRenderingContext2D.h index e59a1a0dee..617fec19ad 100644 --- a/native/cocos/platform/CCCanvasRenderingContext2D.h +++ b/native/cocos/platform/CCCanvasRenderingContext2D.h @@ -89,6 +89,14 @@ public: void set_strokeStyle(const std::string& strokeStyle); void set_globalCompositeOperation(const std::string& globalCompositeOperation); + // transform + void translate(float x, float y); + void scale(float x, float y); + void rotate(float angle); + + void transform(float a, float b, float c, float d, float e, float f); + void setTransform(float a, float b, float c, float d, float e, float f); + private: void recreateBuffer(); diff --git a/native/cocos/platform/CCFileUtils.cpp b/native/cocos/platform/CCFileUtils.cpp index a025361734..07c21cadd8 100644 --- a/native/cocos/platform/CCFileUtils.cpp +++ b/native/cocos/platform/CCFileUtils.cpp @@ -88,6 +88,7 @@ public: public: DictMaker() : _resultType(SAX_RESULT_NONE) + , _state(SAX_NONE) { } @@ -131,7 +132,7 @@ public: return _rootArray; } - void startElement(void *ctx, const char *name, const char **atts) + virtual void startElement(void *ctx, const char *name, const char **atts) override { CC_UNUSED_PARAM(ctx); CC_UNUSED_PARAM(atts); @@ -222,7 +223,7 @@ public: } } - void endElement(void *ctx, const char *name) + virtual void endElement(void *ctx, const char *name) override { CC_UNUSED_PARAM(ctx); SAXState curState = _stateStack.empty() ? SAX_DICT : _stateStack.top(); @@ -294,7 +295,7 @@ public: _state = SAX_NONE; } - void textHandler(void *ctx, const char *ch, int len) + virtual void textHandler(void *ctx, const char *ch, int len) override { CC_UNUSED_PARAM(ctx); if (_state == SAX_NONE) @@ -387,12 +388,12 @@ bool FileUtils::writeValueMapToFile(const ValueMap& dict, const std::string& ful doc->LinkEndChild(docType); tinyxml2::XMLElement *rootEle = doc->NewElement("plist"); - rootEle->SetAttribute("version", "1.0"); if (nullptr == rootEle) { delete doc; return false; } + rootEle->SetAttribute("version", "1.0"); doc->LinkEndChild(rootEle); tinyxml2::XMLElement *innerDict = generateElementForDict(dict, doc); @@ -427,12 +428,12 @@ bool FileUtils::writeValueVectorToFile(const ValueVector& vecData, const std::st doc->LinkEndChild(docType); tinyxml2::XMLElement *rootEle = doc->NewElement("plist"); - rootEle->SetAttribute("version", "1.0"); if (nullptr == rootEle) { delete doc; return false; } + rootEle->SetAttribute("version", "1.0"); doc->LinkEndChild(rootEle); tinyxml2::XMLElement *innerDict = generateElementForArray(vecData, doc); @@ -806,7 +807,6 @@ std::string FileUtils::fullPathForFilename(const std::string &filename) const _fullPathCache.insert(std::make_pair(filename, fullpath)); return fullpath; } - } } @@ -825,6 +825,11 @@ std::string FileUtils::fullPathFromRelativeFile(const std::string &filename, con void FileUtils::setSearchResolutionsOrder(const std::vector& searchResolutionsOrder) { + if (_searchResolutionsOrderArray == searchResolutionsOrder) + { + return; + } + bool existDefault = false; _fullPathCache.clear(); _searchResolutionsOrderArray.clear(); @@ -873,41 +878,64 @@ const std::vector& FileUtils::getSearchPaths() const return _searchPathArray; } +const std::vector& FileUtils::getOriginalSearchPaths() const +{ + return _originalSearchPaths; +} + void FileUtils::setWritablePath(const std::string& writablePath) { _writablePath = writablePath; } +const std::string& FileUtils::getDefaultResourceRootPath() const +{ + return _defaultResRootPath; +} + void FileUtils::setDefaultResourceRootPath(const std::string& path) { - _defaultResRootPath = path; + if (_defaultResRootPath != path) + { + _fullPathCache.clear(); + _defaultResRootPath = path; + if (!_defaultResRootPath.empty() && _defaultResRootPath[_defaultResRootPath.length()-1] != '/') + { + _defaultResRootPath += '/'; + } + + // Updates search paths + setSearchPaths(_originalSearchPaths); + } } void FileUtils::setSearchPaths(const std::vector& searchPaths) { bool existDefaultRootPath = false; + _originalSearchPaths = searchPaths; _fullPathCache.clear(); _searchPathArray.clear(); - for (const auto& iter : searchPaths) + + for (const auto& path : _originalSearchPaths) { std::string prefix; - std::string path; + std::string fullPath; - if (!isAbsolutePath(iter)) + if (!isAbsolutePath(path)) { // Not an absolute path prefix = _defaultResRootPath; } - path = prefix + (iter); + fullPath = prefix + path; if (!path.empty() && path[path.length()-1] != '/') { - path += "/"; + fullPath += "/"; } if (!existDefaultRootPath && path == _defaultResRootPath) { existDefaultRootPath = true; } - _searchPathArray.push_back(path); + _searchPathArray.push_back(fullPath); } if (!existDefaultRootPath) @@ -929,8 +957,10 @@ void FileUtils::addSearchPath(const std::string &searchpath,const bool front) path += "/"; } if (front) { + _originalSearchPaths.insert(_originalSearchPaths.begin(), searchpath); _searchPathArray.insert(_searchPathArray.begin(), path); } else { + _originalSearchPaths.push_back(searchpath); _searchPathArray.push_back(path); } } @@ -1264,9 +1294,9 @@ bool FileUtils::createDirectory(const std::string& path) // Create path recursively subpath = ""; - for (int i = 0; i < dirs.size(); ++i) + for (const auto& iter : dirs) { - subpath += dirs[i]; + subpath += iter; dir = opendir(subpath.c_str()); if (!dir) @@ -1456,7 +1486,7 @@ std::string FileUtils::normalizePath(const std::string& path) const ret = std::regex_replace(ret, std::regex("/\\.$"), ""); size_t pos; - while ((pos = ret.find("..")) != std::string::npos) + while ((pos = ret.find("..")) != std::string::npos && pos > 2) { size_t prevSlash = ret.rfind("/", pos-2); if (prevSlash == std::string::npos) diff --git a/native/cocos/platform/CCFileUtils.h b/native/cocos/platform/CCFileUtils.h index aa48b51532..ce4660ab76 100644 --- a/native/cocos/platform/CCFileUtils.h +++ b/native/cocos/platform/CCFileUtils.h @@ -405,9 +405,9 @@ public: * @note This method could access relative path and absolute path. * If the relative path was passed to the vector, FileUtils will add the default resource directory before the relative path. * For instance: - * On Android, the default resource root path is "assets/". + * On Android, the default resource root path is "@assets/". * If "/mnt/sdcard/" and "resources-large" were set to the search paths vector, - * "resources-large" will be converted to "assets/resources-large" since it was a relative path. + * "resources-large" will be converted to "@assets/resources-large" since it was a relative path. * * @param searchPaths The array contains search paths. * @see fullPathForFilename(const char*) @@ -417,6 +417,11 @@ public: */ virtual void setSearchPaths(const std::vector& searchPaths); + /** + * Get default resource root path. + */ + const std::string& getDefaultResourceRootPath() const; + /** * Set default resource root path. */ @@ -432,12 +437,21 @@ public: /** * Gets the array of search paths. * - * @return The array of search paths. + * @return The array of search paths which may contain the prefix of default resource root path. + * @note In best practise, getter function should return the value of setter function passes in. + * But since we should not break the compatibility, we keep using the old logic. + * Therefore, If you want to get the original search paths, please call 'getOriginalSearchPaths()' instead. * @see fullPathForFilename(const char*). * @lua NA */ virtual const std::vector& getSearchPaths() const; + /** + * Gets the original search path array set by 'setSearchPaths' or 'addSearchPath'. + * @return The array of the original search paths + */ + virtual const std::vector& getOriginalSearchPaths() const; + /** * Gets the writable path. * @return The path that can be write/read a file in @@ -552,7 +566,7 @@ public: /** * Checks whether the path is an absolute path. * - * @note On Android, if the parameter passed in is relative to "assets/", this method will treat it as an absolute path. + * @note On Android, if the parameter passed in is relative to "@assets/", this method will treat it as an absolute path. * Also on Blackberry, path starts with "app/native/Resources/" is treated as an absolute path. * * @param path The path that needs to be checked. @@ -724,11 +738,16 @@ protected: */ std::vector _searchPathArray; + /** + * The search paths which was set by 'setSearchPaths' / 'addSearchPath'. + */ + std::vector _originalSearchPaths; + /** * The default root path of resources. * If the default root path of resources needs to be changed, do it in the `init` method of FileUtils's subclass. * For instance: - * On Android, the default root path of resources will be assigned with "assets/" in FileUtilsAndroid::init(). + * On Android, the default root path of resources will be assigned with "@assets/" in FileUtilsAndroid::init(). * Similarly on Blackberry, we assign "app/native/Resources/" to this variable in FileUtilsBlackberry::init(). */ std::string _defaultResRootPath; diff --git a/native/cocos/platform/android/CCCanvasRenderingContext2D-android.cpp b/native/cocos/platform/android/CCCanvasRenderingContext2D-android.cpp index a3e0a07ae6..d27bee5afa 100644 --- a/native/cocos/platform/android/CCCanvasRenderingContext2D-android.cpp +++ b/native/cocos/platform/android/CCCanvasRenderingContext2D-android.cpp @@ -27,8 +27,8 @@ public: CanvasRenderingContext2DImpl() { - _obj = JniHelper::newObject("org/cocos2dx/lib/CanvasRenderingContext2DImpl"); - JniHelper::getEnv()->NewGlobalRef(_obj); + jobject obj = JniHelper::newObject("org/cocos2dx/lib/CanvasRenderingContext2DImpl"); + _obj = JniHelper::getEnv()->NewGlobalRef(obj); } ~CanvasRenderingContext2DImpl() @@ -38,6 +38,8 @@ public: void recreateBuffer(float w, float h) { + if (w < 1.0f || h < 1.0f) + return; JniHelper::callObjectVoidMethod(_obj, _className, "recreateBuffer", w, h); } @@ -55,18 +57,24 @@ public: void fillText(const std::string& text, float x, float y, float maxWidth) { + if (text.empty()) + return; JniHelper::callObjectVoidMethod(_obj, _className, "fillText", text, x, y, maxWidth); fillData(); } void strokeText(const std::string& text, float x, float y, float maxWidth) { + if (text.empty()) + return; JniHelper::callObjectVoidMethod(_obj, _className, "strokeText", text, x, y, maxWidth); fillData(); } float measureText(const std::string& text) { + if (text.empty()) + return 0.0f; return JniHelper::callObjectFloatMethod(_obj, _className, "measureText", text); } @@ -377,4 +385,32 @@ void CanvasRenderingContext2D::set_globalCompositeOperation(const std::string& g } +// transform +//TODO: + +void CanvasRenderingContext2D::translate(float x, float y) +{ + +} + +void CanvasRenderingContext2D::scale(float x, float y) +{ + +} + +void CanvasRenderingContext2D::rotate(float angle) +{ + +} + +void CanvasRenderingContext2D::transform(float a, float b, float c, float d, float e, float f) +{ + +} + +void CanvasRenderingContext2D::setTransform(float a, float b, float c, float d, float e, float f) +{ + +} + NS_CC_END diff --git a/native/cocos/platform/android/CCDevice-android.cpp b/native/cocos/platform/android/CCDevice-android.cpp index 248fbfb8c2..97cf39c51d 100644 --- a/native/cocos/platform/android/CCDevice-android.cpp +++ b/native/cocos/platform/android/CCDevice-android.cpp @@ -103,9 +103,9 @@ public: fullPathOrFontName = FileUtils::getInstance()->fullPathForFilename(textDefinition._fontName); // If the path name returned includes the 'assets' dir then that needs to be removed, because the android.content.Context // requires this portion of the path to be omitted for assets inside the app package. - if (fullPathOrFontName.find("assets/") == 0) + if (fullPathOrFontName.find("@assets/") == 0) { - fullPathOrFontName = fullPathOrFontName.substr(strlen("assets/")); // Chop out the 'assets/' portion of the path. + fullPathOrFontName = fullPathOrFontName.substr(strlen("@assets/")); // Chop out the 'assets/' portion of the path. } } diff --git a/native/cocos/platform/android/CCFileUtils-android.cpp b/native/cocos/platform/android/CCFileUtils-android.cpp index ac005e75d4..99bd708a82 100644 --- a/native/cocos/platform/android/CCFileUtils-android.cpp +++ b/native/cocos/platform/android/CCFileUtils-android.cpp @@ -162,7 +162,7 @@ bool FileUtilsAndroid::isFileExistInternal(const std::string& strFilePath) const { const char* s = strFilePath.c_str(); - // Found "assets/" at the beginning of the path and we don't want it + // Found "@assets/" at the beginning of the path and we don't want it if (strFilePath.find(_defaultResRootPath) == 0) s += _defaultResRootPath.length(); if (obbfile && obbfile->fileExists(s)) @@ -219,7 +219,7 @@ bool FileUtilsAndroid::isDirectoryExistInternal(const std::string& dirPath_) con else { // find it in apk's assets dir - // Found "assets/" at the beginning of the path and we don't want it + // Found "@assets/" at the beginning of the path and we don't want it CCLOG("find in apk dirPath(%s)", dirPath.c_str()); const char* s = dirPath.c_str(); if (dirPath.find(_defaultResRootPath) == 0) @@ -268,7 +268,7 @@ FileUtils::Status FileUtilsAndroid::getContents(const std::string& filename, Res std::string relativePath; size_t position = fullPath.find(_defaultResRootPath); if (0 == position) { - // "assets/" is at the beginning of the path and we don't want it + // "@assets/" is at the beginning of the path and we don't want it relativePath += fullPath.substr(_defaultResRootPath.length()); } else { relativePath = fullPath; diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/CanvasRenderingContext2DImpl.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/CanvasRenderingContext2DImpl.java index 91d2252c27..63d867a36b 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/CanvasRenderingContext2DImpl.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/CanvasRenderingContext2DImpl.java @@ -36,6 +36,7 @@ import android.util.Log; import java.lang.ref.WeakReference; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.HashMap; public class CanvasRenderingContext2DImpl { @@ -102,31 +103,54 @@ public class CanvasRenderingContext2DImpl { sContext = null; } + private static HashMap sTypefaceCache = new HashMap<>(); + + // url is a full path started with '@assets/' + private static void loadTypeface(String familyName, String url) { + if (!sTypefaceCache.containsKey(familyName)) { + try { + Typeface typeface = null; + if (url.startsWith("/")) { + typeface = Typeface.createFromFile(url); + } else if (sContext.get() != null) { + final String prefix = "@assets/"; + if (url.startsWith(prefix)) { + url = url.substring(prefix.length()); + } + typeface = Typeface.createFromAsset(sContext.get().getAssets(), url); + } + + if (typeface != null) { + sTypefaceCache.put(familyName, typeface); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + // TODO:cjh: native should clear font cache before exiting game. + private static void clearTypefaceCache() { + sTypefaceCache.clear(); + } + private static TextPaint newPaint(final String fontName, final int fontSize, final boolean enableBold) { final TextPaint paint = new TextPaint(); paint.setTextSize(fontSize); paint.setAntiAlias(true); - // Set type face for paint, now it support .ttf file. - if (fontName.endsWith(".ttf")) { - try { - final Typeface typeFace = Cocos2dxTypefaces.get(sContext.get(), fontName); - paint.setTypeface(typeFace); - } catch (final Exception e) { - Log.e("Cocos2dxBitmap", "error to create ttf type face: " - + fontName); - - // The file may not find, use system font. - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - } else { - if(enableBold) { - paint.setTypeface(Typeface.create(fontName, Typeface.BOLD)); + Typeface typeFace; + if (sTypefaceCache.containsKey(fontName)) { + typeFace = sTypefaceCache.get(fontName); + } else { + if (enableBold) { + typeFace = Typeface.create(fontName, Typeface.BOLD); } else { - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); + typeFace = Typeface.create(fontName, Typeface.NORMAL); } } + paint.setTypeface(typeFace); return paint; } diff --git a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java index ad3208f633..cc948d1434 100644 --- a/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java +++ b/native/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java @@ -47,6 +47,7 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer { private int mScreenWidth; private int mScreenHeight; private boolean mNativeInitCompleted = false; + private String mDefaultResourcePath = ""; // =========================================================== // Constructors @@ -65,15 +66,39 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer { this.mScreenHeight = surfaceHeight; } + public void setDefaultResourcePath(String path) { + if (path == null) + return; + mDefaultResourcePath = path; + } + + public interface OnGameEngineInitializedListener { + void onGameEngineInitialized(); + } + + private OnGameEngineInitializedListener mGameEngineInitializedListener; + + public void setOnGameEngineInitializedListener(OnGameEngineInitializedListener listener) { + mGameEngineInitializedListener = listener; + } + // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== @Override public void onSurfaceCreated(final GL10 GL10, final EGLConfig EGLConfig) { - Cocos2dxRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight); + Cocos2dxRenderer.nativeInit(this.mScreenWidth, this.mScreenHeight, mDefaultResourcePath); this.mLastTickInNanoSeconds = System.nanoTime(); mNativeInitCompleted = true; + if (mGameEngineInitializedListener != null) { + Cocos2dxHelper.getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + mGameEngineInitializedListener.onGameEngineInitialized(); + } + }); + } } @Override @@ -117,7 +142,7 @@ public class Cocos2dxRenderer implements GLSurfaceView.Renderer { private static native void nativeTouchesCancel(final int[] ids, final float[] xs, final float[] ys); private static native boolean nativeKeyEvent(final int keyCode,boolean isPressed); private static native void nativeRender(); - private static native void nativeInit(final int width, final int height); + private static native void nativeInit(final int width, final int height, final String resourcePath); private static native void nativeOnSurfaceChanged(final int width, final int height); private static native void nativeOnPause(); private static native void nativeOnResume(); diff --git a/native/cocos/platform/android/jni/JniImp.cpp b/native/cocos/platform/android/jni/JniImp.cpp index ea7b5ea369..66166c6e9b 100644 --- a/native/cocos/platform/android/jni/JniImp.cpp +++ b/native/cocos/platform/android/jni/JniImp.cpp @@ -34,6 +34,7 @@ #include "scripting/js-bindings/event/EventDispatcher.h" #include "platform/android/CCFileUtils-android.h" #include "base/CCScheduler.h" +#include "base/CCAutoreleasePool.h" #define JNI_IMP_LOG_TAG "JniImp" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,JNI_IMP_LOG_TAG,__VA_ARGS__) @@ -125,10 +126,16 @@ extern "C" * Cocos2dxRenderer native functions implementation. *****************************************************/ - JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h) + JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h, jstring jDefaultResourcePath) { + std::string defaultResourcePath = JniHelper::jstring2string(jDefaultResourcePath); + LOGD("CocosRenderer.nativeInit: %d, %d, %s", w, h, defaultResourcePath.c_str()); g_width = w; g_height = h; + + if (!defaultResourcePath.empty()) + FileUtils::getInstance()->setDefaultResourceRootPath(defaultResourcePath); + se::ScriptEngine* se = se::ScriptEngine::getInstance(); se->addRegisterCallback(setCanvasCallback); @@ -141,13 +148,16 @@ extern "C" { static std::chrono::steady_clock::time_point prevTime; static std::chrono::steady_clock::time_point now; - float dt = 0.f; - + static float dt = 0.f; + g_app->getScheduler()->update(dt); EventDispatcher::dispatchTickEvent(dt); + PoolManager::getInstance()->getCurrentPool()->clear(); now = std::chrono::steady_clock::now(); dt = std::chrono::duration_cast(now - prevTime).count() / 1000000.f; + + prevTime = std::chrono::steady_clock::now(); } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() @@ -195,52 +205,64 @@ extern "C" * Touches native functions implementation. ***********************************************************/ + static void dispatchTouchEventWithOnePoint(JNIEnv* env, cocos2d::TouchEvent::Type type, jint id, jfloat x, jfloat y) + { + cocos2d::TouchEvent touchEvent; + touchEvent.type = type; + + cocos2d::TouchInfo touchInfo; + touchInfo.index = id; + touchInfo.x = x; + touchInfo.y = y; + touchEvent.touches.push_back(touchInfo); + + cocos2d::EventDispatcher::dispatchTouchEvent(touchEvent); + } + + static void dispatchTouchEventWithPoints(JNIEnv* env, cocos2d::TouchEvent::Type type, jintArray ids, jfloatArray xs, jfloatArray ys) + { + cocos2d::TouchEvent touchEvent; + touchEvent.type = type; + + int size = env->GetArrayLength(ids); + jint id[size]; + jfloat x[size]; + jfloat y[size]; + + env->GetIntArrayRegion(ids, 0, size, id); + env->GetFloatArrayRegion(xs, 0, size, x); + env->GetFloatArrayRegion(ys, 0, size, y); + + for(int i = 0; i < size; i++) + { + cocos2d::TouchInfo touchInfo; + touchInfo.index = id[i]; + touchInfo.x = x[i]; + touchInfo.y = y[i]; + touchEvent.touches.push_back(touchInfo); + } + + cocos2d::EventDispatcher::dispatchTouchEvent(touchEvent); + } + JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) { - //TODO + dispatchTouchEventWithOnePoint(env, cocos2d::TouchEvent::Type::BEGAN, id, x, y); } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd(JNIEnv * env, jobject thiz, jint id, jfloat x, jfloat y) { - //TODO + dispatchTouchEventWithOnePoint(env, cocos2d::TouchEvent::Type::ENDED, id, x, y); } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesMove(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) { - int size = env->GetArrayLength(ids); - jint id[size]; - jfloat x[size]; - jfloat y[size]; - - env->GetIntArrayRegion(ids, 0, size, id); - env->GetFloatArrayRegion(xs, 0, size, x); - env->GetFloatArrayRegion(ys, 0, size, y); - - intptr_t idlong[size]; - for(int i = 0; i < size; i++) - idlong[i] = id[i]; - - //TODO - // cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesMove(size, idlong, x, y); + dispatchTouchEventWithPoints(env, cocos2d::TouchEvent::Type::MOVED, ids, xs, ys); } JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesCancel(JNIEnv * env, jobject thiz, jintArray ids, jfloatArray xs, jfloatArray ys) { - int size = env->GetArrayLength(ids); - jint id[size]; - jfloat x[size]; - jfloat y[size]; - - env->GetIntArrayRegion(ids, 0, size, id); - env->GetFloatArrayRegion(xs, 0, size, x); - env->GetFloatArrayRegion(ys, 0, size, y); - - intptr_t idlong[size]; - for(int i = 0; i < size; i++) - idlong[i] = id[i]; - - //TODO - // cocos2d::Director::getInstance()->getOpenGLView()->handleTouchesCancel(size, idlong, x, y); + dispatchTouchEventWithPoints(env, cocos2d::TouchEvent::Type::CANCELLED, ids, xs, ys); } JNIEXPORT jboolean JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeKeyEvent(JNIEnv * env, jobject thiz, jint keyCode, jboolean isPressed) @@ -351,12 +373,12 @@ int getObbAssetFileDescriptorJNI(const std::string& path, long* startOffset, lon return fd; } -int getDeviceSampleRate() +int getDeviceSampleRateJNI() { return g_deviceSampleRate; } -int getDeviceAudioBufferSizeInFrames() +int getDeviceAudioBufferSizeInFramesJNI() { return g_deviceAudioBufferSizeInFrames; } diff --git a/native/cocos/platform/android/libcocos2dx/build.gradle b/native/cocos/platform/android/libcocos2dx/build.gradle index cb1d217962..fe444ea3b8 100644 --- a/native/cocos/platform/android/libcocos2dx/build.gradle +++ b/native/cocos/platform/android/libcocos2dx/build.gradle @@ -26,5 +26,5 @@ android { } dependencies { - compile fileTree(dir: '../java/libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: '../java/libs') } diff --git a/native/cocos/platform/ios/CCApplication-ios.mm b/native/cocos/platform/ios/CCApplication-ios.mm index ab8732a57c..46fbfa9eea 100644 --- a/native/cocos/platform/ios/CCApplication-ios.mm +++ b/native/cocos/platform/ios/CCApplication-ios.mm @@ -26,6 +26,7 @@ #import "CCApplication.h" #import #import "base/CCScheduler.h" +#include "base/CCAutoreleasePool.h" #import "CCEAGLView-ios.h" #import "renderer/gfx/DeviceGraphics.h" #import "scripting/js-bindings/jswrapper/jsc/ScriptEngine.hpp" @@ -132,12 +133,15 @@ { static std::chrono::steady_clock::time_point prevTime; static std::chrono::steady_clock::time_point now; - float dt = 0.f; + static float dt = 0.f; + + prevTime = std::chrono::steady_clock::now(); _scheduler->update(dt); cocos2d::EventDispatcher::dispatchTickEvent(dt); [(CCEAGLView*)(_application->getView()) swapBuffers]; + cocos2d::PoolManager::getInstance()->getCurrentPool()->clear(); now = std::chrono::steady_clock::now(); dt = std::chrono::duration_cast(now - prevTime).count() / 1000000.f; diff --git a/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm b/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm index 04798f9261..b0c7bafd1b 100644 --- a/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm +++ b/native/cocos/platform/ios/CCCanvasRenderingContext2D-ios.mm @@ -3,8 +3,10 @@ #include "base/csscolorparser.hpp" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +#include "cocos/scripting/js-bindings/manual/jsb_platform.h" #import +#import #include @@ -74,7 +76,7 @@ namespace { @synthesize textBaseLine = _textBaseLine; -(id) init { - if ([super init]) { + if (self = [super init]) { _width = _height = 0; _context = nil; _colorSpace = nil; @@ -99,23 +101,17 @@ namespace { } -(UIFont*) _createSystemFont { - NSString * fntName = [NSString stringWithString:_fontName]; - NSString* pathExtension = [fntName pathExtension]; - id font = NULL; - if ([pathExtension length] > 0) { - // On iOS custom fonts must be listed beforehand in the App info.plist (in order to be usable) and referenced only the by the font family name itself when - // calling [UIFont fontWithName]. Therefore even if the developer adds 'SomeFont.ttf' or 'fonts/SomeFont.ttf' to the App .plist, the font must - // be referenced as 'SomeFont' when calling [UIFont fontWithName]. Hence we strip out the folder path components and the extension here in order to get just - // the font family name itself. This stripping step is required especially for references to user fonts stored in CCB files; CCB files appear to store - // the '.ttf' extensions when referring to custom fonts. - fntName = [[fntName lastPathComponent] stringByDeletingPathExtension]; + UIFont* font = [UIFont fontWithName:_fontName size:_fontSize]; - // create the font - font = [UIFont fontWithName:fntName size:_fontSize]; + if (font == nil) { + const auto& familyMap = getFontFamilyNameMap(); + auto iter = familyMap.find([_fontName UTF8String]); + if (iter != familyMap.end()) { + font = [UIFont fontWithName:[NSString stringWithUTF8String:iter->second.c_str()] size:_fontSize]; + } } - if (!font) - { + if (font == nil) { if (false) { //TODO: enableBold) { font = [UIFont boldSystemFontOfSize:_fontSize]; } else { @@ -125,7 +121,7 @@ namespace { return font; } --(void) updateFontWithName: (NSString*)fontName fontSize: (CGFloat)fontSize { +-(void) updateFontWithName:(NSString*) fontName fontSize:(CGFloat) fontSize { self.fontName = fontName; _fontSize = fontSize; self.font = [self _createSystemFont]; @@ -329,13 +325,14 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(float width, float height) : __width(width) , __height(height) { - SE_LOGD("CanvasGradient constructor: %p, width: %f, height: %f\n", this, width, height); + SE_LOGD("CanvasRenderingContext2D constructor: %p, width: %f, height: %f\n", this, width, height); _impl = [[CanvasRenderingContext2DImpl alloc] init]; + [_impl recreateBufferWithWidth:width height:height]; } CanvasRenderingContext2D::~CanvasRenderingContext2D() { - SE_LOGD("CanvasGradient destructor: %p\n", this); + SE_LOGD("CanvasRenderingContext2D destructor: %p\n", this); [_impl release]; } @@ -548,4 +545,31 @@ void CanvasRenderingContext2D::set_globalCompositeOperation(const std::string& g } +// transform + +void CanvasRenderingContext2D::translate(float x, float y) +{ + +} + +void CanvasRenderingContext2D::scale(float x, float y) +{ + +} + +void CanvasRenderingContext2D::rotate(float angle) +{ + +} + +void CanvasRenderingContext2D::transform(float a, float b, float c, float d, float e, float f) +{ + +} + +void CanvasRenderingContext2D::setTransform(float a, float b, float c, float d, float e, float f) +{ + +} + NS_CC_END diff --git a/native/cocos/platform/ios/CCEAGLView-ios.mm b/native/cocos/platform/ios/CCEAGLView-ios.mm index 6ac06b6fa7..a67eb208b0 100644 --- a/native/cocos/platform/ios/CCEAGLView-ios.mm +++ b/native/cocos/platform/ios/CCEAGLView-ios.mm @@ -516,8 +516,6 @@ namespace } } - - - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if (_isKeyboardShown) diff --git a/native/cocos/platform/mac/CCApplication-mac.mm b/native/cocos/platform/mac/CCApplication-mac.mm index 983397d665..31838dfe10 100644 --- a/native/cocos/platform/mac/CCApplication-mac.mm +++ b/native/cocos/platform/mac/CCApplication-mac.mm @@ -28,7 +28,8 @@ THE SOFTWARE. #import #import -#import "base/CCScheduler.h" +#include "base/CCScheduler.h" +#include "base/CCAutoreleasePool.h" #import "platform/CCApplication.h" #import "platform/desktop/CCGLView-desktop.h" #import "scripting/js-bindings/event/EventDispatcher.h" @@ -111,7 +112,8 @@ void Application::start() EventDispatcher::dispatchTickEvent(dt); CAST_VIEW(_view)->swapBuffers(); - + PoolManager::getInstance()->getCurrentPool()->clear(); + now = std::chrono::steady_clock::now(); dt = std::chrono::duration_cast(now - prevTime).count() / 1000000.f; } diff --git a/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm b/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm index 77613f3ef3..6eb6359a05 100644 --- a/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm +++ b/native/cocos/platform/mac/CCCanvasRenderingContext2D-mac.mm @@ -3,6 +3,7 @@ #include "base/csscolorparser.hpp" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +#include "cocos/scripting/js-bindings/manual/jsb_platform.h" #import #import @@ -74,7 +75,7 @@ namespace { @synthesize textBaseLine = _textBaseLine; -(id) init { - if ([super init]) { + if (self = [super init]) { _textAlign = CanvasTextAlign::LEFT; _textBaseLine = CanvasTextBaseline::BOTTOM; [self updateFontWithName:@"Arial" fontSize:30]; @@ -93,21 +94,31 @@ namespace { } -(NSFont*) _createSystemFont { - NSString* fntName = [[_fontName lastPathComponent] stringByDeletingPathExtension]; NSFontTraitMask mask = NSUnboldFontMask | NSUnitalicFontMask; - - NSFont *font = [[NSFontManager sharedFontManager] - fontWithFamily:fntName + NSFont* font = [[NSFontManager sharedFontManager] + fontWithFamily:_fontName traits:mask weight:0 size:_fontSize]; + if (font == nil) { + const auto& familyMap = getFontFamilyNameMap(); + auto iter = familyMap.find([_fontName UTF8String]); + if (iter != familyMap.end()) { + font = [[NSFontManager sharedFontManager] + fontWithFamily: [NSString stringWithUTF8String:iter->second.c_str()] + traits: mask + weight: 0 + size: _fontSize]; + } + } + if (font == nil) { font = [[NSFontManager sharedFontManager] - fontWithFamily:@"Arial" + fontWithFamily: @"Arial" traits: mask - weight:0 - size:_fontSize]; + weight: 0 + size: _fontSize]; } return font; } @@ -221,6 +232,16 @@ namespace { unsigned char* data = [bitmap bitmapData]; //Use the same buffer to improve the performance. NSUInteger textureSize = _image.size.width * _image.size.height * 4; + + // For text debugging ... +// for (int i = 0; i < textureSize; i += 4) { +// if (data[i+3] == 0) +// { +// data[i+3] = 255; +// } +// } + // + uint8_t* buffer = (uint8_t*)malloc(sizeof(uint8_t) * textureSize); if (buffer) { memcpy(buffer, data, textureSize); @@ -308,13 +329,14 @@ CanvasRenderingContext2D::CanvasRenderingContext2D(float width, float height) : __width(width) , __height(height) { -// SE_LOGD("CanvasGradient constructor: %p, width: %f, height: %f\n", this, width, height); + SE_LOGD("CanvasGradient constructor: %p, width: %f, height: %f\n", this, width, height); _impl = [[CanvasRenderingContext2DImpl alloc] init]; + [_impl recreateBufferWithWidth:width height:height]; } CanvasRenderingContext2D::~CanvasRenderingContext2D() { - SE_LOGD("CanvasGradient destructor: %p\n", this); + SE_LOGD("CanvasRenderingContext2D destructor: %p\n", this); [_impl release]; } @@ -527,4 +549,31 @@ void CanvasRenderingContext2D::set_globalCompositeOperation(const std::string& g } +// transform + +void CanvasRenderingContext2D::translate(float x, float y) +{ + +} + +void CanvasRenderingContext2D::scale(float x, float y) +{ + +} + +void CanvasRenderingContext2D::rotate(float angle) +{ + +} + +void CanvasRenderingContext2D::transform(float a, float b, float c, float d, float e, float f) +{ + +} + +void CanvasRenderingContext2D::setTransform(float a, float b, float c, float d, float e, float f) +{ + +} + NS_CC_END diff --git a/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js b/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js index 1b7b32cc40..d4a1f2ea5d 100644 --- a/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js +++ b/native/cocos/scripting/js-bindings/auto/api/jsb_cocos2dx_auto_api.js @@ -98,6 +98,28 @@ str return false; }, +/** + * @method normalizePath + * @param {String} arg0 + * @return {String} + */ +normalizePath : function ( +str +) +{ + return ; +}, + +/** + * @method getDefaultResourceRootPath + * @return {String} + */ +getDefaultResourceRootPath : function ( +) +{ + return ; +}, + /** * @method loadFilenameLookupDictionaryFromFile * @param {String} arg0 @@ -140,6 +162,18 @@ getSearchPaths : function ( return new Array(); }, +/** + * @method getFileDir + * @param {String} arg0 + * @return {String} + */ +getFileDir : function ( +str +) +{ + return ; +}, + /** * @method writeToFile * @param {map_object} arg0 @@ -154,6 +188,16 @@ str return false; }, +/** + * @method getOriginalSearchPaths + * @return {Array} + */ +getOriginalSearchPaths : function ( +) +{ + return new Array(); +}, + /** * @method listFiles * @param {String} arg0 @@ -552,6 +596,26 @@ float { }, +/** + * @method setTransform + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {float} arg5 + */ +setTransform : function ( +float, +float, +float, +float, +float, +float +) +{ +}, + /** * @method stroke */ @@ -572,6 +636,18 @@ str return cc.Size; }, +/** + * @method scale + * @param {float} arg0 + * @param {float} arg1 + */ +scale : function ( +float, +float +) +{ +}, + /** * @method clearRect * @param {float} arg0 @@ -588,6 +664,26 @@ float { }, +/** + * @method transform + * @param {float} arg0 + * @param {float} arg1 + * @param {float} arg2 + * @param {float} arg3 + * @param {float} arg4 + * @param {float} arg5 + */ +transform : function ( +float, +float, +float, +float, +float, +float +) +{ +}, + /** * @method fillText * @param {String} arg0 @@ -644,6 +740,16 @@ float { }, +/** + * @method rotate + * @param {float} arg0 + */ +rotate : function ( +float +) +{ +}, + /** * @method beginPath */ @@ -652,6 +758,18 @@ beginPath : function ( { }, +/** + * @method translate + * @param {float} arg0 + * @param {float} arg1 + */ +translate : function ( +float, +float +) +{ +}, + /** * @method createLinearGradient * @param {float} arg0 diff --git a/native/cocos/scripting/js-bindings/auto/api/jsb_renderer_auto_api.js b/native/cocos/scripting/js-bindings/auto/api/jsb_renderer_auto_api.js index 151d53844f..31566cbf84 100644 --- a/native/cocos/scripting/js-bindings/auto/api/jsb_renderer_auto_api.js +++ b/native/cocos/scripting/js-bindings/auto/api/jsb_renderer_auto_api.js @@ -3,6 +3,70 @@ */ var renderer = renderer || {}; +/** + * @class ProgramLib + */ +renderer.ProgramLib = { + +/** + * @method getProgram + * @param {String} arg0 + * @param {map_object} arg1 + * @return {cc.renderer::Program} + */ +getProgram : function ( +str, +map +) +{ + return cc.renderer::Program; +}, + +/** + * @method define + * @param {String} arg0 + * @param {String} arg1 + * @param {String} arg2 + * @param {Array} arg3 + */ +define : function ( +str, +str, +str, +array +) +{ +}, + +/** + * @method getKey + * @param {String} arg0 + * @param {map_object} arg1 + * @return {unsigned int} + */ +getKey : function ( +str, +map +) +{ + return 0; +}, + +/** + * @method ProgramLib + * @constructor + * @param {cc.renderer::DeviceGraphics} arg0 + * @param {Array} arg1 + */ +ProgramLib : function ( +devicegraphics, +array +) +{ +}, + +}; + /** * @class Model */ @@ -140,6 +204,16 @@ Model : function ( */ renderer.Base = { +/** + * @method getProgramLib + * @return {cc.renderer::ProgramLib} + */ +getProgramLib : function ( +) +{ + return cc.renderer::ProgramLib; +}, + /** * @method init * @param {cc.renderer::DeviceGraphics|cc.renderer::DeviceGraphics} devicegraphics @@ -176,13 +250,15 @@ renderer.ForwardRenderer = { * @method init * @param {cc.renderer::DeviceGraphics} arg0 * @param {Array} arg1 - * @param {int} arg2 + * @param {cc.renderer::Texture2D} arg2 * @param {int} arg3 + * @param {int} arg4 * @return {bool} */ init : function ( devicegraphics, array, +texture2d, int, int ) @@ -480,16 +556,6 @@ Camera : function ( */ renderer.Technique = { -/** - * @method getPasses - * @return {Array} - */ -getPasses : function ( -) -{ - return new Array(); -}, - /** * @method getStageIDs * @return {unsigned int} @@ -500,6 +566,18 @@ getStageIDs : function ( return 0; }, +/** + * @method setPass + * @param {int} arg0 + * @param {cc.renderer::Pass} arg1 + */ +setPass : function ( +int, +pass +) +{ +}, + /** * @method setStages * @param {Array} arg0 @@ -510,6 +588,16 @@ array { }, +/** + * @method getPasses + * @return {Array} + */ +getPasses : function ( +) +{ + return new Array(); +}, + /** * @method getParameters * @return {Array} @@ -576,18 +664,6 @@ clear : function ( { }, -/** - * @method setProperty - * @param {String} arg0 - * @param {cc.renderer::Technique::Parameter} arg1 - */ -setProperty : function ( -str, -parameter -) -{ -}, - /** * @method getTechnique * @param {String} arg0 @@ -1136,6 +1212,16 @@ Light : function ( */ renderer.Pass = { +/** + * @method getStencilTest + * @return {bool} + */ +getStencilTest : function ( +) +{ + return false; +}, + /** * @method setStencilBack */ @@ -1144,6 +1230,16 @@ setStencilBack : function ( { }, +/** + * @method setStencilTest + * @param {bool} arg0 + */ +setStencilTest : function ( +bool +) +{ +}, + /** * @method setCullMode * @param {cc.renderer::CullMode} arg0 diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp index 9ed9eeb4e7..a1fd78812b 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp @@ -164,7 +164,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_setCurrentTime(se::State& s) if (argc == 2) { int arg0 = 0; float arg1 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); ok &= seval_to_float(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_setCurrentTime : Error processing arguments"); bool result = cocos2d::experimental::AudioEngine::setCurrentTime(arg0, arg1); @@ -184,7 +184,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_getVolume(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_getVolume : Error processing arguments"); float result = cocos2d::experimental::AudioEngine::getVolume(arg0); ok &= float_to_seval(result, &s.rval()); @@ -246,7 +246,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_pause(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_pause : Error processing arguments"); cocos2d::experimental::AudioEngine::pause(arg0); return true; @@ -308,7 +308,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_getCurrentTime(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_getCurrentTime : Error processing arguments"); float result = cocos2d::experimental::AudioEngine::getCurrentTime(arg0); ok &= float_to_seval(result, &s.rval()); @@ -327,7 +327,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_setMaxAudioInstance(se::State& s CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_setMaxAudioInstance : Error processing arguments"); bool result = cocos2d::experimental::AudioEngine::setMaxAudioInstance(arg0); ok &= boolean_to_seval(result, &s.rval()); @@ -346,7 +346,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_isLoop(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_isLoop : Error processing arguments"); bool result = cocos2d::experimental::AudioEngine::isLoop(arg0); ok &= boolean_to_seval(result, &s.rval()); @@ -392,7 +392,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_setVolume(se::State& s) if (argc == 2) { int arg0 = 0; float arg1 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); ok &= seval_to_float(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_setVolume : Error processing arguments"); cocos2d::experimental::AudioEngine::setVolume(arg0, arg1); @@ -545,7 +545,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_getState(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_getState : Error processing arguments"); int result = (int)cocos2d::experimental::AudioEngine::getState(arg0); ok &= int32_to_seval(result, &s.rval()); @@ -564,7 +564,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_resume(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_resume : Error processing arguments"); cocos2d::experimental::AudioEngine::resume(arg0); return true; @@ -581,7 +581,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_stop(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_stop : Error processing arguments"); cocos2d::experimental::AudioEngine::stop(arg0); return true; @@ -598,7 +598,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_getDuration(se::State& s) CC_UNUSED bool ok = true; if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_getDuration : Error processing arguments"); float result = cocos2d::experimental::AudioEngine::getDuration(arg0); ok &= float_to_seval(result, &s.rval()); @@ -618,7 +618,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_setLoop(se::State& s) if (argc == 2) { int arg0 = 0; bool arg1; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); ok &= seval_to_boolean(args[1], &arg1); SE_PRECONDITION2(ok, false, "js_cocos2dx_audioengine_AudioEngine_setLoop : Error processing arguments"); cocos2d::experimental::AudioEngine::setLoop(arg0, arg1); @@ -652,15 +652,15 @@ static bool js_cocos2dx_audioengine_AudioEngine_setFinishCallback(se::State& s) CC_UNUSED bool ok = true; if (argc == 2) { int arg0 = 0; - std::function &)> arg1; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + std::function arg1; + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); do { if (args[1].isObject() && args[1].toObject()->isFunction()) { se::Value jsThis(s.thisObject()); se::Value jsFunc(args[1]); jsFunc.toObject()->root(); - auto lambda = [=](int larg0, const std::basic_string & larg1) -> void { + auto lambda = [=](int larg0, const std::string& larg1) -> void { se::ScriptEngine::getInstance()->clearException(); se::AutoHandleScope hs; @@ -713,7 +713,7 @@ static bool js_cocos2dx_audioengine_AudioEngine_getProfile(se::State& s) do { if (argc == 1) { int arg0 = 0; - ok &= seval_to_int32(args[0], (int32_t*)&arg0); + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); if (!ok) { ok = true; break; } cocos2d::experimental::AudioProfile* result = cocos2d::experimental::AudioEngine::getProfile(arg0); ok &= native_ptr_to_seval((cocos2d::experimental::AudioProfile*)result, &s.rval()); diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp index 864d857872..a1eb77c9cb 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp @@ -179,6 +179,45 @@ static bool js_cocos2dx_FileUtils_renameFile(se::State& s) } SE_BIND_FUNC(js_cocos2dx_FileUtils_renameFile) +static bool js_cocos2dx_FileUtils_normalizePath(se::State& s) +{ + cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_FileUtils_normalizePath : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= seval_to_std_string(args[0], &arg0); + SE_PRECONDITION2(ok, false, "js_cocos2dx_FileUtils_normalizePath : Error processing arguments"); + std::string result = cobj->normalizePath(arg0); + ok &= std_string_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_cocos2dx_FileUtils_normalizePath : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_cocos2dx_FileUtils_normalizePath) + +static bool js_cocos2dx_FileUtils_getDefaultResourceRootPath(se::State& s) +{ + cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_FileUtils_getDefaultResourceRootPath : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::string& result = cobj->getDefaultResourceRootPath(); + ok &= std_string_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_cocos2dx_FileUtils_getDefaultResourceRootPath : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_cocos2dx_FileUtils_getDefaultResourceRootPath) + static bool js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile(se::State& s) { cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); @@ -255,6 +294,27 @@ static bool js_cocos2dx_FileUtils_getSearchPaths(se::State& s) } SE_BIND_FUNC(js_cocos2dx_FileUtils_getSearchPaths) +static bool js_cocos2dx_FileUtils_getFileDir(se::State& s) +{ + cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_FileUtils_getFileDir : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + std::string arg0; + ok &= seval_to_std_string(args[0], &arg0); + SE_PRECONDITION2(ok, false, "js_cocos2dx_FileUtils_getFileDir : Error processing arguments"); + std::string result = cobj->getFileDir(arg0); + ok &= std_string_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_cocos2dx_FileUtils_getFileDir : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_cocos2dx_FileUtils_getFileDir) + static bool js_cocos2dx_FileUtils_writeToFile(se::State& s) { cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); @@ -278,6 +338,24 @@ static bool js_cocos2dx_FileUtils_writeToFile(se::State& s) } SE_BIND_FUNC(js_cocos2dx_FileUtils_writeToFile) +static bool js_cocos2dx_FileUtils_getOriginalSearchPaths(se::State& s) +{ + cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_FileUtils_getOriginalSearchPaths : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const std::vector& result = cobj->getOriginalSearchPaths(); + ok &= std_vector_string_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_cocos2dx_FileUtils_getOriginalSearchPaths : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_cocos2dx_FileUtils_getOriginalSearchPaths) + static bool js_cocos2dx_FileUtils_listFiles(se::State& s) { cocos2d::FileUtils* cobj = (cocos2d::FileUtils*)s.nativeThisObject(); @@ -865,11 +943,15 @@ bool js_register_cocos2dx_FileUtils(se::Object* obj) cls->defineFunction("getDataFromFile", _SE(js_cocos2dx_FileUtils_getDataFromFile)); cls->defineFunction("isAbsolutePath", _SE(js_cocos2dx_FileUtils_isAbsolutePath)); cls->defineFunction("renameFile", _SE(js_cocos2dx_FileUtils_renameFile)); + cls->defineFunction("normalizePath", _SE(js_cocos2dx_FileUtils_normalizePath)); + cls->defineFunction("getDefaultResourceRootPath", _SE(js_cocos2dx_FileUtils_getDefaultResourceRootPath)); cls->defineFunction("loadFilenameLookup", _SE(js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile)); cls->defineFunction("isPopupNotify", _SE(js_cocos2dx_FileUtils_isPopupNotify)); cls->defineFunction("getValueVectorFromFile", _SE(js_cocos2dx_FileUtils_getValueVectorFromFile)); cls->defineFunction("getSearchPaths", _SE(js_cocos2dx_FileUtils_getSearchPaths)); + cls->defineFunction("getFileDir", _SE(js_cocos2dx_FileUtils_getFileDir)); cls->defineFunction("writeToFile", _SE(js_cocos2dx_FileUtils_writeToFile)); + cls->defineFunction("getOriginalSearchPaths", _SE(js_cocos2dx_FileUtils_getOriginalSearchPaths)); cls->defineFunction("listFiles", _SE(js_cocos2dx_FileUtils_listFiles)); cls->defineFunction("getValueMapFromFile", _SE(js_cocos2dx_FileUtils_getValueMapFromFile)); cls->defineFunction("getFileSize", _SE(js_cocos2dx_FileUtils_getFileSize)); @@ -1078,6 +1160,35 @@ static bool js_cocos2dx_CanvasRenderingContext2D_lineTo(se::State& s) } SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_lineTo) +static bool js_cocos2dx_CanvasRenderingContext2D_setTransform(se::State& s) +{ + cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_CanvasRenderingContext2D_setTransform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 6) { + float arg0 = 0; + float arg1 = 0; + float arg2 = 0; + float arg3 = 0; + float arg4 = 0; + float arg5 = 0; + ok &= seval_to_float(args[0], &arg0); + ok &= seval_to_float(args[1], &arg1); + ok &= seval_to_float(args[2], &arg2); + ok &= seval_to_float(args[3], &arg3); + ok &= seval_to_float(args[4], &arg4); + ok &= seval_to_float(args[5], &arg5); + SE_PRECONDITION2(ok, false, "js_cocos2dx_CanvasRenderingContext2D_setTransform : Error processing arguments"); + cobj->setTransform(arg0, arg1, arg2, arg3, arg4, arg5); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 6); + return false; +} +SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_setTransform) + static bool js_cocos2dx_CanvasRenderingContext2D_stroke(se::State& s) { cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); @@ -1114,6 +1225,27 @@ static bool js_cocos2dx_CanvasRenderingContext2D_measureText(se::State& s) } SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_measureText) +static bool js_cocos2dx_CanvasRenderingContext2D_scale(se::State& s) +{ + cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_CanvasRenderingContext2D_scale : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + float arg0 = 0; + float arg1 = 0; + ok &= seval_to_float(args[0], &arg0); + ok &= seval_to_float(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_cocos2dx_CanvasRenderingContext2D_scale : Error processing arguments"); + cobj->scale(arg0, arg1); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_scale) + static bool js_cocos2dx_CanvasRenderingContext2D_clearRect(se::State& s) { cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); @@ -1139,6 +1271,35 @@ static bool js_cocos2dx_CanvasRenderingContext2D_clearRect(se::State& s) } SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_clearRect) +static bool js_cocos2dx_CanvasRenderingContext2D_transform(se::State& s) +{ + cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_CanvasRenderingContext2D_transform : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 6) { + float arg0 = 0; + float arg1 = 0; + float arg2 = 0; + float arg3 = 0; + float arg4 = 0; + float arg5 = 0; + ok &= seval_to_float(args[0], &arg0); + ok &= seval_to_float(args[1], &arg1); + ok &= seval_to_float(args[2], &arg2); + ok &= seval_to_float(args[3], &arg3); + ok &= seval_to_float(args[4], &arg4); + ok &= seval_to_float(args[5], &arg5); + SE_PRECONDITION2(ok, false, "js_cocos2dx_CanvasRenderingContext2D_transform : Error processing arguments"); + cobj->transform(arg0, arg1, arg2, arg3, arg4, arg5); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 6); + return false; +} +SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_transform) + static bool js_cocos2dx_CanvasRenderingContext2D_fillText(se::State& s) { cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); @@ -1251,6 +1412,25 @@ static bool js_cocos2dx_CanvasRenderingContext2D_fillRect(se::State& s) } SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_fillRect) +static bool js_cocos2dx_CanvasRenderingContext2D_rotate(se::State& s) +{ + cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_CanvasRenderingContext2D_rotate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + float arg0 = 0; + ok &= seval_to_float(args[0], &arg0); + SE_PRECONDITION2(ok, false, "js_cocos2dx_CanvasRenderingContext2D_rotate : Error processing arguments"); + cobj->rotate(arg0); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_rotate) + static bool js_cocos2dx_CanvasRenderingContext2D_beginPath(se::State& s) { cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); @@ -1266,6 +1446,27 @@ static bool js_cocos2dx_CanvasRenderingContext2D_beginPath(se::State& s) } SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_beginPath) +static bool js_cocos2dx_CanvasRenderingContext2D_translate(se::State& s) +{ + cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_cocos2dx_CanvasRenderingContext2D_translate : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + float arg0 = 0; + float arg1 = 0; + ok &= seval_to_float(args[0], &arg0); + ok &= seval_to_float(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_cocos2dx_CanvasRenderingContext2D_translate : Error processing arguments"); + cobj->translate(arg0, arg1); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_cocos2dx_CanvasRenderingContext2D_translate) + static bool js_cocos2dx_CanvasRenderingContext2D_createLinearGradient(se::State& s) { cocos2d::CanvasRenderingContext2D* cobj = (cocos2d::CanvasRenderingContext2D*)s.nativeThisObject(); @@ -1350,14 +1551,19 @@ bool js_register_cocos2dx_CanvasRenderingContext2D(se::Object* obj) cls->defineFunction("restore", _SE(js_cocos2dx_CanvasRenderingContext2D_restore)); cls->defineFunction("moveTo", _SE(js_cocos2dx_CanvasRenderingContext2D_moveTo)); cls->defineFunction("lineTo", _SE(js_cocos2dx_CanvasRenderingContext2D_lineTo)); + cls->defineFunction("setTransform", _SE(js_cocos2dx_CanvasRenderingContext2D_setTransform)); cls->defineFunction("stroke", _SE(js_cocos2dx_CanvasRenderingContext2D_stroke)); cls->defineFunction("measureText", _SE(js_cocos2dx_CanvasRenderingContext2D_measureText)); + cls->defineFunction("scale", _SE(js_cocos2dx_CanvasRenderingContext2D_scale)); cls->defineFunction("clearRect", _SE(js_cocos2dx_CanvasRenderingContext2D_clearRect)); + cls->defineFunction("transform", _SE(js_cocos2dx_CanvasRenderingContext2D_transform)); cls->defineFunction("fillText", _SE(js_cocos2dx_CanvasRenderingContext2D_fillText)); cls->defineFunction("strokeText", _SE(js_cocos2dx_CanvasRenderingContext2D_strokeText)); cls->defineFunction("save", _SE(js_cocos2dx_CanvasRenderingContext2D_save)); cls->defineFunction("fillRect", _SE(js_cocos2dx_CanvasRenderingContext2D_fillRect)); + cls->defineFunction("rotate", _SE(js_cocos2dx_CanvasRenderingContext2D_rotate)); cls->defineFunction("beginPath", _SE(js_cocos2dx_CanvasRenderingContext2D_beginPath)); + cls->defineFunction("translate", _SE(js_cocos2dx_CanvasRenderingContext2D_translate)); cls->defineFunction("createLinearGradient", _SE(js_cocos2dx_CanvasRenderingContext2D_createLinearGradient)); cls->defineFunction("closePath", _SE(js_cocos2dx_CanvasRenderingContext2D_closePath)); cls->defineFinalizeFunction(_SE(js_cocos2d_CanvasRenderingContext2D_finalize)); diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp index a070d9a173..ac692ff110 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp @@ -15,11 +15,15 @@ SE_DECLARE_FUNC(js_cocos2dx_FileUtils_removeFile); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getDataFromFile); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_isAbsolutePath); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_renameFile); +SE_DECLARE_FUNC(js_cocos2dx_FileUtils_normalizePath); +SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getDefaultResourceRootPath); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_isPopupNotify); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getValueVectorFromFile); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getSearchPaths); +SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getFileDir); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_writeToFile); +SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getOriginalSearchPaths); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_listFiles); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getValueMapFromFile); SE_DECLARE_FUNC(js_cocos2dx_FileUtils_getFileSize); @@ -71,14 +75,19 @@ bool register_all_cocos2dx(se::Object* obj); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_restore); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_moveTo); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_lineTo); +SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_setTransform); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_stroke); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_measureText); +SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_scale); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_clearRect); +SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_transform); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_fillText); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_strokeText); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_save); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_fillRect); +SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_rotate); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_beginPath); +SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_translate); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_createLinearGradient); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_closePath); SE_DECLARE_FUNC(js_cocos2dx_CanvasRenderingContext2D_CanvasRenderingContext2D); diff --git a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp index e7864ddf03..eda3e89319 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp @@ -3,6 +3,133 @@ #include "scripting/js-bindings/manual/jsb_global.h" #include "renderer/renderer/Renderer.h" +se::Object* __jsb_cocos2d_renderer_ProgramLib_proto = nullptr; +se::Class* __jsb_cocos2d_renderer_ProgramLib_class = nullptr; + +static bool js_renderer_ProgramLib_getProgram(se::State& s) +{ + cocos2d::renderer::ProgramLib* cobj = (cocos2d::renderer::ProgramLib*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_ProgramLib_getProgram : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + std::string arg0; + cocos2d::ValueMap arg1; + ok &= seval_to_std_string(args[0], &arg0); + ok &= seval_to_ccvaluemap(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_renderer_ProgramLib_getProgram : Error processing arguments"); + cocos2d::renderer::Program* result = cobj->getProgram(arg0, arg1); + ok &= native_ptr_to_seval((cocos2d::renderer::Program*)result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_renderer_ProgramLib_getProgram : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_renderer_ProgramLib_getProgram) + +static bool js_renderer_ProgramLib_define(se::State& s) +{ + cocos2d::renderer::ProgramLib* cobj = (cocos2d::renderer::ProgramLib*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_ProgramLib_define : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 4) { + std::string arg0; + std::string arg1; + std::string arg2; + cocos2d::ValueVector arg3; + ok &= seval_to_std_string(args[0], &arg0); + ok &= seval_to_std_string(args[1], &arg1); + ok &= seval_to_std_string(args[2], &arg2); + ok &= seval_to_ccvaluevector(args[3], &arg3); + SE_PRECONDITION2(ok, false, "js_renderer_ProgramLib_define : Error processing arguments"); + cobj->define(arg0, arg1, arg2, arg3); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 4); + return false; +} +SE_BIND_FUNC(js_renderer_ProgramLib_define) + +static bool js_renderer_ProgramLib_getKey(se::State& s) +{ + cocos2d::renderer::ProgramLib* cobj = (cocos2d::renderer::ProgramLib*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_ProgramLib_getKey : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + std::string arg0; + cocos2d::ValueMap arg1; + ok &= seval_to_std_string(args[0], &arg0); + ok &= seval_to_ccvaluemap(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_renderer_ProgramLib_getKey : Error processing arguments"); + unsigned int result = cobj->getKey(arg0, arg1); + ok &= uint32_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_renderer_ProgramLib_getKey : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_renderer_ProgramLib_getKey) + +SE_DECLARE_FINALIZE_FUNC(js_cocos2d_renderer_ProgramLib_finalize) + +static bool js_renderer_ProgramLib_constructor(se::State& s) +{ + CC_UNUSED bool ok = true; + const auto& args = s.args(); + cocos2d::renderer::DeviceGraphics* arg0 = nullptr; + std::vector arg1; + ok &= seval_to_native_ptr(args[0], &arg0); + ok &= seval_to_std_vector_ProgramLib_Template(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_renderer_ProgramLib_constructor : Error processing arguments"); + cocos2d::renderer::ProgramLib* cobj = new (std::nothrow) cocos2d::renderer::ProgramLib(arg0, arg1); + s.thisObject()->setPrivateData(cobj); + se::NonRefNativePtrCreatedByCtorMap::emplace(cobj); + return true; +} +SE_BIND_CTOR(js_renderer_ProgramLib_constructor, __jsb_cocos2d_renderer_ProgramLib_class, js_cocos2d_renderer_ProgramLib_finalize) + + + + +static bool js_cocos2d_renderer_ProgramLib_finalize(se::State& s) +{ + CCLOGINFO("jsbindings: finalizing JS object %p (cocos2d::renderer::ProgramLib)", s.nativeThisObject()); + auto iter = se::NonRefNativePtrCreatedByCtorMap::find(s.nativeThisObject()); + if (iter != se::NonRefNativePtrCreatedByCtorMap::end()) + { + se::NonRefNativePtrCreatedByCtorMap::erase(iter); + cocos2d::renderer::ProgramLib* cobj = (cocos2d::renderer::ProgramLib*)s.nativeThisObject(); + delete cobj; + } + return true; +} +SE_BIND_FINALIZE_FUNC(js_cocos2d_renderer_ProgramLib_finalize) + +bool js_register_renderer_ProgramLib(se::Object* obj) +{ + auto cls = se::Class::create("ProgramLib", obj, nullptr, _SE(js_renderer_ProgramLib_constructor)); + + cls->defineFunction("getProgram", _SE(js_renderer_ProgramLib_getProgram)); + cls->defineFunction("define", _SE(js_renderer_ProgramLib_define)); + cls->defineFunction("getKey", _SE(js_renderer_ProgramLib_getKey)); + cls->defineFinalizeFunction(_SE(js_cocos2d_renderer_ProgramLib_finalize)); + cls->install(); + JSBClassType::registerClass(cls); + + __jsb_cocos2d_renderer_ProgramLib_proto = cls->getProto(); + __jsb_cocos2d_renderer_ProgramLib_class = cls; + + se::ScriptEngine::getInstance()->clearException(); + return true; +} + se::Object* __jsb_cocos2d_renderer_Model_proto = nullptr; se::Class* __jsb_cocos2d_renderer_Model_class = nullptr; @@ -276,6 +403,24 @@ bool js_register_renderer_Model(se::Object* obj) se::Object* __jsb_cocos2d_renderer_BaseRenderer_proto = nullptr; se::Class* __jsb_cocos2d_renderer_BaseRenderer_class = nullptr; +static bool js_renderer_BaseRenderer_getProgramLib(se::State& s) +{ + cocos2d::renderer::BaseRenderer* cobj = (cocos2d::renderer::BaseRenderer*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_BaseRenderer_getProgramLib : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + cocos2d::renderer::ProgramLib* result = cobj->getProgramLib(); + ok &= native_ptr_to_seval((cocos2d::renderer::ProgramLib*)result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_renderer_BaseRenderer_getProgramLib : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_renderer_BaseRenderer_getProgramLib) + static bool js_renderer_BaseRenderer_init(se::State& s) { CC_UNUSED bool ok = true; @@ -350,6 +495,7 @@ bool js_register_renderer_BaseRenderer(se::Object* obj) { auto cls = se::Class::create("Base", obj, nullptr, _SE(js_renderer_BaseRenderer_constructor)); + cls->defineFunction("getProgramLib", _SE(js_renderer_BaseRenderer_getProgramLib)); cls->defineFunction("init", _SE(js_renderer_BaseRenderer_init)); cls->defineFinalizeFunction(_SE(js_cocos2d_renderer_BaseRenderer_finalize)); cls->install(); @@ -987,24 +1133,6 @@ bool js_register_renderer_Camera(se::Object* obj) se::Object* __jsb_cocos2d_renderer_Technique_proto = nullptr; se::Class* __jsb_cocos2d_renderer_Technique_class = nullptr; -static bool js_renderer_Technique_getPasses(se::State& s) -{ - cocos2d::renderer::Technique* cobj = (cocos2d::renderer::Technique*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_renderer_Technique_getPasses : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 0) { - const cocos2d::Vector& result = cobj->getPasses(); - ok &= Vector_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "js_renderer_Technique_getPasses : Error processing arguments"); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); - return false; -} -SE_BIND_FUNC(js_renderer_Technique_getPasses) - static bool js_renderer_Technique_getStageIDs(se::State& s) { cocos2d::renderer::Technique* cobj = (cocos2d::renderer::Technique*)s.nativeThisObject(); @@ -1023,6 +1151,27 @@ static bool js_renderer_Technique_getStageIDs(se::State& s) } SE_BIND_FUNC(js_renderer_Technique_getStageIDs) +static bool js_renderer_Technique_setPass(se::State& s) +{ + cocos2d::renderer::Technique* cobj = (cocos2d::renderer::Technique*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_Technique_setPass : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + int arg0 = 0; + cocos2d::renderer::Pass* arg1 = nullptr; + do { int32_t tmp = 0; ok &= seval_to_int32(args[0], &tmp); arg0 = (int)tmp; } while(false); + ok &= seval_to_native_ptr(args[1], &arg1); + SE_PRECONDITION2(ok, false, "js_renderer_Technique_setPass : Error processing arguments"); + cobj->setPass(arg0, arg1); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_renderer_Technique_setPass) + static bool js_renderer_Technique_setStages(se::State& s) { cocos2d::renderer::Technique* cobj = (cocos2d::renderer::Technique*)s.nativeThisObject(); @@ -1042,6 +1191,24 @@ static bool js_renderer_Technique_setStages(se::State& s) } SE_BIND_FUNC(js_renderer_Technique_setStages) +static bool js_renderer_Technique_getPasses(se::State& s) +{ + cocos2d::renderer::Technique* cobj = (cocos2d::renderer::Technique*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_Technique_getPasses : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + const cocos2d::Vector& result = cobj->getPasses(); + ok &= Vector_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_renderer_Technique_getPasses : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_renderer_Technique_getPasses) + static bool js_renderer_Technique_getParameters(se::State& s) { cocos2d::renderer::Technique* cobj = (cocos2d::renderer::Technique*)s.nativeThisObject(); @@ -1098,9 +1265,10 @@ bool js_register_renderer_Technique(se::Object* obj) { auto cls = se::Class::create("Technique", obj, nullptr, _SE(js_renderer_Technique_constructor)); - cls->defineFunction("getPasses", _SE(js_renderer_Technique_getPasses)); cls->defineFunction("getStageIDs", _SE(js_renderer_Technique_getStageIDs)); + cls->defineFunction("setPass", _SE(js_renderer_Technique_setPass)); cls->defineFunction("setStages", _SE(js_renderer_Technique_setStages)); + cls->defineFunction("getPasses", _SE(js_renderer_Technique_getPasses)); cls->defineFunction("getParameters", _SE(js_renderer_Technique_getParameters)); cls->defineFinalizeFunction(_SE(js_cocos2d_renderer_Technique_finalize)); cls->install(); @@ -2275,6 +2443,24 @@ bool js_register_renderer_Light(se::Object* obj) se::Object* __jsb_cocos2d_renderer_Pass_proto = nullptr; se::Class* __jsb_cocos2d_renderer_Pass_class = nullptr; +static bool js_renderer_Pass_getStencilTest(se::State& s) +{ + cocos2d::renderer::Pass* cobj = (cocos2d::renderer::Pass*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_Pass_getStencilTest : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 0) { + bool result = cobj->getStencilTest(); + ok &= boolean_to_seval(result, &s.rval()); + SE_PRECONDITION2(ok, false, "js_renderer_Pass_getStencilTest : Error processing arguments"); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 0); + return false; +} +SE_BIND_FUNC(js_renderer_Pass_getStencilTest) + static bool js_renderer_Pass_setStencilBack(se::State& s) { cocos2d::renderer::Pass* cobj = (cocos2d::renderer::Pass*)s.nativeThisObject(); @@ -2382,6 +2568,25 @@ static bool js_renderer_Pass_setStencilBack(se::State& s) } SE_BIND_FUNC(js_renderer_Pass_setStencilBack) +static bool js_renderer_Pass_setStencilTest(se::State& s) +{ + cocos2d::renderer::Pass* cobj = (cocos2d::renderer::Pass*)s.nativeThisObject(); + SE_PRECONDITION2(cobj, false, "js_renderer_Pass_setStencilTest : Invalid Native Object"); + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 1) { + bool arg0; + ok &= seval_to_boolean(args[0], &arg0); + SE_PRECONDITION2(ok, false, "js_renderer_Pass_setStencilTest : Error processing arguments"); + cobj->setStencilTest(arg0); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(js_renderer_Pass_setStencilTest) + static bool js_renderer_Pass_setCullMode(se::State& s) { cocos2d::renderer::Pass* cobj = (cocos2d::renderer::Pass*)s.nativeThisObject(); @@ -2692,7 +2897,9 @@ bool js_register_renderer_Pass(se::Object* obj) { auto cls = se::Class::create("Pass", obj, nullptr, _SE(js_renderer_Pass_constructor)); + cls->defineFunction("getStencilTest", _SE(js_renderer_Pass_getStencilTest)); cls->defineFunction("setStencilBack", _SE(js_renderer_Pass_setStencilBack)); + cls->defineFunction("setStencilTest", _SE(js_renderer_Pass_setStencilTest)); cls->defineFunction("setCullMode", _SE(js_renderer_Pass_setCullMode)); cls->defineFunction("setBlend", _SE(js_renderer_Pass_setBlend)); cls->defineFunction("setStencilFront", _SE(js_renderer_Pass_setStencilFront)); @@ -3111,47 +3318,6 @@ bool js_register_renderer_Scene(se::Object* obj) return true; } -se::Object* __jsb_cocos2d_renderer_ProgramLib_proto = nullptr; -se::Class* __jsb_cocos2d_renderer_ProgramLib_class = nullptr; - -static bool js_renderer_ProgamLib_getProgram(se::State& s) -{ - cocos2d::renderer::ProgramLib* cobj = (cocos2d::renderer::ProgramLib*)s.nativeThisObject(); - SE_PRECONDITION2(cobj, false, "js_renderer_ProgamLib_getProgam : Invalid Native Object"); - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 2) { - std::string arg0; - cocos2d::ValueMap arg1; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_renderer_ProgamLib_getProgam : Error processing arguments 0"); - ok &= seval_to_ccvaluemap(args[1], &arg1); - SE_PRECONDITION2(ok, false, "js_renderer_ProgamLib_getProgam : Error processing arguments 1"); - auto result = cobj->getProgram(arg0, arg1); - native_ptr_to_seval(result, &s.rval()); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_renderer_ProgamLib_getProgram) - -bool js_register_renderer_ProgramLib(se::Object* obj) -{ - auto cls = se::Class::create("ProgramLib", obj, nullptr, nullptr); - - cls->defineFunction("getProgram", _SE(js_renderer_ProgamLib_getProgram)); - cls->install(); - JSBClassType::registerClass(cls); - - __jsb_cocos2d_renderer_ProgramLib_proto = cls->getProto(); - __jsb_cocos2d_renderer_ProgramLib_class = cls; - - se::ScriptEngine::getInstance()->clearException(); - return true; -} - bool register_all_renderer(se::Object* obj) { // Get the ns @@ -3164,6 +3330,7 @@ bool register_all_renderer(se::Object* obj) } se::Object* ns = nsVal.toObject(); + js_register_renderer_ProgramLib(ns); js_register_renderer_Light(ns); js_register_renderer_Technique(ns); js_register_renderer_Effect(ns); @@ -3175,7 +3342,6 @@ bool register_all_renderer(se::Object* obj) js_register_renderer_Model(ns); js_register_renderer_ForwardRenderer(ns); js_register_renderer_View(ns); - js_register_renderer_ProgramLib(ns); return true; } diff --git a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp index 874d39700a..6fcbd567dd 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp @@ -3,6 +3,16 @@ #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +extern se::Object* __jsb_cocos2d_renderer_ProgramLib_proto; +extern se::Class* __jsb_cocos2d_renderer_ProgramLib_class; + +bool js_register_cocos2d_renderer_ProgramLib(se::Object* obj); +bool register_all_renderer(se::Object* obj); +SE_DECLARE_FUNC(js_renderer_ProgramLib_getProgram); +SE_DECLARE_FUNC(js_renderer_ProgramLib_define); +SE_DECLARE_FUNC(js_renderer_ProgramLib_getKey); +SE_DECLARE_FUNC(js_renderer_ProgramLib_ProgramLib); + extern se::Object* __jsb_cocos2d_renderer_Model_proto; extern se::Class* __jsb_cocos2d_renderer_Model_class; @@ -27,6 +37,7 @@ extern se::Class* __jsb_cocos2d_renderer_BaseRenderer_class; bool js_register_cocos2d_renderer_BaseRenderer(se::Object* obj); bool register_all_renderer(se::Object* obj); +SE_DECLARE_FUNC(js_renderer_BaseRenderer_getProgramLib); SE_DECLARE_FUNC(js_renderer_BaseRenderer_init); SE_DECLARE_FUNC(js_renderer_BaseRenderer_BaseRenderer); @@ -80,9 +91,10 @@ extern se::Class* __jsb_cocos2d_renderer_Technique_class; bool js_register_cocos2d_renderer_Technique(se::Object* obj); bool register_all_renderer(se::Object* obj); -SE_DECLARE_FUNC(js_renderer_Technique_getPasses); SE_DECLARE_FUNC(js_renderer_Technique_getStageIDs); +SE_DECLARE_FUNC(js_renderer_Technique_setPass); SE_DECLARE_FUNC(js_renderer_Technique_setStages); +SE_DECLARE_FUNC(js_renderer_Technique_getPasses); SE_DECLARE_FUNC(js_renderer_Technique_getParameters); SE_DECLARE_FUNC(js_renderer_Technique_Technique); @@ -163,7 +175,9 @@ extern se::Class* __jsb_cocos2d_renderer_Pass_class; bool js_register_cocos2d_renderer_Pass(se::Object* obj); bool register_all_renderer(se::Object* obj); +SE_DECLARE_FUNC(js_renderer_Pass_getStencilTest); SE_DECLARE_FUNC(js_renderer_Pass_setStencilBack); +SE_DECLARE_FUNC(js_renderer_Pass_setStencilTest); SE_DECLARE_FUNC(js_renderer_Pass_setCullMode); SE_DECLARE_FUNC(js_renderer_Pass_setBlend); SE_DECLARE_FUNC(js_renderer_Pass_setStencilFront); @@ -195,8 +209,3 @@ SE_DECLARE_FUNC(js_renderer_Scene_addLight); SE_DECLARE_FUNC(js_renderer_Scene_removeLight); SE_DECLARE_FUNC(js_renderer_Scene_Scene); -extern se::Object* __jsb_cocos2d_renderer_ProgramLib_proto; -extern se::Class* __jsb_cocos2d_renderer_ProgramLib_class; -bool js_register_renderer_ProgramLib(se::Object* obj); -SE_DECLARE_FUNC(js_renderer_ProgramLib_getProgram); - diff --git a/native/cocos/scripting/js-bindings/event/EventDispatcher.cpp b/native/cocos/scripting/js-bindings/event/EventDispatcher.cpp index 7caf2bb716..1ac1be9e3a 100644 --- a/native/cocos/scripting/js-bindings/event/EventDispatcher.cpp +++ b/native/cocos/scripting/js-bindings/event/EventDispatcher.cpp @@ -70,6 +70,7 @@ namespace cocos2d void EventDispatcher::dispatchTouchEvent(const struct TouchEvent& touchEvent) { + se::AutoHandleScope scope; assert(_inited); if (_jsbNameSpaceObj == nullptr) { @@ -152,7 +153,7 @@ void EventDispatcher::dispatchTickEvent(float dt) if (_tickVal.isUndefined()) { - jsb_run_script("jsb/index.js", &_tickVal); + se::ScriptEngine::getInstance()->getGlobalObject()->getProperty("gameTick", &_tickVal); } prevTime = std::chrono::steady_clock::now(); diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvert.h b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvert.h new file mode 100644 index 0000000000..71ac5674ee --- /dev/null +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvert.h @@ -0,0 +1,32 @@ +#import +#import + + +#ifdef __cplusplus +extern "C" { +#endif + +NSString *JSValueToNSString( JSContextRef ctx, JSValueRef v ); +JSValueRef NSStringToJSValue( JSContextRef ctx, NSString *string ); +double JSValueToNumberFast( JSContextRef ctx, JSValueRef v ); +void JSValueUnprotectSafe( JSContextRef ctx, JSValueRef v ); +JSValueRef NSObjectToJSValue( JSContextRef ctx, NSObject *obj ); +NSObject *JSValueToNSObject( JSContextRef ctx, JSValueRef value ); + +static inline void *JSValueGetPrivate(JSValueRef v) { + // On 64bit systems we can not safely call JSObjectGetPrivate with any + // JSValueRef. Doing so with immediate values (numbers, null, bool, + // undefined) will crash the app. So we check for these first. + + #if __LP64__ + return !((int64_t)v & 0xffff000000000002ll) + ? JSObjectGetPrivate((JSObjectRef)v) + : NULL; + #else + return JSObjectGetPrivate((JSObjectRef)v); + #endif +} + +#ifdef __cplusplus +} +#endif diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvert.m b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvert.m new file mode 100644 index 0000000000..467f65d680 --- /dev/null +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvert.m @@ -0,0 +1,173 @@ +#import "EJConvert.h" + +NSString *JSValueToNSString( JSContextRef ctx, JSValueRef v ) { + JSStringRef jsString = JSValueToStringCopy( ctx, v, NULL ); + if( !jsString ) return nil; + + NSString *string = (NSString *)JSStringCopyCFString( kCFAllocatorDefault, jsString ); + [string autorelease]; + JSStringRelease( jsString ); + + return string; +} + +JSValueRef NSStringToJSValue( JSContextRef ctx, NSString *string ) { + JSStringRef jstr = JSStringCreateWithCFString((CFStringRef)string); + JSValueRef ret = JSValueMakeString(ctx, jstr); + JSStringRelease(jstr); + return ret; +} + + +// JSValueToNumberFast blindly assumes that the given JSValueRef is a +// a number. Everything else will be silently converted to 0. +// This functions comes in a 64bit and 32bit flavor, since the NaN-Boxing +// in JSC works a bit differently on each platforms. For an explanation +// of the taggging refer to JSC/runtime/JSCJSValue.h +// The 32bit version just calls the normal JSValueToNumber() function +// and is thus a lot slower. + +double JSValueToNumberFast(JSContextRef ctx, JSValueRef v) { + #if __LP64__ // arm64 version + union { + int64_t asInt64; + double asDouble; + struct { int32_t asInt; int32_t tag; } asBits; + } taggedValue = { .asInt64 = (int64_t)v }; + + #define DoubleEncodeOffset 0x1000000000000ll + #define TagTypeNumber 0xffff0000 + #define ValueTrue 0x7 + + if( (taggedValue.asBits.tag & TagTypeNumber) == TagTypeNumber ) { + return taggedValue.asBits.asInt; + } + else if( taggedValue.asBits.tag & TagTypeNumber ) { + taggedValue.asInt64 -= DoubleEncodeOffset; + return taggedValue.asDouble; + } + else if( taggedValue.asBits.asInt == ValueTrue ) { + return 1.0; + } + else { + return 0; // false, undefined, null, object + } + #else // armv7 version + return JSValueToNumber(ctx, v, NULL); + #endif +} + +void JSValueUnprotectSafe( JSContextRef ctx, JSValueRef v ) { + if( ctx && v ) { + JSValueUnprotect(ctx, v); + } +} + +JSValueRef NSObjectToJSValue( JSContextRef ctx, NSObject *obj ) { + JSValueRef ret = NULL; + + // String + if( [obj isKindOfClass:NSString.class] ) { + ret = NSStringToJSValue(ctx, (NSString *)obj); + } + + // Number or Bool + else if( [obj isKindOfClass:NSNumber.class] ) { + NSNumber *number = (NSNumber *)obj; + if( strcmp(number.objCType, @encode(BOOL)) == 0 ) { + ret = JSValueMakeBoolean(ctx, number.boolValue); + } + else { + ret = JSValueMakeNumber(ctx, number.doubleValue); + } + } + + // Date + else if( [obj isKindOfClass:NSDate.class] ) { + NSDate *date = (NSDate *)obj; + JSValueRef timestamp = JSValueMakeNumber(ctx, date.timeIntervalSince1970 * 1000.0); + ret = JSObjectMakeDate(ctx, 1, ×tamp, NULL); + } + + // Array + else if( [obj isKindOfClass:NSArray.class] ) { + NSArray *array = (NSArray *)obj; + JSValueRef *args = malloc(array.count * sizeof(JSValueRef)); + for( int i = 0; i < array.count; i++ ) { + args[i] = NSObjectToJSValue(ctx, array[i] ); + } + ret = JSObjectMakeArray(ctx, array.count, args, NULL); + free(args); + } + + // Dictionary + else if( [obj isKindOfClass:NSDictionary.class] ) { + NSDictionary *dict = (NSDictionary *)obj; + ret = JSObjectMake(ctx, NULL, NULL); + for( NSString *key in dict ) { + JSStringRef jsKey = JSStringCreateWithUTF8CString(key.UTF8String); + JSValueRef value = NSObjectToJSValue(ctx, dict[key]); + JSObjectSetProperty(ctx, (JSObjectRef)ret, jsKey, value, NULL, NULL); + JSStringRelease(jsKey); + } + } + + return ret ? ret : JSValueMakeNull(ctx); +} + +NSObject *JSValueToNSObject( JSContextRef ctx, JSValueRef value ) { + JSType type = JSValueGetType(ctx, value); + + switch( type ) { + case kJSTypeString: return JSValueToNSString(ctx, value); + case kJSTypeBoolean: return [NSNumber numberWithBool:JSValueToBoolean(ctx, value)]; + case kJSTypeNumber: return [NSNumber numberWithDouble:JSValueToNumberFast(ctx, value)]; + case kJSTypeNull: return nil; + case kJSTypeUndefined: return nil; + case kJSTypeObject: break; + } + + if( type == kJSTypeObject ) { + JSObjectRef jsObj = (JSObjectRef)value; + + // Get the Array constructor to check if this Object is an Array + JSStringRef arrayName = JSStringCreateWithUTF8CString("Array"); + JSObjectRef arrayConstructor = (JSObjectRef)JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx), arrayName, NULL); + JSStringRelease(arrayName); + + if( JSValueIsInstanceOfConstructor(ctx, jsObj, arrayConstructor, NULL) ) { + // Array + JSStringRef lengthName = JSStringCreateWithUTF8CString("length"); + int count = JSValueToNumberFast(ctx, JSObjectGetProperty(ctx, jsObj, lengthName, NULL)); + JSStringRelease(lengthName); + + NSMutableArray *array = [NSMutableArray arrayWithCapacity:count]; + for( int i = 0; i < count; i++ ) { + NSObject *obj = JSValueToNSObject(ctx, JSObjectGetPropertyAtIndex(ctx, jsObj, i, NULL)); + [array addObject:(obj ? obj : NSNull.null)]; + } + return array; + } + else { + // Plain Object + JSPropertyNameArrayRef properties = JSObjectCopyPropertyNames(ctx, jsObj); + size_t count = JSPropertyNameArrayGetCount(properties); + + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:count]; + for( size_t i = 0; i < count; i++ ) { + JSStringRef jsName = JSPropertyNameArrayGetNameAtIndex(properties, i); + NSObject *obj = JSValueToNSObject(ctx, JSObjectGetProperty(ctx, jsObj, jsName, NULL)); + + NSString *name = (NSString *)JSStringCopyCFString( kCFAllocatorDefault, jsName ); + dict[name] = obj ? obj : NSNull.null; + [name release]; + } + + JSPropertyNameArrayRelease(properties); + return dict; + } + } + + return nil; +} + diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvertTypedArray.h b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvertTypedArray.h new file mode 100644 index 0000000000..5c65efbf05 --- /dev/null +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvertTypedArray.h @@ -0,0 +1,83 @@ +#import +#import + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@enum JSType +@abstract A constant identifying the Typed Array type of a JSValue. +@constant kEJJSTypedArrayTypeNone Not a Typed Array. +@constant kEJJSTypedArrayTypeInt8Array Int8Array +@constant kEJJSTypedArrayTypeInt16Array Int16Array +@constant kEJJSTypedArrayTypeInt32Array Int32Array +@constant kEJJSTypedArrayTypeUint8Array Int8Array +@constant kEJJSTypedArrayTypeUint8ClampedArray Int8ClampedArray +@constant kEJJSTypedArrayTypeUint16Array Uint16Array +@constant kEJJSTypedArrayTypeUint32Array Uint32Array +@constant kEJJSTypedArrayTypeFloat32Array Float32Array +@constant kEJJSTypedArrayTypeFloat64Array Float64Array +@constant kEJJSTypedArrayTypeArrayBuffer ArrayBuffer +*/ +typedef enum { + kEJJSTypedArrayTypeNone = 0, + kEJJSTypedArrayTypeInt8Array = 1, + kEJJSTypedArrayTypeInt16Array = 2, + kEJJSTypedArrayTypeInt32Array = 3, + kEJJSTypedArrayTypeUint8Array = 4, + kEJJSTypedArrayTypeUint8ClampedArray = 5, + kEJJSTypedArrayTypeUint16Array = 6, + kEJJSTypedArrayTypeUint32Array = 7, + kEJJSTypedArrayTypeFloat32Array = 8, + kEJJSTypedArrayTypeFloat64Array = 9, + kEJJSTypedArrayTypeArrayBuffer = 10 +} EJJSTypedArrayType; + +/*! +@function +@abstract Setup the JSContext for use of the Typed Array functions. +@param ctx The execution context to use +*/ +void EJJSContextPrepareTypedArrayAPI(JSContextRef ctx); + +/*! +@function +@abstract Returns a JavaScript value's Typed Array type +@param ctx The execution context to use. +@param value The JSObject whose Typed Array type you want to obtain. +@result A value of type EJJSTypedArrayType that identifies value's Typed Array type +*/ +EJJSTypedArrayType EJJSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Creates an empty JavaScript Typed Array with the given number of elements +@param ctx The execution context to use. +@param arrayType A value of type EJJSTypedArrayType identifying the type of array you want to create +@param numElements The number of elements for the array. +@result A JSObjectRef that is a Typed Array or NULL if there was an error +*/ +JSObjectRef EJJSObjectMakeTypedArray(JSContextRef ctx, EJJSTypedArrayType arrayType, size_t numElements); + +/*! +@function +@abstract Returns a copy of the Typed Array's data +@param ctx The execution context to use. +@param value The JSObject whose Typed Array data you want to obtain. +@result A copy of the Typed Array's data or NULL if the JSObject is not a Typed Array +*/ +NSMutableData *EJJSObjectGetTypedArrayData(JSContextRef ctx, JSObjectRef object); + +/*! +@function +@abstract Replaces a Typed Array's data +@param ctx The execution context to use. +@param value The JSObject whose Typed Array data you want to replace +*/ +void EJJSObjectSetTypedArrayData(JSContextRef ctx, JSObjectRef object, NSData *data); + +#ifdef __cplusplus +} +#endif + diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvertTypedArray.m b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvertTypedArray.m new file mode 100644 index 0000000000..9953fe5555 --- /dev/null +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/EJConvertTypedArray.m @@ -0,0 +1,394 @@ +#import "EJConvertTypedArray.h" +#import "EJConvert.h" + +#if defined __ARM_NEON__ +#include +#endif + +// These functions deal with getting and setting a JavaScript Typed Array's data. +// The process in which this is done is extremely backwards, prohibitively +// memory inefficient and painfully slow. + +// JavaScriptCore still doesn't have an API to deal with Typed Arrays directly +// and nobody seems to care. See this WebKit bug for the details: +// https://bugs.webkit.org/show_bug.cgi?id=120112 + +// The naive method of getting the array's data would be to read the "length" +// property and call JSObjectGetPropertyAtIndex() for each element. This function +// returns a JSValue and since the array's data is just a raw memory pointer +// internally, this JSValue has be constructed first by JSC. Afterwards this +// JSValue has to be converted back into an int and stored in a native buffer. +// This ordeal takes about 1200ms per megabyte on an iPhone5S. + +// So, instead of extracting each byte on its own, we create Int32 view on the +// Array, so that we can extract 4 bytes at a time. Now, the fastest method to +// get to the values is to call a function with .apply(null, theInt32Array). +// This causes the typed array to be converted into plain JSValues - we can then +// iterate all function arguments and convert each JSValue into a Int32. + +// There's one big caveat, though: a function can only be called with 64k +// arguments at once, or it will blow the stack. So we have to divide the Int32 +// Array into smaller subarrays and convert the data in chunks. + +// Setting the Array's data works about the same. We can create a plain JS +// Array in reasonable time by treating the data as 32bit ints. This plain +// Array can then be used to call .set() on an Int32 View of the Typed Array. + +// To be able to quickly determine the type of a typed array, we install an +// enum with the type id ("__ejTypedArrayType") onto each array constructor's +// prototype. + +// This all brings the time down to about 7ms per megabyte for reading and about +// 20ms per megabyte for writing. Even though this 7ms/MB number may not sound +// all too bad, keep in mind that it's still 7ms slower than what we would have +// with a better API. + + + + + +// Array Types to constructor names. We need to obtain the Constructors from +// the JSGlobalObject when creating Typed Arrays and when attaching our methods +// to them. + +const static char *ConstructorNames[] = { + [kEJJSTypedArrayTypeNone] = NULL, + [kEJJSTypedArrayTypeInt8Array] = "Int8Array", + [kEJJSTypedArrayTypeInt16Array] = "Int16Array", + [kEJJSTypedArrayTypeInt32Array] = "Int32Array", + [kEJJSTypedArrayTypeUint8Array] = "Uint8Array", + [kEJJSTypedArrayTypeUint8ClampedArray] = "Uint8ClampedArray", + [kEJJSTypedArrayTypeUint16Array] = "Uint16Array", + [kEJJSTypedArrayTypeUint32Array] = "Uint32Array", + [kEJJSTypedArrayTypeFloat32Array] = "Float32Array", + [kEJJSTypedArrayTypeFloat64Array] = "Float64Array", + [kEJJSTypedArrayTypeArrayBuffer] = "ArrayBuffer" +}; + + +// Data from Typed Arrays smaller than CopyInChunksThreshold will be extracted +// one byte at a time. + +const static int CopyInChunksThreshold = 32; + + +// For large arrays, copy the data in Chunks of 16k elements, so that we don't +// blow the stack. + +const static int CopyChunkSize = 0x4000; + + + +// Hobo version to get an Int32 from a JSValueRef. This is even faster than +// JSValueToNumberFast() because it blindly assumes the value is an Int32. +// A number stored as double will produce a bogus Int value. JSC stores all +// values that are outside of the Int32 range as double. + +// This function is only fast on 64bit systems. On 32bit systems we can't +// easily access the integer value. +// See JavaScriptCore/runtime/JSCJSValue.h for an explanation of the NaN- +// boxing used in JSC. + +// Use with extreme caution! + +static inline int32_t GetInt32(JSContextRef ctx, JSValueRef v) { + #if __LP64__ + return (int32_t)(0x00000000ffffffffll & (uint64_t)v); + #else + return JSValueToNumber(ctx, v, NULL); + #endif +} + + +// Hobo version to create an Int32 fast. Falls back to JSValueMakeNumber() +// on 32bit systems. + +static inline JSValueRef MakeInt32(JSContextRef ctx, int32_t number) { + #if __LP64__ + return (0xffff000000000000ll | (uint64_t)number); + #else + return JSValueMakeNumber(ctx, number); + #endif +} + + +// Shorthand to get a property by name + +static JSValueRef GetPropertyNamed(JSContextRef ctx, JSObjectRef object, const char *name) { + JSStringRef jsPropertyName = JSStringCreateWithUTF8CString(name); + JSValueRef value = JSObjectGetProperty(ctx, object, jsPropertyName, NULL); + JSStringRelease(jsPropertyName); + return value; +} + + +// Shorthand to get the Constructor for the given EJJSTypedArrayType + +static JSObjectRef GetConstructor(JSContextRef ctx, EJJSTypedArrayType type) { + if( type <= kEJJSTypedArrayTypeNone || type > kEJJSTypedArrayTypeArrayBuffer ) { + return NULL; + } + + const char *constructorName = ConstructorNames[type]; + JSObjectRef global = JSContextGetGlobalObject(ctx); + return (JSObjectRef)GetPropertyNamed(ctx, global, constructorName); +} + + +// Create a typed array view from another typed array or arraybuffer + +static JSObjectRef GetView(JSContextRef ctx, JSObjectRef object, EJJSTypedArrayType type, size_t count) { + EJJSTypedArrayType currentType = EJJSObjectGetTypedArrayType(ctx, object); + if( currentType == kEJJSTypedArrayTypeNone ) { + return NULL; + } + else if( currentType == type ) { + return object; + } + + JSValueRef args[3]; + if( currentType == kEJJSTypedArrayTypeArrayBuffer ) { + args[0] = object; + args[1] = MakeInt32(ctx, 0); + args[2] = MakeInt32(ctx, (int)count); + } + else { + args[0] = GetPropertyNamed(ctx, object, "buffer"); + args[1] = GetPropertyNamed(ctx, object, "byteOffset"); + args[2] = MakeInt32(ctx, (int)count); + } + JSObjectRef constructor = GetConstructor(ctx, type); + return JSObjectCallAsConstructor(ctx, constructor, 3, args, NULL); +} + + +// The callback called from JSObjectGetTypedArrayData with chunks of data. This writes +// into the state's data. + +typedef struct { + int32_t *currentDataPtr; + JSObjectRef jsGetCallback; + JSObjectRef jsGetCallbackApply; +} AppendDataCallbackState; + +static JSValueRef AppendDataCallback( + JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, + size_t argc, const JSValueRef argv[], JSValueRef* exception +) { + AppendDataCallbackState *state = JSObjectGetPrivate(thisObject); + int32_t *dst = state->currentDataPtr; + int remainderStart = 0; + + // On 64bit systems where ARM_NEON instructions are available we can use + // some SIMD intrinsics to extract the lower 32bit of each JSValueRef. + // Hopefully the JSValueRef encodes an Int32 so the lower 32bit corresponds + // to that Int32 exactly. + + #if __LP64__ && defined __ARM_NEON__ + // Iterate over the arguments in packs of 4. + // Load arguments as 2 lanes of 4 int32 values and store the first + // lane (the lower 32bit) into the dst buffer. + + int argPacks4 = (int)argc/4; + int32_t *src = (int32_t*)argv; + + for(int i = 0; i < argPacks4; i++ ) { + const int32x4x2_t lanes32 = vld2q_s32(src); + vst1q_s32(dst, lanes32.val[0]); + src += 8; + dst += 4; + } + remainderStart = argPacks4 * 4; + #endif + + for( int i = remainderStart; i < argc; i++ ) { + *(dst++) = GetInt32(ctx, argv[i]); + } + + state->currentDataPtr += argc; + return MakeInt32(ctx, (int)argc); +} + + +// To store the AppendDataCallbackState and access it _per context_, we create +// a plain JSObject where we can store a pointer to the state in the private +// data. + +static void FinalizeAppendDataCallbackState(JSObjectRef object) { + AppendDataCallbackState *state = JSObjectGetPrivate(object); + free(state); +} + +static JSObjectRef CreateAppendDataCallbackState(JSContextRef ctx) { + // Create a JS function that calls the AppendDataCallback + JSObjectRef jsAppendDataCallback = JSObjectMakeFunctionWithCallback(ctx, NULL, AppendDataCallback); + JSValueProtect(ctx, jsAppendDataCallback); + + // Allocate and create the state and attach the AppendDataCallback + // function and its .apply property. + AppendDataCallbackState *state = malloc(sizeof(AppendDataCallbackState)); + state->currentDataPtr = NULL; + state->jsGetCallback = jsAppendDataCallback; + state->jsGetCallbackApply = (JSObjectRef)GetPropertyNamed(ctx, jsAppendDataCallback, "apply"); + + + // Create the empty js object that holds the state in its Private data + JSClassDefinition internalStateClassDef = kJSClassDefinitionEmpty; + internalStateClassDef.finalize = FinalizeAppendDataCallbackState; + + JSClassRef internalStateClass = JSClassCreate(&internalStateClassDef); + JSObjectRef internalStateObject = JSObjectMake(ctx, internalStateClass, state); + JSClassRelease(internalStateClass); + return internalStateObject; +} + + + + +void EJJSContextPrepareTypedArrayAPI(JSContextRef ctx) { + // The __ejTypedArrayType property is read only, not enumerable + JSPropertyAttributes attributes = + kJSPropertyAttributeReadOnly | + kJSPropertyAttributeDontEnum | + kJSPropertyAttributeDontDelete; + + // Install the __ejTypedArrayType property on each Typed Array prototype + JSStringRef jsTypeName = JSStringCreateWithUTF8CString("__ejTypedArrayType"); + + for( int type = kEJJSTypedArrayTypeInt8Array; type <= kEJJSTypedArrayTypeArrayBuffer; type++ ) { + JSObjectRef jsConstructor = GetConstructor(ctx, type); + JSObjectRef jsPrototype = (JSObjectRef)GetPropertyNamed(ctx, jsConstructor, "prototype"); + + JSValueRef jsType = MakeInt32(ctx, type); + JSObjectSetProperty(ctx, jsPrototype, jsTypeName, jsType, attributes, NULL); + } + + JSStringRelease(jsTypeName); + + + // Create the state object for the AppendData Callback and attach it to the global + // object + JSObjectRef jsCallbackStateObject = CreateAppendDataCallbackState(ctx); + + JSStringRef jsInternalStateName = JSStringCreateWithUTF8CString("__ejTypedArrayState"); + JSObjectRef global = JSContextGetGlobalObject(ctx); + JSObjectSetProperty(ctx, global, jsInternalStateName, jsCallbackStateObject, attributes, NULL); + JSStringRelease(jsInternalStateName); +} + + +EJJSTypedArrayType EJJSObjectGetTypedArrayType(JSContextRef ctx, JSObjectRef object) { + JSValueRef jsType = GetPropertyNamed(ctx, object, "__ejTypedArrayType"); + return jsType ? GetInt32(ctx, jsType) : kEJJSTypedArrayTypeNone; +} + +JSObjectRef EJJSObjectMakeTypedArray(JSContextRef ctx, EJJSTypedArrayType arrayType, size_t numElements) { + JSObjectRef jsConstructor = GetConstructor(ctx, arrayType); + if( !jsConstructor ) { + return NULL; + } + + JSValueRef jsNumElements = MakeInt32(ctx, (int)numElements); + return JSObjectCallAsConstructor(ctx, jsConstructor, 1, (JSValueRef[]){jsNumElements}, NULL); +} + + +NSMutableData *EJJSObjectGetTypedArrayData(JSContextRef ctx, JSObjectRef object) { + size_t length = GetInt32(ctx, GetPropertyNamed(ctx, object, "byteLength")); + if( !length ) { + return NULL; + } + + size_t int32Count = length / 4; + size_t uint8Count = length % 4; + + // For very small typed arrays it's faster to read all bytes individually + // instead of doing the callback dance. + if( length < CopyInChunksThreshold ) { + int32Count = 0; + uint8Count = length; + } + + NSMutableData *data = [NSMutableData dataWithLength:length]; + + // Read data in large chunks of 32bit values + if( int32Count ) { + JSObjectRef int32View = GetView(ctx, object, kEJJSTypedArrayTypeInt32Array, int32Count); + if( !int32View ) { + return NULL; + } + + JSObjectRef jsState = (JSObjectRef)GetPropertyNamed(ctx, JSContextGetGlobalObject(ctx), "__ejTypedArrayState"); + AppendDataCallbackState *state = JSObjectGetPrivate(jsState); + state->currentDataPtr = data.mutableBytes; + + + // If the whole data is smaller than the chunk size, we only have to call our callback once, otherwise + // we have to create subarrays and call the callback with these. + if( int32Count < CopyChunkSize ) { + JSValueRef getArgs[] = {jsState, int32View}; + JSObjectCallAsFunction(ctx, state->jsGetCallbackApply, state->jsGetCallback, 2, getArgs, NULL); + } + else { + JSObjectRef subarrayFunc = (JSObjectRef)GetPropertyNamed(ctx, int32View, "subarray"); + + for( int i = 0; i < int32Count; i+= CopyChunkSize) { + JSValueRef subarrayArgs[] = {MakeInt32(ctx, i), MakeInt32(ctx, i + CopyChunkSize)}; + JSObjectRef jsSubarray = (JSObjectRef)JSObjectCallAsFunction(ctx, subarrayFunc, int32View, 2, subarrayArgs, NULL); + + JSValueRef getArgs[] = {jsState, jsSubarray}; + JSObjectCallAsFunction(ctx, state->jsGetCallbackApply, state->jsGetCallback, 2, getArgs, NULL); + } + } + } + + // Read remaining bytes directly + if( uint8Count ) { + uint8_t *values8 = data.mutableBytes; + JSObjectRef uint8View = GetView(ctx, object, kEJJSTypedArrayTypeUint8Array, length); + for( int i = 0; i < uint8Count; i++ ) { + int index = (int)int32Count * 4 + i; + values8[index] = GetInt32(ctx, JSObjectGetPropertyAtIndex(ctx, uint8View, index, NULL)); + } + } + + return data; +} + + +void EJJSObjectSetTypedArrayData(JSContextRef ctx, JSObjectRef object, NSData *data) { + size_t int32Count = data.length / 4; + size_t uint8Count = data.length % 4; + + if( int32Count ) { + JSObjectRef int32View = GetView(ctx, object, kEJJSTypedArrayTypeInt32Array, int32Count); + if( !int32View ) { + return; + } + + // Construct the JSValues and create the plain JSArray + JSValueRef *jsValues = malloc(int32Count * sizeof(JSValueRef)); + + const int32_t *values32 = data.bytes; + for(int i = 0; i < int32Count; i++) { + jsValues[i] = MakeInt32(ctx, values32[i]); + } + JSObjectRef jsArray = JSObjectMakeArray(ctx, int32Count, jsValues, NULL); + + free(jsValues); + + // Call the .set() function on the Typed Array + JSObjectRef setFunction = (JSObjectRef)GetPropertyNamed(ctx, int32View, "set"); + JSObjectCallAsFunction(ctx, setFunction, int32View, 1, (JSValueRef[]){jsArray}, NULL); + } + + // Set remaining bytes directly + if( uint8Count ) { + const uint8_t *values8 = data.bytes; + JSObjectRef uint8View = GetView(ctx, object, kEJJSTypedArrayTypeUint8Array, data.length); + for( int i = 0; i < uint8Count; i++ ) { + int index = (int)int32Count * 4 + i; + JSObjectSetPropertyAtIndex(ctx, uint8View, index, MakeInt32(ctx, values8[index]), NULL); + } + } +} diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp index ce10213d13..38584f75e7 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.hpp @@ -394,9 +394,6 @@ namespace se { void* _privateData; JSObjectFinalizeCallback _finalizeCb; - mutable uint8_t* _arrayBuffer; - mutable size_t _arrayBufferSize; - uint32_t _rootCount; uint32_t _currentVMId; #if SE_DEBUG > 0 diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.mm similarity index 74% rename from native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp rename to native/cocos/scripting/js-bindings/jswrapper/jsc/Object.mm index 47bccd2fb2..b566e9046f 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/Object.mm @@ -32,6 +32,8 @@ #include "PlatformUtils.h" #include "../MappingUtils.hpp" +#include "EJConvertTypedArray.h" + namespace se { namespace { @@ -60,8 +62,6 @@ namespace se { , _obj(nullptr) , _privateData(nullptr) , _finalizeCb(nullptr) - , _arrayBuffer(nullptr) - , _arrayBufferSize(0) , _rootCount(0) #if SE_DEBUG > 0 , _id(++__id) @@ -75,10 +75,6 @@ namespace se { Object::~Object() { _cleanup(); - if (_arrayBuffer != nullptr) - { - free(_arrayBuffer); - } } Object* Object::createPlainObject() @@ -127,55 +123,19 @@ namespace se { } Object* obj = Object::_createJSObject(nullptr, jsobj); + if (obj != nullptr) + obj->_type = Type::ARRAY_BUFFER; return obj; } - else #endif - { - HandleObject arr(Object::createArrayObject(byteLength)); - if (!arr.isEmpty()) - { - uint8_t* p = (uint8_t*)data; - for (size_t i = 0; i < byteLength; ++i) - { - arr->setArrayElement((uint32_t)i, se::Value(p[i])); - } + JSObjectRef ret = EJJSObjectMakeTypedArray(__cx, kEJJSTypedArrayTypeArrayBuffer, byteLength); + NSData* nsData = [NSData dataWithBytes:data length:byteLength]; + EJJSObjectSetTypedArrayData(__cx, ret, nsData); - ValueArray args; - args.push_back(Value(arr)); - Value func; - bool ok = ScriptEngine::getInstance()->getGlobalObject()->getProperty("__jsc_createArrayBufferObject", &func); - if (ok && func.isObject() && func.toObject()->isFunction()) - { - Value ret; - ok = func.toObject()->call(args, nullptr, &ret); - if (ok && ret.isObject()) - { - Object* obj = Object::_createJSObject(nullptr, ret.toObject()->_obj); - if (obj != nullptr) - obj->_type = Type::ARRAY_BUFFER; - return obj; - } - } - } - } - - return nullptr; - } - - template - static bool _setArrayElement(Object* arr, void* data, size_t byteLength) - { - T* p = (T*)data; - size_t count = byteLength / sizeof(T); - for (size_t i = 0; i < count; ++i) - { - if (!arr->setArrayElement((uint32_t)i, se::Value(p[i]))) - { - return false; - } - } - return true; + Object* obj = Object::_createJSObject(nullptr, ret); + if (obj != nullptr) + obj->_type = Type::ARRAY_BUFFER; + return obj; } Object* Object::createTypedArray(TypedArrayType type, void* data, size_t byteLength) @@ -203,29 +163,42 @@ namespace se { JSValueRef exception = nullptr; JSTypedArrayType jscTypedArrayType = kJSTypedArrayTypeNone; + Type objectType = Type::UNKNOWN; switch (type) { case TypedArrayType::INT8: + objectType = Type::TYPED_ARRAY_INT8; jscTypedArrayType = kJSTypedArrayTypeInt8Array; break; case TypedArrayType::INT16: + objectType = Type::TYPED_ARRAY_INT16; jscTypedArrayType = kJSTypedArrayTypeInt16Array; break; case TypedArrayType::INT32: + objectType = Type::TYPED_ARRAY_INT32; jscTypedArrayType = kJSTypedArrayTypeInt32Array; break; case TypedArrayType::UINT8: + objectType = Type::TYPED_ARRAY_UINT8; jscTypedArrayType = kJSTypedArrayTypeUint8Array; break; + case TypedArrayType::UINT8_CLAMPED: + objectType = Type::TYPED_ARRAY_UINT8_CLAMPED; + jscTypedArrayType = kJSTypedArrayTypeUint8ClampedArray; + break; case TypedArrayType::UINT16: + objectType = Type::TYPED_ARRAY_UINT16; jscTypedArrayType = kJSTypedArrayTypeUint16Array; break; case TypedArrayType::UINT32: + objectType = Type::TYPED_ARRAY_UINT32; jscTypedArrayType = kJSTypedArrayTypeUint32Array; break; case TypedArrayType::FLOAT32: + objectType = Type::TYPED_ARRAY_FLOAT32; jscTypedArrayType = kJSTypedArrayTypeFloat32Array; break; case TypedArrayType::FLOAT64: + objectType = Type::TYPED_ARRAY_FLOAT64; jscTypedArrayType = kJSTypedArrayTypeFloat64Array; break; default: @@ -238,88 +211,72 @@ namespace se { return nullptr; } Object* obj = Object::_createJSObject(nullptr, jsobj); + if (obj != nullptr) + obj->_type = objectType; return obj; } - else #endif - { - HandleObject arr(Object::createArrayObject(byteLength)); - Type objectType = Type::UNKNOWN; - - if (!arr.isEmpty()) - { - const char* typedArrayCtor = nullptr; - switch (type) { - case TypedArrayType::INT8: - typedArrayCtor = "Int8Array"; - objectType = Type::TYPED_ARRAY_INT8; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::INT16: - typedArrayCtor = "Int16Array"; - objectType = Type::TYPED_ARRAY_INT16; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::INT32: - typedArrayCtor = "Int32Array"; - objectType = Type::TYPED_ARRAY_INT32; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::UINT8: - typedArrayCtor = "Uint8Array"; - objectType = Type::TYPED_ARRAY_UINT8; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::UINT16: - typedArrayCtor = "Uint16Array"; - objectType = Type::TYPED_ARRAY_UINT16; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::UINT32: - typedArrayCtor = "Uint32Array"; - objectType = Type::TYPED_ARRAY_UINT32; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::FLOAT32: - typedArrayCtor = "Float32Array"; - objectType = Type::TYPED_ARRAY_FLOAT32; - _setArrayElement(arr.get(), data, byteLength); - break; - case TypedArrayType::FLOAT64: - typedArrayCtor = "Float64Array"; - objectType = Type::TYPED_ARRAY_FLOAT64; - _setArrayElement(arr.get(), data, byteLength); - break; - default: - assert(false); // Should never go here. - break; - } - - Value func; - bool ok = ScriptEngine::getInstance()->getGlobalObject()->getProperty(typedArrayCtor, &func); - // On <= iOS 9, typed array constructor is an object rather than a function. - // Therefore, don't check whether typed array constructor is a function here. - if (ok && func.isObject()/* && func.toObject()->isFunction() */) - { - JSValueRef exception = nullptr; - JSObjectRef ret = JSObjectCallAsConstructor(__cx, func.toObject()->_obj, 1, &arr->_obj, &exception); - if (exception == nullptr) - { - Object* obj = Object::_createJSObject(nullptr, ret); - if (obj != nullptr) - obj->_type = objectType; - - return obj; - } - else - { - ScriptEngine::getInstance()->_clearException(exception); - } - } - } + size_t numElements = 0; + EJJSTypedArrayType jscTypedArrayType = kEJJSTypedArrayTypeNone; + Type objectType = Type::UNKNOWN; + switch (type) { + case TypedArrayType::INT8: + objectType = Type::TYPED_ARRAY_INT8; + jscTypedArrayType = kEJJSTypedArrayTypeInt8Array; + numElements = byteLength; + break; + case TypedArrayType::INT16: + objectType = Type::TYPED_ARRAY_INT16; + jscTypedArrayType = kEJJSTypedArrayTypeInt16Array; + numElements = byteLength / 2; + break; + case TypedArrayType::INT32: + objectType = Type::TYPED_ARRAY_INT32; + jscTypedArrayType = kEJJSTypedArrayTypeInt32Array; + numElements = byteLength / 4; + break; + case TypedArrayType::UINT8: + objectType = Type::TYPED_ARRAY_UINT8; + jscTypedArrayType = kEJJSTypedArrayTypeUint8Array; + numElements = byteLength; + break; + case TypedArrayType::UINT8_CLAMPED: + objectType = Type::TYPED_ARRAY_UINT8_CLAMPED; + jscTypedArrayType = kEJJSTypedArrayTypeUint8ClampedArray; + numElements = byteLength; + break; + case TypedArrayType::UINT16: + objectType = Type::TYPED_ARRAY_UINT16; + jscTypedArrayType = kEJJSTypedArrayTypeUint16Array; + numElements = byteLength / 2; + break; + case TypedArrayType::UINT32: + objectType = Type::TYPED_ARRAY_UINT32; + jscTypedArrayType = kEJJSTypedArrayTypeUint32Array; + numElements = byteLength / 4; + break; + case TypedArrayType::FLOAT32: + objectType = Type::TYPED_ARRAY_FLOAT32; + jscTypedArrayType = kEJJSTypedArrayTypeFloat32Array; + numElements = byteLength / 4; + break; + case TypedArrayType::FLOAT64: + objectType = Type::TYPED_ARRAY_FLOAT64; + jscTypedArrayType = kEJJSTypedArrayTypeFloat64Array; + numElements = byteLength / 8; + break; + default: + break; } - return nullptr; + JSObjectRef ret = EJJSObjectMakeTypedArray(__cx, jscTypedArrayType, numElements); + NSData* nsData = [NSData dataWithBytes:data length:byteLength]; + EJJSObjectSetTypedArrayData(__cx, ret, nsData); + + Object* obj = Object::_createJSObject(nullptr, ret); + if (obj != nullptr) + obj->_type = objectType; + return obj; } Object* Object::createUint8TypedArray(uint8_t* data, size_t dataCount) @@ -711,7 +668,9 @@ namespace se { return ret; } #endif - return isInstanceOfConstructor(__cx, _obj, "__jscTypedArrayConstructor"); + + EJJSTypedArrayType typedArrayType = EJJSObjectGetTypedArrayType(__cx, _obj); + return typedArrayType >= kEJJSTypedArrayTypeInt8Array && typedArrayType <= kEJJSTypedArrayTypeFloat64Array; } Object::TypedArrayType Object::getTypedArrayType() const @@ -788,50 +747,48 @@ namespace se { return typedArrayType; } #endif - if (isInstanceOfConstructor(__cx, _obj, "Int8Array")) - { - _type = Type::TYPED_ARRAY_INT8; - typedArrayType = TypedArrayType::INT8; - } - else if (isInstanceOfConstructor(__cx, _obj, "Int16Array")) - { - _type = Type::TYPED_ARRAY_INT16; - typedArrayType = TypedArrayType::INT16; - } - else if (isInstanceOfConstructor(__cx, _obj, "Int32Array")) - { - _type = Type::TYPED_ARRAY_INT32; - typedArrayType = TypedArrayType::INT32; - } - else if (isInstanceOfConstructor(__cx, _obj, "Uint8Array")) - { - _type = Type::TYPED_ARRAY_UINT8; - typedArrayType = TypedArrayType::UINT8; - } - else if (isInstanceOfConstructor(__cx, _obj, "Uint8ClampedArray")) - { - _type = Type::TYPED_ARRAY_UINT8_CLAMPED; - typedArrayType = TypedArrayType::UINT8_CLAMPED; - } - else if (isInstanceOfConstructor(__cx, _obj, "Uint16Array")) - { - _type = Type::TYPED_ARRAY_UINT16; - typedArrayType = TypedArrayType::UINT16; - } - else if (isInstanceOfConstructor(__cx, _obj, "Uint32Array")) - { - _type = Type::TYPED_ARRAY_UINT32; - typedArrayType = TypedArrayType::UINT32; - } - else if (isInstanceOfConstructor(__cx, _obj, "Float32Array")) - { - _type = Type::TYPED_ARRAY_FLOAT32; - typedArrayType = TypedArrayType::FLOAT32; - } - else if (isInstanceOfConstructor(__cx, _obj, "Float64Array")) - { - _type = Type::TYPED_ARRAY_FLOAT64; - typedArrayType = TypedArrayType::FLOAT64; + EJJSTypedArrayType ejTypedArrayType = EJJSObjectGetTypedArrayType(__cx, _obj); + + switch (ejTypedArrayType) { + case kEJJSTypedArrayTypeInt8Array: + _type = Type::TYPED_ARRAY_INT8; + typedArrayType = TypedArrayType::INT8; + break; + case kEJJSTypedArrayTypeInt16Array: + _type = Type::TYPED_ARRAY_INT16; + typedArrayType = TypedArrayType::INT16; + break; + case kEJJSTypedArrayTypeInt32Array: + _type = Type::TYPED_ARRAY_INT32; + typedArrayType = TypedArrayType::INT32; + break; + case kEJJSTypedArrayTypeUint8Array: + _type = Type::TYPED_ARRAY_UINT8; + typedArrayType = TypedArrayType::UINT8; + break; + case kEJJSTypedArrayTypeUint8ClampedArray: + _type = Type::TYPED_ARRAY_UINT8_CLAMPED; + typedArrayType = TypedArrayType::UINT8_CLAMPED; + break; + case kEJJSTypedArrayTypeUint16Array: + _type = Type::TYPED_ARRAY_UINT16; + typedArrayType = TypedArrayType::UINT16; + break; + case kEJJSTypedArrayTypeUint32Array: + _type = Type::TYPED_ARRAY_UINT32; + typedArrayType = TypedArrayType::UINT32; + break; + case kEJJSTypedArrayTypeFloat32Array: + _type = Type::TYPED_ARRAY_FLOAT32; + typedArrayType = TypedArrayType::FLOAT32; + break; + case kEJJSTypedArrayTypeFloat64Array: + _type = Type::TYPED_ARRAY_FLOAT64; + typedArrayType = TypedArrayType::FLOAT64; + break; + default: + typedArrayType = TypedArrayType::NONE; + break; } return typedArrayType; @@ -876,53 +833,11 @@ namespace se { return true; } - else #endif - { - Value func; - bool ok = ScriptEngine::getInstance()->getGlobalObject()->getProperty("__jsc_getTypedArrayData", &func); - if (ok && func.isObject() && func.toObject()->isFunction()) - { - ValueArray args; - args.push_back(Value((Object*)this)); - - Value rval; - ok = func.toObject()->call(args, nullptr, &rval); - if (ok && rval.isObject() && rval.toObject()->isArray()) - { - uint32_t len = 0; - Object* arrObj = rval.toObject(); - if (arrObj->getArrayLength(&len)) - { - if (len > 0) - { - Value tmp; - if (_arrayBuffer == nullptr) - { - _arrayBuffer = (uint8_t*)malloc(len); - } - else if (_arrayBufferSize != len) - { - _arrayBuffer = (uint8_t*)realloc(_arrayBuffer, len); - } - - *length = _arrayBufferSize = len; - *ptr = _arrayBuffer; - for (uint32_t i = 0; i < len; ++i) - { - if (arrObj->getArrayElement(i, &tmp) && tmp.isNumber()) - { - _arrayBuffer[i] = tmp.toUint8(); - } - } - return true; - } - } - } - } - } - - return false; + NSMutableData* data = EJJSObjectGetTypedArrayData(__cx, _obj); + *ptr = (uint8_t*)data.mutableBytes; + *length = data.length; + return true; } bool Object::_isNativeFunction() const @@ -1009,52 +924,11 @@ namespace se { return (*ptr != nullptr); } - else #endif - { - Value func; - bool ok = ScriptEngine::getInstance()->getGlobalObject()->getProperty("__jsc_getArrayBufferData", &func); - if (ok && func.isObject() && func.toObject()->isFunction()) - { - ValueArray args; - args.push_back(Value((Object*)this)); - - Value rval; - ok = func.toObject()->call(args, nullptr, &rval); - if (ok && rval.isObject() && rval.toObject()->isArray()) - { - uint32_t len = 0; - Object* arrObj = rval.toObject(); - if (arrObj->getArrayLength(&len)) - { - if (len > 0) - { - Value tmp; - if (_arrayBuffer == nullptr) - { - _arrayBuffer = (uint8_t*)malloc(len); - } - else if (_arrayBufferSize != len) - { - _arrayBuffer = (uint8_t*)realloc(_arrayBuffer, len); - } - - *length = _arrayBufferSize = len; - *ptr = _arrayBuffer; - for (uint32_t i = 0; i < len; ++i) - { - if (arrObj->getArrayElement(i, &tmp) && tmp.isNumber()) - { - _arrayBuffer[i] = tmp.toUint8(); - } - } - return true; - } - } - } - } - } - return false; + NSMutableData* data = EJJSObjectGetTypedArrayData(__cx, _obj); + *ptr = (uint8_t*)data.mutableBytes; + *length = data.length; + return true; } void* Object::getPrivateData() const diff --git a/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp b/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.mm similarity index 99% rename from native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp rename to native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.mm index 4bc892d182..0491d579e6 100644 --- a/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.cpp +++ b/native/cocos/scripting/js-bindings/jswrapper/jsc/ScriptEngine.mm @@ -31,6 +31,9 @@ #include "Utils.hpp" #include "../State.hpp" #include "../MappingUtils.hpp" +#include "PlatformUtils.h" + +#import "EJConvertTypedArray.h" #if SE_DEBUG > 0 extern "C" JS_EXPORT void JSSynchronousGarbageCollectForDebugging(JSContextRef); @@ -255,6 +258,9 @@ namespace se { _globalObj->root(); _globalObj->setProperty("window", Value(_globalObj)); + if (!isSupportTypedArrayAPI()) + EJJSContextPrepareTypedArrayAPI(_cx); + if (_globalObj->getProperty("console", &__consoleVal) && __consoleVal.isObject()) { __consoleVal.toObject()->getProperty("log", &__oldConsoleLog); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp index 1304e16519..79d51ba889 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp @@ -719,119 +719,6 @@ static bool js_gfx_IndexBuffer_prop_getBytes(se::State& s) } SE_BIND_PROP_GET(js_gfx_IndexBuffer_prop_getBytes) -static bool js_gfx_getImageInfo(se::State& s) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 1) { - std::string arg0; - ok &= seval_to_std_string(args[0], &arg0); - SE_PRECONDITION2(ok, false, "js_gfx_getImageInfo : Error processing arguments"); - - se::HandleObject retObj(se::Object::createPlainObject()); - - Data data; - Image* img = new (std::nothrow) Image(); - if (img->initWithImageFile(arg0)) - { - data.copy(img->getData(), img->getDataLen()); - // Convert to RGBA8888 because Web engine only supports it. - //FIX ME: How to handle other formats? - if (Image::PixelFormat::RGB888 == img->getRenderFormat()) - { - unsigned char convertedData[img->getWidth() * img->getHeight() * 4]; - auto dataT = data.getBytes(); - for (size_t i = 0, len = data.getSize() / 3; i < len; ++i) - { - convertedData[i * 4] = *dataT++; - convertedData[i * 4 + 1] = *dataT++; - convertedData[i * 4 + 2] = *dataT++; - convertedData[i * 4 + 3] = 255; - } - data.copy(convertedData, sizeof(convertedData)); - } - - se::Value dataVal; - ok &= Data_to_seval(data, &dataVal); - SE_PRECONDITION2(ok, false, "js_gfx_getImageInfo : Error processing arguments"); - retObj->setProperty("data", dataVal); - retObj->setProperty("width", se::Value(img->getWidth())); - retObj->setProperty("height", se::Value(img->getHeight())); - retObj->setProperty("premultiplyAlpha", se::Value(img->hasPremultipliedAlpha())); - retObj->setProperty("bpp", se::Value(32)); - retObj->setProperty("hasAlpha", se::Value(img->hasAlpha())); - retObj->setProperty("compressed", se::Value(img->isCompressed())); - retObj->setProperty("numberOfMipmaps", se::Value(img->getNumberOfMipmaps())); - - const auto& pixelFormatInfo = img->getPixelFormatInfo(); - retObj->setProperty("glFormat", se::Value(GL_RGBA)); - retObj->setProperty("glInternalFormat", se::Value(GL_RGBA)); - retObj->setProperty("glType", se::Value(pixelFormatInfo.type)); - } - else - { - SE_REPORT_ERROR("initWithImageFile: %s failed!", arg0.c_str()); - assert(false); - } - - img->release(); - - s.rval().setObject(retObj); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); - return false; -} -SE_BIND_FUNC(js_gfx_getImageInfo) - -static bool js_gfx_getTextTextureInfo(se::State& s) -{ - const auto& args = s.args(); - size_t argc = args.size(); - CC_UNUSED bool ok = true; - if (argc == 3) { - - /* - const char * text, - const FontDefinition& textDefinition, - TextAlign align, - int &width, - int &height, - bool& hasPremultipliedAlpha - */ - - std::string text; - ok = seval_to_std_string(args[0], &text); - SE_PRECONDITION2(ok, false, "Convert arg0 text failed!"); - FontDefinition fontDef; - ok = seval_to_FontDefinition(args[1], &fontDef); - SE_PRECONDITION2(ok, false, "Convert arg1 fontDef failed!"); - int32_t align; - ok = seval_to_int32(args[2], &align); - Device::TextAlign textAlign = (Device::TextAlign)align; - int width = 0; - int height = 0; - bool hasPremultipliedAlpha = false; - Data data = Device::getTextureDataForText(text.c_str(), fontDef, textAlign, width, height, hasPremultipliedAlpha); - - se::HandleObject retObj(se::Object::createPlainObject()); - se::Value dataVal; - if (Data_to_seval(data, &dataVal)) - retObj->setProperty("data", dataVal); - - retObj->setProperty("width", se::Value(width)); - retObj->setProperty("height", se::Value(height)); - retObj->setProperty("hasPremultipliedAlpha", se::Value(hasPremultipliedAlpha)); - - s.rval().setObject(retObj); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); - return false; -} -SE_BIND_FUNC(js_gfx_getTextTextureInfo) - static bool js_gfx_FrameBuffer_init(se::State& s) { cocos2d::renderer::FrameBuffer* cobj = (cocos2d::renderer::FrameBuffer*)s.nativeThisObject(); @@ -929,9 +816,6 @@ bool jsb_register_gfx_manual(se::Object* global) __jsb_cocos2d_renderer_Texture2D_proto->defineFunction("init", _SE(js_gfx_Texture2D_init)); __jsb_cocos2d_renderer_FrameBuffer_proto->defineFunction("init", _SE(js_gfx_FrameBuffer_init)); - global->defineFunction("getImageInfo", _SE(js_gfx_getImageInfo)); - global->defineFunction("getTextTextureInfo", _SE(js_gfx_getTextTextureInfo)); - se::ScriptEngine::getInstance()->clearException(); return true; } diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp index 68a350bce6..c3b5ee73f5 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp @@ -6,15 +6,22 @@ #include "jsb_conversions.hpp" #include "xxtea/xxtea.h" +#include "base/CCScheduler.h" +#include "base/CCThreadPool.h" +#include "platform/CCApplication.h" + #include using namespace cocos2d; +using namespace cocos2d::experimental; se::Object* __jscObj = nullptr; se::Object* __ccObj = nullptr; se::Object* __jsbObj = nullptr; se::Object* __glObj = nullptr; +static ThreadPool* __threadPool = nullptr; + static std::string xxteaKey = ""; void jsb_set_xxtea_key(const std::string& key) { @@ -197,16 +204,16 @@ namespace { std::unordered_map __moduleCache; -// static bool require(se::State& s) -// { -// const auto& args = s.args(); -// int argc = (int)args.size(); -// assert(argc >= 1); -// assert(args[0].isString()); -// -// return jsb_run_script(args[0].toString(), &s.rval()); -// } -// SE_BIND_FUNC(require) + static bool require(se::State& s) + { + const auto& args = s.args(); + int argc = (int)args.size(); + assert(argc >= 1); + assert(args[0].isString()); + + return jsb_run_script(args[0].toString(), &s.rval()); + } + SE_BIND_FUNC(require) static bool doModuleRequire(const std::string& path, se::Value* ret, const std::string& prevScriptFileDir) { @@ -269,7 +276,7 @@ namespace { snprintf(suffix, sizeof(suffix), "\nwindow.module.exports = window.module.exports || exports;\n})('%s'); ", currentScriptFileDir.c_str()); // Add current script path to require function invocation - scriptBuffer = prefix + std::regex_replace(scriptBuffer, std::regex("([^A-Za-z0-9]|^)require\\((.*?)\\)"), "$1require($2, currentScriptDir)") + suffix; + scriptBuffer = prefix + std::regex_replace(scriptBuffer, std::regex("([^A-Za-z0-9]|^)requireModule\\((.*?)\\)"), "$1requireModule($2, currentScriptDir)") + suffix; // FILE* fp = fopen("/Users/james/Downloads/test.txt", "wb"); // fwrite(scriptBuffer.c_str(), scriptBuffer.length(), 1, fp); @@ -296,7 +303,7 @@ namespace { auto se = se::ScriptEngine::getInstance(); bool succeed = se->evalString(scriptBuffer.c_str(), scriptBuffer.length(), nullptr, reletivePath.c_str()); se::Value moduleVal; - if (se->getGlobalObject()->getProperty("module", &moduleVal) && moduleVal.isObject()) + if (succeed && se->getGlobalObject()->getProperty("module", &moduleVal) && moduleVal.isObject()) { se::Value exportsVal; if (moduleVal.toObject()->getProperty("exports", &exportsVal)) @@ -337,412 +344,15 @@ namespace { return doModuleRequire(args[0].toString(), &s.rval(), args[1].toString()); } SE_BIND_FUNC(moduleRequire) - - static bool ccpAdd(se::State& s) - { - if (s.args().size() == 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt1 + pt2; - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpAdd) - - static bool ccpDistanceSQ(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - float result = pt1.getDistanceSq(pt2); - s.rval().setFloat(result); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpDistanceSQ) - - static bool ccpDistance(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - float result = pt1.getDistance(pt2); - s.rval().setFloat(result); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpDistance) - - static bool ccpSub(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt1 - pt2; - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpSub) - - static bool ccpNeg(se::State& s) - { - if (s.args().size()== 1) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - pt = -pt; - ok = Vec2_to_seval(pt, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccpNeg) - - static bool ccpMult(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - SE_ASSERT(args[1].isNumber(), "Error processing arguments"); - Vec2 result = pt * args[1].toFloat(); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpMult) - - static bool ccpMidpoint(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt1.getMidpoint(pt2); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpMidpoint) - - static bool ccpDot(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - float result = pt1.dot(pt2); - s.rval().setFloat(result); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpDot) - - static bool ccpCross(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - float result = pt1.cross(pt2); - s.rval().setFloat(result); - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpCross) - - static bool ccpPerp(se::State& s) - { - if (s.args().size()== 1) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt.getPerp(); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccpPerp) - - static bool ccpRPerp(se::State& s) - { - if (s.args().size()== 1) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt.getRPerp(); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccpRPerp) - - static bool ccpProject(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt1.project(pt2); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpProject) - - static bool ccpRotate(se::State& s) - { - if (s.args().size()== 2) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt1.rotate(pt2); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 2); - return false; - } - SE_BIND_FUNC(ccpRotate) - - static bool ccpNormalize(se::State& s) - { - if (s.args().size()== 1) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - pt.normalize(); - ok = Vec2_to_seval(pt, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccpNormalize) - - static bool ccpClamp(se::State& s) - { - if (s.args().size()== 3) - { - const se::ValueArray& args = s.args(); - Vec2 pt1, pt2, pt3; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt1); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt2); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - ok = seval_to_Vec2(args[1], &pt3); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - Vec2 result = pt1.getClampPoint(pt2, pt3); - ok = Vec2_to_seval(result, &s.rval()); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 3); - return false; - } - SE_BIND_FUNC(ccpClamp) - - static bool ccpLengthSQ(se::State& s) - { - if (s.args().size()== 1) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - float result = pt.getLengthSq(); - s.rval().setFloat(result); - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccpLengthSQ) - - static bool ccpLength(se::State& s) - { - if (s.args().size()== 1) - { - const se::ValueArray& args = s.args(); - Vec2 pt; - bool ok = false; - ok = seval_to_Vec2(args[0], &pt); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - float result = pt.getLength(); - s.rval().setFloat(result); - return true; - } - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccpLength) - - static bool ccassert(se::State& s) - { - const se::ValueArray& args = s.args(); - size_t argc = args.size(); - if (argc >= 1) - { - if (argc == 1) - { - SE_ASSERT(args[0].toBoolean(), "NO MESSAGE"); - } - else - { - SE_ASSERT(args[0].toBoolean(), "%s", args[1].toString().c_str()); - } - return true; - } - - SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)s.args().size(), 1); - return false; - } - SE_BIND_FUNC(ccassert) - - bool jsb_register_var_under_cc() - { - // Vec2 Math - __ccObj->defineFunction("pAdd", _SE(ccpAdd)); - __ccObj->defineFunction("pDistanceSQ", _SE(ccpDistanceSQ)); - __ccObj->defineFunction("pDistance", _SE(ccpDistance)); - __ccObj->defineFunction("pSub", _SE(ccpSub)); - __ccObj->defineFunction("pNeg", _SE(ccpNeg)); - __ccObj->defineFunction("pMult", _SE(ccpMult)); - __ccObj->defineFunction("pMidpoint", _SE(ccpMidpoint)); - __ccObj->defineFunction("pDot", _SE(ccpDot)); - __ccObj->defineFunction("pCross", _SE(ccpCross)); - __ccObj->defineFunction("pPerp", _SE(ccpPerp)); - __ccObj->defineFunction("pRPerp", _SE(ccpRPerp)); - __ccObj->defineFunction("pProject", _SE(ccpProject)); - __ccObj->defineFunction("pRotate", _SE(ccpRotate)); - __ccObj->defineFunction("pNormalize", _SE(ccpNormalize)); - __ccObj->defineFunction("pClamp", _SE(ccpClamp)); - __ccObj->defineFunction("pLengthSQ", _SE(ccpLengthSQ)); - __ccObj->defineFunction("pLength", _SE(ccpLength)); - - // - __ccObj->defineFunction("assert", _SE(ccassert)); - - return true; - } -} +} // namespace { bool jsb_run_script(const std::string& filePath, se::Value* rval/* = nullptr */) +{ + se::AutoHandleScope hs; + return se::ScriptEngine::getInstance()->runScript(filePath, rval); +} + +bool jsb_run_script_module(const std::string& filePath, se::Value* rval/* = nullptr */) { return doModuleRequire(filePath, rval, ""); } @@ -951,14 +561,174 @@ static bool js_performance_now(se::State& s) } SE_BIND_FUNC(js_performance_now) +static bool js_loadImage(se::State& s) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 2) { + std::string path; + ok &= seval_to_std_string(args[0], &path); + SE_PRECONDITION2(ok, false, "js_loadImage : Error processing arguments"); + + se::Value callbackVal = args[1]; + assert(callbackVal.isObject()); + assert(callbackVal.toObject()->isFunction()); + + std::string fullPath = FileUtils::getInstance()->fullPathForFilename(path); + if (fullPath.empty()) + { + SE_REPORT_ERROR("File (%s) doesn't exist!", path.c_str()); + return false; + } + + Image* img = new (std::nothrow) Image(); + + __threadPool->pushTask([=](int tid){ + // NOTE: FileUtils::getInstance()->fullPathForFilename isn't a threadsafe method, + // Image::initWithImageFile will call fullPathForFilename internally which may + // cause thread race issues. Therefore, we get the full path of file before + // going into task callback. + // Be careful of invoking any Cocos2d-x interface in a sub-thread. + bool loadSucceed = img->initWithImageFile(fullPath); + + Application::getInstance()->getScheduler()->performFunctionInCocosThread([=](){ + if (loadSucceed) + { + se::AutoHandleScope hs; + se::HandleObject retObj(se::Object::createPlainObject()); + Data data; + data.copy(img->getData(), img->getDataLen()); + +#ifdef CC_NEW_RENDERER + // Convert to RGBA8888 because Web engine only supports it. + //FIX ME: How to handle other formats? + if (Image::PixelFormat::RGB888 == img->getRenderFormat()) + { + unsigned char convertedData[img->getWidth() * img->getHeight() * 4]; + auto dataT = data.getBytes(); + for (size_t i = 0, len = data.getSize() / 3; i < len; ++i) + { + convertedData[i * 4] = *dataT++; + convertedData[i * 4 + 1] = *dataT++; + convertedData[i * 4 + 2] = *dataT++; + convertedData[i * 4 + 3] = 255; + } + data.copy(convertedData, sizeof(convertedData)); + } + + se::Value dataVal; + Data_to_seval(data, &dataVal); + SE_PRECONDITION2(ok, false, "js_gfx_getImageInfo : Error processing arguments"); + retObj->setProperty("data", dataVal); + retObj->setProperty("width", se::Value(img->getWidth())); + retObj->setProperty("height", se::Value(img->getHeight())); + retObj->setProperty("premultiplyAlpha", se::Value(img->hasPremultipliedAlpha())); + retObj->setProperty("bpp", se::Value(32)); + retObj->setProperty("hasAlpha", se::Value(img->hasAlpha())); + retObj->setProperty("compressed", se::Value(img->isCompressed())); + retObj->setProperty("numberOfMipmaps", se::Value(img->getNumberOfMipmaps())); + + const auto& pixelFormatInfo = img->getPixelFormatInfo(); + retObj->setProperty("glFormat", se::Value(GL_RGBA)); + retObj->setProperty("glInternalFormat", se::Value(GL_RGBA)); + retObj->setProperty("glType", se::Value(pixelFormatInfo.type)); +#else + se::Value dataVal; + Data_to_seval(data, &dataVal); + retObj->setProperty("data", dataVal); + retObj->setProperty("width", se::Value(img->getWidth())); + retObj->setProperty("height", se::Value(img->getHeight())); + retObj->setProperty("premultiplyAlpha", se::Value(img->hasPremultipliedAlpha())); + retObj->setProperty("bpp", se::Value(img->getBitPerPixel())); + retObj->setProperty("hasAlpha", se::Value(img->hasAlpha())); + retObj->setProperty("compressed", se::Value(img->isCompressed())); + retObj->setProperty("numberOfMipmaps", se::Value(img->getNumberOfMipmaps())); + + const auto& pixelFormatInfo = img->getPixelFormatInfo(); + retObj->setProperty("glFormat", se::Value(pixelFormatInfo.format)); + retObj->setProperty("glInternalFormat", se::Value(pixelFormatInfo.internalFormat)); + retObj->setProperty("glType", se::Value(pixelFormatInfo.type)); +#endif + + se::ValueArray seArgs; + seArgs.push_back(se::Value(retObj)); + callbackVal.toObject()->call(seArgs, nullptr); + } + else + { + SE_REPORT_ERROR("initWithImageFile: %s failed!", path.c_str()); + assert(false); + } + + img->release(); + }); + + }); + + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); + return false; +} +SE_BIND_FUNC(js_loadImage) + +static bool js_getTextTextureInfo(se::State& s) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc == 3) { + + /* + const char * text, + const FontDefinition& textDefinition, + TextAlign align, + int &width, + int &height, + bool& hasPremultipliedAlpha + */ + + std::string text; + ok = seval_to_std_string(args[0], &text); + SE_PRECONDITION2(ok, false, "Convert arg0 text failed!"); + FontDefinition fontDef; + ok = seval_to_FontDefinition(args[1], &fontDef); + SE_PRECONDITION2(ok, false, "Convert arg1 fontDef failed!"); + int32_t align; + ok = seval_to_int32(args[2], &align); + Device::TextAlign textAlign = (Device::TextAlign)align; + int width = 0; + int height = 0; + bool hasPremultipliedAlpha = false; + Data data = Device::getTextureDataForText(text.c_str(), fontDef, textAlign, width, height, hasPremultipliedAlpha); + + se::HandleObject retObj(se::Object::createPlainObject()); + se::Value dataVal; + if (Data_to_seval(data, &dataVal)) + retObj->setProperty("data", dataVal); + + retObj->setProperty("width", se::Value(width)); + retObj->setProperty("height", se::Value(height)); + retObj->setProperty("hasPremultipliedAlpha", se::Value(hasPremultipliedAlpha)); + + s.rval().setObject(retObj); + return true; + } + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 3); + return false; +} +SE_BIND_FUNC(js_getTextTextureInfo) + bool jsb_register_global_variables(se::Object* global) { - global->defineFunction("require", _SE(moduleRequire)); + __threadPool = ThreadPool::newFixedThreadPool(3); + + global->defineFunction("require", _SE(require)); + global->defineFunction("requireModule", _SE(moduleRequire)); getOrCreatePlainObject_r("cc", global, &__ccObj); - jsb_register_var_under_cc(); - getOrCreatePlainObject_r("jsb", global, &__jsbObj); getOrCreatePlainObject_r("__jsc__", global, &__jscObj); getOrCreatePlainObject_r("gl", global, &__glObj); @@ -966,6 +736,8 @@ bool jsb_register_global_variables(se::Object* global) __jscObj->defineFunction("garbageCollect", _SE(jsc_garbageCollect)); __jscObj->defineFunction("dumpNativePtrToSeObjectMap", _SE(jsc_dumpNativePtrToSeObjectMap)); + __jsbObj->defineFunction("loadImage", _SE(js_loadImage)); + global->defineFunction("__getPlatform", _SE(JSBCore_platform)); global->defineFunction("__getOS", _SE(JSBCore_os)); global->defineFunction("__getVersion", _SE(JSBCore_version)); @@ -980,8 +752,17 @@ bool jsb_register_global_variables(se::Object* global) se::ScriptEngine::getInstance()->clearException(); + se::ScriptEngine::getInstance()->addBeforeCleanupHook([](){ + delete __threadPool; + __threadPool = nullptr; + + PoolManager::getInstance()->getCurrentPool()->clear(); + }); + se::ScriptEngine::getInstance()->addAfterCleanupHook([](){ + PoolManager::getInstance()->getCurrentPool()->clear(); + __moduleCache.clear(); __ccObj->decRef(); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.h b/native/cocos/scripting/js-bindings/manual/jsb_global.h index e6d01cafac..0d022cc1fa 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.h +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.h @@ -18,5 +18,6 @@ void jsb_init_file_operation_delegate(); bool jsb_enable_debugger(const std::string& debuggerServerAddr, uint32_t port); bool jsb_set_extend_property(const char* ns, const char* clsName); bool jsb_run_script(const std::string& filePath, se::Value* rval = nullptr); +bool jsb_run_script_module(const std::string& filePath, se::Value* rval = nullptr); void jsb_set_xxtea_key(const std::string& key); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_functions.cpp b/native/cocos/scripting/js-bindings/manual/jsb_opengl_functions.cpp deleted file mode 100644 index ed1ce6d782..0000000000 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_functions.cpp +++ /dev/null @@ -1,2322 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "jsb_opengl_functions.hpp" -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" -#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" -#include "cocos/scripting/js-bindings/manual/jsb_global.h" -#include "cocos/scripting/js-bindings/manual/jsb_opengl_utils.hpp" - -namespace { - -template -class GLData -{ -public: - GLData() - : _data(nullptr) - , _count(0) - , _isOwnData(false) - { - } - - ~GLData() - { - if (_isOwnData) - { - free(_data); - } - } - - void setData(T* data, size_t count, bool isOwnData) - { - _data = data; - _count = count; - _isOwnData = isOwnData; - } - - T* data() const { return _data; } - size_t count() const { return _count; } - -private: - - // Disable copy/move constructor, copy/move assigment - GLData(const GLData&); - GLData(GLData&&); - GLData& operator=(const GLData&); - GLData& operator=(GLData&&); - - T* _data; - size_t _count; - bool _isOwnData; -}; - -} - -template -static bool JSB_jsval_typedarray_to_data(const se::Value& v, GLData& data) -{ - if (v.isObject()) - { - se::Object* obj = v.toObject(); - if (obj->isArray()) - { - uint32_t length = 0; - if (obj->getArrayLength(&length) && length > 0) - { - T* d = (T*)malloc(length * sizeof(T)); - se::Value tmp; - for (uint32_t i = 0; i < length; ++i) - { - if (obj->getArrayElement(i, &tmp)) - { - if (std::is_same::value) - { - d[i] = tmp.toInt32(); - } - else if (std::is_same::value) - { - d[i] = tmp.toFloat(); - } - } - } - data.setData(d, length, true); - return true; - } - SE_LOGE("Failed to get array data"); - } - else if (obj->isTypedArray()) - { - size_t bytes = 0; - uint8_t* ptr = nullptr; - - if (obj->getTypedArrayData(&ptr, &bytes) && bytes > 0) - { - data.setData((T*)ptr, bytes / sizeof(T), false); - return true; - } - - SE_LOGE("Failed to get typed array data"); - } - } - - return false; -} - -bool JSB_get_arraybufferview_dataptr(const se::Value& v, GLsizei *count, GLvoid **data) -{ - assert(count != nullptr && data != nullptr); - - if (v.isObject()) - { - uint8_t* ptr = nullptr; - size_t length = 0; - se::Object* obj = v.toObject(); - if (obj->isTypedArray()) - { - if (obj->getTypedArrayData(&ptr, &length) && ptr != nullptr && length > 0) - { - *data = ptr; - *count = (GLsizei)length; - return true; - } - } - else if (obj->isArrayBuffer()) - { - if (obj->getArrayBufferData(&ptr, &length) && ptr != nullptr && length > 0) - { - *data = ptr; - *count = (GLsizei)length; - return true; - } - } - else - { - SE_LOGE("JSB_get_arraybufferview_dataptr: isn't a typed array!\n"); - } - } - else if (v.isNullOrUndefined()) - { - *count = 0; - *data = nullptr; - return true; - } - else - { - assert(false); - } - return false; -} - -// Arguments: GLenum -// Ret value: void -bool JSB_glActiveTexture(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glActiveTexture((GLenum)arg0)); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glActiveTexture) - -// Arguments: GLuint, GLuint -// Ret value: void -bool JSB_glAttachShader(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glAttachShader((GLuint)arg0 , (GLuint)arg1 )); - - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glAttachShader) - -// Arguments: GLuint, GLuint, char* -// Ret value: void -bool JSB_glBindAttribLocation(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; std::string arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_std_string(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBindAttribLocation((GLuint)arg0 , (GLuint)arg1 , arg2.c_str() )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBindAttribLocation) - -// Arguments: GLenum, GLuint -// Ret value: void -bool JSB_glBindBuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBindBuffer((GLenum)arg0 , (GLuint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBindBuffer) - -// Arguments: GLenum, GLuint -// Ret value: void -bool JSB_glBindFramebuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBindFramebuffer((GLenum)arg0 , (GLuint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBindFramebuffer) - -// Arguments: GLenum, GLuint -// Ret value: void -bool JSB_glBindRenderbuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBindRenderbuffer((GLenum)arg0 , (GLuint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBindRenderbuffer) - -// Arguments: GLenum, GLuint -// Ret value: void -bool JSB_glBindTexture(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBindTexture((GLenum)arg0 , (GLuint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBindTexture) - -// Arguments: GLclampf, GLclampf, GLclampf, GLclampf -// Ret value: void -bool JSB_glBlendColor(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBlendColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBlendColor) - -// Arguments: GLenum -// Ret value: void -bool JSB_glBlendEquation(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBlendEquation((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBlendEquation) - -// Arguments: GLenum, GLenum -// Ret value: void -bool JSB_glBlendEquationSeparate(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBlendEquationSeparate((GLenum)arg0 , (GLenum)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBlendEquationSeparate) - -// Arguments: GLenum, GLenum -// Ret value: void -bool JSB_glBlendFunc(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBlendFunc((GLenum)arg0 , (GLenum)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBlendFunc) - -// Arguments: GLenum, GLenum, GLenum, GLenum -// Ret value: void -bool JSB_glBlendFuncSeparate(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_uint32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBlendFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBlendFuncSeparate) - -// Arguments: GLenum, ArrayBufferView, GLenum -// Ret value: void -bool JSB_glBufferData(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0 = 0; - void* arg1 = nullptr; - uint32_t arg2 = 0; - GLsizei count = 0; - ok &= seval_to_uint32(args[0], &arg0 ); - if (args[1].isNumber()) - { - count = args[1].toUint32(); - } - else - { - ok &= JSB_get_arraybufferview_dataptr(args[1], &count, &arg1); - } - ok &= seval_to_uint32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBufferData((GLenum)arg0 , count, (GLvoid*)arg1 , (GLenum)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBufferData) - -// Arguments: GLenum, GLintptr, ArrayBufferView -// Ret value: void -bool JSB_glBufferSubData(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0 = 0; - int32_t arg1 = 0; - void* arg2 = nullptr; - GLsizei count = 0; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - if (args[2].isNumber()) - { - count = args[2].toUint32(); - } - else - { - ok &= JSB_get_arraybufferview_dataptr(args[2], &count, &arg2); - } - - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glBufferSubData((GLenum)arg0 , (GLintptr)arg1 , count, (GLvoid*)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glBufferSubData) - -// Arguments: GLenum -// Ret value: GLenum -bool JSB_glCheckFramebufferStatus(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLenum ret_val; - - ret_val = glCheckFramebufferStatus((GLenum)arg0); - s.rval().setUint32((uint32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glCheckFramebufferStatus) - -// Arguments: GLbitfield -// Ret value: void -bool JSB_glClear(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glClear((GLbitfield)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glClear) - -// Arguments: GLclampf, GLclampf, GLclampf, GLclampf -// Ret value: void -bool JSB_glClearColor(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glClearColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glClearColor) - -// Arguments: GLclampf -// Ret value: void -bool JSB_glClearDepthf(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glClearDepthf((GLclampf)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glClearDepthf) - -// Arguments: GLint -// Ret value: void -bool JSB_glClearStencil(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glClearStencil((GLint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glClearStencil) - -// Arguments: GLboolean, GLboolean, GLboolean, GLboolean -// Ret value: void -bool JSB_glColorMask(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint16_t arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; - - ok &= seval_to_uint16(args[0], &arg0 ); - ok &= seval_to_uint16(args[1], &arg1 ); - ok &= seval_to_uint16(args[2], &arg2 ); - ok &= seval_to_uint16(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glColorMask((GLboolean)arg0 , (GLboolean)arg1 , (GLboolean)arg2 , (GLboolean)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glColorMask) - -// Arguments: GLuint -// Ret value: void -bool JSB_glCompileShader(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glCompileShader((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glCompileShader) - -// Arguments: GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, ArrayBufferView -// Ret value: void -bool JSB_glCompressedTexImage2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 8, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; void* arg7; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - ok &= seval_to_int32(args[6], &arg6 ); - GLsizei count; - ok &= JSB_get_arraybufferview_dataptr(args[7], &count, &arg7); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glCompressedTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLvoid*)arg7 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glCompressedTexImage2D) - -// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, ArrayBufferView -// Ret value: void -bool JSB_glCompressedTexSubImage2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 9, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; int32_t arg7; void* arg8; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - ok &= seval_to_uint32(args[6], &arg6 ); - ok &= seval_to_int32(args[7], &arg7 ); - GLsizei count; - ok &= JSB_get_arraybufferview_dataptr(args[8], &count, &arg8); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glCompressedTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLsizei)arg7 , (GLvoid*)arg8 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glCompressedTexSubImage2D) - -// Arguments: GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint -// Ret value: void -bool JSB_glCopyTexImage2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 8, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - ok &= seval_to_int32(args[6], &arg6 ); - ok &= seval_to_int32(args[7], &arg7 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glCopyTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLint)arg3 , (GLint)arg4 , (GLsizei)arg5 , (GLsizei)arg6 , (GLint)arg7 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glCopyTexImage2D) - -// Arguments: GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei -// Ret value: void -bool JSB_glCopyTexSubImage2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 8, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - ok &= seval_to_int32(args[6], &arg6 ); - ok &= seval_to_int32(args[7], &arg7 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glCopyTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLsizei)arg7 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glCopyTexSubImage2D) - -// Arguments: -// Ret value: GLuint -bool JSB_glCreateProgram(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); - GLuint ret_val; - - ret_val = glCreateProgram(); - s.rval().setUint32((uint32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glCreateProgram) - -// Arguments: GLenum -// Ret value: GLuint -bool JSB_glCreateShader(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLuint ret_val; - - ret_val = glCreateShader((GLenum)arg0); - s.rval().setUint32((uint32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glCreateShader) - -// Arguments: GLenum -// Ret value: void -bool JSB_glCullFace(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glCullFace((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glCullFace) - -// Arguments: GLuint -// Ret value: void -bool JSB_glDeleteProgram(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDeleteProgram((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDeleteProgram) - -// Arguments: GLuint -// Ret value: void -bool JSB_glDeleteShader(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDeleteShader((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDeleteShader) - -// Arguments: GLenum -// Ret value: void -bool JSB_glDepthFunc(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDepthFunc((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDepthFunc) - -// Arguments: GLboolean -// Ret value: void -bool JSB_glDepthMask(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint16_t arg0; - - ok &= seval_to_uint16(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDepthMask((GLboolean)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDepthMask) - -// Arguments: GLclampf, GLclampf -// Ret value: void -bool JSB_glDepthRangef(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDepthRangef((GLclampf)arg0 , (GLclampf)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDepthRangef) - -// Arguments: GLuint, GLuint -// Ret value: void -bool JSB_glDetachShader(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDetachShader((GLuint)arg0 , (GLuint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDetachShader) - -// Arguments: GLenum -// Ret value: void -bool JSB_glDisable(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDisable((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDisable) - -// Arguments: GLuint -// Ret value: void -bool JSB_glDisableVertexAttribArray(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDisableVertexAttribArray((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDisableVertexAttribArray) - -// Arguments: GLenum, GLint, GLsizei -// Ret value: void -bool JSB_glDrawArrays(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glDrawArrays((GLenum)arg0 , (GLint)arg1 , (GLsizei)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDrawArrays) - -// Arguments: GLenum, GLsizei, GLenum, ArrayBufferView -// Ret value: void -bool JSB_glDrawElements(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; uint32_t arg2; void* arg3 = nullptr; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - - const se::Value& offsetVal = args[3]; - - if (offsetVal.isNumber()) - { - int offset = 0; - ok &= seval_to_int32(offsetVal, &offset); - arg3 = (void*)(intptr_t)offset; - } - else if (offsetVal.isObject()) - { - GLsizei count; - ok &= JSB_get_arraybufferview_dataptr(args[3], &count, &arg3); - } - - SE_PRECONDITION2(ok, false, "Error processing arguments"); - JSB_GL_CHECK(glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glDrawElements) - -// Arguments: GLenum -// Ret value: void -bool JSB_glEnable(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glEnable((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glEnable) - -// Arguments: GLuint -// Ret value: void -bool JSB_glEnableVertexAttribArray(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glEnableVertexAttribArray((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glEnableVertexAttribArray) - -// Arguments: -// Ret value: void -bool JSB_glFinish(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); - JSB_GL_CHECK(glFinish( )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glFinish) - -// Arguments: -// Ret value: void -bool JSB_glFlush(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); - JSB_GL_CHECK(glFlush( )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glFlush) - -// Arguments: GLenum, GLenum, GLenum, GLuint -// Ret value: void -bool JSB_glFramebufferRenderbuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_uint32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glFramebufferRenderbuffer((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glFramebufferRenderbuffer) - -// Arguments: GLenum, GLenum, GLenum, GLuint, GLint -// Ret value: void -bool JSB_glFramebufferTexture2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; int32_t arg4; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_uint32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glFramebufferTexture2D((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 , (GLint)arg4 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glFramebufferTexture2D) - -// Arguments: GLenum -// Ret value: void -bool JSB_glFrontFace(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glFrontFace((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glFrontFace) - -// Arguments: GLenum -// Ret value: void -bool JSB_glGenerateMipmap(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glGenerateMipmap((GLenum)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glGenerateMipmap) - -// Arguments: GLuint, char* -// Ret value: int -bool JSB_glGetAttribLocation(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; std::string arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_std_string(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - int ret_val = glGetAttribLocation((GLuint)arg0 , arg1.c_str()); - JSB_GL_CHECK_ERROR(); - s.rval().setInt32(ret_val); - return true; -} -SE_BIND_FUNC(JSB_glGetAttribLocation) - -// Arguments: -// Ret value: GLenum -bool JSB_glGetError(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); - GLenum ret_val; - - ret_val = glGetError(); - s.rval().setUint32((uint32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glGetError) - -// Arguments: GLuint, char* -// Ret value: int -bool JSB_glGetUniformLocation(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; std::string arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_std_string(args[1], &arg1 ); - - SE_PRECONDITION2(ok, false, "Error processing arguments"); - int ret_val; - - ret_val = glGetUniformLocation((GLuint)arg0 , arg1.c_str()); - JSB_GL_CHECK_ERROR(); - s.rval().setInt32(ret_val); - return true; -} -SE_BIND_FUNC(JSB_glGetUniformLocation) - -// Arguments: GLenum, GLenum -// Ret value: void -bool JSB_glHint(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glHint((GLenum)arg0 , (GLenum)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glHint) - -// Arguments: GLuint -// Ret value: GLboolean -bool JSB_glIsBuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsBuffer((GLuint)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsBuffer) - -// Arguments: GLenum -// Ret value: GLboolean -bool JSB_glIsEnabled(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsEnabled((GLenum)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsEnabled) - -// Arguments: GLuint -// Ret value: GLboolean -bool JSB_glIsFramebuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsFramebuffer((GLuint)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsFramebuffer) - -// Arguments: GLuint -// Ret value: GLboolean -bool JSB_glIsProgram(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsProgram((GLuint)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsProgram) - -// Arguments: GLuint -// Ret value: GLboolean -bool JSB_glIsRenderbuffer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsRenderbuffer((GLuint)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsRenderbuffer) - -// Arguments: GLuint -// Ret value: GLboolean -bool JSB_glIsShader(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsShader((GLuint)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsShader) - -// Arguments: GLuint -// Ret value: GLboolean -bool JSB_glIsTexture(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - GLboolean ret_val; - - ret_val = glIsTexture((GLuint)arg0); - s.rval().setInt32((int32_t)ret_val); - return true; -} -SE_BIND_FUNC(JSB_glIsTexture) - -// Arguments: GLfloat -// Ret value: void -bool JSB_glLineWidth(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glLineWidth((GLfloat)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glLineWidth) - -// Arguments: GLuint -// Ret value: void -bool JSB_glLinkProgram(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glLinkProgram((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glLinkProgram) - -// Arguments: GLenum, GLint -// Ret value: void -bool JSB_glPixelStorei(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - if (arg0 == GL_UNPACK_FLIP_Y_WEBGL) - { - SE_LOGE("cjh FIXME: support GL_UNPACK_FLIP_Y_WEBGL\n"); - return true; - } - - if (arg0 == GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL) - { - SE_LOGE("cjh FIXME: support GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL\n"); - return true; - } - - JSB_GL_CHECK(glPixelStorei((GLenum)arg0 , (GLint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glPixelStorei) - -// Arguments: GLfloat, GLfloat -// Ret value: void -bool JSB_glPolygonOffset(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glPolygonOffset) - -// Arguments: GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView -// Ret value: void -bool JSB_glReadPixels(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 7, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; uint32_t arg4; uint32_t arg5; void* arg6; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_uint32(args[4], &arg4 ); - ok &= seval_to_uint32(args[5], &arg5 ); - GLsizei count; - ok &= JSB_get_arraybufferview_dataptr(args[6], &count, &arg6); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)arg6 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glReadPixels) - -// Arguments: -// Ret value: void -bool JSB_glReleaseShaderCompiler(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); - JSB_GL_CHECK(glReleaseShaderCompiler( )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glReleaseShaderCompiler) - -// Arguments: GLenum, GLenum, GLsizei, GLsizei -// Ret value: void -bool JSB_glRenderbufferStorage(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glRenderbufferStorage) - -// Arguments: GLclampf, GLboolean -// Ret value: void -bool JSB_glSampleCoverage(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; uint16_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_uint16(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glSampleCoverage) - -// Arguments: GLint, GLint, GLsizei, GLsizei -// Ret value: void -bool JSB_glScissor(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glScissor) - -// Arguments: GLenum, GLint, GLuint -// Ret value: void -bool JSB_glStencilFunc(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; uint32_t arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glStencilFunc) - -// Arguments: GLenum, GLenum, GLint, GLuint -// Ret value: void -bool JSB_glStencilFuncSeparate(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; int32_t arg2; uint32_t arg3; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_uint32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glStencilFuncSeparate) - -// Arguments: GLuint -// Ret value: void -bool JSB_glStencilMask(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glStencilMask((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glStencilMask) - -// Arguments: GLenum, GLuint -// Ret value: void -bool JSB_glStencilMaskSeparate(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glStencilMaskSeparate) - -// Arguments: GLenum, GLenum, GLenum -// Ret value: void -bool JSB_glStencilOp(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; uint32_t arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glStencilOp) - -// Arguments: GLenum, GLenum, GLenum, GLenum -// Ret value: void -bool JSB_glStencilOpSeparate(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_uint32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glStencilOpSeparate) - -// Arguments: GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, ArrayBufferView -// Ret value: void -bool JSB_glTexImage2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 9, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - ok &= seval_to_uint32(args[6], &arg6 ); - ok &= seval_to_uint32(args[7], &arg7 ); - GLsizei count; - ok &= JSB_get_arraybufferview_dataptr(args[8], &count, &arg8); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glTexImage2D) - -// Arguments: GLenum, GLenum, GLfloat -// Ret value: void -bool JSB_glTexParameterf(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; int32_t arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glTexParameterf) - -// Arguments: GLenum, GLenum, GLint -// Ret value: void -bool JSB_glTexParameteri(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; uint32_t arg1; int32_t arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_uint32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glTexParameteri) - -// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView -// Ret value: void -bool JSB_glTexSubImage2D(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 9, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - ok &= seval_to_uint32(args[6], &arg6 ); - ok &= seval_to_uint32(args[7], &arg7 ); - GLsizei count; - ok &= JSB_get_arraybufferview_dataptr(args[8], &count, &arg8); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glTexSubImage2D) - -// Arguments: GLint, GLfloat -// Ret value: void -bool JSB_glUniform1f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform1f((GLint)arg0 , (GLfloat)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform1f) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform1fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0;; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform1fv((GLint)arg0 , (GLsizei)data.count() , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform1fv) - -// Arguments: GLint, GLint -// Ret value: void -bool JSB_glUniform1i(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform1i((GLint)arg0 , (GLint)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform1i) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform1iv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform1iv((GLint)arg0 , (GLsizei)data.count() , (GLint*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform1iv) - -// Arguments: GLint, GLfloat, GLfloat -// Ret value: void -bool JSB_glUniform2f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform2f) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform2fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform2fv((GLint)arg0 , (GLsizei)(data.count()/2) , (GLfloat*)data.data() )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform2fv) - -// Arguments: GLint, GLint, GLint -// Ret value: void -bool JSB_glUniform2i(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform2i) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform2iv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform2iv((GLint)arg0 , (GLsizei)(data.count()/2) , (GLint*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform2iv) - -// Arguments: GLint, GLfloat, GLfloat, GLfloat -// Ret value: void -bool JSB_glUniform3f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform3f) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform3fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform3fv((GLint)arg0 , (GLsizei)(data.count()/3) , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform3fv) - -// Arguments: GLint, GLint, GLint, GLint -// Ret value: void -bool JSB_glUniform3i(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform3i) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform3iv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform3iv((GLint)arg0 , (GLsizei)(data.count()/3) , (GLint*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform3iv) - -// Arguments: GLint, GLfloat, GLfloat, GLfloat, GLfloat -// Ret value: void -bool JSB_glUniform4f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform4f) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform4fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0;; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform4fv((GLint)arg0 , (GLsizei)(data.count()/4) , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform4fv) - -// Arguments: GLint, GLint, GLint, GLint, GLint -// Ret value: void -bool JSB_glUniform4i(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform4i) - -// Arguments: GLint, GLsizei, TypedArray/Sequence -// Ret value: void -bool JSB_glUniform4iv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; - - ok &= seval_to_int32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniform4iv((GLint)arg0 , (GLsizei)(data.count()/4) , (GLint*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniform4iv) - -// Arguments: GLint, GLboolean, TypedArray/Sequence -// Ret value: void -bool JSB_glUniformMatrix2fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; uint16_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_uint16(args[1], &arg1 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[2], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniformMatrix2fv(arg0, (GLsizei)(data.count()/4), (GLboolean)arg1 , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniformMatrix2fv) - -// Arguments: GLint, GLboolean, TypedArray/Sequence -// Ret value: void -bool JSB_glUniformMatrix3fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; uint16_t arg1; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_uint16(args[1], &arg1 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[2], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniformMatrix3fv(arg0, (GLsizei)(data.count()/9), (GLboolean)arg1 , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniformMatrix3fv) - -// Arguments: GLint, GLboolean, TypedArray/Sequence -// Ret value: void -bool JSB_glUniformMatrix4fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; uint16_t arg1;; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_uint16(args[1], &arg1 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[2], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUniformMatrix4fv(arg0, (GLsizei)(data.count()/16), (GLboolean)arg1 , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUniformMatrix4fv) - -// Arguments: GLuint -// Ret value: void -bool JSB_glUseProgram(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glUseProgram((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glUseProgram) - -// Arguments: GLuint -// Ret value: void -bool JSB_glValidateProgram(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glValidateProgram((GLuint)arg0 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glValidateProgram) - -// Arguments: GLuint, GLfloat -// Ret value: void -bool JSB_glVertexAttrib1f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib1f) - -// Arguments: GLuint, TypedArray/Sequence -// Ret value: void -bool JSB_glVertexAttrib1fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib1fv((GLuint)arg0 , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib1fv) - -// Arguments: GLuint, GLfloat, GLfloat -// Ret value: void -bool JSB_glVertexAttrib2f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib2f) - -// Arguments: GLuint, TypedArray/Sequence -// Ret value: void -bool JSB_glVertexAttrib2fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib2fv((GLuint)arg0 , (GLfloat*)data.data() )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib2fv) - -// Arguments: GLuint, GLfloat, GLfloat, GLfloat -// Ret value: void -bool JSB_glVertexAttrib3f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib3f) - -// Arguments: GLuint, TypedArray/Sequence -// Ret value: void -bool JSB_glVertexAttrib3fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib3fv((GLuint)arg0 , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib3fv) - -// Arguments: GLuint, GLfloat, GLfloat, GLfloat, GLfloat -// Ret value: void -bool JSB_glVertexAttrib4f(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib4f) - -// Arguments: GLuint, TypedArray/Sequence -// Ret value: void -bool JSB_glVertexAttrib4fv(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; - - ok &= seval_to_uint32(args[0], &arg0 ); - GLData data; - ok &= JSB_jsval_typedarray_to_data(args[1], data); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttrib4fv((GLuint)arg0 , (GLfloat*)data.data())); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttrib4fv) - -// Arguments: GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid* -// Ret value: void -bool JSB_glVertexAttribPointer(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 6, false, "Invalid number of arguments" ); - bool ok = true; - uint32_t arg0; int32_t arg1; uint32_t arg2; uint16_t arg3; int32_t arg4; int32_t arg5; - - ok &= seval_to_uint32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_uint32(args[2], &arg2 ); - ok &= seval_to_uint16(args[3], &arg3 ); - ok &= seval_to_int32(args[4], &arg4 ); - ok &= seval_to_int32(args[5], &arg5 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)arg5 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glVertexAttribPointer) - -// Arguments: GLint, GLint, GLsizei, GLsizei -// Ret value: void -bool JSB_glViewport(se::State& s) { - const auto& args = s.args(); - int argc = (int)args.size(); - SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); - bool ok = true; - int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; - - ok &= seval_to_int32(args[0], &arg0 ); - ok &= seval_to_int32(args[1], &arg1 ); - ok &= seval_to_int32(args[2], &arg2 ); - ok &= seval_to_int32(args[3], &arg3 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); - - JSB_GL_CHECK(glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 )); - s.rval().setUndefined(); - return true; -} -SE_BIND_FUNC(JSB_glViewport) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_functions.hpp b/native/cocos/scripting/js-bindings/manual/jsb_opengl_functions.hpp deleted file mode 100644 index 2a1c8742dd..0000000000 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_functions.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#pragma once - -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" - -SE_DECLARE_FUNC(JSB_glActiveTexture); -SE_DECLARE_FUNC(JSB_glAttachShader); -SE_DECLARE_FUNC(JSB_glBindAttribLocation); -SE_DECLARE_FUNC(JSB_glBindBuffer); -SE_DECLARE_FUNC(JSB_glBindFramebuffer); -SE_DECLARE_FUNC(JSB_glBindRenderbuffer); -SE_DECLARE_FUNC(JSB_glBindTexture); -SE_DECLARE_FUNC(JSB_glBlendColor); -SE_DECLARE_FUNC(JSB_glBlendEquation); -SE_DECLARE_FUNC(JSB_glBlendEquationSeparate); -SE_DECLARE_FUNC(JSB_glBlendFunc); -SE_DECLARE_FUNC(JSB_glBlendFuncSeparate); -SE_DECLARE_FUNC(JSB_glBufferData); -SE_DECLARE_FUNC(JSB_glBufferSubData); -SE_DECLARE_FUNC(JSB_glCheckFramebufferStatus); -SE_DECLARE_FUNC(JSB_glClear); -SE_DECLARE_FUNC(JSB_glClearColor); -SE_DECLARE_FUNC(JSB_glClearDepthf); -SE_DECLARE_FUNC(JSB_glClearStencil); -SE_DECLARE_FUNC(JSB_glColorMask); -SE_DECLARE_FUNC(JSB_glCompileShader); -SE_DECLARE_FUNC(JSB_glCompressedTexImage2D); -SE_DECLARE_FUNC(JSB_glCompressedTexSubImage2D); -SE_DECLARE_FUNC(JSB_glCopyTexImage2D); -SE_DECLARE_FUNC(JSB_glCopyTexSubImage2D); -SE_DECLARE_FUNC(JSB_glCreateProgram); -SE_DECLARE_FUNC(JSB_glCreateShader); -SE_DECLARE_FUNC(JSB_glCullFace); -SE_DECLARE_FUNC(JSB_glDeleteBuffers); -SE_DECLARE_FUNC(JSB_glDeleteFramebuffers); -SE_DECLARE_FUNC(JSB_glDeleteProgram); -SE_DECLARE_FUNC(JSB_glDeleteRenderbuffers); -SE_DECLARE_FUNC(JSB_glDeleteShader); -SE_DECLARE_FUNC(JSB_glDeleteTextures); -SE_DECLARE_FUNC(JSB_glDepthFunc); -SE_DECLARE_FUNC(JSB_glDepthMask); -SE_DECLARE_FUNC(JSB_glDepthRangef); -SE_DECLARE_FUNC(JSB_glDetachShader); -SE_DECLARE_FUNC(JSB_glDisable); -SE_DECLARE_FUNC(JSB_glDisableVertexAttribArray); -SE_DECLARE_FUNC(JSB_glDrawArrays); -SE_DECLARE_FUNC(JSB_glDrawElements); -SE_DECLARE_FUNC(JSB_glEnable); -SE_DECLARE_FUNC(JSB_glEnableVertexAttribArray); -SE_DECLARE_FUNC(JSB_glFinish); -SE_DECLARE_FUNC(JSB_glFlush); -SE_DECLARE_FUNC(JSB_glFramebufferRenderbuffer); -SE_DECLARE_FUNC(JSB_glFramebufferTexture2D); -SE_DECLARE_FUNC(JSB_glFrontFace); -SE_DECLARE_FUNC(JSB_glGenBuffers); -SE_DECLARE_FUNC(JSB_glGenFramebuffers); -SE_DECLARE_FUNC(JSB_glGenRenderbuffers); -SE_DECLARE_FUNC(JSB_glGenTextures); -SE_DECLARE_FUNC(JSB_glGenerateMipmap); -SE_DECLARE_FUNC(JSB_glGetActiveAttrib); -SE_DECLARE_FUNC(JSB_glGetActiveUniform); -SE_DECLARE_FUNC(JSB_glGetAttachedShaders); -SE_DECLARE_FUNC(JSB_glGetAttribLocation); -SE_DECLARE_FUNC(JSB_glGetError); -SE_DECLARE_FUNC(JSB_glGetProgramInfoLog); -SE_DECLARE_FUNC(JSB_glGetProgramiv); -SE_DECLARE_FUNC(JSB_glGetShaderInfoLog); -SE_DECLARE_FUNC(JSB_glGetShaderSource); -SE_DECLARE_FUNC(JSB_glGetShaderiv); -SE_DECLARE_FUNC(JSB_glGetTexParameterfv); -SE_DECLARE_FUNC(JSB_glGetUniformLocation); -SE_DECLARE_FUNC(JSB_glGetUniformfv); -SE_DECLARE_FUNC(JSB_glHint); -SE_DECLARE_FUNC(JSB_glIsBuffer); -SE_DECLARE_FUNC(JSB_glIsEnabled); -SE_DECLARE_FUNC(JSB_glIsFramebuffer); -SE_DECLARE_FUNC(JSB_glIsProgram); -SE_DECLARE_FUNC(JSB_glIsRenderbuffer); -SE_DECLARE_FUNC(JSB_glIsShader); -SE_DECLARE_FUNC(JSB_glIsTexture); -SE_DECLARE_FUNC(JSB_glLineWidth); -SE_DECLARE_FUNC(JSB_glLinkProgram); -SE_DECLARE_FUNC(JSB_glPixelStorei); -SE_DECLARE_FUNC(JSB_glPolygonOffset); -SE_DECLARE_FUNC(JSB_glReadPixels); -SE_DECLARE_FUNC(JSB_glReleaseShaderCompiler); -SE_DECLARE_FUNC(JSB_glRenderbufferStorage); -SE_DECLARE_FUNC(JSB_glSampleCoverage); -SE_DECLARE_FUNC(JSB_glScissor); -SE_DECLARE_FUNC(JSB_glShaderSource); -SE_DECLARE_FUNC(JSB_glStencilFunc); -SE_DECLARE_FUNC(JSB_glStencilFuncSeparate); -SE_DECLARE_FUNC(JSB_glStencilMask); -SE_DECLARE_FUNC(JSB_glStencilMaskSeparate); -SE_DECLARE_FUNC(JSB_glStencilOp); -SE_DECLARE_FUNC(JSB_glStencilOpSeparate); -SE_DECLARE_FUNC(JSB_glTexImage2D); -SE_DECLARE_FUNC(JSB_glTexParameterf); -SE_DECLARE_FUNC(JSB_glTexParameteri); -SE_DECLARE_FUNC(JSB_glTexSubImage2D); -SE_DECLARE_FUNC(JSB_glUniform1f); -SE_DECLARE_FUNC(JSB_glUniform1fv); -SE_DECLARE_FUNC(JSB_glUniform1i); -SE_DECLARE_FUNC(JSB_glUniform1iv); -SE_DECLARE_FUNC(JSB_glUniform2f); -SE_DECLARE_FUNC(JSB_glUniform2fv); -SE_DECLARE_FUNC(JSB_glUniform2i); -SE_DECLARE_FUNC(JSB_glUniform2iv); -SE_DECLARE_FUNC(JSB_glUniform3f); -SE_DECLARE_FUNC(JSB_glUniform3fv); -SE_DECLARE_FUNC(JSB_glUniform3i); -SE_DECLARE_FUNC(JSB_glUniform3iv); -SE_DECLARE_FUNC(JSB_glUniform4f); -SE_DECLARE_FUNC(JSB_glUniform4fv); -SE_DECLARE_FUNC(JSB_glUniform4i); -SE_DECLARE_FUNC(JSB_glUniform4iv); -SE_DECLARE_FUNC(JSB_glUniformMatrix2fv); -SE_DECLARE_FUNC(JSB_glUniformMatrix3fv); -SE_DECLARE_FUNC(JSB_glUniformMatrix4fv); -SE_DECLARE_FUNC(JSB_glUseProgram); -SE_DECLARE_FUNC(JSB_glValidateProgram); -SE_DECLARE_FUNC(JSB_glVertexAttrib1f); -SE_DECLARE_FUNC(JSB_glVertexAttrib1fv); -SE_DECLARE_FUNC(JSB_glVertexAttrib2f); -SE_DECLARE_FUNC(JSB_glVertexAttrib2fv); -SE_DECLARE_FUNC(JSB_glVertexAttrib3f); -SE_DECLARE_FUNC(JSB_glVertexAttrib3fv); -SE_DECLARE_FUNC(JSB_glVertexAttrib4f); -SE_DECLARE_FUNC(JSB_glVertexAttrib4fv); -SE_DECLARE_FUNC(JSB_glVertexAttribPointer); -SE_DECLARE_FUNC(JSB_glViewport); -SE_DECLARE_FUNC(JSB_glGetParameter); -SE_DECLARE_FUNC(JSB_glGetShaderPrecisionFormat); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp index a2be5ea5df..63ea18f0e6 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.cpp @@ -23,16 +23,2342 @@ THE SOFTWARE. ****************************************************************************/ -#include "scripting/js-bindings/manual/jsb_opengl_manual.hpp" -#include "scripting/js-bindings/manual/jsb_opengl_functions.hpp" -#include "scripting/js-bindings/manual/jsb_conversions.hpp" +#include "jsb_opengl_manual.hpp" +#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" +#include "cocos/scripting/js-bindings/manual/jsb_global.h" #include "cocos/scripting/js-bindings/manual/jsb_opengl_utils.hpp" #include "platform/CCGL.h" #include +namespace { + + GLint __defaultFbo = 0; + + template + class GLData + { + public: + GLData() + : _data(nullptr) + , _count(0) + , _isOwnData(false) + { + } + + ~GLData() + { + if (_isOwnData) + { + free(_data); + } + } + + void setData(T* data, size_t count, bool isOwnData) + { + _data = data; + _count = count; + _isOwnData = isOwnData; + } + + T* data() const { return _data; } + size_t count() const { return _count; } + + private: + + // Disable copy/move constructor, copy/move assigment + GLData(const GLData&); + GLData(GLData&&); + GLData& operator=(const GLData&); + GLData& operator=(GLData&&); + + T* _data; + size_t _count; + bool _isOwnData; + }; + +} + +template +static bool JSB_jsval_typedarray_to_data(const se::Value& v, GLData& data) +{ + if (v.isObject()) + { + se::Object* obj = v.toObject(); + if (obj->isArray()) + { + uint32_t length = 0; + if (obj->getArrayLength(&length) && length > 0) + { + T* d = (T*)malloc(length * sizeof(T)); + se::Value tmp; + for (uint32_t i = 0; i < length; ++i) + { + if (obj->getArrayElement(i, &tmp)) + { + if (std::is_same::value) + { + d[i] = tmp.toInt32(); + } + else if (std::is_same::value) + { + d[i] = tmp.toFloat(); + } + } + } + data.setData(d, length, true); + return true; + } + SE_LOGE("Failed to get array data"); + } + else if (obj->isTypedArray()) + { + size_t bytes = 0; + uint8_t* ptr = nullptr; + + if (obj->getTypedArrayData(&ptr, &bytes) && bytes > 0) + { + data.setData((T*)ptr, bytes / sizeof(T), false); + return true; + } + + SE_LOGE("Failed to get typed array data"); + } + else if (obj->isArrayBuffer()) + { + size_t bytes = 0; + uint8_t* ptr = nullptr; + + if (obj->getArrayBufferData(&ptr, &bytes) && bytes > 0) + { + data.setData((T*)ptr, bytes / sizeof(T), false); + return true; + } + + SE_LOGE("Failed to get typed array data"); + } + } + + return false; +} + +static bool JSB_get_arraybufferview_dataptr(const se::Value& v, GLsizei *count, GLvoid **data) +{ + assert(count != nullptr && data != nullptr); + + if (v.isObject()) + { + uint8_t* ptr = nullptr; + size_t length = 0; + se::Object* obj = v.toObject(); + if (obj->isTypedArray()) + { + if (obj->getTypedArrayData(&ptr, &length)) + { + *data = ptr; + *count = (GLsizei)length; + return true; + } + else + { + assert(false); + } + } + else if (obj->isArrayBuffer()) + { + if (obj->getArrayBufferData(&ptr, &length)) + { + *data = ptr; + *count = (GLsizei)length; + return true; + } + else + { + assert(false); + } + } + else + { + SE_LOGE("JSB_get_arraybufferview_dataptr: isn't a typed array!\n"); + } + } + else if (v.isNullOrUndefined()) + { + *count = 0; + *data = nullptr; + return true; + } + else + { + assert(false); + } + return false; +} + +// Arguments: GLenum +// Ret value: void +static bool JSB_glActiveTexture(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glActiveTexture((GLenum)arg0)); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glActiveTexture) + +// Arguments: GLuint, GLuint +// Ret value: void +static bool JSB_glAttachShader(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glAttachShader((GLuint)arg0 , (GLuint)arg1 )); + + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glAttachShader) + +// Arguments: GLuint, GLuint, char* +// Ret value: void +static bool JSB_glBindAttribLocation(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; std::string arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_std_string(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBindAttribLocation((GLuint)arg0 , (GLuint)arg1 , arg2.c_str() )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBindAttribLocation) + +// Arguments: GLenum, GLuint +// Ret value: void +static bool JSB_glBindBuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBindBuffer((GLenum)arg0 , (GLuint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBindBuffer) + +// Arguments: GLenum, GLuint +// Ret value: void +static bool JSB_glBindFramebuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + + if (args[1].isNullOrUndefined()) + { + arg1 = __defaultFbo; + } + else + { + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + } + + JSB_GL_CHECK(glBindFramebuffer((GLenum)arg0 , (GLuint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBindFramebuffer) + +// Arguments: GLenum, GLuint +// Ret value: void +static bool JSB_glBindRenderbuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBindRenderbuffer((GLenum)arg0 , (GLuint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBindRenderbuffer) + +// Arguments: GLenum, GLuint +// Ret value: void +static bool JSB_glBindTexture(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBindTexture((GLenum)arg0 , (GLuint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBindTexture) + +// Arguments: GLclampf, GLclampf, GLclampf, GLclampf +// Ret value: void +static bool JSB_glBlendColor(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBlendColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBlendColor) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glBlendEquation(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBlendEquation((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBlendEquation) + +// Arguments: GLenum, GLenum +// Ret value: void +static bool JSB_glBlendEquationSeparate(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBlendEquationSeparate((GLenum)arg0 , (GLenum)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBlendEquationSeparate) + +// Arguments: GLenum, GLenum +// Ret value: void +static bool JSB_glBlendFunc(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBlendFunc((GLenum)arg0 , (GLenum)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBlendFunc) + +// Arguments: GLenum, GLenum, GLenum, GLenum +// Ret value: void +static bool JSB_glBlendFuncSeparate(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_uint32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBlendFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBlendFuncSeparate) + +// Arguments: GLenum, ArrayBufferView, GLenum +// Ret value: void +static bool JSB_glBufferData(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0 = 0; + void* arg1 = nullptr; + uint32_t arg2 = 0; + GLsizei count = 0; + ok &= seval_to_uint32(args[0], &arg0 ); + if (args[1].isNumber()) + { + count = args[1].toUint32(); + } + else + { + ok &= JSB_get_arraybufferview_dataptr(args[1], &count, &arg1); + } + ok &= seval_to_uint32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBufferData((GLenum)arg0 , count, (GLvoid*)arg1 , (GLenum)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBufferData) + +// Arguments: GLenum, GLintptr, ArrayBufferView +// Ret value: void +static bool JSB_glBufferSubData(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0 = 0; + int32_t arg1 = 0; + void* arg2 = nullptr; + GLsizei count = 0; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + + if (args[2].isNumber()) + { + count = args[2].toUint32(); + } + else + { + ok &= JSB_get_arraybufferview_dataptr(args[2], &count, &arg2); + } + + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glBufferSubData((GLenum)arg0 , (GLintptr)arg1 , count, (GLvoid*)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glBufferSubData) + +// Arguments: GLenum +// Ret value: GLenum +static bool JSB_glCheckFramebufferStatus(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLenum ret_val; + + ret_val = glCheckFramebufferStatus((GLenum)arg0); + s.rval().setUint32((uint32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glCheckFramebufferStatus) + +// Arguments: GLbitfield +// Ret value: void +static bool JSB_glClear(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glClear((GLbitfield)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glClear) + +// Arguments: GLclampf, GLclampf, GLclampf, GLclampf +// Ret value: void +static bool JSB_glClearColor(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glClearColor((GLclampf)arg0 , (GLclampf)arg1 , (GLclampf)arg2 , (GLclampf)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glClearColor) + +// Arguments: GLclampf +// Ret value: void +static bool JSB_glClearDepthf(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glClearDepthf((GLclampf)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glClearDepthf) + +// Arguments: GLint +// Ret value: void +static bool JSB_glClearStencil(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glClearStencil((GLint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glClearStencil) + +// Arguments: GLboolean, GLboolean, GLboolean, GLboolean +// Ret value: void +static bool JSB_glColorMask(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint16_t arg0; uint16_t arg1; uint16_t arg2; uint16_t arg3; + + ok &= seval_to_uint16(args[0], &arg0 ); + ok &= seval_to_uint16(args[1], &arg1 ); + ok &= seval_to_uint16(args[2], &arg2 ); + ok &= seval_to_uint16(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glColorMask((GLboolean)arg0 , (GLboolean)arg1 , (GLboolean)arg2 , (GLboolean)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glColorMask) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glCompileShader(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glCompileShader((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glCompileShader) + +// Arguments: GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, ArrayBufferView +// Ret value: void +static bool JSB_glCompressedTexImage2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 8, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; void* arg7; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + ok &= seval_to_int32(args[6], &arg6 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr(args[7], &count, &arg7); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glCompressedTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLvoid*)arg7 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glCompressedTexImage2D) + +// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, ArrayBufferView +// Ret value: void +static bool JSB_glCompressedTexSubImage2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 9, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; int32_t arg7; void* arg8; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + ok &= seval_to_uint32(args[6], &arg6 ); + ok &= seval_to_int32(args[7], &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr(args[8], &count, &arg8); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glCompressedTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLsizei)arg7 , (GLvoid*)arg8 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glCompressedTexSubImage2D) + +// Arguments: GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint +// Ret value: void +static bool JSB_glCopyTexImage2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 8, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + ok &= seval_to_int32(args[6], &arg6 ); + ok &= seval_to_int32(args[7], &arg7 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glCopyTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLint)arg3 , (GLint)arg4 , (GLsizei)arg5 , (GLsizei)arg6 , (GLint)arg7 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glCopyTexImage2D) + +// Arguments: GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei +// Ret value: void +static bool JSB_glCopyTexSubImage2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 8, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; int32_t arg6; int32_t arg7; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + ok &= seval_to_int32(args[6], &arg6 ); + ok &= seval_to_int32(args[7], &arg7 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glCopyTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 , (GLint)arg5 , (GLsizei)arg6 , (GLsizei)arg7 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glCopyTexSubImage2D) + +// Arguments: +// Ret value: GLuint +static bool JSB_glCreateProgram(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); + GLuint ret_val; + + ret_val = glCreateProgram(); + s.rval().setUint32((uint32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glCreateProgram) + +// Arguments: GLenum +// Ret value: GLuint +static bool JSB_glCreateShader(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLuint ret_val; + + ret_val = glCreateShader((GLenum)arg0); + s.rval().setUint32((uint32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glCreateShader) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glCullFace(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glCullFace((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glCullFace) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glDeleteProgram(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDeleteProgram((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDeleteProgram) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glDeleteShader(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDeleteShader((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDeleteShader) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glDepthFunc(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDepthFunc((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDepthFunc) + +// Arguments: GLboolean +// Ret value: void +static bool JSB_glDepthMask(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint16_t arg0; + + ok &= seval_to_uint16(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDepthMask((GLboolean)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDepthMask) + +// Arguments: GLclampf, GLclampf +// Ret value: void +static bool JSB_glDepthRangef(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDepthRangef((GLclampf)arg0 , (GLclampf)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDepthRangef) + +// Arguments: GLuint, GLuint +// Ret value: void +static bool JSB_glDetachShader(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDetachShader((GLuint)arg0 , (GLuint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDetachShader) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glDisable(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDisable((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDisable) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glDisableVertexAttribArray(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDisableVertexAttribArray((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDisableVertexAttribArray) + +// Arguments: GLenum, GLint, GLsizei +// Ret value: void +static bool JSB_glDrawArrays(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glDrawArrays((GLenum)arg0 , (GLint)arg1 , (GLsizei)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDrawArrays) + +// Arguments: GLenum, GLsizei, GLenum, ArrayBufferView +// Ret value: void +static bool JSB_glDrawElements(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; void* arg3 = nullptr; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + + const se::Value& offsetVal = args[3]; + + if (offsetVal.isNumber()) + { + int offset = 0; + ok &= seval_to_int32(offsetVal, &offset); + arg3 = (void*)(intptr_t)offset; + } + else if (offsetVal.isObject()) + { + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr(args[3], &count, &arg3); + } + + SE_PRECONDITION2(ok, false, "Error processing arguments"); + JSB_GL_CHECK(glDrawElements((GLenum)arg0 , (GLsizei)arg1 , (GLenum)arg2 , (GLvoid*)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glDrawElements) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glEnable(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glEnable((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glEnable) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glEnableVertexAttribArray(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glEnableVertexAttribArray((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glEnableVertexAttribArray) + +// Arguments: +// Ret value: void +static bool JSB_glFinish(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); + JSB_GL_CHECK(glFinish( )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glFinish) + +// Arguments: +// Ret value: void +static bool JSB_glFlush(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); + JSB_GL_CHECK(glFlush( )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glFlush) + +// Arguments: GLenum, GLenum, GLenum, GLuint +// Ret value: void +static bool JSB_glFramebufferRenderbuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_uint32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glFramebufferRenderbuffer((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glFramebufferRenderbuffer) + +// Arguments: GLenum, GLenum, GLenum, GLuint, GLint +// Ret value: void +static bool JSB_glFramebufferTexture2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; int32_t arg4; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_uint32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glFramebufferTexture2D((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLuint)arg3 , (GLint)arg4 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glFramebufferTexture2D) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glFrontFace(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glFrontFace((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glFrontFace) + +// Arguments: GLenum +// Ret value: void +static bool JSB_glGenerateMipmap(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glGenerateMipmap((GLenum)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glGenerateMipmap) + +// Arguments: GLuint, char* +// Ret value: int +static bool JSB_glGetAttribLocation(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; std::string arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_std_string(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + int ret_val = glGetAttribLocation((GLuint)arg0 , arg1.c_str()); + JSB_GL_CHECK_ERROR(); + s.rval().setInt32(ret_val); + return true; +} +SE_BIND_FUNC(JSB_glGetAttribLocation) + +// Arguments: +// Ret value: GLenum +static bool JSB_glGetError(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); + GLenum ret_val; + + ret_val = glGetError(); + s.rval().setUint32((uint32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glGetError) + +// Arguments: GLuint, char* +// Ret value: int +static bool JSB_glGetUniformLocation(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; std::string arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_std_string(args[1], &arg1 ); + + SE_PRECONDITION2(ok, false, "Error processing arguments"); + int ret_val; + + ret_val = glGetUniformLocation((GLuint)arg0 , arg1.c_str()); + JSB_GL_CHECK_ERROR(); + s.rval().setInt32(ret_val); + return true; +} +SE_BIND_FUNC(JSB_glGetUniformLocation) + +// Arguments: GLenum, GLenum +// Ret value: void +static bool JSB_glHint(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glHint((GLenum)arg0 , (GLenum)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glHint) + +// Arguments: GLuint +// Ret value: GLboolean +static bool JSB_glIsBuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsBuffer((GLuint)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsBuffer) + +// Arguments: GLenum +// Ret value: GLboolean +static bool JSB_glIsEnabled(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsEnabled((GLenum)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsEnabled) + +// Arguments: GLuint +// Ret value: GLboolean +static bool JSB_glIsFramebuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsFramebuffer((GLuint)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsFramebuffer) + +// Arguments: GLuint +// Ret value: GLboolean +static bool JSB_glIsProgram(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsProgram((GLuint)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsProgram) + +// Arguments: GLuint +// Ret value: GLboolean +static bool JSB_glIsRenderbuffer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsRenderbuffer((GLuint)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsRenderbuffer) + +// Arguments: GLuint +// Ret value: GLboolean +static bool JSB_glIsShader(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsShader((GLuint)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsShader) + +// Arguments: GLuint +// Ret value: GLboolean +static bool JSB_glIsTexture(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + GLboolean ret_val; + + ret_val = glIsTexture((GLuint)arg0); + s.rval().setInt32((int32_t)ret_val); + return true; +} +SE_BIND_FUNC(JSB_glIsTexture) + +// Arguments: GLfloat +// Ret value: void +static bool JSB_glLineWidth(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glLineWidth((GLfloat)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glLineWidth) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glLinkProgram(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glLinkProgram((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glLinkProgram) + +// Arguments: GLenum, GLint +// Ret value: void +static bool JSB_glPixelStorei(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + if (arg0 == GL_UNPACK_FLIP_Y_WEBGL) + { + SE_LOGE("cjh FIXME: support GL_UNPACK_FLIP_Y_WEBGL\n"); + return true; + } + + if (arg0 == GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL) + { + SE_LOGE("cjh FIXME: support GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL\n"); + return true; + } + + JSB_GL_CHECK(glPixelStorei((GLenum)arg0 , (GLint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glPixelStorei) + +// Arguments: GLfloat, GLfloat +// Ret value: void +static bool JSB_glPolygonOffset(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glPolygonOffset((GLfloat)arg0 , (GLfloat)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glPolygonOffset) + +// Arguments: GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView +// Ret value: void +static bool JSB_glReadPixels(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 7, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; uint32_t arg4; uint32_t arg5; void* arg6; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_uint32(args[4], &arg4 ); + ok &= seval_to_uint32(args[5], &arg5 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr(args[6], &count, &arg6); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glReadPixels((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 , (GLenum)arg4 , (GLenum)arg5 , (GLvoid*)arg6 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glReadPixels) + +// Arguments: +// Ret value: void +static bool JSB_glReleaseShaderCompiler(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 0, false, "Invalid number of arguments" ); + JSB_GL_CHECK(glReleaseShaderCompiler( )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glReleaseShaderCompiler) + +// Arguments: GLenum, GLenum, GLsizei, GLsizei +// Ret value: void +static bool JSB_glRenderbufferStorage(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glRenderbufferStorage((GLenum)arg0 , (GLenum)arg1 , (GLsizei)arg2 , (GLsizei)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glRenderbufferStorage) + +// Arguments: GLclampf, GLboolean +// Ret value: void +static bool JSB_glSampleCoverage(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; uint16_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_uint16(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glSampleCoverage((GLclampf)arg0 , (GLboolean)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glSampleCoverage) + +// Arguments: GLint, GLint, GLsizei, GLsizei +// Ret value: void +static bool JSB_glScissor(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glScissor((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glScissor) + +// Arguments: GLenum, GLint, GLuint +// Ret value: void +static bool JSB_glStencilFunc(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glStencilFunc((GLenum)arg0 , (GLint)arg1 , (GLuint)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glStencilFunc) + +// Arguments: GLenum, GLenum, GLint, GLuint +// Ret value: void +static bool JSB_glStencilFuncSeparate(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; uint32_t arg3; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_uint32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glStencilFuncSeparate((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 , (GLuint)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glStencilFuncSeparate) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glStencilMask(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glStencilMask((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glStencilMask) + +// Arguments: GLenum, GLuint +// Ret value: void +static bool JSB_glStencilMaskSeparate(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glStencilMaskSeparate((GLenum)arg0 , (GLuint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glStencilMaskSeparate) + +// Arguments: GLenum, GLenum, GLenum +// Ret value: void +static bool JSB_glStencilOp(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glStencilOp((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glStencilOp) + +// Arguments: GLenum, GLenum, GLenum, GLenum +// Ret value: void +static bool JSB_glStencilOpSeparate(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; uint32_t arg2; uint32_t arg3; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_uint32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glStencilOpSeparate((GLenum)arg0 , (GLenum)arg1 , (GLenum)arg2 , (GLenum)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glStencilOpSeparate) + +// Arguments: GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, ArrayBufferView +// Ret value: void +static bool JSB_glTexImage2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 9, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + ok &= seval_to_uint32(args[6], &arg6 ); + ok &= seval_to_uint32(args[7], &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr(args[8], &count, &arg8); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glTexImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLsizei)arg3 , (GLsizei)arg4 , (GLint)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glTexImage2D) + +// Arguments: GLenum, GLenum, GLfloat +// Ret value: void +static bool JSB_glTexParameterf(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glTexParameterf((GLenum)arg0 , (GLenum)arg1 , (GLfloat)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glTexParameterf) + +// Arguments: GLenum, GLenum, GLint +// Ret value: void +static bool JSB_glTexParameteri(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; uint32_t arg1; int32_t arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_uint32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glTexParameteri((GLenum)arg0 , (GLenum)arg1 , (GLint)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glTexParameteri) + +// Arguments: GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, ArrayBufferView +// Ret value: void +static bool JSB_glTexSubImage2D(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 9, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; int32_t arg5; uint32_t arg6; uint32_t arg7; void* arg8; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + ok &= seval_to_uint32(args[6], &arg6 ); + ok &= seval_to_uint32(args[7], &arg7 ); + GLsizei count; + ok &= JSB_get_arraybufferview_dataptr(args[8], &count, &arg8); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glTexSubImage2D((GLenum)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLsizei)arg4 , (GLsizei)arg5 , (GLenum)arg6 , (GLenum)arg7 , (GLvoid*)arg8 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glTexSubImage2D) + +// Arguments: GLint, GLfloat +// Ret value: void +static bool JSB_glUniform1f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform1f((GLint)arg0 , (GLfloat)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform1f) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform1fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0;; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform1fv((GLint)arg0 , (GLsizei)data.count() , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform1fv) + +// Arguments: GLint, GLint +// Ret value: void +static bool JSB_glUniform1i(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform1i((GLint)arg0 , (GLint)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform1i) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform1iv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform1iv((GLint)arg0 , (GLsizei)data.count() , (GLint*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform1iv) + +// Arguments: GLint, GLfloat, GLfloat +// Ret value: void +static bool JSB_glUniform2f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform2f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform2f) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform2fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform2fv((GLint)arg0 , (GLsizei)(data.count()/2) , (GLfloat*)data.data() )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform2fv) + +// Arguments: GLint, GLint, GLint +// Ret value: void +static bool JSB_glUniform2i(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform2i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform2i) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform2iv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform2iv((GLint)arg0 , (GLsizei)(data.count()/2) , (GLint*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform2iv) + +// Arguments: GLint, GLfloat, GLfloat, GLfloat +// Ret value: void +static bool JSB_glUniform3f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform3f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform3f) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform3fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform3fv((GLint)arg0 , (GLsizei)(data.count()/3) , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform3fv) + +// Arguments: GLint, GLint, GLint, GLint +// Ret value: void +static bool JSB_glUniform3i(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform3i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform3i) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform3iv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform3iv((GLint)arg0 , (GLsizei)(data.count()/3) , (GLint*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform3iv) + +// Arguments: GLint, GLfloat, GLfloat, GLfloat, GLfloat +// Ret value: void +static bool JSB_glUniform4f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform4f((GLint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform4f) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform4fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0;; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform4fv((GLint)arg0 , (GLsizei)(data.count()/4) , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform4fv) + +// Arguments: GLint, GLint, GLint, GLint, GLint +// Ret value: void +static bool JSB_glUniform4i(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform4i((GLint)arg0 , (GLint)arg1 , (GLint)arg2 , (GLint)arg3 , (GLint)arg4 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform4i) + +// Arguments: GLint, GLsizei, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniform4iv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; + + ok &= seval_to_int32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniform4iv((GLint)arg0 , (GLsizei)(data.count()/4) , (GLint*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniform4iv) + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniformMatrix2fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; uint16_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_uint16(args[1], &arg1 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[2], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniformMatrix2fv(arg0, (GLsizei)(data.count()/4), (GLboolean)arg1 , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniformMatrix2fv) + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniformMatrix3fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; uint16_t arg1; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_uint16(args[1], &arg1 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[2], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniformMatrix3fv(arg0, (GLsizei)(data.count()/9), (GLboolean)arg1 , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniformMatrix3fv) + +// Arguments: GLint, GLboolean, TypedArray/Sequence +// Ret value: void +static bool JSB_glUniformMatrix4fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; uint16_t arg1;; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_uint16(args[1], &arg1 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[2], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUniformMatrix4fv(arg0, (GLsizei)(data.count()/16), (GLboolean)arg1 , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUniformMatrix4fv) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glUseProgram(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glUseProgram((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glUseProgram) + +// Arguments: GLuint +// Ret value: void +static bool JSB_glValidateProgram(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 1, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glValidateProgram((GLuint)arg0 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glValidateProgram) + +// Arguments: GLuint, GLfloat +// Ret value: void +static bool JSB_glVertexAttrib1f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib1f((GLuint)arg0 , (GLfloat)arg1 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib1f) + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +static bool JSB_glVertexAttrib1fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib1fv((GLuint)arg0 , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib1fv) + +// Arguments: GLuint, GLfloat, GLfloat +// Ret value: void +static bool JSB_glVertexAttrib2f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 3, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib2f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib2f) + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +static bool JSB_glVertexAttrib2fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib2fv((GLuint)arg0 , (GLfloat*)data.data() )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib2fv) + +// Arguments: GLuint, GLfloat, GLfloat, GLfloat +// Ret value: void +static bool JSB_glVertexAttrib3f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib3f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib3f) + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +static bool JSB_glVertexAttrib3fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib3fv((GLuint)arg0 , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib3fv) + +// Arguments: GLuint, GLfloat, GLfloat, GLfloat, GLfloat +// Ret value: void +static bool JSB_glVertexAttrib4f(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 5, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; int32_t arg4; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib4f((GLuint)arg0 , (GLfloat)arg1 , (GLfloat)arg2 , (GLfloat)arg3 , (GLfloat)arg4 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib4f) + +// Arguments: GLuint, TypedArray/Sequence +// Ret value: void +static bool JSB_glVertexAttrib4fv(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 2, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; + + ok &= seval_to_uint32(args[0], &arg0 ); + GLData data; + ok &= JSB_jsval_typedarray_to_data(args[1], data); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttrib4fv((GLuint)arg0 , (GLfloat*)data.data())); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttrib4fv) + +// Arguments: GLuint, GLint, GLenum, GLboolean, GLsizei, GLvoid* +// Ret value: void +static bool JSB_glVertexAttribPointer(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 6, false, "Invalid number of arguments" ); + bool ok = true; + uint32_t arg0; int32_t arg1; uint32_t arg2; uint16_t arg3; int32_t arg4; int32_t arg5; + + ok &= seval_to_uint32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_uint32(args[2], &arg2 ); + ok &= seval_to_uint16(args[3], &arg3 ); + ok &= seval_to_int32(args[4], &arg4 ); + ok &= seval_to_int32(args[5], &arg5 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glVertexAttribPointer((GLuint)arg0 , (GLint)arg1 , (GLenum)arg2 , (GLboolean)arg3 , (GLsizei)arg4 , (GLvoid*)arg5 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glVertexAttribPointer) + +// Arguments: GLint, GLint, GLsizei, GLsizei +// Ret value: void +static bool JSB_glViewport(se::State& s) { + const auto& args = s.args(); + int argc = (int)args.size(); + SE_PRECONDITION2( argc == 4, false, "Invalid number of arguments" ); + bool ok = true; + int32_t arg0; int32_t arg1; int32_t arg2; int32_t arg3; + + ok &= seval_to_int32(args[0], &arg0 ); + ok &= seval_to_int32(args[1], &arg1 ); + ok &= seval_to_int32(args[2], &arg2 ); + ok &= seval_to_int32(args[3], &arg3 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + + JSB_GL_CHECK(glViewport((GLint)arg0 , (GLint)arg1 , (GLsizei)arg2 , (GLsizei)arg3 )); + s.rval().setUndefined(); + return true; +} +SE_BIND_FUNC(JSB_glViewport) + + // Helper functions that link "glGenXXXs" (OpenGL ES 2.0 spec), with "gl.createXXX" (WebGL spec) -bool JSB_glGenTextures(se::State& s) { +static bool JSB_glGenTextures(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 0, false, "Invalid number of arguments" ); @@ -45,7 +2371,7 @@ bool JSB_glGenTextures(se::State& s) { } SE_BIND_FUNC(JSB_glGenTextures) -bool JSB_glGenBuffers(se::State& s) { +static bool JSB_glGenBuffers(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 0, false, "Invalid number of arguments" ); @@ -57,7 +2383,7 @@ bool JSB_glGenBuffers(se::State& s) { } SE_BIND_FUNC(JSB_glGenBuffers) -bool JSB_glGenRenderbuffers(se::State& s) { +static bool JSB_glGenRenderbuffers(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 0, false, "Invalid number of arguments" ); @@ -69,7 +2395,7 @@ bool JSB_glGenRenderbuffers(se::State& s) { } SE_BIND_FUNC(JSB_glGenRenderbuffers) -bool JSB_glGenFramebuffers(se::State& s) { +static bool JSB_glGenFramebuffers(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 0, false, "Invalid number of arguments" ); @@ -81,7 +2407,7 @@ bool JSB_glGenFramebuffers(se::State& s) { } SE_BIND_FUNC(JSB_glGenFramebuffers) -bool JSB_glDeleteTextures(se::State& s) { +static bool JSB_glDeleteTextures(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -98,7 +2424,7 @@ bool JSB_glDeleteTextures(se::State& s) { } SE_BIND_FUNC(JSB_glDeleteTextures) -bool JSB_glDeleteBuffers(se::State& s) { +static bool JSB_glDeleteBuffers(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -115,7 +2441,7 @@ bool JSB_glDeleteBuffers(se::State& s) { } SE_BIND_FUNC(JSB_glDeleteBuffers) -bool JSB_glDeleteRenderbuffers(se::State& s) { +static bool JSB_glDeleteRenderbuffers(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -132,7 +2458,7 @@ bool JSB_glDeleteRenderbuffers(se::State& s) { } SE_BIND_FUNC(JSB_glDeleteRenderbuffers) -bool JSB_glDeleteFramebuffers(se::State& s) { +static bool JSB_glDeleteFramebuffers(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -140,8 +2466,15 @@ bool JSB_glDeleteFramebuffers(se::State& s) { bool ok = true; uint32_t arg0; - ok &= seval_to_uint32(args[0], &arg0 ); - SE_PRECONDITION2(ok, false, "Error processing arguments"); + if (args[0].isNullOrUndefined()) + { + arg0 = __defaultFbo; + } + else + { + ok &= seval_to_uint32(args[0], &arg0 ); + SE_PRECONDITION2(ok, false, "Error processing arguments"); + } JSB_GL_CHECK(glDeleteFramebuffers(1, &arg0)); @@ -149,7 +2482,7 @@ bool JSB_glDeleteFramebuffers(se::State& s) { } SE_BIND_FUNC(JSB_glDeleteFramebuffers) -bool JSB_glShaderSource(se::State& s) { +static bool JSB_glShaderSource(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false, "Invalid number of arguments" ); @@ -173,7 +2506,7 @@ bool JSB_glShaderSource(se::State& s) { } SE_BIND_FUNC(JSB_glShaderSource) -bool JSB_glGetShaderiv(se::State& s) { +static bool JSB_glGetShaderiv(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false, "Invalid number of arguments" ); @@ -200,7 +2533,7 @@ bool JSB_glGetShaderiv(se::State& s) { } SE_BIND_FUNC(JSB_glGetShaderiv) -bool JSB_glGetProgramiv(se::State& s) { +static bool JSB_glGetProgramiv(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false, "Invalid number of arguments" ); @@ -219,7 +2552,7 @@ bool JSB_glGetProgramiv(se::State& s) { } SE_BIND_FUNC(JSB_glGetProgramiv) -bool JSB_glGetProgramInfoLog(se::State& s) { +static bool JSB_glGetProgramInfoLog(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -234,7 +2567,7 @@ bool JSB_glGetProgramInfoLog(se::State& s) { JSB_GL_CHECK(glGetProgramiv(arg0, GL_INFO_LOG_LENGTH, &length)); GLchar* src = new (std::nothrow) GLchar[length]; JSB_GL_CHECK(glGetProgramInfoLog(arg0, length, NULL, src)); - + s.rval().setString(src); CC_SAFE_DELETE_ARRAY(src); return true; @@ -242,7 +2575,7 @@ bool JSB_glGetProgramInfoLog(se::State& s) { SE_BIND_FUNC(JSB_glGetProgramInfoLog) // DOMString? getShaderInfoLog(WebGLShader? shader); -bool JSB_glGetShaderInfoLog(se::State& s) { +static bool JSB_glGetShaderInfoLog(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -257,7 +2590,7 @@ bool JSB_glGetShaderInfoLog(se::State& s) { JSB_GL_CHECK(glGetShaderiv(arg0, GL_INFO_LOG_LENGTH, &length)); GLchar* src = new (std::nothrow) GLchar[length]; JSB_GL_CHECK(glGetShaderInfoLog(arg0, length, NULL, src)); - + s.rval().setString(src); CC_SAFE_DELETE_ARRAY(src); return true; @@ -265,7 +2598,7 @@ bool JSB_glGetShaderInfoLog(se::State& s) { SE_BIND_FUNC(JSB_glGetShaderInfoLog) // DOMString? getShaderSource(WebGLShader? shader); -bool JSB_glGetShaderSource(se::State& s) { +static bool JSB_glGetShaderSource(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -292,7 +2625,7 @@ SE_BIND_FUNC(JSB_glGetShaderSource) // readonly attribute GLenum type; // readonly attribute DOMString name; // WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index); -bool JSB_glGetActiveAttrib(se::State& s) { +static bool JSB_glGetActiveAttrib(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false, "Invalid number of arguments" ); @@ -331,7 +2664,7 @@ SE_BIND_FUNC(JSB_glGetActiveAttrib) // readonly attribute DOMString name; // }; // WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index); -bool JSB_glGetActiveUniform(se::State& s) { +static bool JSB_glGetActiveUniform(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false, "Invalid number of arguments" ); @@ -344,7 +2677,7 @@ bool JSB_glGetActiveUniform(se::State& s) { SE_PRECONDITION2(ok, false, "Error processing arguments"); GLsizei length; - JSB_GL_CHECK(glGetProgramiv(arg0, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &length)); + JSB_GL_CHECK(glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length)); GLchar* buffer = new (std::nothrow) GLchar[length]; GLint size = -1; GLenum type = -1; @@ -363,7 +2696,7 @@ bool JSB_glGetActiveUniform(se::State& s) { SE_BIND_FUNC(JSB_glGetActiveUniform) // sequence? getAttachedShaders(WebGLProgram? program); -bool JSB_glGetAttachedShaders(se::State& s) { +static bool JSB_glGetAttachedShaders(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 1, false, "Invalid number of arguments" ); @@ -396,7 +2729,7 @@ bool JSB_glGetAttachedShaders(se::State& s) { SE_BIND_FUNC(JSB_glGetAttachedShaders) // sequence? getSupportedExtensions(); -bool JSB_glGetSupportedExtensions(se::State& s) { +static bool JSB_glGetSupportedExtensions(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 0, false, "Invalid number of arguments" ); @@ -428,12 +2761,12 @@ bool JSB_glGetSupportedExtensions(se::State& s) { s.rval().setObject(jsobj.get()); CC_SAFE_DELETE_ARRAY(copy); return true; - + } SE_BIND_FUNC(JSB_glGetSupportedExtensions) // any getTexParameter(GLenum target, GLenum pname); -bool JSB_glGetTexParameterfv(se::State& s) { +static bool JSB_glGetTexParameterfv(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false,"JSB_glGetTexParameterfv: Invalid number of arguments" ); @@ -455,7 +2788,7 @@ bool JSB_glGetTexParameterfv(se::State& s) { SE_BIND_FUNC(JSB_glGetTexParameterfv) // any getUniform(WebGLProgram? program, WebGLUniformLocation? location); -bool JSB_glGetUniformfv(se::State& s) { +static bool JSB_glGetUniformfv(se::State& s) { const auto& args = s.args(); int argc = (int)args.size(); SE_PRECONDITION2(argc == 2, false,"JSB_glGetUniformfv: Invalid number of arguments" ); @@ -470,7 +2803,7 @@ bool JSB_glGetUniformfv(se::State& s) { GLint activeUniforms; JSB_GL_CHECK(glGetProgramiv(arg0, GL_ACTIVE_UNIFORMS, &activeUniforms)); - + GLsizei length; JSB_GL_CHECK(glGetProgramiv(arg0, GL_ACTIVE_UNIFORM_MAX_LENGTH, &length)); GLchar* namebuffer = new (std::nothrow) GLchar[length+1]; @@ -499,7 +2832,7 @@ bool JSB_glGetUniformfv(se::State& s) { int utype = 0; switch(type) { - // float + // float case GL_FLOAT: usize = 1; utype = GL_FLOAT; @@ -526,10 +2859,10 @@ bool JSB_glGetUniformfv(se::State& s) { break; case GL_FLOAT_VEC4: usize = 4; - utype = GL_FLOAT; + utype = GL_FLOAT; break; - // int + // int case GL_INT: usize = 1; utype = GL_INT; @@ -600,10 +2933,10 @@ static bool JSB_glGetParameter(se::State& s) auto& ret = s.rval(); switch( pname ) { - // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS - // because desktop GL's corresponding queries return the number of components - // whereas GLES2 return the number of vectors (each vector has 4 components). - // Therefore, the value returned by desktop GL needs to be divided by 4. + // Need to emulate MAX_FRAGMENT/VERTEX_UNIFORM_VECTORS and MAX_VARYING_VECTORS + // because desktop GL's corresponding queries return the number of components + // whereas GLES2 return the number of vectors (each vector has 4 components). + // Therefore, the value returned by desktop GL needs to be divided by 4. case GL_MAX_FRAGMENT_UNIFORM_VECTORS: { #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) @@ -615,12 +2948,12 @@ static bool JSB_glGetParameter(se::State& s) #endif } break; - // Float32Array (with 0 elements) + // Float32Array (with 0 elements) case GL_COMPRESSED_TEXTURE_FORMATS: - ret.setObject(se::Object::createTypedArray(se::Object::TypedArrayType::FLOAT32, nullptr, 0), true); - break; + ret.setObject(se::Object::createTypedArray(se::Object::TypedArrayType::FLOAT32, nullptr, 0), true); + break; - // Float32Array (with 2 elements) + // Float32Array (with 2 elements) case GL_ALIASED_LINE_WIDTH_RANGE: case GL_ALIASED_POINT_SIZE_RANGE: case GL_DEPTH_RANGE: @@ -629,9 +2962,9 @@ static bool JSB_glGetParameter(se::State& s) JSB_GL_CHECK(glGetFloatv(pname, params)); ret.setObject(se::Object::createTypedArray(se::Object::TypedArrayType::FLOAT32, params, sizeof(params)), true); } - break; + break; - // Float32Array (with 4 values) + // Float32Array (with 4 values) case GL_BLEND_COLOR: case GL_COLOR_CLEAR_VALUE: { @@ -639,9 +2972,9 @@ static bool JSB_glGetParameter(se::State& s) JSB_GL_CHECK(glGetFloatv(pname, params)); ret.setObject(se::Object::createTypedArray(se::Object::TypedArrayType::FLOAT32, params, sizeof(params)), true); } - break; + break; - // Int32Array (with 2 values) + // Int32Array (with 2 values) case GL_MAX_VIEWPORT_DIMS: { GLfloat params[2]; @@ -649,9 +2982,9 @@ static bool JSB_glGetParameter(se::State& s) int intParams[2] = {(int)params[0], (int)params[1]}; ret.setObject(se::Object::createTypedArray(se::Object::TypedArrayType::INT32, intParams, sizeof(intParams)), true); } - break; + break; - // Int32Array (with 4 values) + // Int32Array (with 4 values) case GL_SCISSOR_BOX: case GL_VIEWPORT: { @@ -660,9 +2993,9 @@ static bool JSB_glGetParameter(se::State& s) int intParams[4] = {(int)params[0], (int)params[1], (int)params[2], (int)params[3]}; ret.setObject(se::Object::createTypedArray(se::Object::TypedArrayType::INT32, intParams, sizeof(intParams)), true); } - break; + break; - // boolean[] (with 4 values) + // boolean[] (with 4 values) case GL_COLOR_WRITEMASK: { JSB_GL_CHECK(glGetIntegerv(pname, intbuffer)); @@ -672,82 +3005,82 @@ static bool JSB_glGetParameter(se::State& s) } ret.setObject(arr, true); } - break; + break; - // WebGLBuffer + // WebGLBuffer case GL_ARRAY_BUFFER_BINDING: case GL_ELEMENT_ARRAY_BUFFER_BINDING: -// JSB_GL_CHECK(glGetIntegerv(pname, intbuffer)); -// ret = [buffers[@(intbuffer[0])] pointerValue]; - break; + // JSB_GL_CHECK(glGetIntegerv(pname, intbuffer)); + // ret = [buffers[@(intbuffer[0])] pointerValue]; + break; - // WebGLProgram + // WebGLProgram case GL_CURRENT_PROGRAM: -// glGetIntegerv(pname, intbuffer); -// ret = [programs[@(intbuffer[0])] pointerValue]; - break; + // glGetIntegerv(pname, intbuffer); + // ret = [programs[@(intbuffer[0])] pointerValue]; + break; - // WebGLFramebuffer + // WebGLFramebuffer case GL_FRAMEBUFFER_BINDING: -// glGetIntegerv(pname, intbuffer); -// ret = [framebuffers[@(intbuffer[0])] pointerValue]; - break; + // glGetIntegerv(pname, intbuffer); + // ret = [framebuffers[@(intbuffer[0])] pointerValue]; + break; - // WebGLRenderbuffer + // WebGLRenderbuffer case GL_RENDERBUFFER_BINDING: -// glGetIntegerv(pname, intbuffer); -// ret = [renderbuffers[@(intbuffer[0])] pointerValue]; - break; + // glGetIntegerv(pname, intbuffer); + // ret = [renderbuffers[@(intbuffer[0])] pointerValue]; + break; - // WebGLTexture + // WebGLTexture case GL_TEXTURE_BINDING_2D: case GL_TEXTURE_BINDING_CUBE_MAP: -// glGetIntegerv(pname, intbuffer); -// ret = [textures[@(intbuffer[0])] pointerValue]; - break; + // glGetIntegerv(pname, intbuffer); + // ret = [textures[@(intbuffer[0])] pointerValue]; + break; - // Ejecta/WebGL specific + // Ejecta/WebGL specific case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: - // device may support more, but we only map 8 here -// ret = JSValueMakeNumber(ctx, EJ_CANVAS_MAX_TEXTURE_UNITS); - break; + // device may support more, but we only map 8 here + // ret = JSValueMakeNumber(ctx, EJ_CANVAS_MAX_TEXTURE_UNITS); + break; case GL_UNPACK_FLIP_Y_WEBGL: -// ret = JSValueMakeBoolean(ctx, unpackFlipY); - break; + // ret = JSValueMakeBoolean(ctx, unpackFlipY); + break; case GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL: -// ret = JSValueMakeBoolean(ctx, premultiplyAlpha); - break; + SE_LOGD("GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL: ...\n"); + // ret = JSValueMakeBoolean(ctx, premultiplyAlpha); + break; case GL_UNPACK_COLORSPACE_CONVERSION_WEBGL: -// ret = JSValueMakeBoolean(ctx, false); - break; + // ret = JSValueMakeBoolean(ctx, false); + break; - // string + // string case GL_RENDERER: case GL_SHADING_LANGUAGE_VERSION: case GL_VENDOR: case GL_VERSION: - ret.setString((char *)glGetString(pname)); - break; + ret.setString((char *)glGetString(pname)); + break; - // single float + // single float case GL_DEPTH_CLEAR_VALUE: case GL_LINE_WIDTH: case GL_POLYGON_OFFSET_FACTOR: case GL_POLYGON_OFFSET_UNITS: case GL_SAMPLE_COVERAGE_VALUE: - JSB_GL_CHECK(glGetFloatv(pname, &floatvalue)); - ret.setFloat(floatvalue); - break; + JSB_GL_CHECK(glGetFloatv(pname, &floatvalue)); + ret.setFloat(floatvalue); + break; - // single int/long/bool - everything else + // single int/long/bool - everything else default: - printf("pname:0x%x\n", pname); JSB_GL_CHECK(glGetIntegerv(pname, intbuffer)); ret.setInt32(intbuffer[0]); - break; + break; } // That was fun! @@ -788,7 +3121,7 @@ static bool JSB_glGetShaderPrecisionFormat(se::State& s) rangeMin = 31; rangeMax = 30; precision = 0; - break; + break; case GL_LOW_FLOAT: case GL_MEDIUM_FLOAT: case GL_HIGH_FLOAT: @@ -796,9 +3129,9 @@ static bool JSB_glGetShaderPrecisionFormat(se::State& s) rangeMin = 127; rangeMax = 127; precision = 23; - break; + break; default: - SE_REPORT_ERROR("Unsupported precisiontype: %u", precisiontype); + SE_REPORT_ERROR("Unsupported precisiontype: %u", precisiontype); return false; } #endif @@ -812,4 +3145,142 @@ static bool JSB_glGetShaderPrecisionFormat(se::State& s) } SE_BIND_FUNC(JSB_glGetShaderPrecisionFormat) +bool JSB_register_opengl(se::Object* obj) +{ + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &__defaultFbo); + + // New WebGL functions, not present on OpenGL ES 2.0 + __glObj->defineFunction("getSupportedExtensions", _SE(JSB_glGetSupportedExtensions)); + __glObj->defineFunction("activeTexture", _SE(JSB_glActiveTexture)); + __glObj->defineFunction("_attachShader", _SE(JSB_glAttachShader)); + __glObj->defineFunction("_bindAttribLocation", _SE(JSB_glBindAttribLocation)); + __glObj->defineFunction("_bindBuffer", _SE(JSB_glBindBuffer)); + __glObj->defineFunction("_bindFramebuffer", _SE(JSB_glBindFramebuffer)); + __glObj->defineFunction("_bindRenderbuffer", _SE(JSB_glBindRenderbuffer)); + __glObj->defineFunction("_bindTexture", _SE(JSB_glBindTexture)); + __glObj->defineFunction("blendColor", _SE(JSB_glBlendColor)); + __glObj->defineFunction("blendEquation", _SE(JSB_glBlendEquation)); + __glObj->defineFunction("blendEquationSeparate", _SE(JSB_glBlendEquationSeparate)); + __glObj->defineFunction("blendFunc", _SE(JSB_glBlendFunc)); + __glObj->defineFunction("blendFuncSeparate", _SE(JSB_glBlendFuncSeparate)); + __glObj->defineFunction("bufferData", _SE(JSB_glBufferData)); + __glObj->defineFunction("bufferSubData", _SE(JSB_glBufferSubData)); + __glObj->defineFunction("checkFramebufferStatus", _SE(JSB_glCheckFramebufferStatus)); + __glObj->defineFunction("clear", _SE(JSB_glClear)); + __glObj->defineFunction("clearColor", _SE(JSB_glClearColor)); + __glObj->defineFunction("clearDepth", _SE(JSB_glClearDepthf)); + __glObj->defineFunction("clearStencil", _SE(JSB_glClearStencil)); + __glObj->defineFunction("colorMask", _SE(JSB_glColorMask)); + __glObj->defineFunction("_compileShader", _SE(JSB_glCompileShader)); + __glObj->defineFunction("compressedTexImage2D", _SE(JSB_glCompressedTexImage2D)); + __glObj->defineFunction("compressedTexSubImage2D", _SE(JSB_glCompressedTexSubImage2D)); + __glObj->defineFunction("copyTexImage2D", _SE(JSB_glCopyTexImage2D)); + __glObj->defineFunction("copyTexSubImage2D", _SE(JSB_glCopyTexSubImage2D)); + __glObj->defineFunction("_createProgram", _SE(JSB_glCreateProgram)); + __glObj->defineFunction("_createShader", _SE(JSB_glCreateShader)); + __glObj->defineFunction("cullFace", _SE(JSB_glCullFace)); + __glObj->defineFunction("_deleteBuffer", _SE(JSB_glDeleteBuffers)); + __glObj->defineFunction("_deleteFramebuffer", _SE(JSB_glDeleteFramebuffers)); + __glObj->defineFunction("_deleteProgram", _SE(JSB_glDeleteProgram)); + __glObj->defineFunction("_deleteRenderbuffer", _SE(JSB_glDeleteRenderbuffers)); + __glObj->defineFunction("_deleteShader", _SE(JSB_glDeleteShader)); + __glObj->defineFunction("_deleteTexture", _SE(JSB_glDeleteTextures)); + __glObj->defineFunction("depthFunc", _SE(JSB_glDepthFunc)); + __glObj->defineFunction("depthMask", _SE(JSB_glDepthMask)); + __glObj->defineFunction("depthRange", _SE(JSB_glDepthRangef)); + __glObj->defineFunction("detachShader", _SE(JSB_glDetachShader)); + __glObj->defineFunction("disable", _SE(JSB_glDisable)); + __glObj->defineFunction("disableVertexAttribArray", _SE(JSB_glDisableVertexAttribArray)); + __glObj->defineFunction("drawArrays", _SE(JSB_glDrawArrays)); + __glObj->defineFunction("drawElements", _SE(JSB_glDrawElements)); + __glObj->defineFunction("enable", _SE(JSB_glEnable)); + __glObj->defineFunction("enableVertexAttribArray", _SE(JSB_glEnableVertexAttribArray)); + __glObj->defineFunction("finish", _SE(JSB_glFinish)); + __glObj->defineFunction("flush", _SE(JSB_glFlush)); + __glObj->defineFunction("framebufferRenderbuffer", _SE(JSB_glFramebufferRenderbuffer)); + __glObj->defineFunction("_framebufferTexture2D", _SE(JSB_glFramebufferTexture2D)); + __glObj->defineFunction("frontFace", _SE(JSB_glFrontFace)); + __glObj->defineFunction("_createBuffer", _SE(JSB_glGenBuffers)); + __glObj->defineFunction("_createFramebuffer", _SE(JSB_glGenFramebuffers)); + __glObj->defineFunction("_createRenderbuffer", _SE(JSB_glGenRenderbuffers)); + __glObj->defineFunction("_createTexture", _SE(JSB_glGenTextures)); + __glObj->defineFunction("generateMipmap", _SE(JSB_glGenerateMipmap)); + __glObj->defineFunction("_getActiveAttrib", _SE(JSB_glGetActiveAttrib)); + __glObj->defineFunction("_getActiveUniform", _SE(JSB_glGetActiveUniform)); + __glObj->defineFunction("_getAttachedShaders", _SE(JSB_glGetAttachedShaders)); + __glObj->defineFunction("_getAttribLocation", _SE(JSB_glGetAttribLocation)); + __glObj->defineFunction("getError", _SE(JSB_glGetError)); + __glObj->defineFunction("_getProgramInfoLog", _SE(JSB_glGetProgramInfoLog)); + __glObj->defineFunction("_getProgramParameter", _SE(JSB_glGetProgramiv)); + __glObj->defineFunction("_getShaderInfoLog", _SE(JSB_glGetShaderInfoLog)); + __glObj->defineFunction("_getShaderSource", _SE(JSB_glGetShaderSource)); + __glObj->defineFunction("_getShaderParameter", _SE(JSB_glGetShaderiv)); + __glObj->defineFunction("getTexParameter", _SE(JSB_glGetTexParameterfv)); + __glObj->defineFunction("_getUniformLocation", _SE(JSB_glGetUniformLocation)); + __glObj->defineFunction("_getUniform", _SE(JSB_glGetUniformfv)); + __glObj->defineFunction("hint", _SE(JSB_glHint)); + __glObj->defineFunction("isBuffer", _SE(JSB_glIsBuffer)); + __glObj->defineFunction("isEnabled", _SE(JSB_glIsEnabled)); + __glObj->defineFunction("isFramebuffer", _SE(JSB_glIsFramebuffer)); + __glObj->defineFunction("isProgram", _SE(JSB_glIsProgram)); + __glObj->defineFunction("isRenderbuffer", _SE(JSB_glIsRenderbuffer)); + __glObj->defineFunction("isShader", _SE(JSB_glIsShader)); + __glObj->defineFunction("isTexture", _SE(JSB_glIsTexture)); + __glObj->defineFunction("lineWidth", _SE(JSB_glLineWidth)); + __glObj->defineFunction("_linkProgram", _SE(JSB_glLinkProgram)); + __glObj->defineFunction("pixelStorei", _SE(JSB_glPixelStorei)); + __glObj->defineFunction("polygonOffset", _SE(JSB_glPolygonOffset)); + __glObj->defineFunction("readPixels", _SE(JSB_glReadPixels)); + __glObj->defineFunction("releaseShaderCompiler", _SE(JSB_glReleaseShaderCompiler)); + __glObj->defineFunction("renderbufferStorage", _SE(JSB_glRenderbufferStorage)); + __glObj->defineFunction("sampleCoverage", _SE(JSB_glSampleCoverage)); + __glObj->defineFunction("scissor", _SE(JSB_glScissor)); + __glObj->defineFunction("_shaderSource", _SE(JSB_glShaderSource)); + __glObj->defineFunction("stencilFunc", _SE(JSB_glStencilFunc)); + __glObj->defineFunction("stencilFuncSeparate", _SE(JSB_glStencilFuncSeparate)); + __glObj->defineFunction("stencilMask", _SE(JSB_glStencilMask)); + __glObj->defineFunction("stencilMaskSeparate", _SE(JSB_glStencilMaskSeparate)); + __glObj->defineFunction("stencilOp", _SE(JSB_glStencilOp)); + __glObj->defineFunction("stencilOpSeparate", _SE(JSB_glStencilOpSeparate)); + __glObj->defineFunction("texImage2D", _SE(JSB_glTexImage2D)); + __glObj->defineFunction("texParameterf", _SE(JSB_glTexParameterf)); + __glObj->defineFunction("texParameteri", _SE(JSB_glTexParameteri)); + __glObj->defineFunction("texSubImage2D", _SE(JSB_glTexSubImage2D)); + __glObj->defineFunction("uniform1f", _SE(JSB_glUniform1f)); + __glObj->defineFunction("uniform1fv", _SE(JSB_glUniform1fv)); + __glObj->defineFunction("uniform1i", _SE(JSB_glUniform1i)); + __glObj->defineFunction("uniform1iv", _SE(JSB_glUniform1iv)); + __glObj->defineFunction("uniform2f", _SE(JSB_glUniform2f)); + __glObj->defineFunction("uniform2fv", _SE(JSB_glUniform2fv)); + __glObj->defineFunction("uniform2i", _SE(JSB_glUniform2i)); + __glObj->defineFunction("uniform2iv", _SE(JSB_glUniform2iv)); + __glObj->defineFunction("uniform3f", _SE(JSB_glUniform3f)); + __glObj->defineFunction("uniform3fv", _SE(JSB_glUniform3fv)); + __glObj->defineFunction("uniform3i", _SE(JSB_glUniform3i)); + __glObj->defineFunction("uniform3iv", _SE(JSB_glUniform3iv)); + __glObj->defineFunction("uniform4f", _SE(JSB_glUniform4f)); + __glObj->defineFunction("uniform4fv", _SE(JSB_glUniform4fv)); + __glObj->defineFunction("uniform4i", _SE(JSB_glUniform4i)); + __glObj->defineFunction("uniform4iv", _SE(JSB_glUniform4iv)); + __glObj->defineFunction("uniformMatrix2fv", _SE(JSB_glUniformMatrix2fv)); + __glObj->defineFunction("uniformMatrix3fv", _SE(JSB_glUniformMatrix3fv)); + __glObj->defineFunction("uniformMatrix4fv", _SE(JSB_glUniformMatrix4fv)); + __glObj->defineFunction("_useProgram", _SE(JSB_glUseProgram)); + __glObj->defineFunction("_validateProgram", _SE(JSB_glValidateProgram)); + __glObj->defineFunction("vertexAttrib1f", _SE(JSB_glVertexAttrib1f)); + __glObj->defineFunction("vertexAttrib1fv", _SE(JSB_glVertexAttrib1fv)); + __glObj->defineFunction("vertexAttrib2f", _SE(JSB_glVertexAttrib2f)); + __glObj->defineFunction("vertexAttrib2fv", _SE(JSB_glVertexAttrib2fv)); + __glObj->defineFunction("vertexAttrib3f", _SE(JSB_glVertexAttrib3f)); + __glObj->defineFunction("vertexAttrib3fv", _SE(JSB_glVertexAttrib3fv)); + __glObj->defineFunction("vertexAttrib4f", _SE(JSB_glVertexAttrib4f)); + __glObj->defineFunction("vertexAttrib4fv", _SE(JSB_glVertexAttrib4fv)); + __glObj->defineFunction("vertexAttribPointer", _SE(JSB_glVertexAttribPointer)); + __glObj->defineFunction("viewport", _SE(JSB_glViewport)); + __glObj->defineFunction("getParameter", _SE(JSB_glGetParameter)); + __glObj->defineFunction("getShaderPrecisionFormat", _SE(JSB_glGetShaderPrecisionFormat)); + + return true; + +} diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.hpp b/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.hpp index a0d2012bb2..fde1fdc65c 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_opengl_manual.hpp @@ -25,7 +25,8 @@ #pragma once -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +namespace se { + class Object; +} -// forward declaration of new functions -SE_DECLARE_FUNC(JSB_glGetSupportedExtensions); +bool JSB_register_opengl(se::Object* obj); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_registration.cpp b/native/cocos/scripting/js-bindings/manual/jsb_opengl_registration.cpp deleted file mode 100644 index daa2dc305a..0000000000 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_registration.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************************** - Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "jsb_opengl_registration.hpp" -#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" -#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" -#include "cocos/scripting/js-bindings/manual/jsb_global.h" -#include "scripting/js-bindings/manual/jsb_opengl_functions.hpp" -#include "scripting/js-bindings/manual/jsb_opengl_manual.hpp" - -bool JSB_register_opengl(se::Object* obj) -{ - // New WebGL functions, not present on OpenGL ES 2.0 - __glObj->defineFunction("getSupportedExtensions", _SE(JSB_glGetSupportedExtensions)); - __glObj->defineFunction("activeTexture", _SE(JSB_glActiveTexture)); - __glObj->defineFunction("_attachShader", _SE(JSB_glAttachShader)); - __glObj->defineFunction("_bindAttribLocation", _SE(JSB_glBindAttribLocation)); - __glObj->defineFunction("_bindBuffer", _SE(JSB_glBindBuffer)); - __glObj->defineFunction("_bindFramebuffer", _SE(JSB_glBindFramebuffer)); - __glObj->defineFunction("_bindRenderbuffer", _SE(JSB_glBindRenderbuffer)); - __glObj->defineFunction("_bindTexture", _SE(JSB_glBindTexture)); - __glObj->defineFunction("blendColor", _SE(JSB_glBlendColor)); - __glObj->defineFunction("blendEquation", _SE(JSB_glBlendEquation)); - __glObj->defineFunction("blendEquationSeparate", _SE(JSB_glBlendEquationSeparate)); - __glObj->defineFunction("blendFunc", _SE(JSB_glBlendFunc)); - __glObj->defineFunction("blendFuncSeparate", _SE(JSB_glBlendFuncSeparate)); - __glObj->defineFunction("bufferData", _SE(JSB_glBufferData)); - __glObj->defineFunction("bufferSubData", _SE(JSB_glBufferSubData)); - __glObj->defineFunction("checkFramebufferStatus", _SE(JSB_glCheckFramebufferStatus)); - __glObj->defineFunction("clear", _SE(JSB_glClear)); - __glObj->defineFunction("clearColor", _SE(JSB_glClearColor)); - __glObj->defineFunction("clearDepth", _SE(JSB_glClearDepthf)); - __glObj->defineFunction("clearStencil", _SE(JSB_glClearStencil)); - __glObj->defineFunction("colorMask", _SE(JSB_glColorMask)); - __glObj->defineFunction("_compileShader", _SE(JSB_glCompileShader)); - __glObj->defineFunction("compressedTexImage2D", _SE(JSB_glCompressedTexImage2D)); - __glObj->defineFunction("compressedTexSubImage2D", _SE(JSB_glCompressedTexSubImage2D)); - __glObj->defineFunction("copyTexImage2D", _SE(JSB_glCopyTexImage2D)); - __glObj->defineFunction("copyTexSubImage2D", _SE(JSB_glCopyTexSubImage2D)); - __glObj->defineFunction("_createProgram", _SE(JSB_glCreateProgram)); - __glObj->defineFunction("_createShader", _SE(JSB_glCreateShader)); - __glObj->defineFunction("cullFace", _SE(JSB_glCullFace)); - __glObj->defineFunction("_deleteBuffer", _SE(JSB_glDeleteBuffers)); - __glObj->defineFunction("_deleteFramebuffer", _SE(JSB_glDeleteFramebuffers)); - __glObj->defineFunction("_deleteProgram", _SE(JSB_glDeleteProgram)); - __glObj->defineFunction("_deleteRenderbuffer", _SE(JSB_glDeleteRenderbuffers)); - __glObj->defineFunction("_deleteShader", _SE(JSB_glDeleteShader)); - __glObj->defineFunction("_deleteTexture", _SE(JSB_glDeleteTextures)); - __glObj->defineFunction("depthFunc", _SE(JSB_glDepthFunc)); - __glObj->defineFunction("depthMask", _SE(JSB_glDepthMask)); - __glObj->defineFunction("depthRange", _SE(JSB_glDepthRangef)); - __glObj->defineFunction("detachShader", _SE(JSB_glDetachShader)); - __glObj->defineFunction("disable", _SE(JSB_glDisable)); - __glObj->defineFunction("disableVertexAttribArray", _SE(JSB_glDisableVertexAttribArray)); - __glObj->defineFunction("drawArrays", _SE(JSB_glDrawArrays)); - __glObj->defineFunction("drawElements", _SE(JSB_glDrawElements)); - __glObj->defineFunction("enable", _SE(JSB_glEnable)); - __glObj->defineFunction("enableVertexAttribArray", _SE(JSB_glEnableVertexAttribArray)); - __glObj->defineFunction("finish", _SE(JSB_glFinish)); - __glObj->defineFunction("flush", _SE(JSB_glFlush)); - __glObj->defineFunction("framebufferRenderbuffer", _SE(JSB_glFramebufferRenderbuffer)); - __glObj->defineFunction("framebufferTexture2D", _SE(JSB_glFramebufferTexture2D)); - __glObj->defineFunction("frontFace", _SE(JSB_glFrontFace)); - __glObj->defineFunction("_createBuffer", _SE(JSB_glGenBuffers)); - __glObj->defineFunction("_createFramebuffer", _SE(JSB_glGenFramebuffers)); - __glObj->defineFunction("_createRenderbuffer", _SE(JSB_glGenRenderbuffers)); - __glObj->defineFunction("_createTexture", _SE(JSB_glGenTextures)); - __glObj->defineFunction("generateMipmap", _SE(JSB_glGenerateMipmap)); - __glObj->defineFunction("_getActiveAttrib", _SE(JSB_glGetActiveAttrib)); - __glObj->defineFunction("_getActiveUniform", _SE(JSB_glGetActiveUniform)); - __glObj->defineFunction("_getAttachedShaders", _SE(JSB_glGetAttachedShaders)); - __glObj->defineFunction("_getAttribLocation", _SE(JSB_glGetAttribLocation)); - __glObj->defineFunction("getError", _SE(JSB_glGetError)); - __glObj->defineFunction("_getProgramInfoLog", _SE(JSB_glGetProgramInfoLog)); - __glObj->defineFunction("_getProgramParameter", _SE(JSB_glGetProgramiv)); - __glObj->defineFunction("_getShaderInfoLog", _SE(JSB_glGetShaderInfoLog)); - __glObj->defineFunction("_getShaderSource", _SE(JSB_glGetShaderSource)); - __glObj->defineFunction("_getShaderParameter", _SE(JSB_glGetShaderiv)); - __glObj->defineFunction("getTexParameter", _SE(JSB_glGetTexParameterfv)); - __glObj->defineFunction("_getUniformLocation", _SE(JSB_glGetUniformLocation)); - __glObj->defineFunction("_getUniform", _SE(JSB_glGetUniformfv)); - __glObj->defineFunction("hint", _SE(JSB_glHint)); - __glObj->defineFunction("isBuffer", _SE(JSB_glIsBuffer)); - __glObj->defineFunction("isEnabled", _SE(JSB_glIsEnabled)); - __glObj->defineFunction("isFramebuffer", _SE(JSB_glIsFramebuffer)); - __glObj->defineFunction("isProgram", _SE(JSB_glIsProgram)); - __glObj->defineFunction("isRenderbuffer", _SE(JSB_glIsRenderbuffer)); - __glObj->defineFunction("isShader", _SE(JSB_glIsShader)); - __glObj->defineFunction("isTexture", _SE(JSB_glIsTexture)); - __glObj->defineFunction("lineWidth", _SE(JSB_glLineWidth)); - __glObj->defineFunction("_linkProgram", _SE(JSB_glLinkProgram)); - __glObj->defineFunction("pixelStorei", _SE(JSB_glPixelStorei)); - __glObj->defineFunction("polygonOffset", _SE(JSB_glPolygonOffset)); - __glObj->defineFunction("readPixels", _SE(JSB_glReadPixels)); - __glObj->defineFunction("releaseShaderCompiler", _SE(JSB_glReleaseShaderCompiler)); - __glObj->defineFunction("renderbufferStorage", _SE(JSB_glRenderbufferStorage)); - __glObj->defineFunction("sampleCoverage", _SE(JSB_glSampleCoverage)); - __glObj->defineFunction("scissor", _SE(JSB_glScissor)); - __glObj->defineFunction("_shaderSource", _SE(JSB_glShaderSource)); - __glObj->defineFunction("stencilFunc", _SE(JSB_glStencilFunc)); - __glObj->defineFunction("stencilFuncSeparate", _SE(JSB_glStencilFuncSeparate)); - __glObj->defineFunction("stencilMask", _SE(JSB_glStencilMask)); - __glObj->defineFunction("stencilMaskSeparate", _SE(JSB_glStencilMaskSeparate)); - __glObj->defineFunction("stencilOp", _SE(JSB_glStencilOp)); - __glObj->defineFunction("stencilOpSeparate", _SE(JSB_glStencilOpSeparate)); - __glObj->defineFunction("texImage2D", _SE(JSB_glTexImage2D)); - __glObj->defineFunction("texParameterf", _SE(JSB_glTexParameterf)); - __glObj->defineFunction("texParameteri", _SE(JSB_glTexParameteri)); - __glObj->defineFunction("texSubImage2D", _SE(JSB_glTexSubImage2D)); - __glObj->defineFunction("uniform1f", _SE(JSB_glUniform1f)); - __glObj->defineFunction("uniform1fv", _SE(JSB_glUniform1fv)); - __glObj->defineFunction("uniform1i", _SE(JSB_glUniform1i)); - __glObj->defineFunction("uniform1iv", _SE(JSB_glUniform1iv)); - __glObj->defineFunction("uniform2f", _SE(JSB_glUniform2f)); - __glObj->defineFunction("uniform2fv", _SE(JSB_glUniform2fv)); - __glObj->defineFunction("uniform2i", _SE(JSB_glUniform2i)); - __glObj->defineFunction("uniform2iv", _SE(JSB_glUniform2iv)); - __glObj->defineFunction("uniform3f", _SE(JSB_glUniform3f)); - __glObj->defineFunction("uniform3fv", _SE(JSB_glUniform3fv)); - __glObj->defineFunction("uniform3i", _SE(JSB_glUniform3i)); - __glObj->defineFunction("uniform3iv", _SE(JSB_glUniform3iv)); - __glObj->defineFunction("uniform4f", _SE(JSB_glUniform4f)); - __glObj->defineFunction("uniform4fv", _SE(JSB_glUniform4fv)); - __glObj->defineFunction("uniform4i", _SE(JSB_glUniform4i)); - __glObj->defineFunction("uniform4iv", _SE(JSB_glUniform4iv)); - __glObj->defineFunction("uniformMatrix2fv", _SE(JSB_glUniformMatrix2fv)); - __glObj->defineFunction("uniformMatrix3fv", _SE(JSB_glUniformMatrix3fv)); - __glObj->defineFunction("uniformMatrix4fv", _SE(JSB_glUniformMatrix4fv)); - __glObj->defineFunction("_useProgram", _SE(JSB_glUseProgram)); - __glObj->defineFunction("_validateProgram", _SE(JSB_glValidateProgram)); - __glObj->defineFunction("vertexAttrib1f", _SE(JSB_glVertexAttrib1f)); - __glObj->defineFunction("vertexAttrib1fv", _SE(JSB_glVertexAttrib1fv)); - __glObj->defineFunction("vertexAttrib2f", _SE(JSB_glVertexAttrib2f)); - __glObj->defineFunction("vertexAttrib2fv", _SE(JSB_glVertexAttrib2fv)); - __glObj->defineFunction("vertexAttrib3f", _SE(JSB_glVertexAttrib3f)); - __glObj->defineFunction("vertexAttrib3fv", _SE(JSB_glVertexAttrib3fv)); - __glObj->defineFunction("vertexAttrib4f", _SE(JSB_glVertexAttrib4f)); - __glObj->defineFunction("vertexAttrib4fv", _SE(JSB_glVertexAttrib4fv)); - __glObj->defineFunction("vertexAttribPointer", _SE(JSB_glVertexAttribPointer)); - __glObj->defineFunction("viewport", _SE(JSB_glViewport)); - __glObj->defineFunction("getParameter", _SE(JSB_glGetParameter)); - __glObj->defineFunction("getShaderPrecisionFormat", _SE(JSB_glGetShaderPrecisionFormat)); - - return true; - -} - diff --git a/native/cocos/scripting/js-bindings/manual/jsb_opengl_registration.hpp b/native/cocos/scripting/js-bindings/manual/jsb_platform.h similarity index 90% rename from native/cocos/scripting/js-bindings/manual/jsb_opengl_registration.hpp rename to native/cocos/scripting/js-bindings/manual/jsb_platform.h index fde1fdc65c..621cecbd87 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_opengl_registration.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_platform.h @@ -25,8 +25,11 @@ #pragma once +#include + namespace se { class Object; } -bool JSB_register_opengl(se::Object* obj); +bool register_platform_bindings(se::Object* obj); +const std::unordered_map& getFontFamilyNameMap(); diff --git a/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp b/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp new file mode 100644 index 0000000000..fcb0ebd9fa --- /dev/null +++ b/native/cocos/scripting/js-bindings/manual/jsb_platform_android.cpp @@ -0,0 +1,66 @@ +#include "jsb_platform.h" + +#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" +#include "cocos/scripting/js-bindings/manual/jsb_global.h" +#include "cocos/platform/CCFileUtils.h" + +#include + +using namespace cocos2d; + +static std::unordered_map _fontFamilyNameMap; + +const std::unordered_map& getFontFamilyNameMap() +{ + return _fontFamilyNameMap; +} + +static bool JSB_loadFont(se::State& s) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc >= 1) { + s.rval().setNull(); + + std::string originalFamilyName; + ok &= seval_to_std_string(args[0], &originalFamilyName); + SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName"); + + std::string source; + ok &= seval_to_std_string(args[1], &source); + SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source"); + + std::string fontFilePath; + std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)"); + std::match_results results; + if (std::regex_search(source.cbegin(), source.cend(), results, re)) + { + fontFilePath = results[1].str(); + } + + fontFilePath = FileUtils::getInstance()->fullPathForFilename(fontFilePath); + if (fontFilePath.empty()) + { + SE_LOGE("Font (%s) doesn't exist!", fontFilePath.c_str()); + return true; + } + + JniHelper::callStaticVoidMethod("org/cocos2dx/lib/CanvasRenderingContext2DImpl", "loadTypeface", originalFamilyName, fontFilePath); + + s.rval().setString(originalFamilyName); + + return true; + } + + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(JSB_loadFont) + +bool register_platform_bindings(se::Object* obj) +{ + __jsbObj->defineFunction("loadFont", _SE(JSB_loadFont)); + return true; +} \ No newline at end of file diff --git a/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm new file mode 100644 index 0000000000..7f8b48cd59 --- /dev/null +++ b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_apple.mm @@ -0,0 +1,147 @@ +#import "jsb_platform.h" + +#include "cocos/scripting/js-bindings/jswrapper/SeApi.h" +#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" +#include "cocos/scripting/js-bindings/manual/jsb_global.h" +#include "cocos/platform/CCFileUtils.h" + +#import +#import +#include + +using namespace cocos2d; + +static std::unordered_map _fontFamilyNameMap; + +const std::unordered_map& getFontFamilyNameMap() +{ + return _fontFamilyNameMap; +} + +static std::vector getAvailableFontFamilyNames() +{ + std::vector ret; + +#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC + CFArrayRef allFamilyNames = CTFontManagerCopyAvailableFontFamilyNames(); +#else + CFArrayRef allFamilyNames = (CFArrayRef) [[UIFont familyNames] retain]; +#endif + + char buf[256] = {0}; + for(CFIndex i = 0; i < CFArrayGetCount(allFamilyNames); i++) + { + CFStringRef fontName = (CFStringRef)CFArrayGetValueAtIndex(allFamilyNames, i); + if (CFStringGetCString(fontName, buf, sizeof(buf), kCFStringEncodingUTF8) != 0) + { + ret.push_back(buf); + } + } + + CFRelease(allFamilyNames); + return ret; +} + +static std::string getFontFamilyByCompareAvailableFontFamilyNames(const std::vector& before, const std::vector& after) +{ + std::string ret; + size_t beforeLen = before.size(); + size_t afterLen = after.size(); + if (afterLen > beforeLen) + { + for (size_t i = 0; i < beforeLen; ++i) + { + if (before[i] != after[i]) + { + ret = after[i]; + break; + } + } + + if (ret.empty()) + ret = after.back(); + } + + return ret; +} + +static bool JSB_loadFont(se::State& s) +{ + const auto& args = s.args(); + size_t argc = args.size(); + CC_UNUSED bool ok = true; + if (argc >= 1) { + s.rval().setNull(); + + std::string originalFamilyName; + ok &= seval_to_std_string(args[0], &originalFamilyName); + SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName"); + + std::string source; + ok &= seval_to_std_string(args[1], &source); + SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source"); + + std::string fontFilePath; + std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)"); + std::match_results results; + if (std::regex_search(source.cbegin(), source.cend(), results, re)) + { + fontFilePath = results[1].str(); + } + + fontFilePath = FileUtils::getInstance()->fullPathForFilename(fontFilePath); + if (fontFilePath.empty()) + { + SE_LOGE("Font (%s) doesn't exist!", fontFilePath.c_str()); + return true; + } + + NSURL* url = [NSURL fileURLWithPath: [NSString stringWithUTF8String:fontFilePath.c_str()]]; + NSData* dynamicFontData = [NSData dataWithContentsOfURL:url]; + if (!dynamicFontData) + { + SE_LOGE("load font (%s) failed!", source.c_str()); + return true; + } + + const auto& familyNamesBeforeRegister = getAvailableFontFamilyNames(); + + bool succeed = true; + CFErrorRef error; + CGDataProviderRef providerRef = CGDataProviderCreateWithCFData((CFDataRef)dynamicFontData); + CGFontRef font = CGFontCreateWithDataProvider(providerRef); + if (!CTFontManagerRegisterGraphicsFont(font, &error)) + { + CFStringRef errorDescription = CFErrorCopyDescription(error); + const char* cErrorStr = CFStringGetCStringPtr(errorDescription, kCFStringEncodingUTF8); + SE_LOGE("Failed to load font: %s", cErrorStr); + CFRelease(errorDescription); + succeed = false; + } + + if (succeed) + { + const auto& familyNamesAfterRegister = getAvailableFontFamilyNames(); + std::string familyName = getFontFamilyByCompareAvailableFontFamilyNames(familyNamesBeforeRegister, familyNamesAfterRegister); + if (!familyName.empty()) + { + _fontFamilyNameMap.emplace(originalFamilyName, familyName); + s.rval().setString(familyName); + } + } + + CFRelease(font); + CFRelease(providerRef); + return true; + } + + SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); + return false; +} +SE_BIND_FUNC(JSB_loadFont) + +bool register_platform_bindings(se::Object* obj) +{ + __jsbObj->defineFunction("loadFont", _SE(JSB_loadFont)); + return true; +} diff --git a/native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.m b/native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.mm similarity index 100% rename from native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.m rename to native/cocos/scripting/js-bindings/manual/jsb_platfrom_ios.mm diff --git a/native/cocos/scripting/js-bindings/script/debugger/DevToolsUtils.js b/native/cocos/scripting/js-bindings/script/debugger/DevToolsUtils.js deleted file mode 100755 index d69f27187d..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/DevToolsUtils.js +++ /dev/null @@ -1,834 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -/* General utilities used throughout devtools. */ - -// var { Ci, Cu, Cc, components } = require("chrome"); -// var Services = require("Services"); -// var promise = require("promise"); - -// loader.lazyRequireGetter(this, "FileUtils", -// "resource://gre/modules/FileUtils.jsm", true); - -function DevToolsUtils() { - -} - -DevToolsUtils.utf16to8 = function utf16to8(str) { - var out, i, len, c; - - out = ""; - len = str.length; - for(i = 0; i < len; i++) - { - c = str.charCodeAt(i); - if ((c >= 0x0001) && (c <= 0x007F)) - { - out += str.charAt(i); - } - else if (c > 0x07FF) - { - out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); - out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); - out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); - } - else - { - out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); - out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); - } - } - return out; -} - -DevToolsUtils.utf8to16 = function utf8to16(str) { - var out, i, len, c; - var char2, char3; - - out = ""; - len = str.length; - i = 0; - while(i < len) { c = str.charCodeAt(i++); switch(c >> 4) - { - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: - // 0xxxxxxx - out += str.charAt(i-1); - break; - case 12: case 13: - // 110x xxxx 10xx xxxx - char2 = str.charCodeAt(i++); - out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); - break; - case 14: - // 1110 xxxx 10xx xxxx 10xx xxxx - char2 = str.charCodeAt(i++); - char3 = str.charCodeAt(i++); - out += String.fromCharCode(((c & 0x0F) << 12) | - ((char2 & 0x3F) << 6) | - ((char3 & 0x3F) << 0)); - break; - } - } - - return out; - } - -/** - * Turn the error |aError| into a string, without fail. - */ -DevToolsUtils.safeErrorString = function safeErrorString(aError) { - try { - let errorString = aError.toString(); - if (typeof errorString == "string") { - // Attempt to attach a stack to |errorString|. If it throws an error, or - // isn't a string, don't use it. - try { - if (aError.stack) { - let stack = aError.stack.toString(); - if (typeof stack == "string") { - errorString += "\nStack: " + stack; - } - } - } catch (ee) { } - - // Append additional line and column number information to the output, - // since it might not be part of the stringified error. - if (typeof aError.lineNumber == "number" && typeof aError.columnNumber == "number") { - errorString += "Line: " + aError.lineNumber + ", column: " + aError.columnNumber; - } - - return errorString; - } - } catch (ee) { } - - // We failed to find a good error description, so do the next best thing. - return Object.prototype.toString.call(aError); -} - -/** - * Report that |aWho| threw an exception, |aException|. - */ -DevToolsUtils.reportException = function reportException(aWho, aException) { - let msg = "" + aWho + " threw an exception: " + DevToolsUtils.safeErrorString(aException); - - log(msg + "\n"); - - // if (Cu && Cu.reportError) { - - // * Note that the xpcshell test harness registers an observer for - // * console messages, so when we're running tests, this will cause - // * the test to quit. - - // Cu.reportError(msg); - // } -} - -/** - * Given a handler function that may throw, return an infallible handler - * function that calls the fallible handler, and logs any exceptions it - * throws. - * - * @param aHandler function - * A handler function, which may throw. - * @param aName string - * A name for aHandler, for use in error messages. If omitted, we use - * aHandler.name. - * - * (SpiderMonkey does generate good names for anonymous functions, but we - * don't have a way to get at them from JavaScript at the moment.) - */ -DevToolsUtils.makeInfallible = function makeInfallible(aHandler, aName) { - if (!aName) - aName = aHandler.name; - - return function (/* arguments */) { - try { - return aHandler.apply(this, arguments); - } catch (ex) { - let who = "Handler function"; - if (aName) { - who += " " + aName; - } - return DevToolsUtils.reportException(who, ex); - } - } -} -/** - * Interleaves two arrays element by element, returning the combined array, like - * a zip. In the case of arrays with different sizes, undefined values will be - * interleaved at the end along with the extra values of the larger array. - * - * @param Array a - * @param Array b - * @returns Array - * The combined array, in the form [a1, b1, a2, b2, ...] - */ -DevToolsUtils.zip = function zip(a, b) { - if (!b) { - return a; - } - if (!a) { - return b; - } - const pairs = []; - for (let i = 0, aLength = a.length, bLength = b.length; - i < aLength || i < bLength; - i++) { - pairs.push([a[i], b[i]]); - } - return pairs; -}; - - -/** - * Converts an object into an array with 2-element arrays as key/value - * pairs of the object. `{ foo: 1, bar: 2}` would become - * `[[foo, 1], [bar 2]]` (order not guaranteed); - * - * @param object obj - * @returns array - */ -DevToolsUtils.entries = function entries(obj) { - return Object.keys(obj).map(k => [k, obj[k]]); -} - -/** - * Composes the given functions into a single function, which will - * apply the results of each function right-to-left, starting with - * applying the given arguments to the right-most function. - * `compose(foo, bar, baz)` === `args => foo(bar(baz(args)` - * - * @param ...function funcs - * @returns function - */ -DevToolsUtils.compose = function compose(...funcs) { - return (...args) => { - const initialValue = funcs[funcs.length - 1].apply(null, args); - const leftFuncs = funcs.slice(0, -1); - return leftFuncs.reduceRight((composed, f) => f(composed), - initialValue); - }; -} - - -/** - * Waits for the next tick in the event loop to execute a callback. - */ -DevToolsUtils.executeSoon = function executeSoon(aFn) { - if (isWorker) { - setImmediate(aFn); - } else { - let executor; - // Only enable async stack reporting when DEBUG_JS_MODULES is set - // (customized local builds) to avoid a performance penalty. - if (AppConstants.DEBUG_JS_MODULES || flags.testing) { - let stack = getStack(); - executor = () => { - callFunctionWithAsyncStack(aFn, stack, "DevToolsUtils.executeSoon"); - }; - } else { - executor = aFn; - } - Services.tm.mainThread.dispatch({ - run: DevToolsUtils.makeInfallible(executor) - }, Ci.nsIThread.DISPATCH_NORMAL); - } -}; - -/** - * Waits for the next tick in the event loop. - * - * @return Promise - * A promise that is resolved after the next tick in the event loop. - */ -DevToolsUtils.waitForTick = function waitForTick() { - let deferred = Promise.defer(); - DevToolsUtils.executeSoon(deferred.resolve); - return deferred.promise; -}; - -/** - * Waits for the specified amount of time to pass. - * - * @param number aDelay - * The amount of time to wait, in milliseconds. - * @return Promise - * A promise that is resolved after the specified amount of time passes. - */ -DevToolsUtils.waitForTime = function waitForTime(aDelay) { - let deferred = Promise.defer(); - require("Timer").setTimeout(deferred.resolve, aDelay); - return deferred.promise; -}; - -/** - * Like Array.prototype.forEach, but doesn't cause jankiness when iterating over - * very large arrays by yielding to the browser and continuing execution on the - * next tick. - * - * @param Array aArray - * The array being iterated over. - * @param Function aFn - * The function called on each item in the array. If a promise is - * returned by this function, iterating over the array will be paused - * until the respective promise is resolved. - * @returns Promise - * A promise that is resolved once the whole array has been iterated - * over, and all promises returned by the aFn callback are resolved. - */ -DevToolsUtils.yieldingEach = function yieldingEach(aArray, aFn) { - const deferred = Promise.defer(); - - let i = 0; - let len = aArray.length; - let outstanding = [deferred.promise]; - - (function loop() { - const start = Date.now(); - - while (i < len) { - // Don't block the main thread for longer than 16 ms at a time. To - // maintain 60fps, you have to render every frame in at least 16ms; we - // aren't including time spent in non-JS here, but this is Good - // Enough(tm). - if (Date.now() - start > 16) { - DevToolsUtils.executeSoon(loop); - return; - } - - try { - outstanding.push(aFn(aArray[i], i++)); - } catch (e) { - deferred.reject(e); - return; - } - } - - deferred.resolve(); - }()); - - return Promise.all(outstanding); -} - -/** - * Like XPCOMUtils.defineLazyGetter, but with a |this| sensitive getter that - * allows the lazy getter to be defined on a prototype and work correctly with - * instances. - * - * @param Object aObject - * The prototype object to define the lazy getter on. - * @param String aKey - * The key to define the lazy getter on. - * @param Function aCallback - * The callback that will be called to determine the value. Will be - * called with the |this| value of the current instance. - */ -DevToolsUtils.defineLazyPrototypeGetter = -function defineLazyPrototypeGetter(aObject, aKey, aCallback) { - Object.defineProperty(aObject, aKey, { - configurable: true, - get: function() { - const value = aCallback.call(this); - - Object.defineProperty(this, aKey, { - configurable: true, - writable: true, - value: value - }); - - return value; - } - }); -} - -/** - * Safely get the property value from a Debugger.Object for a given key. Walks - * the prototype chain until the property is found. - * - * @param Debugger.Object aObject - * The Debugger.Object to get the value from. - * @param String aKey - * The key to look for. - * @return Any - */ -DevToolsUtils.getProperty = function getProperty(aObj, aKey) { - let root = aObj; - try { - do { - const desc = aObj.getOwnPropertyDescriptor(aKey); - if (desc) { - if ("value" in desc) { - return desc.value; - } - // Call the getter if it's safe. - return DevToolsUtils.hasSafeGetter(desc) ? desc.get.call(root).return : undefined; - } - aObj = aObj.proto; - } while (aObj); - } catch (e) { - // If anything goes wrong report the error and return undefined. - DevToolsUtils.reportException("getProperty", e); - } - return undefined; -}; - -/** - * Determines if a descriptor has a getter which doesn't call into JavaScript. - * - * @param Object aDesc - * The descriptor to check for a safe getter. - * @return Boolean - * Whether a safe getter was found. - */ -DevToolsUtils.hasSafeGetter = function hasSafeGetter(aDesc) { - // Scripted functions that are CCWs will not appear scripted until after - // unwrapping. - try { - // let fn = aDesc.get.unwrap(); - let fn = aDesc.get; - return fn && fn.callable && fn.class == "Function" && fn.script === undefined; - } catch (e) { - // Avoid exception 'Object in compartment marked as invisible to Debugger' - return false; - } -}; - -/** - * Check if it is safe to read properties and execute methods from the given JS - * object. Safety is defined as being protected from unintended code execution - * from content scripts (or cross-compartment code). - * - * See bugs 945920 and 946752 for discussion. - * - * @type Object aObj - * The object to check. - * @return Boolean - * True if it is safe to read properties from aObj, or false otherwise. - */ -DevToolsUtils.isSafeJSObject = function isSafeJSObject(aObj) { - return true; - // If we are running on a worker thread, Cu is not available. In this case, - // we always return false, just to be on the safe side. - // if (isWorker) { - // return false; - // } - - // if (Cu.getGlobalForObject(aObj) == - // Cu.getGlobalForObject(DevToolsUtils.isSafeJSObject)) { - // return true; // aObj is not a cross-compartment wrapper. - // } - - // let principal = Cu.getObjectPrincipal(aObj); - // if (Services.scriptSecurityManager.isSystemPrincipal(principal)) { - // return true; // allow chrome objects - // } - - // return Cu.isXrayWrapper(aObj); -}; - -DevToolsUtils.dumpn = function dumpn(str) { - if (DevToolsUtils.dumpn.wantLogging) { - dump("DBG-SERVER: " + str + "\n"); - } -} - -// We want wantLogging to be writable. The DevToolsUtils object is frozen by the -// loader, so define it on dumpn instead. -DevToolsUtils.dumpn.wantLogging = false; - -/** - * A verbose logger for low-level tracing. - */ -DevToolsUtils.dumpv = function(msg) { - if (DevToolsUtils.dumpv.wantVerbose) { - DevToolsUtils.dumpn(msg); - } -}; - -// We want wantLogging to be writable. The DevToolsUtils object is frozen by the -// loader, so define it on dumpn instead. -DevToolsUtils.dumpv.wantVerbose = false; - -DevToolsUtils.assert = function assert(cond, e) { - if (!cond) { - return e; - } -}; - - -/** - * Utility function for updating an object with the properties of - * other objects. - * - * @param aTarget Object - * The object being updated. - * @param aNewAttrs Object - * The rest params are objects to update aTarget with. You - * can pass as many as you like. - */ -DevToolsUtils.update = function update(aTarget, ...aArgs) { - for (let attrs of aArgs) { - for (let key in attrs) { - let desc = Object.getOwnPropertyDescriptor(attrs, key); - - if (desc) { - Object.defineProperty(aTarget, key, desc); - } - } - } - - return aTarget; -} - -/** - * Utility function for getting the values from an object as an array - * - * @param aObject Object - * The object to iterate over - */ -DevToolsUtils.values = function values(aObject) { - return Object.keys(aObject).map(k => aObject[k]); -} - -/** - * Defines a getter on a specified object that will be created upon first use. - * - * @param aObject - * The object to define the lazy getter on. - * @param aName - * The name of the getter to define on aObject. - * @param aLambda - * A function that returns what the getter should return. This will - * only ever be called once. - */ -DevToolsUtils.defineLazyGetter = function defineLazyGetter(aObject, aName, aLambda) { - Object.defineProperty(aObject, aName, { - get: function () { - delete aObject[aName]; - return aObject[aName] = aLambda.apply(aObject); - }, - configurable: true, - enumerable: true - }); -}; - -/** - * Defines a getter on a specified object for a module. The module will not - * be imported until first use. - * - * @param aObject - * The object to define the lazy getter on. - * @param aName - * The name of the getter to define on aObject for the module. - * @param aResource - * The URL used to obtain the module. - * @param aSymbol - * The name of the symbol exported by the module. - * This parameter is optional and defaults to aName. - */ -DevToolsUtils.defineLazyModuleGetter = function defineLazyModuleGetter(aObject, aName, - aResource, - aSymbol) -{ - this.defineLazyGetter(aObject, aName, function XPCU_moduleLambda() { - var temp = {}; - Cu.import(aResource, temp); - return temp[aSymbol || aName]; - }); -}; - -DevToolsUtils.defineLazyGetter(this, "NetUtil", () => { - return Cu.import("resource://gre/modules/NetUtil.jsm", {}).NetUtil; -}); - -DevToolsUtils.defineLazyGetter(this, "OS", () => { - return Cu.import("resource://gre/modules/osfile.jsm", {}).OS; -}); - -DevToolsUtils.defineLazyGetter(this, "TextDecoder", () => { - return Cu.import("resource://gre/modules/osfile.jsm", {}).TextDecoder; -}); - -DevToolsUtils.defineLazyGetter(this, "NetworkHelper", () => { - return require("devtools/shared/webconsole/network-helper"); -}); - -/** - * Performs a request to load the desired URL and returns a promise. - * - * @param aURL String - * The URL we will request. - * @param aOptions Object - * An object with the following optional properties: - * - loadFromCache: if false, will bypass the cache and - * always load fresh from the network (default: true) - * - policy: the nsIContentPolicy type to apply when fetching the URL - * (only works when loading from system principal) - * - window: the window to get the loadGroup from - * - charset: the charset to use if the channel doesn't provide one - * - principal: the principal to use, if omitted, the request is loaded - * with a codebase principal corresponding to the url being - * loaded, using the origin attributes of the window, if any. - * - cacheKey: when loading from cache, use this key to retrieve a cache - * specific to a given SHEntry. (Allows loading POST - * requests from cache) - * @returns Promise that resolves with an object with the following members on - * success: - * - content: the document at that URL, as a string, - * - contentType: the content type of the document - * - * If an error occurs, the promise is rejected with that error. - * - * XXX: It may be better to use nsITraceableChannel to get to the sources - * without relying on caching when we can (not for eval, etc.): - * http://www.softwareishard.com/blog/firebug/nsitraceablechannel-intercept-http-traffic/ - */ -function mainThreadFetch(aURL, aOptions = { loadFromCache: true, - policy: Ci.nsIContentPolicy.TYPE_OTHER, - window: null, - charset: null, - principal: null, - cacheKey: null }) { - // Create a channel. - let url = aURL.split(" -> ").pop(); - let channel; - try { - channel = newChannelForURL(url, aOptions); - } catch (ex) { - return Promise.reject(ex); - } - - // Set the channel options. - channel.loadFlags = aOptions.loadFromCache - ? channel.LOAD_FROM_CACHE - : channel.LOAD_BYPASS_CACHE; - - if (aOptions.window) { - // Respect private browsing. - channel.loadGroup = aOptions.window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocumentLoader) - .loadGroup; - } - - let deferred = Promise.defer(); - let onResponse = (stream, status, request) => { -// if (!components.isSuccessCode(status)) { -// deferred.reject(new Error('Failed to fetch ${url}. Code ${status}.')); -// return; -// } - - try { - // We cannot use NetUtil to do the charset conversion as if charset - // information is not available and our default guess is wrong the method - // might fail and we lose the stream data. This means we can't fall back - // to using the locale default encoding (bug 1181345). - - // Read and decode the data according to the locale default encoding. - let available = stream.available(); - let source = NetUtil.readInputStreamToString(stream, available); - stream.close(); - - // If the channel or the caller has correct charset information, the - // content will be decoded correctly. If we have to fall back to UTF-8 and - // the guess is wrong, the conversion fails and convertToUnicode returns - // the input unmodified. Essentially we try to decode the data as UTF-8 - // and if that fails, we use the locale specific default encoding. This is - // the best we can do if the source does not provide charset info. - let charset = channel.contentCharset || aOptions.charset || "UTF-8"; - let unicodeSource = NetworkHelper.convertToUnicode(source, charset); - - deferred.resolve({ - content: unicodeSource, - contentType: request.contentType - }); - } catch (ex) { - let uri = request.originalURI; - if (ex.name === "NS_BASE_STREAM_CLOSED" && uri instanceof Ci.nsIFileURL) { - // Empty files cause NS_BASE_STREAM_CLOSED exception. Use OS.File to - // differentiate between empty files and other errors (bug 1170864). - // This can be removed when bug 982654 is fixed. - - uri.QueryInterface(Ci.nsIFileURL); - let result = OS.File.read(uri.file.path).then(bytes => { - // Convert the bytearray to a String. - let decoder = new TextDecoder(); - let content = decoder.decode(bytes); - - // We can't detect the contentType without opening a channel - // and that failed already. This is the best we can do here. - return { - content, - contentType: "text/plain" - }; - }); - - deferred.resolve(result); - } else { - deferred.reject(ex); - } - } - }; - - // Open the channel - try { - NetUtil.asyncFetch(channel, onResponse); - } catch (ex) { - return Promise.reject(ex); - } - - return deferred.promise; -} - -/** - * Opens a channel for given URL. Tries a bit harder than NetUtil.newChannel. - * - * @param {String} url - The URL to open a channel for. - * @param {Object} options - The options object passed to @method fetch. - * @return {nsIChannel} - The newly created channel. Throws on failure. - */ -function newChannelForURL(url, { policy }) { - let channelOptions = { - contentPolicyType: policy, - loadUsingSystemPrincipal: true, - uri: url - }; - - try { - return NetUtil.newChannel(channelOptions); - } catch (e) { - // In the xpcshell tests, the script url is the absolute path of the test - // file, which will make a malformed URI error be thrown. Add the file - // scheme to see if it helps. - channelOptions.uri = "file://" + url; - - return NetUtil.newChannel(channelOptions); - } -} - -// Fetch is defined differently depending on whether we are on the main thread -// or a worker thread. -if (!this.isWorker) { - DevToolsUtils.fetch = mainThreadFetch; -} else { - // Services is not available in worker threads, nor is there any other way - // to fetch a URL. We need to enlist the help from the main thread here, by - // issuing an rpc request, to fetch the URL on our behalf. - DevToolsUtils.fetch = function (url, options) { - return rpc("fetch", url, options); - } -} - -/** - * Returns a promise that is resolved or rejected when all promises have settled - * (resolved or rejected). - * - * This differs from Promise.all, which will reject immediately after the first - * rejection, instead of waiting for the remaining promises to settle. - * - * @param values - * Iterable of promises that may be pending, resolved, or rejected. When - * when all promises have settled (resolved or rejected), the returned - * promise will be resolved or rejected as well. - * - * @return A new promise that is fulfilled when all values have settled - * (resolved or rejected). Its resolution value will be an array of all - * resolved values in the given order, or undefined if values is an - * empty array. The reject reason will be forwarded from the first - * promise in the list of given promises to be rejected. - */ -DevToolsUtils.settleAll = values => { - if (values === null || typeof(values[Symbol.iterator]) != "function") { - throw new Error("settleAll() expects an iterable."); - } - - let deferred = Promise.defer(); - - values = Array.isArray(values) ? values : [...values]; - let countdown = values.length; - let resolutionValues = new Array(countdown); - let rejectionValue; - let rejectionOccurred = false; - - if (!countdown) { - deferred.resolve(resolutionValues); - return deferred.promise; - } - - function checkForCompletion() { - if (--countdown > 0) { - return; - } - if (!rejectionOccurred) { - deferred.resolve(resolutionValues); - } else { - deferred.reject(rejectionValue); - } - } - - for (let i = 0; i < values.length; i++) { - let index = i; - let value = values[i]; - let resolver = result => { - resolutionValues[index] = result; - checkForCompletion(); - }; - let rejecter = error => { - if (!rejectionOccurred) { - rejectionValue = error; - rejectionOccurred = true; - } - checkForCompletion(); - }; - - if (value && typeof(value.then) == "function") { - value.then(resolver, rejecter); - } else { - // Given value is not a promise, forward it as a resolution value. - resolver(value); - } - } - - return deferred.promise; -}; - -/** - * When the testing flag is set, various behaviors may be altered from - * production mode, typically to enable easier testing or enhanced debugging. - */ -var testing = false; -Object.defineProperty(DevToolsUtils, "testing", { - get: function() { - return testing; - }, - set: function(state) { - testing = state; - } -}); - -/** - * Open the file at the given path for reading. - * - * @param {String} filePath - * - * @returns Promise - */ -DevToolsUtils.openFileStream = function (filePath) { - return new Promise((resolve, reject) => { - const uri = NetUtil.newURI(new FileUtils.File(filePath)); - NetUtil.asyncFetch( - { uri, loadUsingSystemPrincipal: true }, - (stream, result) => { -// if (!components.isSuccessCode(result)) { -// reject(new Error('Could not open "${filePath}": result = ${result}')); -// return; -// } - - Promise.resolve(stream); - } - ); - }); -} diff --git a/native/cocos/scripting/js-bindings/script/debugger/README.md b/native/cocos/scripting/js-bindings/script/debugger/README.md deleted file mode 100755 index 9e1d7bebd0..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/README.md +++ /dev/null @@ -1,54 +0,0 @@ -Remote Debugging By Using FireFox -================================= - -Requirement ------------ - -* Firefox: From v24 - -How To Use ----------- - -### Prepare ### - -Please refer to https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging . - -### Enable Debugger Support For Your JSB Project ### - -``` -bool AppDelegate::applicationDidFinishLaunching() -{ - ... - - ScriptingCore* sc = ScriptingCore::getInstance(); - sc->addRegisterCallback(register_all_cocos2dx); - sc->addRegisterCallback(register_all_cocos2dx_extension); - sc->addRegisterCallback(register_cocos2dx_js_extensions); - sc->addRegisterCallback(jsb_register_chipmunk); - sc->addRegisterCallback(register_all_cocos2dx_extension_manual); - sc->addRegisterCallback(register_CCBuilderReader); - sc->addRegisterCallback(jsb_register_system); - sc->addRegisterCallback(JSB_register_opengl); - - sc->start(); - -#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) - sc->enableDebugger(); // Enable debugger here -#endif - - ... -} -``` - -Run your game. - -### Open Firefox And Follow The Step As Follows ### - - -![pic 1](https://lh5.googleusercontent.com/-HoxLGBdV2J0/UlZ7ZoFUjyI/AAAAAAAAADM/68GDaCQ1vP0/s0-I/Firefox-Remote-Debug01.jpg) -![pic 2](https://lh6.googleusercontent.com/-7FDIHAYsKAY/UlZ7Yf8W-pI/AAAAAAAAAFQ/joG0AymnuBk/s0-I/Firefox-Remote-Debug02.jpg) -![pic 3](https://lh4.googleusercontent.com/-idvnMRGcGy8/UlZ7Wj6DDuI/AAAAAAAAAC0/L9IVyHLNqeQ/s0-I/Firefox-Remote-Debug04.jpg) -![pic 4](https://lh6.googleusercontent.com/-YuZj7JGAtFE/UlZ9DDGDczI/AAAAAAAAAEQ/D2qIedjP5FU/s0-I/Firefox-Remote-Debug04.png.png) -![pic 5](https://lh3.googleusercontent.com/-cdIcNa3jT5c/UlZ9uapf3OI/AAAAAAAAAEg/MGq3vLHsauw/s0-I/Firefox-Remote-Debug05.png) -![pic 6](https://lh5.googleusercontent.com/-T79-o5ylJKI/UlZ_JJQe3MI/AAAAAAAAAE8/F63fSVxlJKs/s0-I/Firefox-Remote-Debug06.png) - diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/breakpoint.js b/native/cocos/scripting/js-bindings/script/debugger/actors/breakpoint.js deleted file mode 100644 index 758d06d506..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/breakpoint.js +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public -* License, v. 2.0. If a copy of the MPL was not distributed with this -* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const { ActorClassWithSpec } = require("devtools/shared/protocol"); -// const { breakpointSpec } = require("devtools/shared/specs/breakpoint"); - -// from "devtools/shared/specs/breakpoint" -const breakpointSpec = generateActorSpec({ - typeName: "breakpoint", - - methods: { - delete: {} - }, -}); - -// --------------- - -/** - * Set breakpoints on all the given entry points with the given - * BreakpointActor as the handler. - * - * @param BreakpointActor actor - * The actor handling the breakpoint hits. - * @param Array entryPoints - * An array of objects of the form `{ script, offsets }`. - */ -function setBreakpointAtEntryPoints(actor, entryPoints) { - for (let { script, offsets } of entryPoints) { - actor.addScript(script); - for (let offset of offsets) { - script.setBreakpoint(offset, actor); - } - } -} - -// exports.setBreakpointAtEntryPoints = setBreakpointAtEntryPoints; - -/** - * BreakpointActors exist for the lifetime of their containing thread and are - * responsible for deleting breakpoints, handling breakpoint hits and - * associating breakpoints with scripts. - */ -let BreakpointActor = ActorClassWithSpec(breakpointSpec, { - /** - * Create a Breakpoint actor. - * - * @param ThreadActor threadActor - * The parent thread actor that contains this breakpoint. - * @param OriginalLocation originalLocation - * The original location of the breakpoint. - */ - initialize: function (threadActor, originalLocation) { - // The set of Debugger.Script instances that this breakpoint has been set - // upon. - this.scripts = new Set(); - - this.threadActor = threadActor; - this.originalLocation = originalLocation; - this.condition = null; - this.isPending = true; - }, - - disconnect: function () { - this.removeScripts(); - }, - - hasScript: function (script) { - return this.scripts.has(script); - }, - - /** - * Called when this same breakpoint is added to another Debugger.Script - * instance. - * - * @param script Debugger.Script - * The new source script on which the breakpoint has been set. - */ - addScript: function (script) { - this.scripts.add(script); - this.isPending = false; - }, - - /** - * Remove the breakpoints from associated scripts and clear the script cache. - */ - removeScripts: function () { - for (let script of this.scripts) { - script.clearBreakpoint(this); - } - this.scripts.clear(); - }, - - /** - * Check if this breakpoint has a condition that doesn't error and - * evaluates to true in frame. - * - * @param frame Debugger.Frame - * The frame to evaluate the condition in - * @returns Object - * - result: boolean|undefined - * True when the conditional breakpoint should trigger a pause, - * false otherwise. If the condition evaluation failed/killed, - * `result` will be `undefined`. - * - message: string - * If the condition throws, this is the thrown message. - */ - checkCondition: function (frame) { - let completion = frame.eval(this.condition); - if (completion) { - if (completion.throw) { - // The evaluation failed and threw - let message = "Unknown exception"; - try { - if (completion.throw.getOwnPropertyDescriptor) { - message = completion.throw.getOwnPropertyDescriptor("message") - .value; - } else if (completion.toString) { - message = completion.toString(); - } - } catch (ex) {} - return { - result: true, - message: message - }; - } else if (completion.yield) { - assert(false, "Shouldn't ever get yield completions from an eval"); - } else { - return { result: completion.return ? true : false }; - } - } else { - // The evaluation was killed (possibly by the slow script dialog) - return { result: undefined }; - } - }, - - /** - * A function that the engine calls when a breakpoint has been hit. - * - * @param frame Debugger.Frame - * The stack frame that contained the breakpoint. - */ - hit: function (frame) { - // Don't pause if we are currently stepping (in or over) or the frame is - // black-boxed. - let generatedLocation = this.threadActor.sources.getFrameLocation(frame); - let { originalSourceActor } = this.threadActor.unsafeSynchronize( - this.threadActor.sources.getOriginalLocation(generatedLocation)); - let url = originalSourceActor.url; - - if (this.threadActor.sources.isBlackBoxed(url) - || frame.onStep) { - return undefined; - } - - let reason = {}; - - if (this.threadActor._hiddenBreakpoints.has(this.actorID)) { - reason.type = "pauseOnDOMEvents"; - } else if (!this.condition) { - reason.type = "breakpoint"; - // TODO: add the rest of the breakpoints on that line (bug 676602). - reason.actors = [ this.actorID ]; - } else { - let { result, message } = this.checkCondition(frame); - - if (result) { - if (!message) { - reason.type = "breakpoint"; - } else { - reason.type = "breakpointConditionThrown"; - reason.message = message; - } - reason.actors = [ this.actorID ]; - } else { - return undefined; - } - } - return this.threadActor._pauseAndRespond(frame, reason); - }, - - /** - * Handle a protocol request to remove this breakpoint. - */ - delete: function () { - // Remove from the breakpoint store. - if (this.originalLocation) { - this.threadActor.breakpointActorMap.deleteActor(this.originalLocation); - } - this.threadActor.threadLifetimePool.removeActor(this); - // Remove the actual breakpoint from the associated scripts. - this.removeScripts(); - } -}); - -// exports.BreakpointActor = BreakpointActor; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/common.js b/native/cocos/scripting/js-bindings/script/debugger/actors/common.js deleted file mode 100755 index b5312bbd8d..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/common.js +++ /dev/null @@ -1,512 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -/** - * Creates "registered" actors factory meant for creating another kind of - * factories, ObservedActorFactory, during the call to listTabs. - * These factories live in DebuggerServer.{tab|global}ActorFactories. - * - * These actors only exposes: - * - `name` string attribute used to match actors by constructor name - * in DebuggerServer.remove{Global,Tab}Actor. - * - `createObservedActorFactory` function to create "observed" actors factory - * - * @param options object, function - * Either an object or a function. - * If given an object: - * - * If given a function (deprecated): - * Constructor function of an actor. - * The constructor function for this actor type. - * This expects to be called as a constructor (i.e. with 'new'), - * and passed two arguments: the DebuggerServerConnection, and - * the BrowserTabActor with which it will be associated. - * Only used for deprecated eagerly loaded actors. - * - */ -function RegisteredActorFactory(options, prefix) { - // By default the actor name will also be used for the actorID prefix. - this._prefix = prefix; - if (typeof (options) != "function") { - // actors definition registered by actorRegistryActor - if (options.constructorFun) { - this._getConstructor = () => options.constructorFun; - } else { - // Lazy actor definition, where options contains all the information - // required to load the actor lazily. - this._getConstructor = function () { - // Load the module - let mod; - try { - mod = require(options.id); - } catch (e) { - throw new Error("Unable to load actor module '" + options.id + "'.\n" + - e.message + "\n" + e.stack + "\n"); - } - // Fetch the actor constructor - let c = mod[options.constructorName]; - if (!c) { - throw new Error("Unable to find actor constructor named '" + - options.constructorName + "'. (Is it exported?)"); - } - return c; - }; - } - // Exposes `name` attribute in order to allow removeXXXActor to match - // the actor by its actor constructor name. - this.name = options.constructorName; - } else { - // Old actor case, where options is a function that is the actor constructor. - this._getConstructor = () => options; - // Exposes `name` attribute in order to allow removeXXXActor to match - // the actor by its actor constructor name. - this.name = options.name; - - // For old actors, we allow the use of a different prefix for actorID - // than for listTabs actor names, by fetching a prefix on the actor prototype. - // (Used by ChromeDebuggerActor) - if (options.prototype && options.prototype.actorPrefix) { - this._prefix = options.prototype.actorPrefix; - } - } -} -RegisteredActorFactory.prototype.createObservedActorFactory = function (conn, parentActor) { - return new ObservedActorFactory(this._getConstructor, this._prefix, conn, parentActor); -}; -// exports.RegisteredActorFactory = RegisteredActorFactory; - -/** - * Creates "observed" actors factory meant for creating real actor instances. - * These factories lives in actor pools and fake various actor attributes. - * They will be replaced in actor pools by final actor instances during - * the first request for the same actorID from DebuggerServer._getOrCreateActor. - * - * ObservedActorFactory fakes the following actors attributes: - * actorPrefix (string) Used by ActorPool.addActor to compute the actor id - * actorID (string) Set by ActorPool.addActor just after being instantiated - * registeredPool (object) Set by ActorPool.addActor just after being - * instantiated - * And exposes the following method: - * createActor (function) Instantiate an actor that is going to replace - * this factory in the actor pool. - */ -function ObservedActorFactory(getConstructor, prefix, conn, parentActor) { - this._getConstructor = getConstructor; - this._conn = conn; - this._parentActor = parentActor; - - this.actorPrefix = prefix; - - this.actorID = null; - this.registeredPool = null; -} -ObservedActorFactory.prototype.createActor = function () { - // Fetch the actor constructor - let c = this._getConstructor(); - // Instantiate a new actor instance - let instance = new c(this._conn, this._parentActor); - instance.conn = this._conn; - instance.parentID = this._parentActor.actorID; - // We want the newly-constructed actor to completely replace the factory - // actor. Reusing the existing actor ID will make sure ActorPool.addActor - // does the right thing. - instance.actorID = this.actorID; - this.registeredPool.addActor(instance); - return instance; -}; -// exports.ObservedActorFactory = ObservedActorFactory; - - -/** - * Methods shared between RootActor and BrowserTabActor. - */ - -/** - * Populate |this._extraActors| as specified by |aFactories|, reusing whatever - * actors are already there. Add all actors in the final extra actors table to - * |aPool|. - * - * The root actor and the tab actor use this to instantiate actors that other - * parts of the browser have specified with DebuggerServer.addTabActor and - * DebuggerServer.addGlobalActor. - * - * @param aFactories - * An object whose own property names are the names of properties to add to - * some reply packet (say, a tab actor grip or the "listTabs" response - * form), and whose own property values are actor constructor functions, as - * documented for addTabActor and addGlobalActor. - * - * @param this - * The BrowserRootActor or BrowserTabActor with which the new actors will - * be associated. It should support whatever API the |aFactories| - * constructor functions might be interested in, as it is passed to them. - * For the sake of CommonCreateExtraActors itself, it should have at least - * the following properties: - * - * - _extraActors - * An object whose own property names are factory table (and packet) - * property names, and whose values are no-argument actor constructors, - * of the sort that one can add to an ActorPool. - * - * - conn - * The DebuggerServerConnection in which the new actors will participate. - * - * - actorID - * The actor's name, for use as the new actors' parentID. - */ -function createExtraActors(aFactories, aPool) { - // Walk over global actors added by extensions. - for (let name in aFactories) { - let actor = this._extraActors[name]; - if (!actor) { - // Register another factory, but this time specific to this connection. - // It creates a fake actor that looks like an regular actor in the pool, - // but without actually instantiating the actor. - // It will only be instantiated on the first request made to the actor. - actor = aFactories[name].createObservedActorFactory(this.conn, this); - this._extraActors[name] = actor; - } - - // If the actor already exists in the pool, it may have been instantiated, - // so make sure not to overwrite it by a non-instantiated version. - if (!aPool.has(actor.actorID)) { - aPool.addActor(actor); - } - } -}; - -/** - * Append the extra actors in |this._extraActors|, constructed by a prior call - * to CommonCreateExtraActors, to |aObject|. - * - * @param aObject - * The object to which the extra actors should be added, under the - * property names given in the |aFactories| table passed to - * CommonCreateExtraActors. - * - * @param this - * The BrowserRootActor or BrowserTabActor whose |_extraActors| table we - * should use; see above. - */ -function appendExtraActors(aObject) { - for (let name in this._extraActors) { - let actor = this._extraActors[name]; - aObject[name] = actor.actorID; - } -}; - -/** - * Construct an ActorPool. - * - * ActorPools are actorID -> actor mapping and storage. These are - * used to accumulate and quickly dispose of groups of actors that - * share a lifetime. - */ -function ActorPool(aConnection) -{ - this.conn = aConnection; - this._actors = {}; -} - -ActorPool.prototype = { - /** - * Destroy the pool. This will remove all actors from the pool. - */ - destroy: function AP_destroy() { - for (let id in this._actors) { - this.removeActor(this._actors[id]); - } - }, - - /** - * Add an actor to the pool. If the actor doesn't have an ID, allocate one - * from the connection. - * - * @param Object aActor - * The actor to be added to the pool. - */ - addActor: function AP_addActor(aActor) { - aActor.conn = this.conn; - if (!aActor.actorID) { - let prefix = aActor.actorPrefix; - if (!prefix && typeof aActor == "function") { - // typeName is a convention used with protocol.js-based actors - prefix = aActor.prototype.actorPrefix || aActor.prototype.typeName; - } - aActor.actorID = this.conn.allocID(prefix || undefined); - } - - // If the actor is already in a pool, remove it without destroying it. - if (aActor.registeredPool) { - delete aActor.registeredPool._actors[aActor.actorID]; - } - aActor.registeredPool = this; - - this._actors[aActor.actorID] = aActor; - }, - - /** - * Remove an actor from the pool. If the actor has a disconnect method, call - * it. - */ - removeActor: function AP_remove(aActor) { - delete this._actors[aActor.actorID]; - if (aActor.disconnect) { - aActor.disconnect(); - } - }, - - get: function AP_get(aActorID) { - return this._actors[aActorID] || undefined; - }, - - has: function AP_has(aActorID) { - return aActorID in this._actors; - }, - - /** - * Returns true if the pool is empty. - */ - isEmpty: function AP_isEmpty() { - return Object.keys(this._actors).length == 0; - }, - - /** - * Match the api expected by the protocol library. - */ - unmanage: function (aActor) { - return this.removeActor(aActor); - }, - - forEach: function (callback) { - for (let name in this._actors) { - callback(this._actors[name]); - } - }, -}; - -// exports.ActorPool = ActorPool; - -/** - * An OriginalLocation represents a location in an original source. - * - * @param SourceActor actor - * A SourceActor representing an original source. - * @param Number line - * A line within the given source. - * @param Number column - * A column within the given line. - * @param String name - * The name of the symbol corresponding to this OriginalLocation. - */ - -function OriginalLocation(actor, line, column, name) { - this._connection = actor ? actor.conn : null; - this._actorID = actor ? actor.actorID : undefined; - this._line = line; - this._column = column; - this._name = name; -} - -OriginalLocation.fromGeneratedLocation = function (generatedLocation) { - return new OriginalLocation( - generatedLocation.generatedSourceActor, - generatedLocation.generatedLine, - generatedLocation.generatedColumn - ); -}; - -OriginalLocation.prototype = { - get originalSourceActor() { - return this._connection ? this._connection.getActor(this._actorID) : null; - }, - - get originalUrl() { - let actor = this.originalSourceActor; - let source = actor.source; - return source ? source.url : actor._originalUrl; - }, - - get originalLine() { - return this._line; - }, - - get originalColumn() { - return this._column; - }, - - get originalName() { - return this._name; - }, - - get generatedSourceActor() { - throw new Error("Shouldn't access generatedSourceActor from an OriginalLocation"); - }, - - get generatedLine() { - throw new Error("Shouldn't access generatedLine from an OriginalLocation"); - }, - - get generatedColumn() { - throw new Error("Shouldn't access generatedColumn from an Originallocation"); - }, - - equals: function (other) { - return this.originalSourceActor.url == other.originalSourceActor.url && - this.originalLine === other.originalLine && - (this.originalColumn === undefined || - other.originalColumn === undefined || - this.originalColumn === other.originalColumn); - }, - - toJSON: function () { - return { - source: this.originalSourceActor.form(), - line: this.originalLine, - column: this.originalColumn - }; - } -}; - -/** - * A GeneratedLocation represents a location in a generated source. - * - * @param SourceActor actor - * A SourceActor representing a generated source. - * @param Number line - * A line within the given source. - * @param Number column - * A column within the given line. - */ -function GeneratedLocation(actor, line, column, lastColumn) { - this._connection = actor ? actor.conn : null; - this._actorID = actor ? actor.actorID : undefined; - this._line = line; - this._column = column; - this._lastColumn = (lastColumn !== undefined) ? lastColumn : column + 1; -} - -GeneratedLocation.fromOriginalLocation = function (originalLocation) { - return new GeneratedLocation( - originalLocation.originalSourceActor, - originalLocation.originalLine, - originalLocation.originalColumn - ); -}; - -GeneratedLocation.prototype = { - get originalSourceActor() { - throw new Error(); - }, - - get originalUrl() { - throw new Error("Shouldn't access originalUrl from a GeneratedLocation"); - }, - - get originalLine() { - throw new Error("Shouldn't access originalLine from a GeneratedLocation"); - }, - - get originalColumn() { - throw new Error("Shouldn't access originalColumn from a GeneratedLocation"); - }, - - get originalName() { - throw new Error("Shouldn't access originalName from a GeneratedLocation"); - }, - - get generatedSourceActor() { - return this._connection ? this._connection.getActor(this._actorID) : null; - }, - - get generatedLine() { - return this._line; - }, - - get generatedColumn() { - return this._column; - }, - - get generatedLastColumn() { - return this._lastColumn; - }, - - equals: function (other) { - return this.generatedSourceActor.url == other.generatedSourceActor.url && - this.generatedLine === other.generatedLine && - (this.generatedColumn === undefined || - other.generatedColumn === undefined || - this.generatedColumn === other.generatedColumn); - }, - - toJSON: function () { - return { - source: this.generatedSourceActor.form(), - line: this.generatedLine, - column: this.generatedColumn, - lastColumn: this.generatedLastColumn - }; - } -}; - -/** - * A method decorator that ensures the actor is in the expected state before - * proceeding. If the actor is not in the expected state, the decorated method - * returns a rejected promise. - * - * The actor's state must be at this.state property. - * - * @param String expectedState - * The expected state. - * @param String activity - * Additional info about what's going on. - * @param Function method - * The actor method to proceed with when the actor is in the expected - * state. - * - * @returns Function - * The decorated method. - */ -function expectState(expectedState, method, activity) { - return function (...args) { - if (this.state !== expectedState) { - const msg = `Wrong state while ${activity}:` + - `Expected '${expectedState}', ` + - `but current state is '${this.state}'.`; - return Promise.reject(new Error(msg)); - } - - return method.apply(this, args); - }; -} - -/** - * Proxies a call from an actor to an underlying module, stored - * as `bridge` on the actor. This allows a module to be defined in one - * place, usable by other modules/actors on the server, but a separate - * module defining the actor/RDP definition. - * - * @see Framerate implementation: devtools/server/performance/framerate.js - * @see Framerate actor definition: devtools/server/actors/framerate.js - */ -function actorBridge(methodName, definition = {}) { - return method(function () { - return this.bridge[methodName].apply(this.bridge, arguments); - }, definition); -} - -/** - * Like `actorBridge`, but without a spec definition, for when the actor is - * created with `ActorClassWithSpec` rather than vanilla `ActorClass`. - */ -function actorBridgeWithSpec (methodName) { - return method(function () { - return this.bridge[methodName].apply(this.bridge, arguments); - }); -} - diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/environment.js b/native/cocos/scripting/js-bindings/script/debugger/actors/environment.js deleted file mode 100644 index c1dd473578..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/environment.js +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -// const { ActorClassWithSpec } = require("devtools/shared/protocol"); -// const { createValueGrip } = require("devtools/server/actors/object"); -// const { environmentSpec } = require("devtools/shared/specs/environment"); - -// from "devtools/shared/specs/environment" -const environmentSpec = generateActorSpec({ - typeName: "environment", - - methods: { - assign: { - request: { - name: Arg(1), - value: Arg(2) - } - }, - bindings: { - request: {}, - response: { - bindings: RetVal("json") - } - }, - }, -}); - -// ------------ - -/** - * Creates an EnvironmentActor. EnvironmentActors are responsible for listing - * the bindings introduced by a lexical environment and assigning new values to - * those identifier bindings. - * - * @param Debugger.Environment aEnvironment - * The lexical environment that will be used to create the actor. - * @param ThreadActor aThreadActor - * The parent thread actor that contains this environment. - */ -let EnvironmentActor = ActorClassWithSpec(environmentSpec, { - initialize: function (environment, threadActor) { - this.obj = environment; - this.threadActor = threadActor; - }, - - /** - * Return an environment form for use in a protocol message. - */ - form: function () { - let form = { actor: this.actorID }; - - // What is this environment's type? - if (this.obj.type == "declarative") { - form.type = this.obj.callee ? "function" : "block"; - } else { - form.type = this.obj.type; - } - - // Does this environment have a parent? - if (this.obj.parent) { - form.parent = (this.threadActor - .createEnvironmentActor(this.obj.parent, - this.registeredPool) - .form()); - } - - // Does this environment reflect the properties of an object as variables? - if (this.obj.type == "object" || this.obj.type == "with") { - form.object = createValueGrip(this.obj.object, - this.registeredPool, this.threadActor.objectGrip); - } - - // Is this the environment created for a function call? - if (this.obj.callee) { - form.function = createValueGrip(this.obj.callee, - this.registeredPool, this.threadActor.objectGrip); - } - - // Shall we list this environment's bindings? - if (this.obj.type == "declarative") { - form.bindings = this.bindings(); - } - - return form; - }, - - /** - * Handle a protocol request to change the value of a variable bound in this - * lexical environment. - * - * @param string name - * The name of the variable to be changed. - * @param any value - * The value to be assigned. - */ - assign: function (name, value) { - // TODO: enable the commented-out part when getVariableDescriptor lands - // (bug 725815). - /* let desc = this.obj.getVariableDescriptor(name); - - if (!desc.writable) { - return { error: "immutableBinding", - message: "Changing the value of an immutable binding is not " + - "allowed" }; - }*/ - - try { - this.obj.setVariable(name, value); - } catch (e) { - if (e instanceof Debugger.DebuggeeWouldRun) { - throw { - error: "threadWouldRun", - message: "Assigning a value would cause the debuggee to run" - }; - } else { - throw e; - } - } - return { from: this.actorID }; - }, - - /** - * Handle a protocol request to fully enumerate the bindings introduced by the - * lexical environment. - */ - bindings: function () { - let bindings = { arguments: [], variables: {} }; - - // TODO: this part should be removed in favor of the commented-out part - // below when getVariableDescriptor lands (bug 725815). - if (typeof this.obj.getVariable != "function") { - // if (typeof this.obj.getVariableDescriptor != "function") { - return bindings; - } - - let parameterNames; - if (this.obj.callee) { - parameterNames = this.obj.callee.parameterNames; - } else { - parameterNames = []; - } - for (let name of parameterNames) { - let arg = {}; - let value = this.obj.getVariable(name); - - // TODO: this part should be removed in favor of the commented-out part - // below when getVariableDescriptor lands (bug 725815). - let desc = { - value: value, - configurable: false, - writable: !(value && value.optimizedOut), - enumerable: true - }; - - // let desc = this.obj.getVariableDescriptor(name); - let descForm = { - enumerable: true, - configurable: desc.configurable - }; - if ("value" in desc) { - descForm.value = createValueGrip(desc.value, - this.registeredPool, this.threadActor.objectGrip); - descForm.writable = desc.writable; - } else { - descForm.get = createValueGrip(desc.get, this.registeredPool, - this.threadActor.objectGrip); - descForm.set = createValueGrip(desc.set, this.registeredPool, - this.threadActor.objectGrip); - } - arg[name] = descForm; - bindings.arguments.push(arg); - } - - for (let name of this.obj.names()) { - if (bindings.arguments.some(function exists(element) { - return !!element[name]; - })) { - continue; - } - - let value = this.obj.getVariable(name); - - // TODO: this part should be removed in favor of the commented-out part - // below when getVariableDescriptor lands. - let desc = { - value: value, - configurable: false, - writable: !(value && - (value.optimizedOut || - value.uninitialized || - value.missingArguments)), - enumerable: true - }; - - // let desc = this.obj.getVariableDescriptor(name); - let descForm = { - enumerable: true, - configurable: desc.configurable - }; - if ("value" in desc) { - descForm.value = createValueGrip(desc.value, - this.registeredPool, this.threadActor.objectGrip); - descForm.writable = desc.writable; - } else { - descForm.get = createValueGrip(desc.get || undefined, - this.registeredPool, this.threadActor.objectGrip); - descForm.set = createValueGrip(desc.set || undefined, - this.registeredPool, this.threadActor.objectGrip); - } - bindings.variables[name] = descForm; - } - - return bindings; - } -}); - -// exports.EnvironmentActor = EnvironmentActor; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/frame.js b/native/cocos/scripting/js-bindings/script/debugger/actors/frame.js deleted file mode 100644 index 06cc2f584d..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/frame.js +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const { ActorPool } = require("devtools/server/actors/common"); -// const { createValueGrip } = require("devtools/server/actors/object"); -// const { ActorClassWithSpec } = require("devtools/shared/protocol"); -// const { frameSpec } = require("devtools/shared/specs/frame"); - -// from "devtools/shared/specs/frame" -const frameSpec = generateActorSpec({ - typeName: "frame", - - methods: {}, -}); - -// -------------- - -/** - * An actor for a specified stack frame. - */ -let FrameActor = ActorClassWithSpec(frameSpec, { - /** - * Creates the Frame actor. - * - * @param frame Debugger.Frame - * The debuggee frame. - * @param threadActor ThreadActor - * The parent thread actor for this frame. - */ - initialize: function (frame, threadActor) { - this.frame = frame; - this.threadActor = threadActor; - }, - - /** - * A pool that contains frame-lifetime objects, like the environment. - */ - _frameLifetimePool: null, - get frameLifetimePool() { - if (!this._frameLifetimePool) { - this._frameLifetimePool = new ActorPool(this.conn); - this.conn.addActorPool(this._frameLifetimePool); - } - return this._frameLifetimePool; - }, - - /** - * Finalization handler that is called when the actor is being evicted from - * the pool. - */ - disconnect: function () { - this.conn.removeActorPool(this._frameLifetimePool); - this._frameLifetimePool = null; - }, - - /** - * Returns a frame form for use in a protocol message. - */ - form: function () { - let threadActor = this.threadActor; - let form = { actor: this.actorID, - type: this.frame.type }; - if (this.frame.type === "call") { - form.callee = createValueGrip(this.frame.callee, threadActor._pausePool, - threadActor.objectGrip); - } - - if (this.frame.environment) { - let envActor = threadActor.createEnvironmentActor( - this.frame.environment, - this.frameLifetimePool - ); - form.environment = envActor.form(); - } - form.this = createValueGrip(this.frame.this, threadActor._pausePool, - threadActor.objectGrip); - form.arguments = this._args(); - if (this.frame.script) { - var generatedLocation = this.threadActor.sources.getFrameLocation(this.frame); - form.where = { - source: generatedLocation.generatedSourceActor.form(), - line: generatedLocation.generatedLine, - column: generatedLocation.generatedColumn - }; - } - - if (!this.frame.older) { - form.oldest = true; - } - - return form; - }, - - _args: function () { - if (!this.frame.arguments) { - return []; - } - - return this.frame.arguments.map(arg => createValueGrip(arg, - this.threadActor._pausePool, this.threadActor.objectGrip)); - } -}); - -// exports.FrameActor = FrameActor; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/object.js b/native/cocos/scripting/js-bindings/script/debugger/actors/object.js deleted file mode 100755 index a7085082d1..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/object.js +++ /dev/null @@ -1,2250 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const { Cu, Ci } = require("chrome"); -// const { GeneratedLocation } = require("devtools/server/actors/common"); -// const { DebuggerServer } = require("devtools/server/main"); -// const DevToolsUtils = require("devtools/shared/DevToolsUtils"); -// const { assert, dumpn } = DevToolsUtils; -// const PromiseDebugging = require("PromiseDebugging"); - -const TYPED_ARRAY_CLASSES = ["Uint8Array", "Uint8ClampedArray", "Uint16Array", - "Uint32Array", "Int8Array", "Int16Array", "Int32Array", "Float32Array", - "Float64Array"]; - -// Number of items to preview in objects, arrays, maps, sets, lists, -// collections, etc. -const OBJECT_PREVIEW_MAX_ITEMS = 10; - -/** - * Creates an actor for the specified object. - * - * @param obj Debugger.Object - * The debuggee object. - * @param hooks Object - * A collection of abstract methods that are implemented by the caller. - * ObjectActor requires the following functions to be implemented by - * the caller: - * - createValueGrip - * Creates a value grip for the given object - * - sources - * TabSources getter that manages the sources of a thread - * - createEnvironmentActor - * Creates and return an environment actor - * - getGripDepth - * An actor's grip depth getter - * - incrementGripDepth - * Increment the actor's grip depth - * - decrementGripDepth - * Decrement the actor's grip depth - * - globalDebugObject - * The Debuggee Global Object as given by the ThreadActor - */ -function ObjectActor(obj, { - createValueGrip, - sources, - createEnvironmentActor, - getGripDepth, - incrementGripDepth, - decrementGripDepth, - getGlobalDebugObject -}) { - assert(!obj.optimizedOut, - "Should not create object actors for optimized out values!"); - this.obj = obj; - this.hooks = { - createValueGrip, - sources, - createEnvironmentActor, - getGripDepth, - incrementGripDepth, - decrementGripDepth, - getGlobalDebugObject - }; - this.iterators = new Set(); -} - -ObjectActor.prototype = { - actorPrefix: "obj", - - /** - * Returns a grip for this actor for returning in a protocol message. - */ - grip: function () { - this.hooks.incrementGripDepth(); - - let g = { - "type": "object", - "actor": this.actorID - }; - - // If it's a proxy, lie and tell that it belongs to an invented - // "Proxy" class, and avoid calling the [[IsExtensible]] trap - if(this.obj.isProxy) { - g.class = "Proxy"; - g.proxyTarget = this.hooks.createValueGrip(this.obj.proxyTarget); - g.proxyHandler = this.hooks.createValueGrip(this.obj.proxyHandler); - } else { - g.class = this.obj.class; - g.extensible = this.obj.isExtensible(); - g.frozen = this.obj.isFrozen(); - g.sealed = this.obj.isSealed(); - } - - if (g.class != "DeadObject") { - if (g.class == "Promise") { - g.promiseState = this._createPromiseState(); - } - - // FF40+: Allow to know how many properties an object has - // to lazily display them when there is a bunch. - // Throws on some MouseEvent object in tests. - try { - // Bug 1163520: Assert on internal functions - if (!["Function", "Proxy"].includes(g.class)) { - g.ownPropertyLength = this.obj.getOwnPropertyNames().length; - } - } catch (e) {} - - let raw = this.obj.unsafeDereference(); - - // If Cu is not defined, we are running on a worker thread, where xrays - // don't exist. - // if (Cu) { - // raw = Cu.unwaiveXrays(raw); - // } - - if (!DevToolsUtils.isSafeJSObject(raw)) { - raw = null; - } - - // let previewers = DebuggerServer.ObjectActorPreviewers[g.class] || - // DebuggerServer.ObjectActorPreviewers.Object; - // for (let fn of previewers) { - // try { - // if (fn(this, g, raw)) { - // break; - // } - // } catch (e) { - // let msg = "ObjectActor.prototype.grip previewer function"; - // DevToolsUtils.reportException(msg, e); - // } - // } - } - - this.hooks.decrementGripDepth(); - return g; - }, - - /** - * Returns an object exposing the internal Promise state. - */ - _createPromiseState: function () { - const { state, value, reason } = getPromiseState(this.obj); - let promiseState = { state }; - - if (state == "fulfilled") { - promiseState.value = this.hooks.createValueGrip(value); - } else if (state == "rejected") { - promiseState.reason = this.hooks.createValueGrip(reason); - } - - promiseState.creationTimestamp = Date.now() - this.obj.promiseLifetime; - - // Only add the timeToSettle property if the Promise isn't pending. - if (state !== "pending") { - promiseState.timeToSettle = this.obj.promiseTimeToResolution; - } - - return promiseState; - }, - - /** - * Releases this actor from the pool. - */ - release: function () { - if (this.registeredPool.objectActors) { - this.registeredPool.objectActors.delete(this.obj); - } - this.iterators.forEach(actor => this.registeredPool.removeActor(actor)); - this.iterators.clear(); - this.registeredPool.removeActor(this); - }, - - /** - * Handle a protocol request to provide the definition site of this function - * object. - */ - onDefinitionSite: function () { - if (this.obj.class != "Function") { - return { - from: this.actorID, - error: "objectNotFunction", - message: this.actorID + " is not a function." - }; - } - - if (!this.obj.script) { - return { - from: this.actorID, - error: "noScript", - message: this.actorID + " has no Debugger.Script" - }; - } - - return this.hooks.sources().getOriginalLocation(new GeneratedLocation( - this.hooks.sources().createNonSourceMappedActor(this.obj.script.source), - this.obj.script.startLine, - 0 // TODO bug 901138: use Debugger.Script.prototype.startColumn - )).then((originalLocation) => { - return { - source: originalLocation.originalSourceActor.form(), - line: originalLocation.originalLine, - column: originalLocation.originalColumn - }; - }); - }, - - /** - * Handle a protocol request to provide the names of the properties defined on - * the object and not its prototype. - */ - onOwnPropertyNames: function () { - return { from: this.actorID, - ownPropertyNames: this.obj.getOwnPropertyNames() }; - }, - - /** - * Creates an actor to iterate over an object property names and values. - * See PropertyIteratorActor constructor for more info about options param. - * - * @param request object - * The protocol request object. - */ - onEnumProperties: function (request) { - let actor = new PropertyIteratorActor(this, request.options); - this.registeredPool.addActor(actor); - this.iterators.add(actor); - return { iterator: actor.grip() }; - }, - - /** - * Creates an actor to iterate over entries of a Map/Set-like object. - */ - onEnumEntries: function () { - let actor = new PropertyIteratorActor(this, { enumEntries: true }); - this.registeredPool.addActor(actor); - this.iterators.add(actor); - return { iterator: actor.grip() }; - }, - - /** - * Handle a protocol request to provide the prototype and own properties of - * the object. - */ - onPrototypeAndProperties: function () { - let ownProperties = Object.create(null); - let names; - try { - names = this.obj.getOwnPropertyNames(); - } catch (ex) { - // The above can throw if this.obj points to a dead object. - // TODO: we should use Cu.isDeadWrapper() - see bug 885800. - return { from: this.actorID, - prototype: this.hooks.createValueGrip(null), - ownProperties: ownProperties, - safeGetterValues: Object.create(null) }; - } - for (let name of names) { - ownProperties[name] = this._propertyDescriptor(name); - } - return { from: this.actorID, - prototype: this.hooks.createValueGrip(this.obj.proto), - ownProperties: ownProperties, - safeGetterValues: this._findSafeGetterValues(names) }; - }, - - /** - * Find the safe getter values for the current Debugger.Object, |this.obj|. - * - * @private - * @param array ownProperties - * The array that holds the list of known ownProperties names for - * |this.obj|. - * @param number [limit=0] - * Optional limit of getter values to find. - * @return object - * An object that maps property names to safe getter descriptors as - * defined by the remote debugging protocol. - */ - _findSafeGetterValues: function (ownProperties, limit = 0) { - let safeGetterValues = Object.create(null); - let obj = this.obj; - let level = 0, i = 0; - - // Most objects don't have any safe getters but inherit some from their - // prototype. Avoid calling getOwnPropertyNames on objects that may have - // many properties like Array, strings or js objects. That to avoid - // freezing firefox when doing so. - if (TYPED_ARRAY_CLASSES.includes(this.obj.class) || - ["Array", "Object", "String"].includes(this.obj.class)) { - obj = obj.proto; - level++; - } - - while (obj) { - let getters = this._findSafeGetters(obj); - for (let name of getters) { - // Avoid overwriting properties from prototypes closer to this.obj. Also - // avoid providing safeGetterValues from prototypes if property |name| - // is already defined as an own property. - if (name in safeGetterValues || - (obj != this.obj && ownProperties.indexOf(name) !== -1)) { - continue; - } - - // Ignore __proto__ on Object.prototye. - if (!obj.proto && name == "__proto__") { - continue; - } - - let desc = null, getter = null; - try { - desc = obj.getOwnPropertyDescriptor(name); - getter = desc.get; - } catch (ex) { - // The above can throw if the cache becomes stale. - } - if (!getter) { - obj._safeGetters = null; - continue; - } - - let result = getter.call(this.obj); - if (result && !("throw" in result)) { - let getterValue = undefined; - if ("return" in result) { - getterValue = result.return; - } else if ("yield" in result) { - getterValue = result.yield; - } - // WebIDL attributes specified with the LenientThis extended attribute - // return undefined and should be ignored. - if (getterValue !== undefined) { - safeGetterValues[name] = { - getterValue: this.hooks.createValueGrip(getterValue), - getterPrototypeLevel: level, - enumerable: desc.enumerable, - writable: level == 0 ? desc.writable : true, - }; - if (limit && ++i == limit) { - break; - } - } - } - } - if (limit && i == limit) { - break; - } - - obj = obj.proto; - level++; - } - - return safeGetterValues; - }, - - /** - * Find the safe getters for a given Debugger.Object. Safe getters are native - * getters which are safe to execute. - * - * @private - * @param Debugger.Object object - * The Debugger.Object where you want to find safe getters. - * @return Set - * A Set of names of safe getters. This result is cached for each - * Debugger.Object. - */ - _findSafeGetters: function (object) { - if (object._safeGetters) { - return object._safeGetters; - } - - let getters = new Set(); - let names = []; - try { - names = object.getOwnPropertyNames(); - } catch (ex) { - // Calling getOwnPropertyNames() on some wrapped native prototypes is not - // allowed: "cannot modify properties of a WrappedNative". See bug 952093. - } - - for (let name of names) { - let desc = null; - try { - desc = object.getOwnPropertyDescriptor(name); - } catch (e) { - // Calling getOwnPropertyDescriptor on wrapped native prototypes is not - // allowed (bug 560072). - } - if (!desc || desc.value !== undefined || !("get" in desc)) { - continue; - } - - if (DevToolsUtils.hasSafeGetter(desc)) { - getters.add(name); - } - } - - object._safeGetters = getters; - return getters; - }, - - /** - * Handle a protocol request to provide the prototype of the object. - */ - onPrototype: function () { - return { from: this.actorID, - prototype: this.hooks.createValueGrip(this.obj.proto) }; - }, - - /** - * Handle a protocol request to provide the property descriptor of the - * object's specified property. - * - * @param request object - * The protocol request object. - */ - onProperty: function (request) { - if (!request.name) { - return { error: "missingParameter", - message: "no property name was specified" }; - } - - return { from: this.actorID, - descriptor: this._propertyDescriptor(request.name) }; - }, - - /** - * Handle a protocol request to provide the display string for the object. - */ - onDisplayString: function () { - const string = stringify(this.obj); - return { from: this.actorID, - displayString: this.hooks.createValueGrip(string) }; - }, - - /** - * A helper method that creates a property descriptor for the provided object, - * properly formatted for sending in a protocol response. - * - * @private - * @param string name - * The property that the descriptor is generated for. - * @param boolean [onlyEnumerable] - * Optional: true if you want a descriptor only for an enumerable - * property, false otherwise. - * @return object|undefined - * The property descriptor, or undefined if this is not an enumerable - * property and onlyEnumerable=true. - */ - _propertyDescriptor: function (name, onlyEnumerable) { - let desc; - try { - desc = this.obj.getOwnPropertyDescriptor(name); - } catch (e) { - // Calling getOwnPropertyDescriptor on wrapped native prototypes is not - // allowed (bug 560072). Inform the user with a bogus, but hopefully - // explanatory, descriptor. - return { - configurable: false, - writable: false, - enumerable: false, - value: e.name - }; - } - - if (!desc || onlyEnumerable && !desc.enumerable) { - return undefined; - } - - let retval = { - configurable: desc.configurable, - enumerable: desc.enumerable - }; - - if ("value" in desc) { - retval.writable = desc.writable; - retval.value = this.hooks.createValueGrip(desc.value); - } else { - if ("get" in desc) { - retval.get = this.hooks.createValueGrip(desc.get); - } - if ("set" in desc) { - retval.set = this.hooks.createValueGrip(desc.set); - } - } - return retval; - }, - - /** - * Handle a protocol request to provide the source code of a function. - * - * @param request object - * The protocol request object. - */ - onDecompile: function (request) { - if (this.obj.class !== "Function") { - return { error: "objectNotFunction", - message: "decompile request is only valid for object grips " + - "with a 'Function' class." }; - } - - return { from: this.actorID, - decompiledCode: this.obj.decompile(!!request.pretty) }; - }, - - /** - * Handle a protocol request to provide the parameters of a function. - */ - onParameterNames: function () { - if (this.obj.class !== "Function") { - return { error: "objectNotFunction", - message: "'parameterNames' request is only valid for object " + - "grips with a 'Function' class." }; - } - - return { parameterNames: this.obj.parameterNames }; - }, - - /** - * Handle a protocol request to release a thread-lifetime grip. - */ - onRelease: function () { - this.release(); - return {}; - }, - - /** - * Handle a protocol request to provide the lexical scope of a function. - */ - onScope: function () { - if (this.obj.class !== "Function") { - return { error: "objectNotFunction", - message: "scope request is only valid for object grips with a" + - " 'Function' class." }; - } - - let envActor = this.hooks.createEnvironmentActor(this.obj.environment, - this.registeredPool); - if (!envActor) { - return { error: "notDebuggee", - message: "cannot access the environment of this function." }; - } - - return { from: this.actorID, scope: envActor.form() }; - }, - - /** - * Handle a protocol request to get the list of dependent promises of a - * promise. - * - * @return object - * Returns an object containing an array of object grips of the - * dependent promises - */ - onDependentPromises: function () { - if (this.obj.class != "Promise") { - return { error: "objectNotPromise", - message: "'dependentPromises' request is only valid for " + - "object grips with a 'Promise' class." }; - } - - let promises = this.obj.promiseDependentPromises.map(p => this.hooks.createValueGrip(p)); - - return { promises }; - }, - - /** - * Handle a protocol request to get the allocation stack of a promise. - */ - onAllocationStack: function () { - if (this.obj.class != "Promise") { - return { error: "objectNotPromise", - message: "'allocationStack' request is only valid for " + - "object grips with a 'Promise' class." }; - } - - let stack = this.obj.promiseAllocationSite; - let allocationStacks = []; - - while (stack) { - if (stack.source) { - let source = this._getSourceOriginalLocation(stack); - - if (source) { - allocationStacks.push(source); - } - } - stack = stack.parent; - } - - return Promise.all(allocationStacks).then(stacks => { - return { allocationStack: stacks }; - }); - }, - - /** - * Handle a protocol request to get the fulfillment stack of a promise. - */ - onFulfillmentStack: function () { - if (this.obj.class != "Promise") { - return { error: "objectNotPromise", - message: "'fulfillmentStack' request is only valid for " + - "object grips with a 'Promise' class." }; - } - - let stack = this.obj.promiseResolutionSite; - let fulfillmentStacks = []; - - while (stack) { - if (stack.source) { - let source = this._getSourceOriginalLocation(stack); - - if (source) { - fulfillmentStacks.push(source); - } - } - stack = stack.parent; - } - - return Promise.all(fulfillmentStacks).then(stacks => { - return { fulfillmentStack: stacks }; - }); - }, - - /** - * Handle a protocol request to get the rejection stack of a promise. - */ - onRejectionStack: function () { - if (this.obj.class != "Promise") { - return { error: "objectNotPromise", - message: "'rejectionStack' request is only valid for " + - "object grips with a 'Promise' class." }; - } - - let stack = this.obj.promiseResolutionSite; - let rejectionStacks = []; - - while (stack) { - if (stack.source) { - let source = this._getSourceOriginalLocation(stack); - - if (source) { - rejectionStacks.push(source); - } - } - stack = stack.parent; - } - - return Promise.all(rejectionStacks).then(stacks => { - return { rejectionStack: stacks }; - }); - }, - - /** - * Helper function for fetching the source location of a SavedFrame stack. - * - * @param SavedFrame stack - * The promise allocation stack frame - * @return object - * Returns an object containing the source location of the SavedFrame - * stack. - */ - _getSourceOriginalLocation: function (stack) { - let source; - - // Catch any errors if the source actor cannot be found - try { - source = this.hooks.sources().getSourceActorByURL(stack.source); - } catch (e) {} - - if (!source) { - return null; - } - - return this.hooks.sources().getOriginalLocation(new GeneratedLocation( - source, - stack.line, - stack.column - )).then((originalLocation) => { - return { - source: originalLocation.originalSourceActor.form(), - line: originalLocation.originalLine, - column: originalLocation.originalColumn, - functionDisplayName: stack.functionDisplayName - }; - }); - } -}; - -ObjectActor.prototype.requestTypes = { - "definitionSite": ObjectActor.prototype.onDefinitionSite, - "parameterNames": ObjectActor.prototype.onParameterNames, - "prototypeAndProperties": ObjectActor.prototype.onPrototypeAndProperties, - "enumProperties": ObjectActor.prototype.onEnumProperties, - "prototype": ObjectActor.prototype.onPrototype, - "property": ObjectActor.prototype.onProperty, - "displayString": ObjectActor.prototype.onDisplayString, - "ownPropertyNames": ObjectActor.prototype.onOwnPropertyNames, - "decompile": ObjectActor.prototype.onDecompile, - "release": ObjectActor.prototype.onRelease, - "scope": ObjectActor.prototype.onScope, - "dependentPromises": ObjectActor.prototype.onDependentPromises, - "allocationStack": ObjectActor.prototype.onAllocationStack, - "fulfillmentStack": ObjectActor.prototype.onFulfillmentStack, - "rejectionStack": ObjectActor.prototype.onRejectionStack, - "enumEntries": ObjectActor.prototype.onEnumEntries, -}; - -/** - * Creates an actor to iterate over an object's property names and values. - * - * @param objectActor ObjectActor - * The object actor. - * @param options Object - * A dictionary object with various boolean attributes: - * - enumEntries Boolean - * If true, enumerates the entries of a Map or Set object - * instead of enumerating properties. - * - ignoreIndexedProperties Boolean - * If true, filters out Array items. - * e.g. properties names between `0` and `object.length`. - * - ignoreNonIndexedProperties Boolean - * If true, filters out items that aren't array items - * e.g. properties names that are not a number between `0` - * and `object.length`. - * - sort Boolean - * If true, the iterator will sort the properties by name - * before dispatching them. - * - query String - * If non-empty, will filter the properties by names and values - * containing this query string. The match is not case-sensitive. - * Regarding value filtering it just compare to the stringification - * of the property value. - */ -function PropertyIteratorActor(objectActor, options) { - if (options.enumEntries) { - let cls = objectActor.obj.class; - if (cls == "Map") { - this.iterator = enumMapEntries(objectActor); - } else if (cls == "WeakMap") { - this.iterator = enumWeakMapEntries(objectActor); - } else if (cls == "Set") { - this.iterator = enumSetEntries(objectActor); - } else if (cls == "WeakSet") { - this.iterator = enumWeakSetEntries(objectActor); - } else { - throw new Error("Unsupported class to enumerate entries from: " + cls); - } - } else if (options.ignoreNonIndexedProperties && !options.query) { - this.iterator = enumArrayProperties(objectActor, options); - } else { - this.iterator = enumObjectProperties(objectActor, options); - } -} - -PropertyIteratorActor.prototype = { - actorPrefix: "propertyIterator", - - grip() { - return { - type: this.actorPrefix, - actor: this.actorID, - count: this.iterator.size - }; - }, - - names({ indexes }) { - let list = []; - for (let idx of indexes) { - list.push(this.iterator.propertyName(idx)); - } - return { - names: indexes - }; - }, - - slice({ start, count }) { - let ownProperties = Object.create(null); - for (let i = start, m = start + count; i < m; i++) { - let name = this.iterator.propertyName(i); - ownProperties[name] = this.iterator.propertyDescription(i); - } - return { - ownProperties - }; - }, - - all() { - return this.slice({ start: 0, count: this.length }); - } -}; - -PropertyIteratorActor.prototype.requestTypes = { - "names": PropertyIteratorActor.prototype.names, - "slice": PropertyIteratorActor.prototype.slice, - "all": PropertyIteratorActor.prototype.all, -}; - -function enumArrayProperties(objectActor, options) { - let length = DevToolsUtils.getProperty(objectActor.obj, "length"); - if (typeof length !== "number") { - // Pseudo arrays are flagged as ArrayLike if they have - // subsequent indexed properties without having any length attribute. - length = 0; - let names = objectActor.obj.getOwnPropertyNames(); - for (let key of names) { - if (isNaN(key) || key != length++) { - break; - } - } - } - - return { - size: length, - propertyName(index) { - return index; - }, - propertyDescription(index) { - return objectActor._propertyDescriptor(index); - } - }; -} - -function enumObjectProperties(objectActor, options) { - let names = []; - try { - names = objectActor.obj.getOwnPropertyNames(); - } catch (ex) { - // Calling getOwnPropertyNames() on some wrapped native prototypes is not - // allowed: "cannot modify properties of a WrappedNative". See bug 952093. - } - - if (options.ignoreNonIndexedProperties || options.ignoreIndexedProperties) { - let length = DevToolsUtils.getProperty(objectActor.obj, "length"); - if (typeof length !== "number") { - // Pseudo arrays are flagged as ArrayLike if they have - // subsequent indexed properties without having any length attribute. - length = 0; - for (let key of names) { - if (isNaN(key) || key != length++) { - break; - } - } - } - - // It appears that getOwnPropertyNames always returns indexed properties - // first, so we can safely slice `names` for/against indexed properties. - // We do such clever operation to optimize very large array inspection, - // like webaudio buffers. - if (options.ignoreIndexedProperties) { - // Keep items after `length` index - names = names.slice(length); - } else if (options.ignoreNonIndexedProperties) { - // Remove `length` first items - names.splice(length); - } - } - - let safeGetterValues = objectActor._findSafeGetterValues(names, 0); - let safeGetterNames = Object.keys(safeGetterValues); - // Merge the safe getter values into the existing properties list. - for (let name of safeGetterNames) { - if (!names.includes(name)) { - names.push(name); - } - } - - if (options.query) { - let { query } = options; - query = query.toLowerCase(); - names = names.filter(name => { - // Filter on attribute names - if (name.toLowerCase().includes(query)) { - return true; - } - // and then on attribute values - let desc; - try { - desc = objectActor.obj.getOwnPropertyDescriptor(name); - } catch (e) { - // Calling getOwnPropertyDescriptor on wrapped native prototypes is not - // allowed (bug 560072). - } - if (desc && desc.value && - String(desc.value).includes(query)) { - return true; - } - return false; - }); - } - - if (options.sort) { - names.sort(); - } - - return { - size: names.length, - propertyName(index) { - return names[index]; - }, - propertyDescription(index) { - let name = names[index]; - let desc = objectActor._propertyDescriptor(name); - if (!desc) { - desc = safeGetterValues[name]; - } else if (name in safeGetterValues) { - // Merge the safe getter values into the existing properties list. - let { getterValue, getterPrototypeLevel } = safeGetterValues[name]; - desc.getterValue = getterValue; - desc.getterPrototypeLevel = getterPrototypeLevel; - } - return desc; - } - }; -} - -/** - * Helper function to create a grip from a Map/Set entry - */ -function gripFromEntry({ obj, hooks }, entry) { - return hooks.createValueGrip( - makeDebuggeeValueIfNeeded(obj, Cu.unwaiveXrays(entry))); -} - -function enumMapEntries(objectActor) { - // Iterating over a Map via .entries goes through various intermediate - // objects - an Iterator object, then a 2-element Array object, then the - // actual values we care about. We don't have Xrays to Iterator objects, - // so we get Opaque wrappers for them. And even though we have Xrays to - // Arrays, the semantics often deny access to the entires based on the - // nature of the values. So we need waive Xrays for the iterator object - // and the tupes, and then re-apply them on the underlying values until - // we fix bug 1023984. - // - // Even then though, we might want to continue waiving Xrays here for the - // same reason we do so for Arrays above - this filtering behavior is likely - // to be more confusing than beneficial in the case of Object previews. - let raw = objectActor.obj.unsafeDereference(); - - let keys = [...Cu.waiveXrays(Map.prototype.keys.call(raw))]; - return { - [Symbol.iterator]: function* () { - for (let key of keys) { - let value = Map.prototype.get.call(raw, key); - yield [ key, value ].map(val => gripFromEntry(objectActor, val)); - } - }, - size: keys.length, - propertyName(index) { - return index; - }, - propertyDescription(index) { - let key = keys[index]; - let val = Map.prototype.get.call(raw, key); - return { - enumerable: true, - value: { - type: "mapEntry", - preview: { - key: gripFromEntry(objectActor, key), - value: gripFromEntry(objectActor, val) - } - } - }; - } - }; -} - -function enumWeakMapEntries(objectActor) { - // We currently lack XrayWrappers for WeakMap, so when we iterate over - // the values, the temporary iterator objects get created in the target - // compartment. However, we _do_ have Xrays to Object now, so we end up - // Xraying those temporary objects, and filtering access to |it.value| - // based on whether or not it's Xrayable and/or callable, which breaks - // the for/of iteration. - // - // This code is designed to handle untrusted objects, so we can safely - // waive Xrays on the iterable, and relying on the Debugger machinery to - // make sure we handle the resulting objects carefully. - let raw = objectActor.obj.unsafeDereference(); - let keys = Cu.waiveXrays( - ThreadSafeChromeUtils.nondeterministicGetWeakMapKeys(raw)); - - return { - [Symbol.iterator]: function* () { - for (let key of keys) { - let value = WeakMap.prototype.get.call(raw, key); - yield [ key, value ].map(val => gripFromEntry(objectActor, val)); - } - }, - size: keys.length, - propertyName(index) { - return index; - }, - propertyDescription(index) { - let key = keys[index]; - let val = WeakMap.prototype.get.call(raw, key); - return { - enumerable: true, - value: { - type: "mapEntry", - preview: { - key: gripFromEntry(objectActor, key), - value: gripFromEntry(objectActor, val) - } - } - }; - } - }; -} - -function enumSetEntries(objectActor) { - // We currently lack XrayWrappers for Set, so when we iterate over - // the values, the temporary iterator objects get created in the target - // compartment. However, we _do_ have Xrays to Object now, so we end up - // Xraying those temporary objects, and filtering access to |it.value| - // based on whether or not it's Xrayable and/or callable, which breaks - // the for/of iteration. - // - // This code is designed to handle untrusted objects, so we can safely - // waive Xrays on the iterable, and relying on the Debugger machinery to - // make sure we handle the resulting objects carefully. - let raw = objectActor.obj.unsafeDereference(); - let values = [...Cu.waiveXrays(Set.prototype.values.call(raw))]; - - return { - [Symbol.iterator]: function* () { - for (let item of values) { - yield gripFromEntry(objectActor, item); - } - }, - size: values.length, - propertyName(index) { - return index; - }, - propertyDescription(index) { - let val = values[index]; - return { - enumerable: true, - value: gripFromEntry(objectActor, val) - }; - } - }; -} - -function enumWeakSetEntries(objectActor) { - // We currently lack XrayWrappers for WeakSet, so when we iterate over - // the values, the temporary iterator objects get created in the target - // compartment. However, we _do_ have Xrays to Object now, so we end up - // Xraying those temporary objects, and filtering access to |it.value| - // based on whether or not it's Xrayable and/or callable, which breaks - // the for/of iteration. - // - // This code is designed to handle untrusted objects, so we can safely - // waive Xrays on the iterable, and relying on the Debugger machinery to - // make sure we handle the resulting objects carefully. - let raw = objectActor.obj.unsafeDereference(); - let keys = Cu.waiveXrays( - ThreadSafeChromeUtils.nondeterministicGetWeakSetKeys(raw)); - - return { - [Symbol.iterator]: function* () { - for (let item of keys) { - yield gripFromEntry(objectActor, item); - } - }, - size: keys.length, - propertyName(index) { - return index; - }, - propertyDescription(index) { - let val = keys[index]; - return { - enumerable: true, - value: gripFromEntry(objectActor, val) - }; - } - }; -} - -/** - * Functions for adding information to ObjectActor grips for the purpose of - * having customized output. This object holds arrays mapped by - * Debugger.Object.prototype.class. - * - * In each array you can add functions that take three - * arguments: - * - the ObjectActor instance and its hooks to make a preview for, - * - the grip object being prepared for the client, - * - the raw JS object after calling Debugger.Object.unsafeDereference(). This - * argument is only provided if the object is safe for reading properties and - * executing methods. See DevToolsUtils.isSafeJSObject(). - * - * Functions must return false if they cannot provide preview - * information for the debugger object, or true otherwise. - */ -DebuggerServer.ObjectActorPreviewers = { - String: [function (objectActor, grip, rawObj) { - return wrappedPrimitivePreviewer("String", String, objectActor, grip, rawObj); - }], - - Boolean: [function (objectActor, grip, rawObj) { - return wrappedPrimitivePreviewer("Boolean", Boolean, objectActor, grip, rawObj); - }], - - Number: [function (objectActor, grip, rawObj) { - return wrappedPrimitivePreviewer("Number", Number, objectActor, grip, rawObj); - }], - - Function: [function ({obj, hooks}, grip) { - if (obj.name) { - grip.name = obj.name; - } - - if (obj.displayName) { - grip.displayName = obj.displayName.substr(0, 500); - } - - if (obj.parameterNames) { - grip.parameterNames = obj.parameterNames; - } - - // Check if the developer has added a de-facto standard displayName - // property for us to use. - let userDisplayName; - try { - userDisplayName = obj.getOwnPropertyDescriptor("displayName"); - } catch (e) { - // Calling getOwnPropertyDescriptor with displayName might throw - // with "permission denied" errors for some functions. - dumpn(e); - } - - if (userDisplayName && typeof userDisplayName.value == "string" && - userDisplayName.value) { - grip.userDisplayName = hooks.createValueGrip(userDisplayName.value); - } - - let dbgGlobal = hooks.getGlobalDebugObject(); - if (dbgGlobal) { - let script = dbgGlobal.makeDebuggeeValue(obj.unsafeDereference()).script; - if (script) { - grip.location = { - url: script.url, - line: script.startLine - }; - } - } - - return true; - }], - - RegExp: [function ({obj, hooks}, grip) { - // Avoid having any special preview for the RegExp.prototype itself. - if (!obj.proto || obj.proto.class != "RegExp") { - return false; - } - - let str = RegExp.prototype.toString.call(obj.unsafeDereference()); - grip.displayString = hooks.createValueGrip(str); - return true; - }], - - Date: [function ({obj, hooks}, grip) { - let time = Date.prototype.getTime.call(obj.unsafeDereference()); - - grip.preview = { - timestamp: hooks.createValueGrip(time), - }; - return true; - }], - - Array: [function ({obj, hooks}, grip) { - let length = DevToolsUtils.getProperty(obj, "length"); - if (typeof length != "number") { - return false; - } - - grip.preview = { - kind: "ArrayLike", - length: length, - }; - - if (hooks.getGripDepth() > 1) { - return true; - } - - let raw = obj.unsafeDereference(); - let items = grip.preview.items = []; - - for (let i = 0; i < length; ++i) { - // Array Xrays filter out various possibly-unsafe properties (like - // functions, and claim that the value is undefined instead. This - // is generally the right thing for privileged code accessing untrusted - // objects, but quite confusing for Object previews. So we manually - // override this protection by waiving Xrays on the array, and re-applying - // Xrays on any indexed value props that we pull off of it. - let desc = Object.getOwnPropertyDescriptor(Cu.waiveXrays(raw), i); - if (desc && !desc.get && !desc.set) { - let value = Cu.unwaiveXrays(desc.value); - value = makeDebuggeeValueIfNeeded(obj, value); - items.push(hooks.createValueGrip(value)); - } else { - items.push(null); - } - - if (items.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - return true; - }], - - Set: [function (objectActor, grip) { - let size = DevToolsUtils.getProperty(objectActor.obj, "size"); - if (typeof size != "number") { - return false; - } - - grip.preview = { - kind: "ArrayLike", - length: size, - }; - - // Avoid recursive object grips. - if (objectActor.hooks.getGripDepth() > 1) { - return true; - } - - let items = grip.preview.items = []; - for (let item of enumSetEntries(objectActor)) { - items.push(item); - if (items.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - return true; - }], - - WeakSet: [function (objectActor, grip) { - let enumEntries = enumWeakSetEntries(objectActor); - - grip.preview = { - kind: "ArrayLike", - length: enumEntries.size - }; - - // Avoid recursive object grips. - if (objectActor.hooks.getGripDepth() > 1) { - return true; - } - - let items = grip.preview.items = []; - for (let item of enumEntries) { - items.push(item); - if (items.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - return true; - }], - - Map: [function (objectActor, grip) { - let size = DevToolsUtils.getProperty(objectActor.obj, "size"); - if (typeof size != "number") { - return false; - } - - grip.preview = { - kind: "MapLike", - size: size, - }; - - if (objectActor.hooks.getGripDepth() > 1) { - return true; - } - - let entries = grip.preview.entries = []; - for (let entry of enumMapEntries(objectActor)) { - entries.push(entry); - if (entries.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - return true; - }], - - WeakMap: [function (objectActor, grip) { - let enumEntries = enumWeakMapEntries(objectActor); - - grip.preview = { - kind: "MapLike", - size: enumEntries.size - }; - - if (objectActor.hooks.getGripDepth() > 1) { - return true; - } - - let entries = grip.preview.entries = []; - for (let entry of enumEntries) { - entries.push(entry); - if (entries.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - return true; - }], - - DOMStringMap: [function ({obj, hooks}, grip, rawObj) { - if (!rawObj) { - return false; - } - - let keys = obj.getOwnPropertyNames(); - grip.preview = { - kind: "MapLike", - size: keys.length, - }; - - if (hooks.getGripDepth() > 1) { - return true; - } - - let entries = grip.preview.entries = []; - for (let key of keys) { - let value = makeDebuggeeValueIfNeeded(obj, rawObj[key]); - entries.push([key, hooks.createValueGrip(value)]); - if (entries.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - return true; - }], - - Proxy: [function ({obj, hooks}, grip, rawObj) { - grip.preview = { - kind: "Object", - ownProperties: Object.create(null), - ownPropertiesLength: 2 - }; - - if (hooks.getGripDepth() > 1) { - return true; - } - - grip.preview.ownProperties[''] = {value: grip.proxyTarget}; - grip.preview.ownProperties[''] = {value: grip.proxyHandler}; - - return true; - }], -}; - -/** - * Generic previewer for classes wrapping primitives, like String, - * Number and Boolean. - * - * @param string className - * Class name to expect. - * @param object classObj - * The class to expect, eg. String. The valueOf() method of the class is - * invoked on the given object. - * @param ObjectActor objectActor - * The object actor - * @param Object grip - * The result grip to fill in - * @return Booolean true if the object was handled, false otherwise - */ -function wrappedPrimitivePreviewer(className, classObj, objectActor, grip, rawObj) { - let {obj, hooks} = objectActor; - - if (!obj.proto || obj.proto.class != className) { - return false; - } - - let v = null; - try { - v = classObj.prototype.valueOf.call(rawObj); - } catch (ex) { - // valueOf() can throw if the raw JS object is "misbehaved". - return false; - } - - if (v === null) { - return false; - } - - let canHandle = GenericObject(objectActor, grip, rawObj, className === "String"); - if (!canHandle) { - return false; - } - - grip.preview.wrappedValue = - hooks.createValueGrip(makeDebuggeeValueIfNeeded(obj, v)); - return true; -} - -function GenericObject(objectActor, grip, rawObj, specialStringBehavior = false) { - let {obj, hooks} = objectActor; - if (grip.preview || grip.displayString || hooks.getGripDepth() > 1) { - return false; - } - - let i = 0, names = []; - let preview = grip.preview = { - kind: "Object", - ownProperties: Object.create(null), - }; - - try { - names = obj.getOwnPropertyNames(); - } catch (ex) { - // Calling getOwnPropertyNames() on some wrapped native prototypes is not - // allowed: "cannot modify properties of a WrappedNative". See bug 952093. - } - - preview.ownPropertiesLength = names.length; - - let length; - if (specialStringBehavior) { - length = DevToolsUtils.getProperty(obj, "length"); - if (typeof length != "number") { - specialStringBehavior = false; - } - } - - for (let name of names) { - if (specialStringBehavior && /^[0-9]+$/.test(name)) { - let num = parseInt(name, 10); - if (num.toString() === name && num >= 0 && num < length) { - continue; - } - } - - let desc = objectActor._propertyDescriptor(name, true); - if (!desc) { - continue; - } - - preview.ownProperties[name] = desc; - if (++i == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - - if (i < OBJECT_PREVIEW_MAX_ITEMS) { - preview.safeGetterValues = objectActor._findSafeGetterValues( - Object.keys(preview.ownProperties), - OBJECT_PREVIEW_MAX_ITEMS - i); - } - - return true; -} - -// Preview functions that do not rely on the object class. -DebuggerServer.ObjectActorPreviewers.Object = [ - function TypedArray({obj, hooks}, grip) { - if (TYPED_ARRAY_CLASSES.indexOf(obj.class) == -1) { - return false; - } - - let length = DevToolsUtils.getProperty(obj, "length"); - if (typeof length != "number") { - return false; - } - - grip.preview = { - kind: "ArrayLike", - length: length, - }; - - if (hooks.getGripDepth() > 1) { - return true; - } - - let raw = obj.unsafeDereference(); - let global = Cu.getGlobalForObject(DebuggerServer); - let classProto = global[obj.class].prototype; - // The Xray machinery for TypedArrays denies indexed access on the grounds - // that it's slow, and advises callers to do a structured clone instead. - let safeView = Cu.cloneInto(classProto.subarray.call(raw, 0, - OBJECT_PREVIEW_MAX_ITEMS), global); - let items = grip.preview.items = []; - for (let i = 0; i < safeView.length; i++) { - items.push(safeView[i]); - } - - return true; - }, - - function Error({obj, hooks}, grip) { - switch (obj.class) { - case "Error": - case "EvalError": - case "RangeError": - case "ReferenceError": - case "SyntaxError": - case "TypeError": - case "URIError": - let name = DevToolsUtils.getProperty(obj, "name"); - let msg = DevToolsUtils.getProperty(obj, "message"); - let stack = DevToolsUtils.getProperty(obj, "stack"); - let fileName = DevToolsUtils.getProperty(obj, "fileName"); - let lineNumber = DevToolsUtils.getProperty(obj, "lineNumber"); - let columnNumber = DevToolsUtils.getProperty(obj, "columnNumber"); - grip.preview = { - kind: "Error", - name: hooks.createValueGrip(name), - message: hooks.createValueGrip(msg), - stack: hooks.createValueGrip(stack), - fileName: hooks.createValueGrip(fileName), - lineNumber: hooks.createValueGrip(lineNumber), - columnNumber: hooks.createValueGrip(columnNumber), - }; - return true; - default: - return false; - } - }, - - function CSSMediaRule({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMCSSMediaRule)) { - return false; - } - grip.preview = { - kind: "ObjectWithText", - text: hooks.createValueGrip(rawObj.conditionText), - }; - return true; - }, - - function CSSStyleRule({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMCSSStyleRule)) { - return false; - } - grip.preview = { - kind: "ObjectWithText", - text: hooks.createValueGrip(rawObj.selectorText), - }; - return true; - }, - - function ObjectWithURL({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMCSSImportRule || - rawObj instanceof Ci.nsIDOMCSSStyleSheet || - rawObj instanceof Ci.nsIDOMLocation || - rawObj instanceof Ci.nsIDOMWindow)) { - return false; - } - - let url; - if (rawObj instanceof Ci.nsIDOMWindow && rawObj.location) { - url = rawObj.location.href; - } else if (rawObj.href) { - url = rawObj.href; - } else { - return false; - } - - grip.preview = { - kind: "ObjectWithURL", - url: hooks.createValueGrip(url), - }; - - return true; - }, - - function ArrayLike({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || - obj.class != "DOMStringList" && - obj.class != "DOMTokenList" && - !(rawObj instanceof Ci.nsIDOMMozNamedAttrMap || - rawObj instanceof Ci.nsIDOMCSSRuleList || - rawObj instanceof Ci.nsIDOMCSSValueList || - rawObj instanceof Ci.nsIDOMFileList || - rawObj instanceof Ci.nsIDOMFontFaceList || - rawObj instanceof Ci.nsIDOMMediaList || - rawObj instanceof Ci.nsIDOMNodeList || - rawObj instanceof Ci.nsIDOMStyleSheetList)) { - return false; - } - - if (typeof rawObj.length != "number") { - return false; - } - - grip.preview = { - kind: "ArrayLike", - length: rawObj.length, - }; - - if (hooks.getGripDepth() > 1) { - return true; - } - - let items = grip.preview.items = []; - - for (let i = 0; i < rawObj.length && - items.length < OBJECT_PREVIEW_MAX_ITEMS; i++) { - let value = makeDebuggeeValueIfNeeded(obj, rawObj[i]); - items.push(hooks.createValueGrip(value)); - } - - return true; - }, - - function CSSStyleDeclaration({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || - !(rawObj instanceof Ci.nsIDOMCSSStyleDeclaration)) { - return false; - } - - grip.preview = { - kind: "MapLike", - size: rawObj.length, - }; - - let entries = grip.preview.entries = []; - - for (let i = 0; i < OBJECT_PREVIEW_MAX_ITEMS && - i < rawObj.length; i++) { - let prop = rawObj[i]; - let value = rawObj.getPropertyValue(prop); - entries.push([prop, hooks.createValueGrip(value)]); - } - - return true; - }, - - function DOMNode({obj, hooks}, grip, rawObj) { - if (isWorker || obj.class == "Object" || !rawObj || - !(rawObj instanceof Ci.nsIDOMNode)) { - return false; - } - - let preview = grip.preview = { - kind: "DOMNode", - nodeType: rawObj.nodeType, - nodeName: rawObj.nodeName, - }; - - if (rawObj instanceof Ci.nsIDOMDocument && rawObj.location) { - preview.location = hooks.createValueGrip(rawObj.location.href); - } else if (rawObj instanceof Ci.nsIDOMDocumentFragment) { - preview.childNodesLength = rawObj.childNodes.length; - - if (hooks.getGripDepth() < 2) { - preview.childNodes = []; - for (let node of rawObj.childNodes) { - let actor = hooks.createValueGrip(obj.makeDebuggeeValue(node)); - preview.childNodes.push(actor); - if (preview.childNodes.length == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - } - } else if (rawObj instanceof Ci.nsIDOMElement) { - // Add preview for DOM element attributes. - if (rawObj instanceof Ci.nsIDOMHTMLElement) { - preview.nodeName = preview.nodeName.toLowerCase(); - } - - let i = 0; - preview.attributes = {}; - preview.attributesLength = rawObj.attributes.length; - for (let attr of rawObj.attributes) { - preview.attributes[attr.nodeName] = hooks.createValueGrip(attr.value); - } - } else if (rawObj instanceof Ci.nsIDOMAttr) { - preview.value = hooks.createValueGrip(rawObj.value); - } else if (rawObj instanceof Ci.nsIDOMText || - rawObj instanceof Ci.nsIDOMComment) { - preview.textContent = hooks.createValueGrip(rawObj.textContent); - } - - return true; - }, - - function DOMEvent({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMEvent)) { - return false; - } - - let preview = grip.preview = { - kind: "DOMEvent", - type: rawObj.type, - properties: Object.create(null), - }; - - if (hooks.getGripDepth() < 2) { - let target = obj.makeDebuggeeValue(rawObj.target); - preview.target = hooks.createValueGrip(target); - } - - let props = []; - if (rawObj instanceof Ci.nsIDOMMouseEvent) { - props.push("buttons", "clientX", "clientY", "layerX", "layerY"); - } else if (rawObj instanceof Ci.nsIDOMKeyEvent) { - let modifiers = []; - if (rawObj.altKey) { - modifiers.push("Alt"); - } - if (rawObj.ctrlKey) { - modifiers.push("Control"); - } - if (rawObj.metaKey) { - modifiers.push("Meta"); - } - if (rawObj.shiftKey) { - modifiers.push("Shift"); - } - preview.eventKind = "key"; - preview.modifiers = modifiers; - - props.push("key", "charCode", "keyCode"); - } else if (rawObj instanceof Ci.nsIDOMTransitionEvent) { - props.push("propertyName", "pseudoElement"); - } else if (rawObj instanceof Ci.nsIDOMAnimationEvent) { - props.push("animationName", "pseudoElement"); - } else if (rawObj instanceof Ci.nsIDOMClipboardEvent) { - props.push("clipboardData"); - } - - // Add event-specific properties. - for (let prop of props) { - let value = rawObj[prop]; - if (value && (typeof value == "object" || typeof value == "function")) { - // Skip properties pointing to objects. - if (hooks.getGripDepth() > 1) { - continue; - } - value = obj.makeDebuggeeValue(value); - } - preview.properties[prop] = hooks.createValueGrip(value); - } - - // Add any properties we find on the event object. - if (!props.length) { - let i = 0; - for (let prop in rawObj) { - let value = rawObj[prop]; - if (prop == "target" || prop == "type" || value === null || - typeof value == "function") { - continue; - } - if (value && typeof value == "object") { - if (hooks.getGripDepth() > 1) { - continue; - } - value = obj.makeDebuggeeValue(value); - } - preview.properties[prop] = hooks.createValueGrip(value); - if (++i == OBJECT_PREVIEW_MAX_ITEMS) { - break; - } - } - } - - return true; - }, - - function DOMException({obj, hooks}, grip, rawObj) { - if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMDOMException)) { - return false; - } - - grip.preview = { - kind: "DOMException", - name: hooks.createValueGrip(rawObj.name), - message: hooks.createValueGrip(rawObj.message), - code: hooks.createValueGrip(rawObj.code), - result: hooks.createValueGrip(rawObj.result), - filename: hooks.createValueGrip(rawObj.filename), - lineNumber: hooks.createValueGrip(rawObj.lineNumber), - columnNumber: hooks.createValueGrip(rawObj.columnNumber), - }; - - return true; - }, - - function PseudoArray({obj, hooks}, grip, rawObj) { - let length; - - let keys = obj.getOwnPropertyNames(); - if (keys.length == 0) { - return false; - } - - // If no item is going to be displayed in preview, better display as sparse object. - // The first key should contain the smallest integer index (if any). - if(keys[0] >= OBJECT_PREVIEW_MAX_ITEMS) { - return false; - } - - // Pseudo-arrays should only have array indices and, optionally, a "length" property. - // Since integer indices are sorted first, check if the last property is "length". - if(keys[keys.length-1] === "length") { - keys.pop(); - length = DevToolsUtils.getProperty(obj, "length"); - } else { - // Otherwise, let length be the (presumably) greatest array index plus 1. - length = +keys[keys.length-1] + 1; - } - // Check if length is a valid array length, i.e. is a Uint32 number. - if(typeof length !== "number" || length >>> 0 !== length) { - return false; - } - - // Ensure all keys are increasing array indices smaller than length. The order is not - // guaranteed for exotic objects but, in most cases, big array indices and properties - // which are not integer indices should be at the end. Then, iterating backwards - // allows us to return earlier when the object is not completely a pseudo-array. - let prev = length; - for(let i = keys.length - 1; i >= 0; --i) { - let key = keys[i]; - let numKey = key >>> 0; // ToUint32(key) - if (numKey + '' !== key || numKey >= prev) { - return false; - } - prev = numKey; - } - - grip.preview = { - kind: "ArrayLike", - length: length, - }; - - // Avoid recursive object grips. - if (hooks.getGripDepth() > 1) { - return true; - } - - let items = grip.preview.items = []; - let numItems = Math.min(OBJECT_PREVIEW_MAX_ITEMS, length); - - for (let i = 0; i < numItems; ++i) { - let desc = obj.getOwnPropertyDescriptor(i); - if (desc && 'value' in desc) { - items.push(hooks.createValueGrip(desc.value)); - } else { - items.push(null); - } - } - - return true; - }, - - function Object(objectActor, grip, rawObj) { - return GenericObject(objectActor, grip, rawObj, /* specialStringBehavior = */ false); - }, -]; - -/** - * Get thisDebugger.Object referent's `promiseState`. - * - * @returns Object - * An object of one of the following forms: - * - { state: "pending" } - * - { state: "fulfilled", value } - * - { state: "rejected", reason } - */ -function getPromiseState(obj) { - if (obj.class != "Promise") { - throw new Error( - "Can't call `getPromiseState` on `Debugger.Object`s that don't " + - "refer to Promise objects."); - } - - let state = { state: obj.promiseState }; - if (state.state === "fulfilled") { - state.value = obj.promiseValue; - } else if (state.state === "rejected") { - state.reason = obj.promiseReason; - } - return state; -} - -/** - * Determine if a given value is non-primitive. - * - * @param Any value - * The value to test. - * @return Boolean - * Whether the value is non-primitive. - */ -function isObject(value) { - const type = typeof value; - return type == "object" ? value !== null : type == "function"; -} - -/** - * Create a function that can safely stringify Debugger.Objects of a given - * builtin type. - * - * @param Function ctor - * The builtin class constructor. - * @return Function - * The stringifier for the class. - */ -function createBuiltinStringifier(ctor) { - return obj => ctor.prototype.toString.call(obj.unsafeDereference()); -} - -/** - * Stringify a Debugger.Object-wrapped Error instance. - * - * @param Debugger.Object obj - * The object to stringify. - * @return String - * The stringification of the object. - */ -function errorStringify(obj) { - let name = DevToolsUtils.getProperty(obj, "name"); - if (name === "" || name === undefined) { - name = obj.class; - } else if (isObject(name)) { - name = stringify(name); - } - - let message = DevToolsUtils.getProperty(obj, "message"); - if (isObject(message)) { - message = stringify(message); - } - - if (message === "" || message === undefined) { - return name; - } - return name + ": " + message; -} - -/** - * Stringify a Debugger.Object based on its class. - * - * @param Debugger.Object obj - * The object to stringify. - * @return String - * The stringification for the object. - */ -function stringify(obj) { - if (obj.class == "DeadObject") { - const error = new Error("Dead object encountered."); - DevToolsUtils.reportException("stringify", error); - return ""; - } - - const stringifier = stringifiers[obj.class] || stringifiers.Object; - - try { - return stringifier(obj); - } catch (e) { - DevToolsUtils.reportException("stringify", e); - return ""; - } -} - -// Used to prevent infinite recursion when an array is found inside itself. -var seen = null; - -var stringifiers = { - Error: errorStringify, - EvalError: errorStringify, - RangeError: errorStringify, - ReferenceError: errorStringify, - SyntaxError: errorStringify, - TypeError: errorStringify, - URIError: errorStringify, - Boolean: createBuiltinStringifier(Boolean), - Function: createBuiltinStringifier(Function), - Number: createBuiltinStringifier(Number), - RegExp: createBuiltinStringifier(RegExp), - String: createBuiltinStringifier(String), - Object: obj => "[object " + obj.class + "]", - Array: obj => { - // If we're at the top level then we need to create the Set for tracking - // previously stringified arrays. - const topLevel = !seen; - if (topLevel) { - seen = new Set(); - } else if (seen.has(obj)) { - return ""; - } - - seen.add(obj); - - const len = DevToolsUtils.getProperty(obj, "length"); - let string = ""; - - // The following check is only required because the debuggee could possibly - // be a Proxy and return any value. For normal objects, array.length is - // always a non-negative integer. - if (typeof len == "number" && len > 0) { - for (let i = 0; i < len; i++) { - const desc = obj.getOwnPropertyDescriptor(i); - if (desc) { - const { value } = desc; - if (value != null) { - string += isObject(value) ? stringify(value) : value; - } - } - - if (i < len - 1) { - string += ","; - } - } - } - - if (topLevel) { - seen = null; - } - - return string; - }, - DOMException: obj => { - const message = DevToolsUtils.getProperty(obj, "message") || ""; - const result = (+DevToolsUtils.getProperty(obj, "result")).toString(16); - const code = DevToolsUtils.getProperty(obj, "code"); - const name = DevToolsUtils.getProperty(obj, "name") || ""; - - return '[Exception... "' + message + '" ' + - 'code: "' + code + '" ' + - 'nsresult: "0x' + result + " (" + name + ')"]'; - }, - Promise: obj => { - const { state, value, reason } = getPromiseState(obj); - let statePreview = state; - if (state != "pending") { - const settledValue = state === "fulfilled" ? value : reason; - statePreview += ": " + (typeof settledValue === "object" && settledValue !== null - ? stringify(settledValue) - : settledValue); - } - return "Promise (" + statePreview + ")"; - }, -}; - -/** - * Make a debuggee value for the given object, if needed. Primitive values - * are left the same. - * - * Use case: you have a raw JS object (after unsafe dereference) and you want to - * send it to the client. In that case you need to use an ObjectActor which - * requires a debuggee value. The Debugger.Object.prototype.makeDebuggeeValue() - * method works only for JS objects and functions. - * - * @param Debugger.Object obj - * @param any value - * @return object - */ -function makeDebuggeeValueIfNeeded(obj, value) { - if (value && (typeof value == "object" || typeof value == "function")) { - return obj.makeDebuggeeValue(value); - } - return value; -} - -/** - * Creates an actor for the specied "very long" string. "Very long" is specified - * at the server's discretion. - * - * @param string String - * The string. - */ -function LongStringActor(string) { - this.string = string; - this.stringLength = string.length; -} - -LongStringActor.prototype = { - actorPrefix: "longString", - - disconnect: function () { - // Because longStringActors is not a weak map, we won't automatically leave - // it so we need to manually leave on disconnect so that we don't leak - // memory. - this._releaseActor(); - }, - - /** - * Returns a grip for this actor for returning in a protocol message. - */ - grip: function () { - return { - "type": "longString", - "initial": this.string.substring( - 0, DebuggerServer.LONG_STRING_INITIAL_LENGTH), - "length": this.stringLength, - "actor": this.actorID - }; - }, - - /** - * Handle a request to extract part of this actor's string. - * - * @param request object - * The protocol request object. - */ - onSubstring: function (request) { - return { - "from": this.actorID, - "substring": this.string.substring(request.start, request.end) - }; - }, - - /** - * Handle a request to release this LongStringActor instance. - */ - onRelease: function () { - // TODO: also check if registeredPool === threadActor.threadLifetimePool - // when the web console moves aray from manually releasing pause-scoped - // actors. - this._releaseActor(); - this.registeredPool.removeActor(this); - return {}; - }, - - _releaseActor: function () { - if (this.registeredPool && this.registeredPool.longStringActors) { - delete this.registeredPool.longStringActors[this.string]; - } - } -}; - -LongStringActor.prototype.requestTypes = { - "substring": LongStringActor.prototype.onSubstring, - "release": LongStringActor.prototype.onRelease -}; - -/** - * Create a grip for the given debuggee value. If the value is an - * object, will create an actor with the given lifetime. - */ -function createValueGrip(value, pool, makeObjectGrip) { - switch (typeof value) { - case "boolean": - return value; - - case "string": - if (stringIsLong(value)) { - return longStringGrip(value, pool); - } - return value; - - case "number": - if (value === Infinity) { - return { type: "Infinity" }; - } else if (value === -Infinity) { - return { type: "-Infinity" }; - } else if (Number.isNaN(value)) { - return { type: "NaN" }; - } else if (!value && 1 / value === -Infinity) { - return { type: "-0" }; - } - return value; - - case "undefined": - return { type: "undefined" }; - - case "object": - if (value === null) { - return { type: "null" }; - } - else if (value.optimizedOut || - value.uninitialized || - value.missingArguments) { - // The slot is optimized out, an uninitialized binding, or - // arguments on a dead scope - return { - type: "null", - optimizedOut: value.optimizedOut, - uninitialized: value.uninitialized, - missingArguments: value.missingArguments - }; - } - return makeObjectGrip(value, pool); - - case "symbol": - let form = { - type: "symbol" - }; - let name = getSymbolName(value); - if (name !== undefined) { - form.name = createValueGrip(name, pool, makeObjectGrip); - } - return form; - - default: - assert(false, "Failed to provide a grip for: " + value); - return null; - } -} - -// const symbolProtoToString = Symbol.prototype.toString; - -// function getSymbolName(symbol) { -// const name = symbolProtoToString.call(symbol).slice("Symbol(".length, -1); -// return name || undefined; -// } - -/** - * Returns true if the string is long enough to use a LongStringActor instead - * of passing the value directly over the protocol. - * - * @param str String - * The string we are checking the length of. - */ -function stringIsLong(str) { - return str.length >= DebuggerServer.LONG_STRING_LENGTH; -} - -/** - * Create a grip for the given string. - * - * @param str String - * The string we are creating a grip for. - * @param pool ActorPool - * The actor pool where the new actor will be added. - */ -function longStringGrip(str, pool) { - if (!pool.longStringActors) { - pool.longStringActors = {}; - } - - if (pool.longStringActors.hasOwnProperty(str)) { - return pool.longStringActors[str].grip(); - } - - let actor = new LongStringActor(str); - pool.addActor(actor); - pool.longStringActors[str] = actor; - return actor.grip(); -} - -// exports.ObjectActor = ObjectActor; -// exports.PropertyIteratorActor = PropertyIteratorActor; -// exports.LongStringActor = LongStringActor; -// exports.createValueGrip = createValueGrip; -// exports.stringIsLong = stringIsLong; -// exports.longStringGrip = longStringGrip; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/root.js b/native/cocos/scripting/js-bindings/script/debugger/actors/root.js deleted file mode 100755 index e5f5b85326..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/root.js +++ /dev/null @@ -1,536 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const { Cc, Ci, Cu } = require("chrome"); -// const Services = require("Services"); -// const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common"); -// const { DebuggerServer } = require("devtools/server/main"); - -// loader.lazyGetter(this, "ppmm", () => { -// return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIMessageBroadcaster); -// }); - -/* Root actor for the remote debugging protocol. */ - -/** - * Create a remote debugging protocol root actor. - * - * @param aConnection - * The DebuggerServerConnection whose root actor we are constructing. - * - * @param aParameters - * The properties of |aParameters| provide backing objects for the root - * actor's requests; if a given property is omitted from |aParameters|, the - * root actor won't implement the corresponding requests or notifications. - * Supported properties: - * - * - tabList: a live list (see below) of tab actors. If present, the - * new root actor supports the 'listTabs' request, providing the live - * list's elements as its tab actors, and sending 'tabListChanged' - * notifications when the live list's contents change. One actor in - * this list must have a true '.selected' property. - * - * - addonList: a live list (see below) of addon actors. If present, the - * new root actor supports the 'listAddons' request, providing the live - * list's elements as its addon actors, and sending 'addonListchanged' - * notifications when the live list's contents change. - * - * - globalActorFactories: an object |A| describing further actors to - * attach to the 'listTabs' reply. This is the type accumulated by - * DebuggerServer.addGlobalActor. For each own property |P| of |A|, - * the root actor adds a property named |P| to the 'listTabs' - * reply whose value is the name of an actor constructed by - * |A[P]|. - * - * - onShutdown: a function to call when the root actor is disconnected. - * - * Instance properties: - * - * - applicationType: the string the root actor will include as the - * "applicationType" property in the greeting packet. By default, this - * is "browser". - * - * Live lists: - * - * A "live list", as used for the |tabList|, is an object that presents a - * list of actors, and also notifies its clients of changes to the list. A - * live list's interface is two properties: - * - * - getList: a method that returns a promise to the contents of the list. - * - * - onListChanged: a handler called, with no arguments, when the set of - * values the iterator would produce has changed since the last - * time 'iterator' was called. This may only be set to null or a - * callable value (one for which the typeof operator returns - * 'function'). (Note that the live list will not call the - * onListChanged handler until the list has been iterated over - * once; if nobody's seen the list in the first place, nobody - * should care if its contents have changed!) - * - * When the list changes, the list implementation should ensure that any - * actors yielded in previous iterations whose referents (tabs) still exist - * get yielded again in subsequent iterations. If the underlying referent - * is the same, the same actor should be presented for it. - * - * The root actor registers an 'onListChanged' handler on the appropriate - * list when it may need to send the client 'tabListChanged' notifications, - * and is careful to remove the handler whenever it does not need to send - * such notifications (including when it is disconnected). This means that - * live list implementations can use the state of the handler property (set - * or null) to install and remove observers and event listeners. - * - * Note that, as the only way for the root actor to see the members of the - * live list is to begin an iteration over the list, the live list need not - * actually produce any actors until they are reached in the course of - * iteration: alliterative lazy live lists. - */ - -function RootActor(aConnection, aParameters) { - this.conn = aConnection; - this._parameters = aParameters; - this._onTabListChanged = this.onTabListChanged.bind(this); - this._onAddonListChanged = this.onAddonListChanged.bind(this); - this._onWorkerListChanged = this.onWorkerListChanged.bind(this); - this._onServiceWorkerRegistrationListChanged = this.onServiceWorkerRegistrationListChanged.bind(this); - this._onProcessListChanged = this.onProcessListChanged.bind(this); - this._extraActors = {}; - - this._globalActorPool = new ActorPool(this.conn); - this.conn.addActorPool(this._globalActorPool); - - this._chromeActor = null; -} - -RootActor.prototype = { - constructor: RootActor, - applicationType: "browser", - - traits: { - sources: true, - // Whether the inspector actor allows modifying outer HTML. - editOuterHTML: true, - // Whether the inspector actor allows modifying innerHTML and inserting - // adjacent HTML. - pasteHTML: true, - // Whether the server-side highlighter actor exists and can be used to - // remotely highlight nodes (see server/actors/highlighters.js) - highlightable: true, - // Which custom highlighter does the server-side highlighter actor supports? - // (see server/actors/highlighters.js) - customHighlighters: true, - // Whether the inspector actor implements the getImageDataFromURL - // method that returns data-uris for image URLs. This is used for image - // tooltips for instance - urlToImageDataResolver: true, - networkMonitor: true, - // Whether the storage inspector actor to inspect cookies, etc. - storageInspector: true, - // Whether storage inspector is read only - storageInspectorReadOnly: true, - // Whether conditional breakpoints are supported - conditionalBreakpoints: true, - // Whether the server supports full source actors (breakpoints on - // eval scripts, etc) - debuggerSourceActors: true, - bulk: true, - // Whether the style rule actor implements the modifySelector method - // that modifies the rule's selector - selectorEditable: true, - // Whether the page style actor implements the addNewRule method that - // adds new rules to the page - addNewRule: true, - // Whether the dom node actor implements the getUniqueSelector method - getUniqueSelector: true, - // Whether the director scripts are supported - directorScripts: true, - // Whether the debugger server supports - // blackboxing/pretty-printing (not supported in Fever Dream yet) - noBlackBoxing: false, - noPrettyPrinting: false, - // Whether the page style actor implements the getUsedFontFaces method - // that returns the font faces used on a node - getUsedFontFaces: true, - // Trait added in Gecko 38, indicating that all features necessary for - // grabbing allocations from the MemoryActor are available for the performance tool - memoryActorAllocations: true, - // Added in Gecko 40, indicating that the backend isn't stupid about - // sending resumption packets on tab navigation. - noNeedToFakeResumptionOnNavigation: true, - // Added in Firefox 40. Indicates that the backend supports registering custom - // commands through the WebConsoleCommands API. - webConsoleCommands: true, - // Whether root actor exposes tab actors - // if allowChromeProcess is true, you can fetch a ChromeActor instance - // to debug chrome and any non-content ressource via getProcess request - // if allocChromeProcess is defined, but not true, it means that root actor - // no longer expose tab actors, but also that getProcess forbids - // exposing actors for security reasons - get allowChromeProcess() { - return DebuggerServer.allowChromeProcess; - }, - // Whether or not `getProfile()` supports specifying a `startTime` - // and `endTime` to filter out samples. Fx40+ - profilerDataFilterable: true, - // Whether or not the MemoryActor's heap snapshot abilities are - // fully equipped to handle heap snapshots for the memory tool. Fx44+ - heapSnapshots: true, - // Whether or not the timeline actor can emit DOMContentLoaded and Load - // markers, currently in use by the network monitor. Fx45+ - documentLoadingMarkers: true - }, - - /** - * Return a 'hello' packet as specified by the Remote Debugging Protocol. - */ - sayHello: function () { - return { - from: this.actorID, - applicationType: this.applicationType, - /* This is not in the spec, but it's used by tests. */ - testConnectionPrefix: this.conn.prefix, - traits: this.traits - }; - }, - - forwardingCancelled: function (prefix) { - return { - from: this.actorID, - type: "forwardingCancelled", - prefix, - }; - }, - - /** - * Disconnects the actor from the browser window. - */ - disconnect: function () { - /* Tell the live lists we aren't watching any more. */ - if (this._parameters.tabList) { - this._parameters.tabList.onListChanged = null; - } - if (this._parameters.addonList) { - this._parameters.addonList.onListChanged = null; - } - if (this._parameters.workerList) { - this._parameters.workerList.onListChanged = null; - } - if (this._parameters.serviceWorkerRegistrationList) { - this._parameters.serviceWorkerRegistrationList.onListChanged = null; - } - if (typeof this._parameters.onShutdown === "function") { - this._parameters.onShutdown(); - } - this._extraActors = null; - this.conn = null; - this._tabActorPool = null; - this._globalActorPool = null; - this._parameters = null; - this._chromeActor = null; - }, - - /* The 'listTabs' request and the 'tabListChanged' notification. */ - - /** - * Handles the listTabs request. The actors will survive until at least - * the next listTabs request. - */ - onListTabs: function () { - let tabList = this._parameters.tabList; - if (!tabList) { - return { from: this.actorID, error: "noTabs", - message: "This root actor has no browser tabs." }; - } - - /* - * Walk the tab list, accumulating the array of tab actors for the - * reply, and moving all the actors to a new ActorPool. We'll - * replace the old tab actor pool with the one we build here, thus - * retiring any actors that didn't get listed again, and preparing any - * new actors to receive packets. - */ - let newActorPool = new ActorPool(this.conn); - let tabActorList = []; - let selected; - return tabList.getList().then((tabActors) => { - for (let tabActor of tabActors) { - if (tabActor.selected) { - selected = tabActorList.length; - } - tabActor.parentID = this.actorID; - newActorPool.addActor(tabActor); - tabActorList.push(tabActor); - } - /* DebuggerServer.addGlobalActor support: create actors. */ - if (!this._globalActorPool) { - this._globalActorPool = new ActorPool(this.conn); - this.conn.addActorPool(this._globalActorPool); - } - // this._createExtraActors(this._parameters.globalActorFactories, this._globalActorPool); - /* - * Drop the old actorID -> actor map. Actors that still mattered were - * added to the new map; others will go away. - */ - if (this._tabActorPool) { - this.conn.removeActorPool(this._tabActorPool); - } - this._tabActorPool = newActorPool; - this.conn.addActorPool(this._tabActorPool); - - let reply = { - "from": this.actorID, - "selected": selected || 0, - "tabs": tabActorList.map(actor => actor.form()) - }; - - /* If a root window is accessible, include its URL. */ - if (this.url) { - reply.url = this.url; - } - - /* DebuggerServer.addGlobalActor support: name actors in 'listTabs' reply. */ - // this._appendExtraActors(reply); - - /* - * Now that we're actually going to report the contents of tabList to - * the client, we're responsible for letting the client know if it - * changes. - */ - tabList.onListChanged = this._onTabListChanged; - - return reply; - }); - }, - - onGetTab: function (options) { - let tabList = this._parameters.tabList; - if (!tabList) { - return { error: "noTabs", - message: "This root actor has no browser tabs." }; - } - if (!this._tabActorPool) { - this._tabActorPool = new ActorPool(this.conn); - this.conn.addActorPool(this._tabActorPool); - } - return tabList.getTab(options) - .then(tabActor => { - tabActor.parentID = this.actorID; - this._tabActorPool.addActor(tabActor); - - return { tab: tabActor.form() }; - }, error => { - if (error.error) { - // Pipe expected errors as-is to the client - return error; - } else { - return { error: "noTab", - message: "Unexpected error while calling getTab(): " + error }; - } - }); - }, - - onTabListChanged: function () { - this.conn.send({ from: this.actorID, type:"tabListChanged" }); - /* It's a one-shot notification; no need to watch any more. */ - this._parameters.tabList.onListChanged = null; - }, - - onListAddons: function () { - let addonList = this._parameters.addonList; - if (!addonList) { - return { from: this.actorID, error: "noAddons", - message: "This root actor has no browser addons." }; - } - - return addonList.getList().then((addonActors) => { - let addonActorPool = new ActorPool(this.conn); - for (let addonActor of addonActors) { - addonActorPool.addActor(addonActor); - } - - if (this._addonActorPool) { - this.conn.removeActorPool(this._addonActorPool); - } - this._addonActorPool = addonActorPool; - this.conn.addActorPool(this._addonActorPool); - - addonList.onListChanged = this._onAddonListChanged; - - return { - "from": this.actorID, - "addons": addonActors.map(addonActor => addonActor.form()) - }; - }); - }, - - onAddonListChanged: function () { - this.conn.send({ from: this.actorID, type: "addonListChanged" }); - this._parameters.addonList.onListChanged = null; - }, - - onListWorkers: function () { - let workerList = this._parameters.workerList; - if (!workerList) { - return { from: this.actorID, error: "noWorkers", - message: "This root actor has no workers." }; - } - - return workerList.getList().then(actors => { - let pool = new ActorPool(this.conn); - for (let actor of actors) { - pool.addActor(actor); - } - - this.conn.removeActorPool(this._workerActorPool); - this._workerActorPool = pool; - this.conn.addActorPool(this._workerActorPool); - - workerList.onListChanged = this._onWorkerListChanged; - - return { - "from": this.actorID, - "workers": actors.map(actor => actor.form()) - }; - }); - }, - - onWorkerListChanged: function () { - this.conn.send({ from: this.actorID, type: "workerListChanged" }); - this._parameters.workerList.onListChanged = null; - }, - - onListServiceWorkerRegistrations: function () { - let registrationList = this._parameters.serviceWorkerRegistrationList; - if (!registrationList) { - return { from: this.actorID, error: "noServiceWorkerRegistrations", - message: "This root actor has no service worker registrations." }; - } - - return registrationList.getList().then(actors => { - let pool = new ActorPool(this.conn); - for (let actor of actors) { - pool.addActor(actor); - } - - this.conn.removeActorPool(this._serviceWorkerRegistrationActorPool); - this._serviceWorkerRegistrationActorPool = pool; - this.conn.addActorPool(this._serviceWorkerRegistrationActorPool); - - registrationList.onListChanged = this._onServiceWorkerRegistrationListChanged; - - return { - "from": this.actorID, - "registrations": actors.map(actor => actor.form()) - }; - }); - }, - - onServiceWorkerRegistrationListChanged: function () { - this.conn.send({ from: this.actorID, type: "serviceWorkerRegistrationListChanged" }); - this._parameters.serviceWorkerRegistrationList.onListChanged = null; - }, - - onListProcesses: function () { - let { processList } = this._parameters; - if (!processList) { - return { from: this.actorID, error: "noProcesses", - message: "This root actor has no processes." }; - } - processList.onListChanged = this._onProcessListChanged; - return { - processes: processList.getList() - }; - }, - - onProcessListChanged: function () { - this.conn.send({ from: this.actorID, type: "processListChanged" }); - this._parameters.processList.onListChanged = null; - }, - - onGetProcess: function (aRequest) { - if (!DebuggerServer.allowChromeProcess) { - return { error: "forbidden", - message: "You are not allowed to debug chrome." }; - } - if (("id" in aRequest) && typeof (aRequest.id) != "number") { - return { error: "wrongParameter", - message: "getProcess requires a valid `id` attribute." }; - } - // If the request doesn't contains id parameter or id is 0 - // (id == 0, based on onListProcesses implementation) - if ((!("id" in aRequest)) || aRequest.id === 0) { - if (!this._chromeActor) { - // Create a ChromeActor for the parent process - let { ChromeActor } = require("devtools/server/actors/chrome"); - this._chromeActor = new ChromeActor(this.conn); - this._globalActorPool.addActor(this._chromeActor); - } - - return { form: this._chromeActor.form() }; - } else { - let mm = ppmm.getChildAt(aRequest.id); - if (!mm) { - return { error: "noProcess", - message: "There is no process with id '" + aRequest.id + "'." }; - } - return DebuggerServer.connectToContent(this.conn, mm) - .then(form => ({ form })); - } - }, - - /* This is not in the spec, but it's used by tests. */ - onEcho: function (aRequest) { - /* - * Request packets are frozen. Copy aRequest, so that - * DebuggerServerConnection.onPacket can attach a 'from' property. - */ - return Cu.cloneInto(aRequest, {}); - }, - - onProtocolDescription: function () { - return require("devtools/shared/protocol").dumpProtocolSpec(); - }, - - /* Support for DebuggerServer.addGlobalActor. */ - // _createExtraActors: createExtraActors, - // _appendExtraActors: appendExtraActors, - - /** - * Remove the extra actor (added by DebuggerServer.addGlobalActor or - * DebuggerServer.addTabActor) name |aName|. - */ - removeActorByName: function (aName) { - if (aName in this._extraActors) { - const actor = this._extraActors[aName]; - if (this._globalActorPool.has(actor)) { - this._globalActorPool.removeActor(actor); - } - if (this._tabActorPool) { - // Iterate over TabActor instances to also remove tab actors - // created during listTabs for each document. - this._tabActorPool.forEach(tab => { - tab.removeActorByName(aName); - }); - } - delete this._extraActors[aName]; - } - } -}; - -RootActor.prototype.requestTypes = { - "listTabs": RootActor.prototype.onListTabs, - "getTab": RootActor.prototype.onGetTab, - "listAddons": RootActor.prototype.onListAddons, - "listWorkers": RootActor.prototype.onListWorkers, - "listServiceWorkerRegistrations": RootActor.prototype.onListServiceWorkerRegistrations, - "listProcesses": RootActor.prototype.onListProcesses, - "getProcess": RootActor.prototype.onGetProcess, - "echo": RootActor.prototype.onEcho, - "protocolDescription": RootActor.prototype.onProtocolDescription -}; - -// exports.RootActor = RootActor; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/script.js b/native/cocos/scripting/js-bindings/script/debugger/actors/script.js deleted file mode 100755 index c9fa8b6fff..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/script.js +++ /dev/null @@ -1,2372 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const Services = require("Services"); -// const { Cc, Ci, Cu, Cr, components, ChromeWorker } = require("chrome"); -// const { ActorPool, OriginalLocation, GeneratedLocation } = require("devtools/server/actors/common"); -// const { BreakpointActor, setBreakpointAtEntryPoints } = require("devtools/server/actors/breakpoint"); -// const { EnvironmentActor } = require("devtools/server/actors/environment"); -// const { FrameActor } = require("devtools/server/actors/frame"); -// const { ObjectActor, createValueGrip, longStringGrip } = require("devtools/server/actors/object"); -// const { SourceActor, getSourceURL } = require("devtools/server/actors/source"); -// const { DebuggerServer } = require("devtools/server/main"); -// const { ActorClassWithSpec } = require("devtools/shared/protocol"); -// const DevToolsUtils = require("devtools/shared/DevToolsUtils"); -// const flags = require("devtools/shared/flags"); -const { assert, dumpn, update, fetch } = DevToolsUtils; -// const promise = require("promise"); -// const xpcInspector = require("xpcInspector"); -// const { DevToolsWorker } = require("devtools/shared/worker/worker"); -// const object = require("sdk/util/object"); -// const { threadSpec } = require("devtools/shared/specs/script"); - -// const { defer, resolve, reject, all } = promise; - -// loader.lazyGetter(this, "Debugger", () => { -// let Debugger = require("Debugger"); -// hackDebugger(Debugger); -// return Debugger; -// }); -// loader.lazyRequireGetter(this, "CssLogic", "devtools/server/css-logic", true); -// loader.lazyRequireGetter(this, "events", "sdk/event/core"); -// loader.lazyRequireGetter(this, "mapURIToAddonID", "devtools/server/actors/utils/map-uri-to-addon-id"); - -/** - * A BreakpointActorMap is a map from locations to instances of BreakpointActor. - */ -function BreakpointActorMap() { - this._size = 0; - this._actors = {}; -} - -BreakpointActorMap.prototype = { - /** - * Return the number of BreakpointActors in this BreakpointActorMap. - * - * @returns Number - * The number of BreakpointActor in this BreakpointActorMap. - */ - get size() { - return this._size; - }, - - /** - * Generate all BreakpointActors that match the given location in - * this BreakpointActorMap. - * - * @param OriginalLocation location - * The location for which matching BreakpointActors should be generated. - */ - findActors: function* (location = new OriginalLocation()) { - // Fast shortcut for when we know we won't find any actors. Surprisingly - // enough, this speeds up refreshing when there are no breakpoints set by - // about 2x! - if (this.size === 0) { - return; - } - - function* findKeys(object, key) { - if (key !== undefined) { - if (key in object) { - yield key; - } - } - else { - for (let key of Object.keys(object)) { - yield key; - } - } - } - - let query = { - sourceActorID: location.originalSourceActor ? location.originalSourceActor.actorID : undefined, - line: location.originalLine, - }; - - // If location contains a line, assume we are searching for a whole line - // breakpoint, and set begin/endColumn accordingly. Otherwise, we are - // searching for all breakpoints, so begin/endColumn should be left unset. - if (location.originalLine) { - query.beginColumn = location.originalColumn ? location.originalColumn : 0; - query.endColumn = location.originalColumn ? location.originalColumn + 1 : Infinity; - } else { - query.beginColumn = location.originalColumn ? query.originalColumn : undefined; - query.endColumn = location.originalColumn ? query.originalColumn + 1 : undefined; - } - - for (let sourceActorID of findKeys(this._actors, query.sourceActorID)) - for (let line of findKeys(this._actors[sourceActorID], query.line)) - for (let beginColumn of findKeys(this._actors[sourceActorID][line], query.beginColumn)) - for (let endColumn of findKeys(this._actors[sourceActorID][line][beginColumn], query.endColumn)) { - yield this._actors[sourceActorID][line][beginColumn][endColumn]; - } - }, - - /** - * Return the BreakpointActor at the given location in this - * BreakpointActorMap. - * - * @param OriginalLocation location - * The location for which the BreakpointActor should be returned. - * - * @returns BreakpointActor actor - * The BreakpointActor at the given location. - */ - getActor: function (originalLocation) { - for (let actor of this.findActors(originalLocation)) { - return actor; - } - - return null; - }, - - /** - * Set the given BreakpointActor to the given location in this - * BreakpointActorMap. - * - * @param OriginalLocation location - * The location to which the given BreakpointActor should be set. - * - * @param BreakpointActor actor - * The BreakpointActor to be set to the given location. - */ - setActor: function (location, actor) { - let { originalSourceActor, originalLine, originalColumn } = location; - - let sourceActorID = originalSourceActor.actorID; - let line = originalLine; - let beginColumn = originalColumn ? originalColumn : 0; - let endColumn = originalColumn ? originalColumn + 1 : Infinity; - - if (!this._actors[sourceActorID]) { - this._actors[sourceActorID] = []; - } - if (!this._actors[sourceActorID][line]) { - this._actors[sourceActorID][line] = []; - } - if (!this._actors[sourceActorID][line][beginColumn]) { - this._actors[sourceActorID][line][beginColumn] = []; - } - if (!this._actors[sourceActorID][line][beginColumn][endColumn]) { - ++this._size; - } - this._actors[sourceActorID][line][beginColumn][endColumn] = actor; - }, - - /** - * Delete the BreakpointActor from the given location in this - * BreakpointActorMap. - * - * @param OriginalLocation location - * The location from which the BreakpointActor should be deleted. - */ - deleteActor: function (location) { - let { originalSourceActor, originalLine, originalColumn } = location; - - let sourceActorID = originalSourceActor.actorID; - let line = originalLine; - let beginColumn = originalColumn ? originalColumn : 0; - let endColumn = originalColumn ? originalColumn + 1 : Infinity; - - if (this._actors[sourceActorID]) { - if (this._actors[sourceActorID][line]) { - if (this._actors[sourceActorID][line][beginColumn]) { - if (this._actors[sourceActorID][line][beginColumn][endColumn]) { - --this._size; - } - delete this._actors[sourceActorID][line][beginColumn][endColumn]; - if (Object.keys(this._actors[sourceActorID][line][beginColumn]).length === 0) { - delete this._actors[sourceActorID][line][beginColumn]; - } - } - if (Object.keys(this._actors[sourceActorID][line]).length === 0) { - delete this._actors[sourceActorID][line]; - } - } - } - } -}; - -// exports.BreakpointActorMap = BreakpointActorMap; - -/** - * Keeps track of persistent sources across reloads and ties different - * source instances to the same actor id so that things like - * breakpoints survive reloads. ThreadSources uses this to force the - * same actorID on a SourceActor. - */ -function SourceActorStore() { - // source identifier --> actor id - this._sourceActorIds = Object.create(null); -} - -SourceActorStore.prototype = { - /** - * Lookup an existing actor id that represents this source, if available. - */ - getReusableActorId: function (aSource, aOriginalUrl) { - let url = this.getUniqueKey(aSource, aOriginalUrl); - if (url && url in this._sourceActorIds) { - return this._sourceActorIds[url]; - } - return null; - }, - - /** - * Update a source with an actorID. - */ - setReusableActorId: function (aSource, aOriginalUrl, actorID) { - let url = this.getUniqueKey(aSource, aOriginalUrl); - if (url) { - this._sourceActorIds[url] = actorID; - } - }, - - /** - * Make a unique URL from a source that identifies it across reloads. - */ - getUniqueKey: function (aSource, aOriginalUrl) { - if (aOriginalUrl) { - // Original source from a sourcemap. - return aOriginalUrl; - } - else { - return getSourceURL(aSource); - } - } -}; - -// exports.SourceActorStore = SourceActorStore; - -/** - * Manages pushing event loops and automatically pops and exits them in the - * correct order as they are resolved. - * - * @param ThreadActor thread - * The thread actor instance that owns this EventLoopStack. - * @param DebuggerServerConnection connection - * The remote protocol connection associated with this event loop stack. - * @param Object hooks - * An object with the following properties: - * - url: The URL string of the debuggee we are spinning an event loop - * for. - * - preNest: function called before entering a nested event loop - * - postNest: function called after exiting a nested event loop - */ -function EventLoopStack({ thread, connection, hooks }) { - this._hooks = hooks; - this._thread = thread; - this._connection = connection; -} - -EventLoopStack.prototype = { - /** - * The number of nested event loops on the stack. - */ - get size() { - // return xpcInspector.eventLoopNestLevel; - return _getEventLoopNestLevel(); - }, - - /** - * The URL of the debuggee who pushed the event loop on top of the stack. - */ - get lastPausedUrl() { - let url = null; - if (this.size > 0) { - try { - url = xpcInspector.lastNestRequestor.url; - } catch (e) { - // The tab's URL getter may throw if the tab is destroyed by the time - // this code runs, but we don't really care at this point. - dumpn(e); - } - } - return url; - }, - - /** - * The DebuggerServerConnection of the debugger who pushed the event loop on - * top of the stack - */ - get lastConnection() { - return xpcInspector.lastNestRequestor._connection; - }, - - /** - * Push a new nested event loop onto the stack. - * - * @returns EventLoop - */ - push: function () { - return new EventLoop({ - thread: this._thread, - connection: this._connection, - hooks: this._hooks - }); - } -}; - -/** - * An object that represents a nested event loop. It is used as the nest - * requestor with nsIJSInspector instances. - * - * @param ThreadActor thread - * The thread actor that is creating this nested event loop. - * @param DebuggerServerConnection connection - * The remote protocol connection associated with this event loop. - * @param Object hooks - * The same hooks object passed into EventLoopStack during its - * initialization. - */ -function EventLoop({ thread, connection, hooks }) { - this._thread = thread; - this._hooks = hooks; - this._connection = connection; - - this.enter = this.enter.bind(this); - this.resolve = this.resolve.bind(this); -} - -EventLoop.prototype = { - entered: false, - resolved: false, - get url() { return this._hooks.url; }, - - /** - * Enter this nested event loop. - */ - enter: function () { - let nestData = this._hooks.preNest - ? this._hooks.preNest() - : null; - - this.entered = true; - // xpcInspector.enterNestedEventLoop(this); - _enterNestedEventLoop(); - - // Keep exiting nested event loops while the last requestor is resolved. - // if (xpcInspector.eventLoopNestLevel > 0) { - // const { resolved } = xpcInspector.lastNestRequestor; - // if (resolved) { - // xpcInspector.exitNestedEventLoop(); - // } - // } - - if (this._hooks.postNest) { - this._hooks.postNest(nestData); - } - }, - - /** - * Resolve this nested event loop. - * - * @returns boolean - * True if we exited this nested event loop because it was on top of - * the stack, false if there is another nested event loop above this - * one that hasn't resolved yet. - */ - resolve: function () { - if (!this.entered) { - throw new Error("Can't resolve an event loop before it has been entered!"); - } - if (this.resolved) { - throw new Error("Already resolved this nested event loop!"); - } - this.resolved = true; - // if (this === xpcInspector.lastNestRequestor) - { - // xpcInspector.exitNestedEventLoop(); - _exitNestedEventLoop(); - return true; - } - return false; - }, -}; - -/** - * JSD2 actors. - */ - -/** - * Creates a ThreadActor. - * - * ThreadActors manage a JSInspector object and manage execution/inspection - * of debuggees. - * - * @param aParent object - * This |ThreadActor|'s parent actor. It must implement the following - * properties: - * - url: The URL string of the debuggee. - * - window: The global window object. - * - preNest: Function called before entering a nested event loop. - * - postNest: Function called after exiting a nested event loop. - * - makeDebugger: A function that takes no arguments and instantiates - * a Debugger that manages its globals on its own. - * @param aGlobal object [optional] - * An optional (for content debugging only) reference to the content - * window. - */ -function ThreadActor (aParent, aGlobal) { - this._state = "detached"; - this._frameActors = []; - this._parent = aParent; - this._dbg = null; - this._gripDepth = 0; - this._threadLifetimePool = null; - this._tabClosed = false; - this._scripts = null; - this._pauseOnDOMEvents = null; - - this._options = { - useSourceMaps: false, - autoBlackBox: false - }; - - this.breakpointActorMap = new BreakpointActorMap(); - this.sourceActorStore = new SourceActorStore(); - - this._debuggerSourcesSeen = null; - - // A map of actorID -> actor for breakpoints created and managed by the - // server. - this._hiddenBreakpoints = new Map(); - - this.global = aGlobal; - - this._allEventsListener = this._allEventsListener.bind(this); - this.onNewGlobal = this.onNewGlobal.bind(this); - this.onSourceEvent = this.onSourceEvent.bind(this); - this.uncaughtExceptionHook = this.uncaughtExceptionHook.bind(this); - this.onDebuggerStatement = this.onDebuggerStatement.bind(this); - this.onNewScript = this.onNewScript.bind(this); - this.objectGrip = this.objectGrip.bind(this); - this.pauseObjectGrip = this.pauseObjectGrip.bind(this); - this._onWindowReady = this._onWindowReady.bind(this); - // events.on(this._parent, "window-ready", this._onWindowReady); - // Set a wrappedJSObject property so |this| can be sent via the observer svc - // for the xpcshell harness. - this.wrappedJSObject = this; -}; - -ThreadActor.prototype = { - constructor: ThreadActor, - // Used by the ObjectActor to keep track of the depth of grip() calls. - _gripDepth: null, - - get dbg() { - if (!this._dbg) { - this._dbg = this._parent.makeDebugger(); - this._dbg.uncaughtExceptionHook = this.uncaughtExceptionHook; - this._dbg.onDebuggerStatement = this.onDebuggerStatement; - this._dbg.onNewScript = this.onNewScript; - // this._dbg.on("newGlobal", this.onNewGlobal); - // Keep the debugger disabled until a client attaches. - this._dbg.enabled = this._state != "detached"; - } - return this._dbg; - }, - - get globalDebugObject() { - if (!this._parent.window) { - return null; - } - return this.dbg.makeGlobalObjectReference(this._parent.window); - }, - - get state() { - return this._state; - }, - - get attached() { - return this.state == "attached" || - this.state == "running" || - this.state == "paused"; - }, - - get threadLifetimePool() { - if (!this._threadLifetimePool) { - this._threadLifetimePool = new ActorPool(this.conn); - this.conn.addActorPool(this._threadLifetimePool); - this._threadLifetimePool.objectActors = new WeakMap(); - } - return this._threadLifetimePool; - }, - - get scripts() { - if (!this._scripts) { - this._scripts = new ScriptStore(); - this._scripts.addScripts(this.dbg.findScripts()); - } - return this._scripts; - }, - - get sources() { - return this._parent.sources; - }, - - get youngestFrame() { - if (this.state != "paused") { - return null; - } - return this.dbg.getNewestFrame(); - }, - - _prettyPrintWorker: null, - get prettyPrintWorker() { - if (!this._prettyPrintWorker) { - this._prettyPrintWorker = new DevToolsWorker( - "resource://devtools/server/actors/pretty-print-worker.js", - { name: "pretty-print", - verbose: dumpn.wantLogging } - ); - } - return this._prettyPrintWorker; - }, - - /** - * Keep track of all of the nested event loops we use to pause the debuggee - * when we hit a breakpoint/debugger statement/etc in one place so we can - * resolve them when we get resume packets. We have more than one (and keep - * them in a stack) because we can pause within client evals. - */ - _threadPauseEventLoops: null, - _pushThreadPause: function () { - if (!this._threadPauseEventLoops) { - this._threadPauseEventLoops = []; - } - const eventLoop = this._nestedEventLoops.push(); - this._threadPauseEventLoops.push(eventLoop); - eventLoop.enter(); - }, - _popThreadPause: function () { - const eventLoop = this._threadPauseEventLoops.pop(); - assert(eventLoop, "Should have an event loop."); - eventLoop.resolve(); - }, - - /** - * Remove all debuggees and clear out the thread's sources. - */ - clearDebuggees: function () { - if (this._dbg) { - this.dbg.removeAllDebuggees(); - } - this._sources = null; - this._scripts = null; - }, - - /** - * Listener for our |Debugger|'s "newGlobal" event. - */ - onNewGlobal: function (aGlobal) { - // Notify the client. - this.conn.send({ - from: this.actorID, - type: "newGlobal", - // TODO: after bug 801084 lands see if we need to JSONify this. - hostAnnotations: aGlobal.hostAnnotations - }); - }, - - disconnect: function () { - dumpn("in ThreadActor.prototype.disconnect"); - if (this._state == "paused") { - this.onResume(); - } - - // Blow away our source actor ID store because those IDs are only - // valid for this connection. This is ok because we never keep - // things like breakpoints across connections. - this._sourceActorStore = null; - - // events.off(this._parent, "window-ready", this._onWindowReady); - this.sources.off("newSource", this.onSourceEvent); - this.sources.off("updatedSource", this.onSourceEvent); - this.clearDebuggees(); - this.conn.removeActorPool(this._threadLifetimePool); - this._threadLifetimePool = null; - - if (this._prettyPrintWorker) { - this._prettyPrintWorker.destroy(); - this._prettyPrintWorker = null; - } - - if (!this._dbg) { - return; - } - this._dbg.enabled = false; - this._dbg = null; - }, - - /** - * Disconnect the debugger and put the actor in the exited state. - */ - exit: function () { - this.disconnect(); - this._state = "exited"; - }, - - // Request handlers - onAttach: function (aRequest) { - if (this.state === "exited") { - return { type: "exited" }; - } - - if (this.state !== "detached") { - return { error: "wrongState", - message: "Current state is " + this.state }; - } - - this._state = "attached"; - this._debuggerSourcesSeen = new WeakSet(); - - Object.assign(this._options, aRequest.options || {}); - this.sources.setOptions(this._options); - this.sources.on("newSource", this.onSourceEvent); - this.sources.on("updatedSource", this.onSourceEvent); - - // Initialize an event loop stack. This can't be done in the constructor, - // because this.conn is not yet initialized by the actor pool at that time. - this._nestedEventLoops = new EventLoopStack({ - hooks: this._parent, - connection: this.conn, - thread: this - }); - - // this.dbg.addDebuggees(); - this.dbg.enabled = true; - try { - // Put ourselves in the paused state. - let packet = this._paused(); - if (!packet) { - return { error: "notAttached" }; - } - packet.why = { type: "attached" }; - - // Send the response to the attach request now (rather than - // returning it), because we're going to start a nested event loop - // here. - this.conn.send(packet); - - // Start a nested event loop. - this._pushThreadPause(); - - // We already sent a response to this request, don't send one - // now. - return null; - } catch (e) { - reportError(e); - return { error: "notAttached", message: e.toString() }; - } - }, - - onDetach: function (aRequest) { - this.disconnect(); - this._state = "detached"; - this._debuggerSourcesSeen = null; - - dumpn("ThreadActor.prototype.onDetach: returning 'detached' packet"); - return { - type: "detached" - }; - }, - - onReconfigure: function (aRequest) { - if (this.state == "exited") { - return { error: "wrongState" }; - } - const options = aRequest.options || {}; - - if ("observeAsmJS" in options) { - this.dbg.allowUnobservedAsmJS = !options.observeAsmJS; - } - - Object.assign(this._options, options); - - // Update the global source store -// this.sources.setOptions(options); - - return {}; - }, - - /** - * Pause the debuggee, by entering a nested event loop, and return a 'paused' - * packet to the client. - * - * @param Debugger.Frame aFrame - * The newest debuggee frame in the stack. - * @param object aReason - * An object with a 'type' property containing the reason for the pause. - * @param function onPacket - * Hook to modify the packet before it is sent. Feel free to return a - * promise. - */ - _pauseAndRespond: function (aFrame, aReason, onPacket = function (k) { return k; }) { - try { - let packet = this._paused(aFrame); - if (!packet) { - return undefined; - } - packet.why = aReason; - - let generatedLocation = this.sources.getFrameLocation(aFrame); - this.sources.getOriginalLocation(generatedLocation) - .then((originalLocation) => { - if (!originalLocation.originalSourceActor) { - // The only time the source actor will be null is if there - // was a sourcemap and it tried to look up the original - // location but there was no original URL. This is a strange - // scenario so we simply don't pause. - DevToolsUtils.reportException( - "ThreadActor", - new Error("Attempted to pause in a script with a sourcemap but " + - "could not find original location.") - ); - - return undefined; - } - - packet.frame.where = { - source: originalLocation.originalSourceActor.form(), - line: originalLocation.originalLine, - column: originalLocation.originalColumn - }; - Promise.resolve(onPacket(packet)) - .then(null, error => { - reportError(error); - return { - error: "unknownError", - message: error.message + "\n" + error.stack - }; - }) - .then(packet => { - this.conn.send(packet); - }); - }); - - this._pushThreadPause(); - } catch (e) { - reportError(e, "Got an exception during TA__pauseAndRespond: "); - } - - // If the browser tab has been closed, terminate the debuggee script - // instead of continuing. Executing JS after the content window is gone is - // a bad idea. - return this._tabClosed ? null : undefined; - }, - - _makeOnEnterFrame: function ({ pauseAndRespond }) { - return aFrame => { - const generatedLocation = this.sources.getFrameLocation(aFrame); - let { originalSourceActor } = this.unsafeSynchronize(this.sources.getOriginalLocation( - generatedLocation)); - let url = originalSourceActor.url; - - return this.sources.isBlackBoxed(url) - ? undefined - : pauseAndRespond(aFrame); - }; - }, - - _makeOnPop: function ({ thread, pauseAndRespond, createValueGrip }) { - return function (aCompletion) { - // onPop is called with 'this' set to the current frame. - - const generatedLocation = thread.sources.getFrameLocation(this); - const { originalSourceActor } = thread.unsafeSynchronize(thread.sources.getOriginalLocation( - generatedLocation)); - const url = originalSourceActor.url; - - if (thread.sources.isBlackBoxed(url)) { - return undefined; - } - - // Note that we're popping this frame; we need to watch for - // subsequent step events on its caller. - this.reportedPop = true; - - return pauseAndRespond(this, aPacket => { - aPacket.why.frameFinished = {}; - if (!aCompletion) { - aPacket.why.frameFinished.terminated = true; - } else if (aCompletion.hasOwnProperty("return")) { - aPacket.why.frameFinished.return = createValueGrip(aCompletion.return); - } else if (aCompletion.hasOwnProperty("yield")) { - aPacket.why.frameFinished.return = createValueGrip(aCompletion.yield); - } else { - aPacket.why.frameFinished.throw = createValueGrip(aCompletion.throw); - } - return aPacket; - }); - }; - }, - - _makeOnStep: function ({ thread, pauseAndRespond, startFrame, - startLocation, steppingType }) { - // Breaking in place: we should always pause. - if (steppingType === "break") { - return function () { - return pauseAndRespond(this); - }; - } - - // Otherwise take what a "step" means into consideration. - return function () { - // onStep is called with 'this' set to the current frame. - - // Only allow stepping stops at entry points for the line, when - // the stepping occurs in a single frame. The "same frame" - // check makes it so a sequence of steps can step out of a frame - // and into subsequent calls in the outer frame. E.g., if there - // is a call "a(b())" and the user steps into b, then this - // condition makes it possible to step out of b and into a. - if (this === startFrame && - !this.script.getOffsetLocation(this.offset).isEntryPoint) { - return undefined; - } - - const generatedLocation = thread.sources.getFrameLocation(this); - const newLocation = thread.unsafeSynchronize(thread.sources.getOriginalLocation( - generatedLocation)); - - // Cases when we should pause because we have executed enough to consider - // a "step" to have occured: - // - // 1.1. We change frames. - // 1.2. We change URLs (can happen without changing frames thanks to - // source mapping). - // 1.3. We change lines. - // - // Cases when we should always continue execution, even if one of the - // above cases is true: - // - // 2.1. We are in a source mapped region, but inside a null mapping - // (doesn't correlate to any region of original source) - // 2.2. The source we are in is black boxed. - - // Cases 2.1 and 2.2 - if (newLocation.originalUrl == null - || thread.sources.isBlackBoxed(newLocation.originalUrl)) { - return undefined; - } - - // Cases 1.1, 1.2 and 1.3 - if (this !== startFrame - || startLocation.originalUrl !== newLocation.originalUrl - || startLocation.originalLine !== newLocation.originalLine) { - return pauseAndRespond(this); - } - - // Otherwise, let execution continue (we haven't executed enough code to - // consider this a "step" yet). - return undefined; - }; - }, - - /** - * Define the JS hook functions for stepping. - */ - _makeSteppingHooks: function (aStartLocation, steppingType) { - // Bind these methods and state because some of the hooks are called - // with 'this' set to the current frame. Rather than repeating the - // binding in each _makeOnX method, just do it once here and pass it - // in to each function. - const steppingHookState = { - pauseAndRespond: (aFrame, onPacket = k=>k) => { - return this._pauseAndRespond(aFrame, { type: "resumeLimit" }, onPacket); - }, - createValueGrip: v => createValueGrip(v, this._pausePool, - this.objectGrip), - thread: this, - startFrame: this.youngestFrame, - startLocation: aStartLocation, - steppingType: steppingType - }; - - return { - onEnterFrame: this._makeOnEnterFrame(steppingHookState), - onPop: this._makeOnPop(steppingHookState), - onStep: this._makeOnStep(steppingHookState) - }; - }, - - /** - * Handle attaching the various stepping hooks we need to attach when we - * receive a resume request with a resumeLimit property. - * - * @param Object aRequest - * The request packet received over the RDP. - * @returns A promise that resolves to true once the hooks are attached, or is - * rejected with an error packet. - */ - _handleResumeLimit: function (aRequest) { - let steppingType = aRequest.resumeLimit.type; - if (["break", "step", "next", "finish"].indexOf(steppingType) == -1) { - return reject({ error: "badParameterType", - message: "Unknown resumeLimit type" }); - } - - const generatedLocation = this.sources.getFrameLocation(this.youngestFrame); - return this.sources.getOriginalLocation(generatedLocation) - .then(originalLocation => { - const { onEnterFrame, onPop, onStep } = this._makeSteppingHooks(originalLocation, - steppingType); - - // Make sure there is still a frame on the stack if we are to continue - // stepping. - let stepFrame = this._getNextStepFrame(this.youngestFrame); - if (stepFrame) { - switch (steppingType) { - case "step": - this.dbg.onEnterFrame = onEnterFrame; - // Fall through. - case "break": - case "next": - if (stepFrame.script) { - stepFrame.onStep = onStep; - } - stepFrame.onPop = onPop; - break; - case "finish": - stepFrame.onPop = onPop; - } - } - - return true; - }); - }, - - /** - * Clear the onStep and onPop hooks from the given frame and all of the frames - * below it. - * - * @param Debugger.Frame aFrame - * The frame we want to clear the stepping hooks from. - */ - _clearSteppingHooks: function (aFrame) { - if (aFrame && aFrame.live) { - while (aFrame) { - aFrame.onStep = undefined; - aFrame.onPop = undefined; - aFrame = aFrame.older; - } - } - }, - - /** - * Listen to the debuggee's DOM events if we received a request to do so. - * - * @param Object aRequest - * The resume request packet received over the RDP. - */ - _maybeListenToEvents: function (aRequest) { - // Break-on-DOMEvents is only supported in content debugging. - let events = aRequest.pauseOnDOMEvents; - if (this.global && events && - (events == "*" || - (Array.isArray(events) && events.length))) { - this._pauseOnDOMEvents = events; - let els = Cc["@mozilla.org/eventlistenerservice;1"] - .getService(Ci.nsIEventListenerService); - els.addListenerForAllEvents(this.global, this._allEventsListener, true); - } - }, - - /** - * If we are tasked with breaking on the load event, we have to add the - * listener early enough. - */ - _onWindowReady: function () { - this._maybeListenToEvents({ - pauseOnDOMEvents: this._pauseOnDOMEvents - }); - }, - - /** - * Handle a protocol request to resume execution of the debuggee. - */ - onResume: function (aRequest) { - if (this._state !== "paused") { - return { - error: "wrongState", - message: "Can't resume when debuggee isn't paused. Current state is '" - + this._state + "'", - state: this._state - }; - } - - // In case of multiple nested event loops (due to multiple debuggers open in - // different tabs or multiple debugger clients connected to the same tab) - // only allow resumption in a LIFO order. - if (this._nestedEventLoops.size && this._nestedEventLoops.lastPausedUrl - && (this._nestedEventLoops.lastPausedUrl !== this._parent.url - || this._nestedEventLoops.lastConnection !== this.conn)) { - return { - error: "wrongOrder", - message: "trying to resume in the wrong order.", - lastPausedUrl: this._nestedEventLoops.lastPausedUrl - }; - } - let resumeLimitHandled; - if (aRequest && aRequest.resumeLimit) { - resumeLimitHandled = this._handleResumeLimit(aRequest); - } else { - this._clearSteppingHooks(this.youngestFrame); - resumeLimitHandled = Promise.resolve(true); - } - - return resumeLimitHandled.then(() => { - if (aRequest) { - this._options.pauseOnExceptions = aRequest.pauseOnExceptions; - this._options.ignoreCaughtExceptions = aRequest.ignoreCaughtExceptions; - this.maybePauseOnExceptions(); - this._maybeListenToEvents(aRequest); - } - - let packet = this._resumed(); - this._popThreadPause(); - // Tell anyone who cares of the resume (as of now, that's the xpcshell - // harness) - // if (Services.obs) { - // Services.obs.notifyObservers(this, "devtools-thread-resumed", null); - // } - return packet; - }, error => { - return error instanceof Error - ? { error: "unknownError", - message: DevToolsUtils.safeErrorString(error) } - // It is a known error, and the promise was rejected with an error - // packet. - : error; - }); - }, - - /** - * Spin up a nested event loop so we can synchronously resolve a promise. - * - * DON'T USE THIS UNLESS YOU ABSOLUTELY MUST! Nested event loops suck: the - * world's state can change out from underneath your feet because JS is no - * longer run-to-completion. - * - * @param aPromise - * The promise we want to resolve. - * @returns The promise's resolution. - */ - unsafeSynchronize: function (aPromise) { - let needNest = true; - let eventLoop; - let returnVal; - - aPromise - .then((aResolvedVal) => { - needNest = false; - returnVal = aResolvedVal; - }) - .then(null, (aError) => { - reportError(aError, "Error inside unsafeSynchronize:"); - }) - .then(() => { - if (eventLoop) { - eventLoop.resolve(); - } - }); - - if (needNest) { - eventLoop = this._nestedEventLoops.push(); - eventLoop.enter(); - } - - return returnVal; - }, - - /** - * Set the debugging hook to pause on exceptions if configured to do so. - */ - maybePauseOnExceptions: function () { - if (this._options.pauseOnExceptions) { - this.dbg.onExceptionUnwind = this.onExceptionUnwind.bind(this); - } - }, - - /** - * A listener that gets called for every event fired on the page, when a list - * of interesting events was provided with the pauseOnDOMEvents property. It - * is used to set server-managed breakpoints on any existing event listeners - * for those events. - * - * @param Event event - * The event that was fired. - */ - _allEventsListener: function (event) { - if (this._pauseOnDOMEvents == "*" || - this._pauseOnDOMEvents.indexOf(event.type) != -1) { - for (let listener of this._getAllEventListeners(event.target)) { - if (event.type == listener.type || this._pauseOnDOMEvents == "*") { - this._breakOnEnter(listener.script); - } - } - } - }, - - /** - * Return an array containing all the event listeners attached to the - * specified event target and its ancestors in the event target chain. - * - * @param EventTarget eventTarget - * The target the event was dispatched on. - * @returns Array - */ - _getAllEventListeners: function (eventTarget) { - let els = Cc["@mozilla.org/eventlistenerservice;1"] - .getService(Ci.nsIEventListenerService); - - let targets = els.getEventTargetChainFor(eventTarget, true); - let listeners = []; - - for (let target of targets) { - let handlers = els.getListenerInfoFor(target); - for (let handler of handlers) { - // Null is returned for all-events handlers, and native event listeners - // don't provide any listenerObject, which makes them not that useful to - // a JS debugger. - if (!handler || !handler.listenerObject || !handler.type) - continue; - // Create a listener-like object suitable for our purposes. - let l = Object.create(null); - l.type = handler.type; - let listener = handler.listenerObject; - let listenerDO = this.globalDebugObject.makeDebuggeeValue(listener); - // If the listener is not callable, assume it is an event handler object. - if (!listenerDO.callable) { - // For some events we don't have permission to access the - // 'handleEvent' property when running in content scope. - if (!listenerDO.unwrap()) { - continue; - } - let heDesc; - while (!heDesc && listenerDO) { - heDesc = listenerDO.getOwnPropertyDescriptor("handleEvent"); - listenerDO = listenerDO.proto; - } - if (heDesc && heDesc.value) { - listenerDO = heDesc.value; - } - } - // When the listener is a bound function, we are actually interested in - // the target function. - while (listenerDO.isBoundFunction) { - listenerDO = listenerDO.boundTargetFunction; - } - l.script = listenerDO.script; - // Chrome listeners won't be converted to debuggee values, since their - // compartment is not added as a debuggee. - if (!l.script) - continue; - listeners.push(l); - } - } - return listeners; - }, - - /** - * Set a breakpoint on the first line of the given script that has an entry - * point. - */ - _breakOnEnter: function (script) { - let offsets = script.getAllOffsets(); - for (let line = 0, n = offsets.length; line < n; line++) { - if (offsets[line]) { - // N.B. Hidden breakpoints do not have an original location, and are not - // stored in the breakpoint actor map. - let actor = new BreakpointActor(this); - this.threadLifetimePool.addActor(actor); - - let scripts = this.dbg.findScripts({ source: script.source, line: line }); - let entryPoints = findEntryPointsForLine(scripts, line); - setBreakpointAtEntryPoints(actor, entryPoints); - this._hiddenBreakpoints.set(actor.actorID, actor); - break; - } - } - }, - - /** - * Helper method that returns the next frame when stepping. - */ - _getNextStepFrame: function (aFrame) { - let stepFrame = aFrame.reportedPop ? aFrame.older : aFrame; - if (!stepFrame || !stepFrame.script) { - stepFrame = null; - } - return stepFrame; - }, - - onClientEvaluate: function (aRequest) { - if (this.state !== "paused") { - return { error: "wrongState", - message: "Debuggee must be paused to evaluate code." }; - } - - let frame = this._requestFrame(aRequest.frame); - if (!frame) { - return { error: "unknownFrame", - message: "Evaluation frame not found" }; - } - - if (!frame.environment) { - return { error: "notDebuggee", - message: "cannot access the environment of this frame." }; - } - - let youngest = this.youngestFrame; - - // Put ourselves back in the running state and inform the client. - let resumedPacket = this._resumed(); - this.conn.send(resumedPacket); - - // Run the expression. - // XXX: test syntax errors - let completion = frame.eval(aRequest.expression); - - // Put ourselves back in the pause state. - let packet = this._paused(youngest); - packet.why = { type: "clientEvaluated", - frameFinished: this.createProtocolCompletionValue(completion) }; - - // Return back to our previous pause's event loop. - return packet; - }, - - onFrames: function (aRequest) { - if (this.state !== "paused") { - return { error: "wrongState", - message: "Stack frames are only available while the debuggee is paused."}; - } - - let start = aRequest.start ? aRequest.start : 0; - let count = aRequest.count; - - // Find the starting frame... - let frame = this.youngestFrame; - let i = 0; - while (frame && (i < start)) { - frame = frame.older; - i++; - } - - // Return request.count frames, or all remaining - // frames if count is not defined. - let promises = []; - for (; frame && (!count || i < (start + count)); i++, frame = frame.older) { - let form = this._createFrameActor(frame).form(); - form.depth = i; - - let promise = this.sources.getOriginalLocation(new GeneratedLocation( - this.sources.createNonSourceMappedActor(frame.script.source), - form.where.line, - form.where.column - )).then((originalLocation) => { - if (!originalLocation.originalSourceActor) { - return null; - } - - let sourceForm = originalLocation.originalSourceActor.form(); - form.where = { - source: sourceForm, - line: originalLocation.originalLine, - column: originalLocation.originalColumn - }; - form.source = sourceForm; - return form; - }); - promises.push(promise); - } - - return Promise.all(promises).then(function (frames) { - // Filter null values because sourcemapping may have failed. - return { frames: frames.filter(x => !!x) }; - }); - }, - - onReleaseMany: function (aRequest) { - if (!aRequest.actors) { - return { error: "missingParameter", - message: "no actors were specified" }; - } - - let res; - for (let actorID of aRequest.actors) { - let actor = this.threadLifetimePool.get(actorID); - if (!actor) { - if (!res) { - res = { error: "notReleasable", - message: "Only thread-lifetime actors can be released." }; - } - continue; - } - actor.onRelease(); - } - return res ? res : {}; - }, - - /** - * Get the script and source lists from the debugger. - */ - _discoverSources: function () { - // Only get one script per Debugger.Source. - const sourcesToScripts = new Map(); - const scripts = this.dbg.findScripts(); - - for (let i = 0, len = scripts.length; i < len; i++) { - let s = scripts[i]; - if (s.source) { - sourcesToScripts.set(s.source, s); - } - } - - return Promise.all([...sourcesToScripts.values()].map(script => { - return this.sources.createSourceActors(script.source); - })); - }, - - onSources: function (aRequest) { - return this._discoverSources().then(() => { - // No need to flush the new source packets here, as we are sending the - // list of sources out immediately and we don't need to invoke the - // overhead of an RDP packet for every source right now. Let the default - // timeout flush the buffered packets. - - return { - sources: this.sources.iter().map(s => s.form()) - }; - }); - }, - - /** - * Disassociate all breakpoint actors from their scripts and clear the - * breakpoint handlers. This method can be used when the thread actor intends - * to keep the breakpoint store, but needs to clear any actual breakpoints, - * e.g. due to a page navigation. This way the breakpoint actors' script - * caches won't hold on to the Debugger.Script objects leaking memory. - */ - disableAllBreakpoints: function () { - for (let bpActor of this.breakpointActorMap.findActors()) { - bpActor.removeScripts(); - } - }, - - - /** - * Handle a protocol request to pause the debuggee. - */ - onInterrupt: function (aRequest) { - if (this.state == "exited") { - return { type: "exited" }; - } else if (this.state == "paused") { - // TODO: return the actual reason for the existing pause. - return { type: "paused", why: { type: "alreadyPaused" } }; - } else if (this.state != "running") { - return { error: "wrongState", - message: "Received interrupt request in " + this.state + - " state." }; - } - - try { - // If execution should pause just before the next JavaScript bytecode is - // executed, just set an onEnterFrame handler. - if (aRequest.when == "onNext") { - let onEnterFrame = (aFrame) => { - return this._pauseAndRespond(aFrame, { type: "interrupted", onNext: true }); - }; - this.dbg.onEnterFrame = onEnterFrame; - - return { type: "willInterrupt" }; - } - - // If execution should pause immediately, just put ourselves in the paused - // state. - let packet = this._paused(); - if (!packet) { - return { error: "notInterrupted" }; - } - packet.why = { type: "interrupted" }; - - // Send the response to the interrupt request now (rather than - // returning it), because we're going to start a nested event loop - // here. - this.conn.send(packet); - - // Start a nested event loop. - this._pushThreadPause(); - - // We already sent a response to this request, don't send one - // now. - return null; - } catch (e) { - reportError(e); - return { error: "notInterrupted", message: e.toString() }; - } - }, - - /** - * Handle a protocol request to retrieve all the event listeners on the page. - */ - onEventListeners: function (aRequest) { - // This request is only supported in content debugging. - if (!this.global) { - return { - error: "notImplemented", - message: "eventListeners request is only supported in content debugging" - }; - } - - let els = Cc["@mozilla.org/eventlistenerservice;1"] - .getService(Ci.nsIEventListenerService); - - let nodes = this.global.document.getElementsByTagName("*"); - nodes = [this.global].concat([].slice.call(nodes)); - let listeners = []; - - for (let node of nodes) { - let handlers = els.getListenerInfoFor(node); - - for (let handler of handlers) { - // Create a form object for serializing the listener via the protocol. - let listenerForm = Object.create(null); - let listener = handler.listenerObject; - // Native event listeners don't provide any listenerObject or type and - // are not that useful to a JS debugger. - if (!listener || !handler.type) { - continue; - } - - // There will be no tagName if the event listener is set on the window. - let selector = node.tagName ? CssLogic.findCssSelector(node) : "window"; - let nodeDO = this.globalDebugObject.makeDebuggeeValue(node); - listenerForm.node = { - selector: selector, - object: createValueGrip(nodeDO, this._pausePool, this.objectGrip) - }; - listenerForm.type = handler.type; - listenerForm.capturing = handler.capturing; - listenerForm.allowsUntrusted = handler.allowsUntrusted; - listenerForm.inSystemEventGroup = handler.inSystemEventGroup; - let handlerName = "on" + listenerForm.type; - listenerForm.isEventHandler = false; - if (typeof node.hasAttribute !== "undefined") { - listenerForm.isEventHandler = !!node.hasAttribute(handlerName); - } - if (!!node[handlerName]) { - listenerForm.isEventHandler = !!node[handlerName]; - } - // Get the Debugger.Object for the listener object. - let listenerDO = this.globalDebugObject.makeDebuggeeValue(listener); - // If the listener is an object with a 'handleEvent' method, use that. - if (listenerDO.class == "Object" || listenerDO.class == "XULElement") { - // For some events we don't have permission to access the - // 'handleEvent' property when running in content scope. - if (!listenerDO.unwrap()) { - continue; - } - let heDesc; - while (!heDesc && listenerDO) { - heDesc = listenerDO.getOwnPropertyDescriptor("handleEvent"); - listenerDO = listenerDO.proto; - } - if (heDesc && heDesc.value) { - listenerDO = heDesc.value; - } - } - // When the listener is a bound function, we are actually interested in - // the target function. - while (listenerDO.isBoundFunction) { - listenerDO = listenerDO.boundTargetFunction; - } - listenerForm.function = createValueGrip(listenerDO, this._pausePool, - this.objectGrip); - listeners.push(listenerForm); - } - } - return { listeners: listeners }; - }, - - /** - * Return the Debug.Frame for a frame mentioned by the protocol. - */ - _requestFrame: function (aFrameID) { - if (!aFrameID) { - return this.youngestFrame; - } - - if (this._framePool.has(aFrameID)) { - return this._framePool.get(aFrameID).frame; - } - - return undefined; - }, - - _paused: function (aFrame) { - // We don't handle nested pauses correctly. Don't try - if we're - // paused, just continue running whatever code triggered the pause. - // We don't want to actually have nested pauses (although we - // have nested event loops). If code runs in the debuggee during - // a pause, it should cause the actor to resume (dropping - // pause-lifetime actors etc) and then repause when complete. - - if (this.state === "paused") { - return undefined; - } - - // Clear stepping hooks. - this.dbg.onEnterFrame = undefined; - this.dbg.onExceptionUnwind = undefined; - if (aFrame) { - aFrame.onStep = undefined; - aFrame.onPop = undefined; - } - - // Clear DOM event breakpoints. - // XPCShell tests don't use actual DOM windows for globals and cause - // removeListenerForAllEvents to throw. - // if (!isWorker && this.global && !this.global.toString().includes("Sandbox")) { - // let els = Cc["@mozilla.org/eventlistenerservice;1"] - // .getService(Ci.nsIEventListenerService); - // els.removeListenerForAllEvents(this.global, this._allEventsListener, true); - // for (let [, bp] of this._hiddenBreakpoints) { - // bp.delete(); - // } - // this._hiddenBreakpoints.clear(); - // } - - this._state = "paused"; - - // Create the actor pool that will hold the pause actor and its - // children. - assert(!this._pausePool, "No pause pool should exist yet"); - this._pausePool = new ActorPool(this.conn); - this.conn.addActorPool(this._pausePool); - - // Give children of the pause pool a quick link back to the - // thread... - this._pausePool.threadActor = this; - - // Create the pause actor itself... - assert(!this._pauseActor, "No pause actor should exist yet"); - this._pauseActor = new PauseActor(this._pausePool); - this._pausePool.addActor(this._pauseActor); - - // Update the list of frames. - let poppedFrames = this._updateFrames(); - - // Send off the paused packet and spin an event loop. - let packet = { from: this.actorID, - type: "paused", - actor: this._pauseActor.actorID }; - if (aFrame) { - packet.frame = this._createFrameActor(aFrame).form(); - } - - if (poppedFrames) { - packet.poppedFrames = poppedFrames; - } - - return packet; - }, - - _resumed: function () { - this._state = "running"; - - // Drop the actors in the pause actor pool. - this.conn.removeActorPool(this._pausePool); - - this._pausePool = null; - this._pauseActor = null; - - return { from: this.actorID, type: "resumed" }; - }, - - /** - * Expire frame actors for frames that have been popped. - * - * @returns A list of actor IDs whose frames have been popped. - */ - _updateFrames: function () { - let popped = []; - - // Create the actor pool that will hold the still-living frames. - let framePool = new ActorPool(this.conn); - let frameList = []; - - for (let frameActor of this._frameActors) { - if (frameActor.frame.live) { - framePool.addActor(frameActor); - frameList.push(frameActor); - } else { - popped.push(frameActor.actorID); - } - } - - // Remove the old frame actor pool, this will expire - // any actors that weren't added to the new pool. - if (this._framePool) { - this.conn.removeActorPool(this._framePool); - } - - this._frameActors = frameList; - this._framePool = framePool; - this.conn.addActorPool(framePool); - - return popped; - }, - - _createFrameActor: function (aFrame) { - if (aFrame.actor) { - return aFrame.actor; - } - - let actor = new FrameActor(aFrame, this); - this._frameActors.push(actor); - this._framePool.addActor(actor); - aFrame.actor = actor; - - return actor; - }, - - /** - * Create and return an environment actor that corresponds to the provided - * Debugger.Environment. - * @param Debugger.Environment aEnvironment - * The lexical environment we want to extract. - * @param object aPool - * The pool where the newly-created actor will be placed. - * @return The EnvironmentActor for aEnvironment or undefined for host - * functions or functions scoped to a non-debuggee global. - */ - createEnvironmentActor: function (aEnvironment, aPool) { - if (!aEnvironment) { - return undefined; - } - - if (aEnvironment.actor) { - return aEnvironment.actor; - } - - let actor = new EnvironmentActor(aEnvironment, this); - aPool.addActor(actor); - aEnvironment.actor = actor; - - return actor; - }, - - /** - * Return a protocol completion value representing the given - * Debugger-provided completion value. - */ - createProtocolCompletionValue: function (aCompletion) { - let protoValue = {}; - if (aCompletion == null) { - protoValue.terminated = true; - } else if ("return" in aCompletion) { - protoValue.return = createValueGrip(aCompletion.return, - this._pausePool, this.objectGrip); - } else if ("throw" in aCompletion) { - protoValue.throw = createValueGrip(aCompletion.throw, - this._pausePool, this.objectGrip); - } else { - protoValue.return = createValueGrip(aCompletion.yield, - this._pausePool, this.objectGrip); - } - return protoValue; - }, - - /** - * Create a grip for the given debuggee object. - * - * @param aValue Debugger.Object - * The debuggee object value. - * @param aPool ActorPool - * The actor pool where the new object actor will be added. - */ - objectGrip: function (aValue, aPool) { - if (!aPool.objectActors) { - aPool.objectActors = new WeakMap(); - } - - if (aPool.objectActors.has(aValue)) { - return aPool.objectActors.get(aValue).grip(); - } else if (this.threadLifetimePool.objectActors.has(aValue)) { - return this.threadLifetimePool.objectActors.get(aValue).grip(); - } - - let actor = new PauseScopedObjectActor(aValue, { - getGripDepth: () => this._gripDepth, - incrementGripDepth: () => this._gripDepth++, - decrementGripDepth: () => this._gripDepth--, - createValueGrip: v => createValueGrip(v, this._pausePool, - this.pauseObjectGrip), - sources: () => this.sources, - createEnvironmentActor: (env, pool) => - this.createEnvironmentActor(env, pool), - promote: () => this.threadObjectGrip(actor), - isThreadLifetimePool: () => - actor.registeredPool !== this.threadLifetimePool, - getGlobalDebugObject: () => this.globalDebugObject - }); - aPool.addActor(actor); - aPool.objectActors.set(aValue, actor); - return actor.grip(); - }, - - /** - * Create a grip for the given debuggee object with a pause lifetime. - * - * @param aValue Debugger.Object - * The debuggee object value. - */ - pauseObjectGrip: function (aValue) { - if (!this._pausePool) { - throw "Object grip requested while not paused."; - } - - return this.objectGrip(aValue, this._pausePool); - }, - - /** - * Extend the lifetime of the provided object actor to thread lifetime. - * - * @param aActor object - * The object actor. - */ - threadObjectGrip: function (aActor) { - // We want to reuse the existing actor ID, so we just remove it from the - // current pool's weak map and then let pool.addActor do the rest. - aActor.registeredPool.objectActors.delete(aActor.obj); - this.threadLifetimePool.addActor(aActor); - this.threadLifetimePool.objectActors.set(aActor.obj, aActor); - }, - - /** - * Handle a protocol request to promote multiple pause-lifetime grips to - * thread-lifetime grips. - * - * @param aRequest object - * The protocol request object. - */ - onThreadGrips: function (aRequest) { - if (this.state != "paused") { - return { error: "wrongState" }; - } - - if (!aRequest.actors) { - return { error: "missingParameter", - message: "no actors were specified" }; - } - - for (let actorID of aRequest.actors) { - let actor = this._pausePool.get(actorID); - if (actor) { - this.threadObjectGrip(actor); - } - } - return {}; - }, - - /** - * Create a long string grip that is scoped to a pause. - * - * @param aString String - * The string we are creating a grip for. - */ - pauseLongStringGrip: function (aString) { - return longStringGrip(aString, this._pausePool); - }, - - /** - * Create a long string grip that is scoped to a thread. - * - * @param aString String - * The string we are creating a grip for. - */ - threadLongStringGrip: function (aString) { - return longStringGrip(aString, this._threadLifetimePool); - }, - - // JS Debugger API hooks. - - /** - * A function that the engine calls when a call to a debug event hook, - * breakpoint handler, watchpoint handler, or similar function throws some - * exception. - * - * @param aException exception - * The exception that was thrown in the debugger code. - */ - uncaughtExceptionHook: function (aException) { - dumpn("Got an exception: " + aException.message + "\n" + aException.stack); - }, - - /** - * A function that the engine calls when a debugger statement has been - * executed in the specified frame. - * - * @param aFrame Debugger.Frame - * The stack frame that contained the debugger statement. - */ - onDebuggerStatement: function (aFrame) { - // Don't pause if we are currently stepping (in or over) or the frame is - // black-boxed. - const generatedLocation = this.sources.getFrameLocation(aFrame); - const { originalSourceActor } = this.unsafeSynchronize(this.sources.getOriginalLocation( - generatedLocation)); - const url = originalSourceActor ? originalSourceActor.url : null; - - return this.sources.isBlackBoxed(url) || aFrame.onStep - ? undefined - : this._pauseAndRespond(aFrame, { type: "debuggerStatement" }); - }, - - /** - * A function that the engine calls when an exception has been thrown and has - * propagated to the specified frame. - * - * @param aFrame Debugger.Frame - * The youngest remaining stack frame. - * @param aValue object - * The exception that was thrown. - */ - onExceptionUnwind: function (aFrame, aValue) { - let willBeCaught = false; - for (let frame = aFrame; frame != null; frame = frame.older) { - if (frame.script.isInCatchScope(frame.offset)) { - willBeCaught = true; - break; - } - } - - if (willBeCaught && this._options.ignoreCaughtExceptions) { - return undefined; - } - - // NS_ERROR_NO_INTERFACE exceptions are a special case in browser code, - // since they're almost always thrown by QueryInterface functions, and - // handled cleanly by native code. -// if (aValue == Cr.NS_ERROR_NO_INTERFACE) { -// return undefined; -// } - - const generatedLocation = this.sources.getFrameLocation(aFrame); - const { originalSourceActor } = this.unsafeSynchronize(this.sources.getOriginalLocation( - generatedLocation)); - const url = originalSourceActor ? originalSourceActor.url : null; - - if (this.sources.isBlackBoxed(url)) { - return undefined; - } - - try { - let packet = this._paused(aFrame); - if (!packet) { - return undefined; - } - - packet.why = { type: "exception", - exception: createValueGrip(aValue, this._pausePool, - this.objectGrip) - }; - this.conn.send(packet); - - this._pushThreadPause(); - } catch (e) { - reportError(e, "Got an exception during TA_onExceptionUnwind: "); - } - - return undefined; - }, - - /** - * A function that the engine calls when a new script has been loaded into the - * scope of the specified debuggee global. - * - * @param aScript Debugger.Script - * The source script that has been loaded into a debuggee compartment. - * @param aGlobal Debugger.Object - * A Debugger.Object instance whose referent is the global object. - */ - onNewScript: function (aScript, aGlobal) { - this._addSource(aScript.source); - }, - - /** - * A function called when there's a new or updated source from a thread actor's - * sources. Emits `newSource` and `updatedSource` on the tab actor. - * - * @param {String} name - * @param {SourceActor} source - */ - onSourceEvent: function (name, source) { - this.conn.send({ - from: this._parent.actorID, - type: name, - source: source.form() - }); - - // For compatibility and debugger still using `newSource` on the thread client, - // still emit this event here. Clean up in bug 1247084 - if (name === "newSource") { - this.conn.send({ - from: this.actorID, - type: name, - source: source.form() - }); - } - }, - - /** - * Add the provided source to the server cache. - * - * @param aSource Debugger.Source - * The source that will be stored. - * @returns true, if the source was added; false otherwise. - */ - _addSource: function (aSource) { - if (!this.sources.allowSource(aSource) || this._debuggerSourcesSeen.has(aSource)) { - return false; - } - - let sourceActor = this.sources.createNonSourceMappedActor(aSource); - let bpActors = [...this.breakpointActorMap.findActors()]; - - if (this._options.useSourceMaps) { - let promises = []; - - // Go ahead and establish the source actors for this script, which - // fetches sourcemaps if available and sends onNewSource - // notifications. - let sourceActorsCreated = this.sources._createSourceMappedActors(aSource); - - if (bpActors.length) { - // We need to use unsafeSynchronize here because if the page is being reloaded, - // this call will replace the previous set of source actors for this source - // with a new one. If the source actors have not been replaced by the time - // we try to reset the breakpoints below, their location objects will still - // point to the old set of source actors, which point to different - // scripts. - this.unsafeSynchronize(sourceActorsCreated); - } - - for (let _actor of bpActors) { - // XXX bug 1142115: We do async work in here, so we need to create a fresh - // binding because for/of does not yet do that in SpiderMonkey. - let actor = _actor; - - if (actor.isPending) { - promises.push(actor.originalLocation.originalSourceActor._setBreakpoint(actor)); - } else { - promises.push(this.sources.getAllGeneratedLocations(actor.originalLocation) - .then((generatedLocations) => { - if (generatedLocations.length > 0 && - generatedLocations[0].generatedSourceActor.actorID === sourceActor.actorID) { - sourceActor._setBreakpointAtAllGeneratedLocations(actor, generatedLocations); - } - })); - } - } - - if (promises.length > 0) { - this.unsafeSynchronize(Promise.all(promises)); - } - } else { - // Bug 1225160: If addSource is called in response to a new script - // notification, and this notification was triggered by loading a JSM from - // chrome code, calling unsafeSynchronize could cause a debuggee timer to - // fire. If this causes the JSM to be loaded a second time, the browser - // will crash, because loading JSMS is not reentrant, and the first load - // has not completed yet. - // - // The root of the problem is that unsafeSynchronize can cause debuggee - // code to run. Unfortunately, fixing that is prohibitively difficult. The - // best we can do at the moment is disable source maps for the browser - // debugger, and carefully avoid the use of unsafeSynchronize in this - // function when source maps are disabled. - for (let actor of bpActors) { - if (actor.isPending) { - actor.originalLocation.originalSourceActor._setBreakpoint(actor); - } else { - actor.originalLocation.originalSourceActor._setBreakpointAtGeneratedLocation( - actor, GeneratedLocation.fromOriginalLocation(actor.originalLocation) - ); - } - } - } - - this._debuggerSourcesSeen.add(aSource); - return true; - }, - - - /** - * Get prototypes and properties of multiple objects. - */ - onPrototypesAndProperties: function (aRequest) { - let result = {}; - for (let actorID of aRequest.actors) { - // This code assumes that there are no lazily loaded actors returned - // by this call. - let actor = this.conn.getActor(actorID); - if (!actor) { - return { from: this.actorID, - error: "noSuchActor" }; - } - let handler = actor.onPrototypeAndProperties; - if (!handler) { - return { from: this.actorID, - error: "unrecognizedPacketType", - message: ('Actor "' + actorID + - '" does not recognize the packet type ' + - '"prototypeAndProperties"') }; - } - result[actorID] = handler.call(actor, {}); - } - return { from: this.actorID, - actors: result }; - } -}; - -ThreadActor.prototype.requestTypes = { - "attach": ThreadActor.prototype.onAttach, - "detach": ThreadActor.prototype.onDetach, - "reconfigure": ThreadActor.prototype.onReconfigure, - "resume": ThreadActor.prototype.onResume, - "clientEvaluate": ThreadActor.prototype.onClientEvaluate, - "frames": ThreadActor.prototype.onFrames, - "interrupt": ThreadActor.prototype.onInterrupt, - "eventListeners": ThreadActor.prototype.onEventListeners, - "releaseMany": ThreadActor.prototype.onReleaseMany, - "sources": ThreadActor.prototype.onSources, - "threadGrips": ThreadActor.prototype.onThreadGrips, - "prototypesAndProperties": ThreadActor.prototype.onPrototypesAndProperties -}; - -// exports.ThreadActor = ThreadActor; - -/** - * Creates a PauseActor. - * - * PauseActors exist for the lifetime of a given debuggee pause. Used to - * scope pause-lifetime grips. - * - * @param ActorPool aPool - * The actor pool created for this pause. - */ -function PauseActor(aPool) -{ - this.pool = aPool; -} - -PauseActor.prototype = { - actorPrefix: "pause" -}; - - -/** - * A base actor for any actors that should only respond receive messages in the - * paused state. Subclasses may expose a `threadActor` which is used to help - * determine when we are in a paused state. Subclasses should set their own - * "constructor" property if they want better error messages. You should never - * instantiate a PauseScopedActor directly, only through subclasses. - */ -function PauseScopedActor() -{ -} - -/** - * A function decorator for creating methods to handle protocol messages that - * should only be received while in the paused state. - * - * @param aMethod Function - * The function we are decorating. - */ -PauseScopedActor.withPaused = function (aMethod) { - return function () { - if (this.isPaused()) { - return aMethod.apply(this, arguments); - } else { - return this._wrongState(); - } - }; -}; - -PauseScopedActor.prototype = { - - /** - * Returns true if we are in the paused state. - */ - isPaused: function () { - // When there is not a ThreadActor available (like in the webconsole) we - // have to be optimistic and assume that we are paused so that we can - // respond to requests. - return this.threadActor ? this.threadActor.state === "paused" : true; - }, - - /** - * Returns the wrongState response packet for this actor. - */ - _wrongState: function () { - return { - error: "wrongState", - message: this.constructor.name + - " actors can only be accessed while the thread is paused." - }; - } -}; - -/** - * Creates a pause-scoped actor for the specified object. - * @see ObjectActor - */ -function PauseScopedObjectActor(obj, hooks) { - ObjectActor.call(this, obj, hooks); - this.hooks.promote = hooks.promote; - this.hooks.isThreadLifetimePool = hooks.isThreadLifetimePool; -} - -PauseScopedObjectActor.prototype = Object.create(PauseScopedActor.prototype); - -Object.assign(PauseScopedObjectActor.prototype, ObjectActor.prototype); - -Object.assign(PauseScopedObjectActor.prototype, { - constructor: PauseScopedObjectActor, - actorPrefix: "pausedobj", - - onOwnPropertyNames: - PauseScopedActor.withPaused(ObjectActor.prototype.onOwnPropertyNames), - - onPrototypeAndProperties: - PauseScopedActor.withPaused(ObjectActor.prototype.onPrototypeAndProperties), - - onPrototype: PauseScopedActor.withPaused(ObjectActor.prototype.onPrototype), - onProperty: PauseScopedActor.withPaused(ObjectActor.prototype.onProperty), - onDecompile: PauseScopedActor.withPaused(ObjectActor.prototype.onDecompile), - - onDisplayString: - PauseScopedActor.withPaused(ObjectActor.prototype.onDisplayString), - - onParameterNames: - PauseScopedActor.withPaused(ObjectActor.prototype.onParameterNames), - - /** - * Handle a protocol request to promote a pause-lifetime grip to a - * thread-lifetime grip. - * - * @param aRequest object - * The protocol request object. - */ - onThreadGrip: PauseScopedActor.withPaused(function (aRequest) { - this.hooks.promote(); - return {}; - }), - - /** - * Handle a protocol request to release a thread-lifetime grip. - * - * @param aRequest object - * The protocol request object. - */ - onRelease: PauseScopedActor.withPaused(function (aRequest) { - if (this.hooks.isThreadLifetimePool()) { - return { error: "notReleasable", - message: "Only thread-lifetime actors can be released." }; - } - - this.release(); - return {}; - }), -}); - -Object.assign(PauseScopedObjectActor.prototype.requestTypes, { - "threadGrip": PauseScopedObjectActor.prototype.onThreadGrip, -}); - -function hackDebugger(Debugger) { - // TODO: Improve native code instead of hacking on top of it - - /** - * Override the toString method in order to get more meaningful script output - * for debugging the debugger. - */ - Debugger.Script.prototype.toString = function () { - let output = ""; - if (this.url) { - output += this.url; - } - if (typeof this.staticLevel != "undefined") { - output += ":L" + this.staticLevel; - } - if (typeof this.startLine != "undefined") { - output += ":" + this.startLine; - if (this.lineCount && this.lineCount > 1) { - output += "-" + (this.startLine + this.lineCount - 1); - } - } - if (typeof this.startLine != "undefined") { - output += ":" + this.startLine; - if (this.lineCount && this.lineCount > 1) { - output += "-" + (this.startLine + this.lineCount - 1); - } - } - if (this.strictMode) { - output += ":strict"; - } - return output; - }; - - /** - * Helper property for quickly getting to the line number a stack frame is - * currently paused at. - */ - Object.defineProperty(Debugger.Frame.prototype, "line", { - configurable: true, - get: function () { - if (this.script) { - return this.script.getOffsetLocation(this.offset).lineNumber; - } else { - return null; - } - } - }); -} - - -/** - * Creates an actor for handling chrome debugging. ChromeDebuggerActor is a - * thin wrapper over ThreadActor, slightly changing some of its behavior. - * - * @param aConnection object - * The DebuggerServerConnection with which this ChromeDebuggerActor - * is associated. (Currently unused, but required to make this - * constructor usable with addGlobalActor.) - * - * @param aParent object - * This actor's parent actor. See ThreadActor for a list of expected - * properties. - */ -function ChromeDebuggerActor(aConnection, aParent) -{ - ThreadActor.prototype.initialize.call(this, aParent); -} - -ChromeDebuggerActor.prototype = Object.create(ThreadActor.prototype); - -Object.assign(ChromeDebuggerActor.prototype, { - constructor: ChromeDebuggerActor, - - // A constant prefix that will be used to form the actor ID by the server. - actorPrefix: "chromeDebugger" -}); - -// exports.ChromeDebuggerActor = ChromeDebuggerActor; - -/** - * Creates an actor for handling add-on debugging. AddonThreadActor is - * a thin wrapper over ThreadActor. - * - * @param aConnection object - * The DebuggerServerConnection with which this AddonThreadActor - * is associated. (Currently unused, but required to make this - * constructor usable with addGlobalActor.) - * - * @param aParent object - * This actor's parent actor. See ThreadActor for a list of expected - * properties. - */ -function AddonThreadActor(aConnect, aParent) { - ThreadActor.prototype.initialize.call(this, aParent); -} - -AddonThreadActor.prototype = Object.create(ThreadActor.prototype); - -Object.assign(AddonThreadActor.prototype, { - constructor: AddonThreadActor, - - // A constant prefix that will be used to form the actor ID by the server. - actorPrefix: "addonThread" -}); - -// exports.AddonThreadActor = AddonThreadActor; - -// Utility functions. - -/** - * Report the given error in the error console and to stdout. - * - * @param Error aError - * The error object you wish to report. - * @param String aPrefix - * An optional prefix for the reported error message. - */ -// var oldReportError = reportError; -function reportError(aError, aPrefix="") { - // assert(aError instanceof Error, "Must pass Error objects to reportError"); - let msg = "" + aPrefix + aError.message + ":\n" + aError.stack; - // oldReportError(msg); - log(msg); -} - -/** - * Find the scripts which contain offsets that are an entry point to the given - * line. - * - * @param Array scripts - * The set of Debugger.Scripts to consider. - * @param Number line - * The line we are searching for entry points into. - * @returns Array of objects of the form { script, offsets } where: - * - script is a Debugger.Script - * - offsets is an array of offsets that are entry points into the - * given line. - */ -function findEntryPointsForLine(scripts, line) { - const entryPoints = []; - for (let script of scripts) { - const offsets = script.getLineOffsets(line); - if (offsets.length) { - entryPoints.push({ script, offsets }); - } - } - return entryPoints; -} - -/** - * Unwrap a global that is wrapped in a |Debugger.Object|, or if the global has - * become a dead object, return |undefined|. - * - * @param Debugger.Object wrappedGlobal - * The |Debugger.Object| which wraps a global. - * - * @returns {Object|undefined} - * Returns the unwrapped global object or |undefined| if unwrapping - * failed. - */ -var unwrapDebuggerObjectGlobal = wrappedGlobal => { - try { - // Because of bug 991399 we sometimes get nuked window references here. We - // just bail out in that case. - // - // Note that addon sandboxes have a DOMWindow as their prototype. So make - // sure that we can touch the prototype too (whatever it is), in case _it_ - // is it a nuked window reference. We force stringification to make sure - // that any dead object proxies make themselves known. - let global = wrappedGlobal.unsafeDereference(); - Object.getPrototypeOf(global) + ""; - return global; - } - catch (e) { - return undefined; - } -}; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/source.js b/native/cocos/scripting/js-bindings/script/debugger/actors/source.js deleted file mode 100644 index f2d2db1fed..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/source.js +++ /dev/null @@ -1,937 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public -* License, v. 2.0. If a copy of the MPL was not distributed with this -* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const { Cc, Ci } = require("chrome"); -// const Services = require("Services"); -// const { BreakpointActor, setBreakpointAtEntryPoints } = require("devtools/server/actors/breakpoint"); -// const { OriginalLocation, GeneratedLocation } = require("devtools/server/actors/common"); -// const { createValueGrip } = require("devtools/server/actors/object"); -// const { ActorClassWithSpec, Arg, RetVal, method } = require("devtools/shared/protocol"); -// const DevToolsUtils = require("devtools/shared/DevToolsUtils"); -// const { assert, fetch } = DevToolsUtils; -// const { joinURI } = require("devtools/shared/path"); -// const promise = require("promise"); -// const { defer, resolve, reject, all } = promise; -// const { sourceSpec } = require("devtools/shared/specs/source"); - -// loader.lazyRequireGetter(this, "SourceMapConsumer", "source-map", true); -// loader.lazyRequireGetter(this, "SourceMapGenerator", "source-map", true); -// loader.lazyRequireGetter(this, "mapURIToAddonID", "devtools/server/actors/utils/map-uri-to-addon-id"); - -// from "devtools/shared/specs/source" -const sourceSpec = generateActorSpec({ - typeName: "source", - - methods: { - getExecutableLines: { response: { lines: RetVal("json") } }, - onSource: { - request: { type: "source" }, - response: RetVal("json") - }, - prettyPrint: { - request: { indent: Arg(0, "number") }, - response: RetVal("json") - }, - disablePrettyPrint: { - response: RetVal("json") - }, - blackbox: { response: { pausedInSource: RetVal("boolean") } }, - unblackbox: {}, - setBreakpoint: { - request: { - location: { - line: Arg(0, "number"), - column: Arg(1, "nullable:number") - }, - condition: Arg(2, "nullable:string"), - noSliding: Arg(3, "nullable:boolean") - }, - response: RetVal("json") - }, - }, -}); - -// --------------- - -function isEvalSource(source) { - let introType = source.introductionType; - // These are all the sources that are essentially eval-ed (either - // by calling eval or passing a string to one of these functions). - return (introType === "eval" || - introType === "Function" || - introType === "eventHandler" || - introType === "setTimeout" || - introType === "setInterval"); -} - -// exports.isEvalSource = isEvalSource; - -function getSourceURL(source, window) { - if (isEvalSource(source)) { - // Eval sources have no urls, but they might have a `displayURL` - // created with the sourceURL pragma. If the introduction script - // is a non-eval script, generate an full absolute URL relative to it. - - if (source.displayURL && source.introductionScript && - !isEvalSource(source.introductionScript.source)) { - - if (source.introductionScript.source.url === "debugger eval code") { - if (window) { - // If this is a named eval script created from the console, make it - // relative to the current page. window is only available - // when we care about this. - return joinURI(window.location.href, source.displayURL); - } - } - else { - return joinURI(source.introductionScript.source.url, source.displayURL); - } - } - - return source.displayURL; - } - else if (source.url === "debugger eval code") { - // Treat code evaluated by the console as unnamed eval scripts - return null; - } - return source.url; -} - -// exports.getSourceURL = getSourceURL; - -/** - * Resolve a URI back to physical file. - * - * Of course, this works only for URIs pointing to local resources. - * - * @param aURI - * URI to resolve - * @return - * resolved nsIURI - */ -function resolveURIToLocalPath(aURI) { - let resolved; - switch (aURI.scheme) { - case "jar": - case "file": - return aURI; - - case "chrome": - resolved = Cc["@mozilla.org/chrome/chrome-registry;1"]. - getService(Ci.nsIChromeRegistry).convertChromeURL(aURI); - return resolveURIToLocalPath(resolved); - - case "resource": - resolved = Cc["@mozilla.org/network/protocol;1?name=resource"]. - getService(Ci.nsIResProtocolHandler).resolveURI(aURI); - aURI = Services.io.newURI(resolved, null, null); - return resolveURIToLocalPath(aURI); - - default: - return null; - } -} - -/** - * A SourceActor provides information about the source of a script. There - * are two kinds of source actors: ones that represent real source objects, - * and ones that represent non-existant "original" sources when the real - * sources are sourcemapped. When a source is sourcemapped, actors are - * created for both the "generated" and "original" sources, and the client will - * only see the original sources. We separate these because there isn't - * a 1:1 mapping of generated to original sources; one generated source - * may represent N original sources, so we need to create N + 1 separate - * actors. - * - * There are 4 different scenarios for sources that you should - * understand: - * - * - A single non-sourcemapped source that is not inlined in HTML - * (separate JS file, eval'ed code, etc) - * - A single sourcemapped source which creates N original sources - * - An HTML page with multiple inline scripts, which are distinct - * sources, but should be represented as a single source - * - A pretty-printed source (which may or may not be an original - * sourcemapped source), which generates a sourcemap for itself - * - * The complexity of `SourceActor` and `ThreadSources` are to handle - * all of thise cases and hopefully internalize the complexities. - * - * @param Debugger.Source source - * The source object we are representing. - * @param ThreadActor thread - * The current thread actor. - * @param String originalUrl - * Optional. For sourcemapped urls, the original url this is representing. - * @param Debugger.Source generatedSource - * Optional, passed in when aSourceMap is also passed in. The generated - * source object that introduced this source. - * @param Boolean isInlineSource - * Optional. True if this is an inline source from a HTML or XUL page. - * @param String contentType - * Optional. The content type of this source, if immediately available. - */ -let SourceActor = ActorClassWithSpec(sourceSpec, { - typeName: "source", - - initialize: function ({ source, thread, originalUrl, generatedSource, - isInlineSource, contentType }) { - this._threadActor = thread; - this._originalUrl = originalUrl; - this._source = source; - this._generatedSource = generatedSource; - this._contentType = contentType; - this._isInlineSource = isInlineSource; - - this.onSource = this.onSource.bind(this); - this._invertSourceMap = this._invertSourceMap.bind(this); - this._encodeAndSetSourceMapURL = this._encodeAndSetSourceMapURL.bind(this); - this._getSourceText = this._getSourceText.bind(this); - - this._mapSourceToAddon(); - - if (this.threadActor.sources.isPrettyPrinted(this.url)) { - this._init = this.prettyPrint( - this.threadActor.sources.prettyPrintIndent(this.url) - ).then(null, error => { - DevToolsUtils.reportException("SourceActor", error); - }); - } else { - this._init = null; - } - }, - - get isSourceMapped() { - return !!(!this.isInlineSource && ( - this._originalURL || this._generatedSource || - this.threadActor.sources.isPrettyPrinted(this.url) - )); - }, - - get isInlineSource() { - return this._isInlineSource; - }, - - get threadActor() { return this._threadActor; }, - get sources() { return this._threadActor.sources; }, - get dbg() { return this.threadActor.dbg; }, - get source() { return this._source; }, - get generatedSource() { return this._generatedSource; }, - get breakpointActorMap() { return this.threadActor.breakpointActorMap; }, - get url() { - if (this.source) { - return getSourceURL(this.source, this.threadActor._parent.window); - } - return this._originalUrl; - }, - get addonID() { return this._addonID; }, - get addonPath() { return this._addonPath; }, - - get prettyPrintWorker() { - return this.threadActor.prettyPrintWorker; - }, - - form: function () { - let source = this.source || this.generatedSource; - // This might not have a source or a generatedSource because we - // treat HTML pages with inline scripts as a special SourceActor - // that doesn't have either - let introductionUrl = null; - if (source && source.introductionScript) { - introductionUrl = source.introductionScript.source.url; - } - - return { - actor: this.actorID, - generatedUrl: this.generatedSource ? this.generatedSource.url : null, - url: this.url ? this.url.split(" -> ").pop() : null, - addonID: this._addonID, - addonPath: this._addonPath, - isBlackBoxed: this.threadActor.sources.isBlackBoxed(this.url), - isPrettyPrinted: this.threadActor.sources.isPrettyPrinted(this.url), - isSourceMapped: this.isSourceMapped, - sourceMapURL: source ? source.sourceMapURL : null, - introductionUrl: introductionUrl ? introductionUrl.split(" -> ").pop() : null, - introductionType: source ? source.introductionType : null - }; - }, - - disconnect: function () { - if (this.registeredPool && this.registeredPool.sourceActors) { - delete this.registeredPool.sourceActors[this.actorID]; - } - }, - - _mapSourceToAddon: function () { - try { - var nsuri = Services.io.newURI(this.url.split(" -> ").pop(), null, null); - } - catch (e) { - // We can't do anything with an invalid URI - return; - } - - let localURI = resolveURIToLocalPath(nsuri); - if (!localURI) { - return; - } - - let id = mapURIToAddonID(localURI); - if (!id) { - return; - } - this._addonID = id; - - if (localURI instanceof Ci.nsIJARURI) { - // The path in the add-on is easy for jar: uris - this._addonPath = localURI.JAREntry; - } - else if (localURI instanceof Ci.nsIFileURL) { - // For file: uris walk up to find the last directory that is part of the - // add-on - let target = localURI.file; - let path = target.leafName; - - // We can assume that the directory containing the source file is part - // of the add-on - let root = target.parent; - let file = root.parent; - while (file && mapURIToAddonID(Services.io.newFileURI(file))) { - path = root.leafName + "/" + path; - root = file; - file = file.parent; - } - - if (!file) { - const error = new Error("Could not find the root of the add-on for " + this.url); - DevToolsUtils.reportException("SourceActor.prototype._mapSourceToAddon", error); - return; - } - - this._addonPath = path; - } - }, - - _reportLoadSourceError: function (error, map = null) { - try { - DevToolsUtils.reportException("SourceActor", error); - - JSON.stringify(this.form(), null, 4).split(/\n/g) - .forEach(line => console.error("\t", line)); - - if (!map) { - return; - } - - console.error("\t", "source map's sourceRoot =", map.sourceRoot); - - console.error("\t", "source map's sources ="); - map.sources.forEach(s => { - let hasSourceContent = map.sourceContentFor(s, true); - console.error("\t\t", s, "\t", - hasSourceContent ? "has source content" : "no source content"); - }); - - console.error("\t", "source map's sourcesContent ="); - map.sourcesContent.forEach(c => { - if (c.length > 80) { - c = c.slice(0, 77) + "..."; - } - c = c.replace(/\n/g, "\\n"); - console.error("\t\t", c); - }); - } catch (e) { } - }, - - _getSourceText: function () { - let toResolvedContent = t => ({ - content: t, - contentType: this._contentType - }); - - let genSource = this.generatedSource || this.source; - return this.threadActor.sources.fetchSourceMap(genSource).then(map => { - if (map) { - try { - let sourceContent = map.sourceContentFor(this.url); - if (sourceContent) { - return toResolvedContent(sourceContent); - } - } catch (error) { - this._reportLoadSourceError(error, map); - throw error; - } - } - - // Use `source.text` if it exists, is not the "no source" string, and - // the content type of the source is JavaScript or it is synthesized - // wasm. It will be "no source" if the Debugger API wasn't able to load - // the source because sources were discarded - // (javascript.options.discardSystemSource == true). Re-fetch non-JS - // sources to get the contentType from the headers. - if (this.source && - this.source.text !== "[no source]" && - this._contentType && - (this._contentType.indexOf("javascript") !== -1 || - this._contentType === "text/wasm")) { - return toResolvedContent(this.source.text); - } - else { - // Only load the HTML page source from cache (which exists when - // there are inline sources). Otherwise, we can't trust the - // cache because we are most likely here because we are - // fetching the original text for sourcemapped code, and the - // page hasn't requested it before (if it has, it was a - // previous debugging session). - let loadFromCache = this.isInlineSource; - - // Fetch the sources with the same principal as the original document - let win = this.threadActor._parent.window; - let principal, cacheKey; - // On xpcshell, we don't have a window but a Sandbox - if (!isWorker && win instanceof Ci.nsIDOMWindow) { - let webNav = win.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation); - let channel = webNav.currentDocumentChannel; - principal = channel.loadInfo.loadingPrincipal; - - // Retrieve the cacheKey in order to load POST requests from cache - // Note that chrome:// URLs don't support this interface. - if (loadFromCache && - webNav.currentDocumentChannel instanceof Ci.nsICacheInfoChannel) { - cacheKey = webNav.currentDocumentChannel.cacheKey; - assert( - cacheKey, - "Could not fetch the cacheKey from the related document." - ); - } - } - - let sourceFetched = fetch(this.url, { - principal, - cacheKey, - loadFromCache - }); - - // Record the contentType we just learned during fetching - return sourceFetched - .then(result => { - this._contentType = result.contentType; - return result; - }, error => { - this._reportLoadSourceError(error, map); - throw error; - }); - } - }); - }, - - /** - * Get all executable lines from the current source - * @return Array - Executable lines of the current script - **/ - getExecutableLines: function () { - function sortLines(lines) { - // Converting the Set into an array - lines = [...lines]; - lines.sort((a, b) => { - return a - b; - }); - return lines; - } - - if (this.generatedSource) { - return this.threadActor.sources.getSourceMap(this.generatedSource).then(sm => { - let lines = new Set(); - - // Position of executable lines in the generated source - let offsets = this.getExecutableOffsets(this.generatedSource, false); - for (let offset of offsets) { - let {line, source: sourceUrl} = sm.originalPositionFor({ - line: offset.lineNumber, - column: offset.columnNumber - }); - - if (sourceUrl === this.url) { - lines.add(line); - } - } - - return sortLines(lines); - }); - } - - let lines = this.getExecutableOffsets(this.source, true); - return sortLines(lines); - }, - - /** - * Extract all executable offsets from the given script - * @param String url - extract offsets of the script with this url - * @param Boolean onlyLine - will return only the line number - * @return Set - Executable offsets/lines of the script - **/ - getExecutableOffsets: function (source, onlyLine) { - let offsets = new Set(); - for (let s of this.dbg.findScripts({ source })) { - for (let offset of s.getAllColumnOffsets()) { - offsets.add(onlyLine ? offset.lineNumber : offset); - } - } - - return offsets; - }, - - /** - * Handler for the "source" packet. - */ - onSource: function () { - return Promise.resolve(this._init) - .then(this._getSourceText) - .then(({ content, contentType }) => { - return { - source: createValueGrip(content, this.threadActor.threadLifetimePool, - this.threadActor.objectGrip), - contentType: contentType - }; - }) - .then(null, aError => { - reportError(aError, "Got an exception during SA_onSource: "); - throw new Error("Could not load the source for " + this.url + ".\n" + - DevToolsUtils.safeErrorString(aError)); - }); - }, - - /** - * Handler for the "prettyPrint" packet. - */ - prettyPrint: function (indent) { - this.threadActor.sources.prettyPrint(this.url, indent); - return this._getSourceText() - .then(this._sendToPrettyPrintWorker(indent)) - .then(this._invertSourceMap) - .then(this._encodeAndSetSourceMapURL) - .then(() => { - // We need to reset `_init` now because we have already done the work of - // pretty printing, and don't want onSource to wait forever for - // initialization to complete. - this._init = null; - }) - .then(this.onSource) - .then(null, error => { - this.disablePrettyPrint(); - throw new Error(DevToolsUtils.safeErrorString(error)); - }); - }, - - /** - * Return a function that sends a request to the pretty print worker, waits on - * the worker's response, and then returns the pretty printed code. - * - * @param Number aIndent - * The number of spaces to indent by the code by, when we send the - * request to the pretty print worker. - * @returns Function - * Returns a function which takes an AST, and returns a promise that - * is resolved with `{ code, mappings }` where `code` is the pretty - * printed code, and `mappings` is an array of source mappings. - */ - _sendToPrettyPrintWorker: function (aIndent) { - return ({ content }) => { - return this.prettyPrintWorker.performTask("pretty-print", { - url: this.url, - indent: aIndent, - source: content - }); - }; - }, - - /** - * Invert a source map. So if a source map maps from a to b, return a new - * source map from b to a. We need to do this because the source map we get - * from _generatePrettyCodeAndMap goes the opposite way we want it to for - * debugging. - * - * Note that the source map is modified in place. - */ - _invertSourceMap: function ({ code, mappings }) { - const generator = new SourceMapGenerator({ file: this.url }); - return DevToolsUtils.yieldingEach(mappings._array, m => { - let mapping = { - generated: { - line: m.originalLine, - column: m.originalColumn - } - }; - if (m.source) { - mapping.source = m.source; - mapping.original = { - line: m.generatedLine, - column: m.generatedColumn - }; - mapping.name = m.name; - } - generator.addMapping(mapping); - }).then(() => { - generator.setSourceContent(this.url, code); - let consumer = SourceMapConsumer.fromSourceMap(generator); - - return { - code: code, - map: consumer - }; - }); - }, - - /** - * Save the source map back to our thread's ThreadSources object so that - * stepping, breakpoints, debugger statements, etc can use it. If we are - * pretty printing a source mapped source, we need to compose the existing - * source map with our new one. - */ - _encodeAndSetSourceMapURL: function ({ map: sm }) { - let source = this.generatedSource || this.source; - let sources = this.threadActor.sources; - - return sources.getSourceMap(source).then(prevMap => { - if (prevMap) { - // Compose the source maps - this._oldSourceMapping = { - url: source.sourceMapURL, - map: prevMap - }; - - prevMap = SourceMapGenerator.fromSourceMap(prevMap); - prevMap.applySourceMap(sm, this.url); - sm = SourceMapConsumer.fromSourceMap(prevMap); - } - - let sources = this.threadActor.sources; - sources.clearSourceMapCache(source.sourceMapURL); - sources.setSourceMapHard(source, null, sm); - }); - }, - - /** - * Handler for the "disablePrettyPrint" packet. - */ - disablePrettyPrint: function () { - let source = this.generatedSource || this.source; - let sources = this.threadActor.sources; - let sm = sources.getSourceMap(source); - - sources.clearSourceMapCache(source.sourceMapURL, { hard: true }); - - if (this._oldSourceMapping) { - sources.setSourceMapHard(source, - this._oldSourceMapping.url, - this._oldSourceMapping.map); - this._oldSourceMapping = null; - } - - this.threadActor.sources.disablePrettyPrint(this.url); - return this.onSource(); - }, - - /** - * Handler for the "blackbox" packet. - */ - blackbox: function () { - this.threadActor.sources.blackBox(this.url); - if (this.threadActor.state == "paused" - && this.threadActor.youngestFrame - && this.threadActor.youngestFrame.script.url == this.url) { - return true; - } - return false; - }, - - /** - * Handler for the "unblackbox" packet. - */ - unblackbox: function () { - this.threadActor.sources.unblackBox(this.url); - }, - - /** - * Handle a request to set a breakpoint. - * - * @param Number line - * Line to break on. - * @param Number column - * Column to break on. - * @param String condition - * A condition which must be true for breakpoint to be hit. - * @param Boolean noSliding - * If true, disables breakpoint sliding. - * - * @returns Promise - * A promise that resolves to a JSON object representing the - * response. - */ - setBreakpoint: function (line, column, condition, noSliding) { - if (this.threadActor.state !== "paused") { - throw { - error: "wrongState", - message: "Cannot set breakpoint while debuggee is running." - }; - } - - let location = new OriginalLocation(this, line, column); - return this._getOrCreateBreakpointActor( - location, - condition, - noSliding - ).then((actor) => { - let response = { - actor: actor.actorID, - isPending: actor.isPending - }; - - let actualLocation = actor.originalLocation; - if (!actualLocation.equals(location)) { - response.actualLocation = actualLocation.toJSON(); - } - - return response; - }); - }, - - /** - * Get or create a BreakpointActor for the given location in the original - * source, and ensure it is set as a breakpoint handler on all scripts that - * match the given location. - * - * @param OriginalLocation originalLocation - * An OriginalLocation representing the location of the breakpoint in - * the original source. - * @param String condition - * A string that is evaluated whenever the breakpoint is hit. If the - * string evaluates to false, the breakpoint is ignored. - * @param Boolean noSliding - * If true, disables breakpoint sliding. - * - * @returns BreakpointActor - * A BreakpointActor representing the breakpoint. - */ - _getOrCreateBreakpointActor: function (originalLocation, condition, noSliding) { - let actor = this.breakpointActorMap.getActor(originalLocation); - if (!actor) { - actor = new BreakpointActor(this.threadActor, originalLocation); - this.threadActor.threadLifetimePool.addActor(actor); - this.breakpointActorMap.setActor(originalLocation, actor); - } - - actor.condition = condition; - - return this._setBreakpoint(actor, noSliding); - }, - - /* - * Ensure the given BreakpointActor is set as a breakpoint handler on all - * scripts that match its location in the original source. - * - * If there are no scripts that match the location of the BreakpointActor, - * we slide its location to the next closest line (for line breakpoints) or - * column (for column breakpoint) that does. - * - * If breakpoint sliding fails, then either there are no scripts that contain - * any code for the given location, or they were all garbage collected before - * the debugger started running. We cannot distinguish between these two - * cases, so we insert the BreakpointActor in the BreakpointActorMap as - * a pending breakpoint. Whenever a new script is introduced, this method is - * called again for each pending breakpoint. - * - * @param BreakpointActor actor - * The BreakpointActor to be set as a breakpoint handler. - * @param Boolean noSliding - * If true, disables breakpoint sliding. - * - * @returns A Promise that resolves to the given BreakpointActor. - */ - _setBreakpoint: function (actor, noSliding) { - const { originalLocation } = actor; - const { originalLine, originalSourceActor } = originalLocation; - - if (!this.isSourceMapped) { - const generatedLocation = GeneratedLocation.fromOriginalLocation(originalLocation); - if (!this._setBreakpointAtGeneratedLocation(actor, generatedLocation) && - !noSliding) { - const query = { line: originalLine }; - // For most cases, we have a real source to query for. The - // only time we don't is for HTML pages. In that case we want - // to query for scripts in an HTML page based on its URL, as - // there could be several sources within an HTML page. - if (this.source) { - query.source = this.source; - } else { - query.url = this.url; - } - const scripts = this.dbg.findScripts(query); - - // Never do breakpoint sliding for column breakpoints. - // Additionally, never do breakpoint sliding if no scripts - // exist on this line. - // - // Sliding can go horribly wrong if we always try to find the - // next line with valid entry points in the entire file. - // Scripts may be completely GCed and we never knew they - // existed, so we end up sliding through whole functions to - // the user's bewilderment. - // - // We can slide reliably if any scripts exist, however, due - // to how scripts are kept alive. A parent Debugger.Script - // keeps all of its children alive, so as long as we have a - // valid script, we can slide through it and know we won't - // slide through any of its child scripts. Additionally, if a - // script gets GCed, that means that all parents scripts are - // GCed as well, and no scripts will exist on those lines - // anymore. We will never slide through a GCed script. - if (originalLocation.originalColumn || scripts.length === 0) { - return Promise.resolve(actor); - } - - // Find the script that spans the largest amount of code to - // determine the bounds for sliding. - const largestScript = scripts.reduce((largestScript, script) => { - if (script.lineCount > largestScript.lineCount) { - return script; - } - return largestScript; - }); - const maxLine = largestScript.startLine + largestScript.lineCount - 1; - - let actualLine = originalLine; - for (; actualLine <= maxLine; actualLine++) { - const loc = new GeneratedLocation(this, actualLine); - if (this._setBreakpointAtGeneratedLocation(actor, loc)) { - break; - } - } - - // The above loop should never complete. We only did breakpoint sliding - // because we found scripts on the line we started from, - // which means there must be valid entry points somewhere - // within those scripts. - assert( - actualLine <= maxLine, - "Could not find any entry points to set a breakpoint on, " + - "even though I was told a script existed on the line I started " + - "the search with." - ); - - // Update the actor to use the new location (reusing a - // previous breakpoint if it already exists on that line). - const actualLocation = new OriginalLocation(originalSourceActor, actualLine); - const existingActor = this.breakpointActorMap.getActor(actualLocation); - this.breakpointActorMap.deleteActor(originalLocation); - if (existingActor) { - actor.delete(); - actor = existingActor; - } else { - actor.originalLocation = actualLocation; - this.breakpointActorMap.setActor(actualLocation, actor); - } - } - - return Promise.resolve(actor); - } else { - return this.sources.getAllGeneratedLocations(originalLocation).then((generatedLocations) => { - this._setBreakpointAtAllGeneratedLocations( - actor, - generatedLocations - ); - - return actor; - }); - } - }, - - _setBreakpointAtAllGeneratedLocations: function (actor, generatedLocations) { - let success = false; - for (let generatedLocation of generatedLocations) { - if (this._setBreakpointAtGeneratedLocation( - actor, - generatedLocation - )) { - success = true; - } - } - return success; - }, - - /* - * Ensure the given BreakpointActor is set as breakpoint handler on all - * scripts that match the given location in the generated source. - * - * @param BreakpointActor actor - * The BreakpointActor to be set as a breakpoint handler. - * @param GeneratedLocation generatedLocation - * A GeneratedLocation representing the location in the generated - * source for which the given BreakpointActor is to be set as a - * breakpoint handler. - * - * @returns A Boolean that is true if the BreakpointActor was set as a - * breakpoint handler on at least one script, and false otherwise. - */ - _setBreakpointAtGeneratedLocation: function (actor, generatedLocation) { - let { - generatedSourceActor, - generatedLine, - generatedColumn, - generatedLastColumn - } = generatedLocation; - - // Find all scripts that match the given source actor and line - // number. - const query = { line: generatedLine }; - if (generatedSourceActor.source) { - query.source = generatedSourceActor.source; - } else { - query.url = generatedSourceActor.url; - } - let scripts = this.dbg.findScripts(query); - - scripts = scripts.filter((script) => !actor.hasScript(script)); - - // Find all entry points that correspond to the given location. - let entryPoints = []; - if (generatedColumn === undefined) { - // This is a line breakpoint, so we are interested in all offsets - // that correspond to the given line number. - for (let script of scripts) { - let offsets = script.getLineOffsets(generatedLine); - if (offsets.length > 0) { - entryPoints.push({ script, offsets }); - } - } - } else { - // This is a column breakpoint, so we are interested in all column - // offsets that correspond to the given line *and* column number. - for (let script of scripts) { - let columnToOffsetMap = script.getAllColumnOffsets() - .filter(({ lineNumber }) => { - return lineNumber === generatedLine; - }); - for (let { columnNumber: column, offset } of columnToOffsetMap) { - if (column >= generatedColumn && column <= generatedLastColumn) { - entryPoints.push({ script, offsets: [offset] }); - } - } - } - } - - if (entryPoints.length === 0) { - return false; - } - setBreakpointAtEntryPoints(actor, entryPoints); - return true; - } -}); - -// exports.SourceActor = SourceActor; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/utils/ScriptStore.js b/native/cocos/scripting/js-bindings/script/debugger/actors/utils/ScriptStore.js deleted file mode 100755 index cbd9830ec1..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/utils/ScriptStore.js +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const { noop } = DevToolsUtils; - -/** - * A `ScriptStore` is a cache of `Debugger.Script` instances. It holds strong - * references to the cached scripts to alleviate the GC-sensitivity issues that - * plague `Debugger.prototype.findScripts`, but this means that its lifetime - * must be managed carefully. It is the `ScriptStore` user's responsibility to - * ensure that the `ScriptStore` stays up to date. - * - * Implementation Notes: - * - * The ScriptStore's prototype methods are very hot, in general. To help the - * JIT, they avoid ES6-isms and higher-order iteration functions, for the most - * part. You might be wondering why we don't maintain indices on, say, - * Debugger.Source for faster querying, if these methods are so hot. First, the - * hottest method is actually just getting all scripts; second, populating the - * store becomes prohibitively expensive. So we fall back to linear queries - * (which isn't so bad, because Debugger.prototype.findScripts is also linear). - */ -function ScriptStore() { - // Set of every Debugger.Script in the cache. - this._scripts = new NoDeleteSet; -} - -// module.exports = ScriptStore; - -ScriptStore.prototype = { - // Populating a ScriptStore. - - /** - * Add one script to the cache. - * - * @param Debugger.Script script - */ - addScript: function(script) { - this._scripts.add(script); - }, - - /** - * Add many scripts to the cache at once. - * - * @param Array scripts - * The set of Debugger.Scripts to add to the cache. - */ - addScripts: function(scripts) { - for (var i = 0, len = scripts.length; i < len; i++) { - this.addScript(scripts[i]); - } - }, - - // Querying a ScriptStore. - - /** - * Get all the sources for which we have scripts cached. - * - * @returns Array of Debugger.Source - */ - getSources: function() { - return [...new Set(this._scripts.items.map(s => s.source))]; - }, - - /** - * Get all the scripts in the cache. - * - * @returns read-only Array of Debugger.Script. - * - * NB: The ScriptStore retains ownership of the returned array, and the - * ScriptStore's consumers MUST NOT MODIFY its contents! - */ - getAllScripts: function() { - return this._scripts.items; - }, - - getScriptsBySourceActor: function(sourceActor) { - return sourceActor.source ? - this.getScriptsBySource(sourceActor.source) : - this.getScriptsByURL(sourceActor._originalUrl); - }, - - getScriptsBySourceActorAndLine: function(sourceActor, line) { - return sourceActor.source ? - this.getScriptsBySourceAndLine(sourceActor.source, line) : - this.getScriptsByURLAndLine(sourceActor._originalUrl, line); - }, - - /** - * Get all scripts produced from the given source. - * - * @param Debugger.Source source - * @returns Array of Debugger.Script - */ - getScriptsBySource: function(source) { - var results = []; - var scripts = this._scripts.items; - var length = scripts.length; - for (var i = 0; i < length; i++) { - if (scripts[i].source === source) { - results.push(scripts[i]); - } - } - return results; - }, - - /** - * Get all scripts produced from the given source whose source code definition - * spans the given line. - * - * @param Debugger.Source source - * @param Number line - * @returns Array of Debugger.Script - */ - getScriptsBySourceAndLine: function(source, line) { - var results = []; - var scripts = this._scripts.items; - var length = scripts.length; - for (var i = 0; i < length; i++) { - var script = scripts[i]; - if (script.source === source && - script.startLine <= line && - (script.startLine + script.lineCount) > line) { - results.push(script); - } - } - return results; - }, - - /** - * Get all scripts defined by a source at the given URL. - * - * @param String url - * @returns Array of Debugger.Script - */ - getScriptsByURL: function(url) { - var results = []; - var scripts = this._scripts.items; - var length = scripts.length; - for (var i = 0; i < length; i++) { - if (scripts[i].url === url) { - results.push(scripts[i]); - } - } - return results; - }, - - /** - * Get all scripts defined by a source a the given URL and whose source code - * definition spans the given line. - * - * @param String url - * @param Number line - * @returns Array of Debugger.Script - */ - getScriptsByURLAndLine: function(url, line) { - var results = []; - var scripts = this._scripts.items; - var length = scripts.length; - for (var i = 0; i < length; i++) { - var script = scripts[i]; - if (script.url === url && - script.startLine <= line && - (script.startLine + script.lineCount) > line) { - results.push(script); - } - } - return results; - }, -}; - - -/** - * A set which can only grow, and does not support the delete operation. - * Provides faster iteration than the native Set by maintaining an array of all - * items, in addition to the internal set of all items, which allows direct - * iteration (without the iteration protocol and calling into C++, which are - * both expensive). - */ -function NoDeleteSet() { - this._set = new Set(); - this.items = []; -} - -NoDeleteSet.prototype = { - /** - * An array containing every item in the set for convenience and faster - * iteration. This is public for reading only, and consumers MUST NOT modify - * this array! - */ - items: null, - - /** - * Add an item to the set. - * - * @param any item - */ - add: function(item) { - if (!this._set.has(item)) { - this._set.add(item); - this.items.push(item); - } - }, - - /** - * Return true if the item is in the set, false otherwise. - * - * @param any item - * @returns Boolean - */ - has: function(item) { - return this._set.has(item); - } -}; diff --git a/native/cocos/scripting/js-bindings/script/debugger/actors/utils/TabSources.js b/native/cocos/scripting/js-bindings/script/debugger/actors/utils/TabSources.js deleted file mode 100755 index ced3724138..0000000000 --- a/native/cocos/scripting/js-bindings/script/debugger/actors/utils/TabSources.js +++ /dev/null @@ -1,847 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -// const { Ci, Cu } = require("chrome"); -// const DevToolsUtils = require("devtools/shared/DevToolsUtils"); -// const { assert, fetch } = DevToolsUtils.; -// const EventEmitter = require("devtools/shared/event-emitter"); -// const { OriginalLocation, GeneratedLocation } = require("devtools/server/actors/common"); -// const { resolve } = require("promise"); -// const { joinURI } = require("devtools/shared/path"); - -// loader.lazyRequireGetter(this, "SourceActor", "devtools/server/actors/source", true); -// loader.lazyRequireGetter(this, "isEvalSource", "devtools/server/actors/source", true); -// loader.lazyRequireGetter(this, "SourceMapConsumer", "source-map", true); -// loader.lazyRequireGetter(this, "SourceMapGenerator", "source-map", true); - -/** - * Manages the sources for a thread. Handles source maps, locations in the - * sources, etc for ThreadActors. - */ -function TabSources(threadActor, allowSourceFn = () => true) { - EventEmitter.decorate(this); - - this._thread = threadActor; - this._useSourceMaps = true; - this._autoBlackBox = true; - this._anonSourceMapId = 1; - this.allowSource = source => { - return !isHiddenSource(source) && allowSourceFn(source); - }; - - this.blackBoxedSources = new Set(); - this.prettyPrintedSources = new Map(); - this.neverAutoBlackBoxSources = new Set(); - - // generated Debugger.Source -> promise of SourceMapConsumer - this._sourceMaps = new Map(); - // sourceMapURL -> promise of SourceMapConsumer - this._sourceMapCache = Object.create(null); - // Debugger.Source -> SourceActor - this._sourceActors = new Map(); - // url -> SourceActor - this._sourceMappedSourceActors = Object.create(null); -} - -/** - * Matches strings of the form "foo.min.js" or "foo-min.js", etc. If the regular - * expression matches, we can be fairly sure that the source is minified, and - * treat it as such. - */ -const MINIFIED_SOURCE_REGEXP = /\bmin\.js$/; - -TabSources.prototype = { - /** - * Update preferences and clear out existing sources - */ - reconfigure: function(options) { - if ('useSourceMaps' in options) { - this._useSourceMaps = options.useSourceMaps; - } - - if ('autoBlackBox' in options) { - this._autoBlackBox = options.autoBlackBox; - } - - this.reset(); - }, - - /** - * Update preferences and clear out existing sources - */ - setOptions: function (options) { - let shouldReset = false; - - if ("useSourceMaps" in options) { - shouldReset = true; - this._useSourceMaps = options.useSourceMaps; - } - - if ("autoBlackBox" in options) { - shouldReset = true; - this._autoBlackBox = options.autoBlackBox; - } - - if (shouldReset) { - this.reset(); - } - }, - - /** - * Clear existing sources so they are recreated on the next access. - * - * @param Object opts - * Specify { sourceMaps: true } if you also want to clear - * the source map cache (usually done on reload). - */ - reset: function (opts = {}) { - this._sourceActors = new Map(); - this._sourceMaps = new Map(); - this._sourceMappedSourceActors = Object.create(null); - - if (opts.sourceMaps) { - this._sourceMapCache = Object.create(null); - } - }, - - /** - * Return the source actor representing the `source` (or - * `originalUrl`), creating one if none exists already. May return - * null if the source is disallowed. - * - * @param Debugger.Source source - * The source to make an actor for - * @param String originalUrl - * The original source URL of a sourcemapped source - * @param optional Debguger.Source generatedSource - * The generated source that introduced this source via source map, - * if any. - * @param optional String contentType - * The content type of the source, if immediately available. - * @returns a SourceActor representing the source or null. - */ - source: function ({ source, originalUrl, generatedSource, - isInlineSource, contentType }) { - DevToolsUtils.assert(source || (originalUrl && generatedSource), - "TabSources.prototype.source needs an originalUrl or a source"); - - if (source) { - // If a source is passed, we are creating an actor for a real - // source, which may or may not be sourcemapped. - - if (!this.allowSource(source)) { - return null; - } - - // It's a hack, but inline HTML scripts each have real sources, - // but we want to represent all of them as one source as the - // HTML page. The actor representing this fake HTML source is - // stored in this array, which always has a URL, so check it - // first. - if (source.url in this._sourceMappedSourceActors) { - return this._sourceMappedSourceActors[source.url]; - } - - if (isInlineSource) { - // If it's an inline source, the fake HTML source hasn't been - // created yet (would have returned above), so flip this source - // into a sourcemapped state by giving it an `originalUrl` which - // is the HTML url. - originalUrl = source.url; - source = null; - } - else if (this._sourceActors.has(source)) { - return this._sourceActors.get(source); - } - } - else if (originalUrl) { - // Not all "original" scripts are distinctly separate from the - // generated script. Pretty-printed sources have a sourcemap for - // themselves, so we need to make sure there a real source - // doesn't already exist with this URL. - for (let [source, actor] of this._sourceActors) { - if (source.url === originalUrl) { - return actor; - } - } - - if (originalUrl in this._sourceMappedSourceActors) { - return this._sourceMappedSourceActors[originalUrl]; - } - } - - let actor = new SourceActor({ - thread: this._thread, - source: source, - originalUrl: originalUrl, - generatedSource: generatedSource, - isInlineSource: isInlineSource, - contentType: contentType - }); - - let sourceActorStore = this._thread.sourceActorStore; - var id = sourceActorStore.getReusableActorId(source, originalUrl); - if (id) { - actor.actorID = id; - } - - this._thread.threadLifetimePool.addActor(actor); - sourceActorStore.setReusableActorId(source, originalUrl, actor.actorID); - - if (this._autoBlackBox && - !this.neverAutoBlackBoxSources.has(actor.url) && - this._isMinifiedURL(actor.url)) { - - this.blackBox(actor.url); - this.neverAutoBlackBoxSources.add(actor.url); - } - - if (source) { - this._sourceActors.set(source, actor); - } - else { - this._sourceMappedSourceActors[originalUrl] = actor; - } - - this._emitNewSource(actor); - return actor; - }, - - _emitNewSource: function (actor) { - if (!actor.source) { - // Always notify if we don't have a source because that means - // it's something that has been sourcemapped, or it represents - // the HTML file that contains inline sources. - this.emit("newSource", actor); - } - else { - // If sourcemapping is enabled and a source has sourcemaps, we - // create `SourceActor` instances for both the original and - // generated sources. The source actors for the generated - // sources are only for internal use, however; breakpoints are - // managed by these internal actors. We only want to notify the - // user of the original sources though, so if the actor has a - // `Debugger.Source` instance and a valid source map (meaning - // it's a generated source), don't send the notification. - this.fetchSourceMap(actor.source).then(map => { - if (!map) { - this.emit("newSource", actor); - } - }); - } - }, - - getSourceActor: function (source) { - if (source.url in this._sourceMappedSourceActors) { - return this._sourceMappedSourceActors[source.url]; - } - - if (this._sourceActors.has(source)) { - return this._sourceActors.get(source); - } - - throw new Error("getSource: could not find source actor for " + - (source.url || "source")); - }, - - getSourceActorByURL: function (url) { - if (url) { - for (let [source, actor] of this._sourceActors) { - if (source.url === url) { - return actor; - } - } - - if (url in this._sourceMappedSourceActors) { - return this._sourceMappedSourceActors[url]; - } - } - - throw new Error("getSourceActorByURL: could not find source for " + url); - return null; - }, - - /** - * Returns true if the URL likely points to a minified resource, false - * otherwise. - * - * @param String aURL - * The URL to test. - * @returns Boolean - */ - _isMinifiedURL: function (aURL) { - if (!aURL) { - return false; - } - - try { - let url = new URL(aURL); - let pathname = url.pathname; - return MINIFIED_SOURCE_REGEXP.test(pathname.slice(pathname.lastIndexOf("/") + 1)); - } catch (e) { - // Not a valid URL so don't try to parse out the filename, just test the - // whole thing with the minified source regexp. - return MINIFIED_SOURCE_REGEXP.test(aURL); - } - }, - - /** - * Create a source actor representing this source. This ignores - * source mapping and always returns an actor representing this real - * source. Use `createSourceActors` if you want to respect source maps. - * - * @param Debugger.Source aSource - * The source instance to create an actor for. - * @returns SourceActor - */ - createNonSourceMappedActor: function (aSource) { - // Don't use getSourceURL because we don't want to consider the - // displayURL property if it's an eval source. We only want to - // consider real URLs, otherwise if there is a URL but it's - // invalid the code below will not set the content type, and we - // will later try to fetch the contents of the URL to figure out - // the content type, but it's a made up URL for eval sources. - let url = isEvalSource(aSource) ? null : aSource.url; - let spec = { source: aSource }; - - // XXX bug 915433: We can't rely on Debugger.Source.prototype.text - // if the source is an HTML-embedded